Databricks C++ SDK 0.2.4
Interact with Databricks via an SDK
Loading...
Searching...
No Matches
compute_types.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <map>
5#include <cstdint>
6
7namespace databricks {
8
9 /**
10 * @brief Enumeration of possible cluster lifecycle states
11 *
12 * Represents the various states a Databricks cluster can be in during its lifecycle.
13 */
14 enum class ClusterStateEnum {
15 PENDING, ///< Cluster is being created
16 RUNNING, ///< Cluster is running and ready for use
17 RESTARTING, ///< Cluster is restarting
18 RESIZING, ///< Cluster is being resized
19 TERMINATING, ///< Cluster is being terminated
20 TERMINATED, ///< Cluster has been terminated
21 ERROR, ///< Cluster is in an error state
22 UNKNOWN ///< Unknown or unrecognized state
23 };
24
25 /**
26 * @brief Parse a cluster state string into ClusterStateEnum
27 * @param state_str String representation of the cluster state
28 * @return ClusterStateEnum corresponding to the string
29 */
30 ClusterStateEnum parse_cluster_state(const std::string& state_str);
31
32 /**
33 * @brief Convert ClusterStateEnum to string representation
34 * @param state ClusterStateEnum value
35 * @return String representation of the state
36 */
38
39 /**
40 * @brief Represents a Databricks cluster
41 *
42 * Clusters are compute resources used to run notebooks, jobs, and other workloads.
43 * This struct contains the core metadata about a cluster configuration and its state.
44 */
45 struct Cluster {
46 std::string cluster_id; ///< Unique identifier for the cluster
47 std::string cluster_name; ///< Display name of the cluster
48 std::string state; ///< Current lifecycle state (e.g., "RUNNING", "TERMINATED")
49 std::string creator_user_name; ///< Username of the cluster creator
50 uint64_t start_time = 0; ///< Unix timestamp in milliseconds when cluster started
51 uint64_t terminated_time = 0; ///< Unix timestamp in milliseconds when cluster terminated (0 if running)
52 std::string spark_version; ///< Spark runtime version (e.g., "11.3.x-scala2.12")
53 std::string node_type_id; ///< Cloud provider instance type (e.g., "i3.xlarge")
54 int num_workers = 0; ///< Number of worker nodes in the cluster
55 std::map<std::string, std::string> custom_tags; ///< User-defined tags for organization and tracking
56 };
57
58 /**
59 * @brief Represents detailed state information for a cluster
60 *
61 * Provides more granular state information including state messages
62 * that can help diagnose issues or understand cluster status.
63 */
64 struct ClusterState {
65 std::string cluster_id; ///< Unique identifier for the cluster
66 ClusterStateEnum cluster_state = ClusterStateEnum::UNKNOWN; ///< Enumerated state value (default: UNKNOWN)
67 std::string state_message; ///< Human-readable message describing the state
68
69 /**
70 * @brief Parse a ClusterState from JSON string
71 * @param json_str JSON representation of cluster state
72 * @return Parsed ClusterState object
73 * @throws std::runtime_error if parsing fails
74 */
75 static ClusterState from_json(const std::string& json_str);
76 };
77
78} // namespace databricks
ClusterStateEnum
Enumeration of possible cluster lifecycle states.
@ RESTARTING
Cluster is restarting.
@ RUNNING
Cluster is running and ready for use.
@ UNKNOWN
Unknown or unrecognized state.
@ TERMINATED
Cluster has been terminated.
@ ERROR
Cluster is in an error state.
@ PENDING
Cluster is being created.
@ TERMINATING
Cluster is being terminated.
@ RESIZING
Cluster is being resized.
ClusterStateEnum parse_cluster_state(const std::string &state_str)
Parse a cluster state string into ClusterStateEnum.
std::string cluster_state_to_string(ClusterStateEnum state)
Convert ClusterStateEnum to string representation.
Represents detailed state information for a cluster.
ClusterStateEnum cluster_state
Enumerated state value (default: UNKNOWN)
std::string cluster_id
Unique identifier for the cluster.
std::string state_message
Human-readable message describing the state.
static ClusterState from_json(const std::string &json_str)
Parse a ClusterState from JSON string.
Represents a Databricks cluster.
uint64_t terminated_time
Unix timestamp in milliseconds when cluster terminated (0 if running)
std::map< std::string, std::string > custom_tags
User-defined tags for organization and tracking.
std::string cluster_name
Display name of the cluster.
std::string state
Current lifecycle state (e.g., "RUNNING", "TERMINATED")
int num_workers
Number of worker nodes in the cluster.
uint64_t start_time
Unix timestamp in milliseconds when cluster started.
std::string node_type_id
Cloud provider instance type (e.g., "i3.xlarge")
std::string spark_version
Spark runtime version (e.g., "11.3.x-scala2.12")
std::string cluster_id
Unique identifier for the cluster.
std::string creator_user_name
Username of the cluster creator.