@Generated public class ClustersAPI extends Object
Databricks maps cluster node instance types to compute units known as DBUs. See the instance type pricing page for a list of the supported instance types and their corresponding DBUs.
A Databricks cluster is a set of computation resources and configurations on which you run data engineering, data science, and data analytics workloads, such as production ETL pipelines, streaming analytics, ad-hoc analytics, and machine learning.
You run these workloads as a set of commands in a notebook or as an automated job. Databricks makes a distinction between all-purpose clusters and job clusters. You use all-purpose clusters to analyze data collaboratively using interactive notebooks. You use job clusters to run fast and robust automated jobs.
You can create an all-purpose cluster using the UI, CLI, or REST API. You can manually terminate and restart an all-purpose cluster. Multiple users can share such clusters to do collaborative interactive analysis.
IMPORTANT: Databricks retains cluster configuration information for terminated clusters for 30 days. To keep an all-purpose cluster configuration even after it has been terminated for more than 30 days, an administrator can pin a cluster to the cluster list.
| Constructor and Description |
|---|
ClustersAPI(ApiClient apiClient)
Regular-use constructor
|
ClustersAPI(ClustersService mock)
Constructor for mocks
|
| Modifier and Type | Method and Description |
|---|---|
void |
changeOwner(ChangeClusterOwner request)
Change the owner of the cluster.
|
Wait<ClusterDetails,CreateClusterResponse> |
create(CreateCluster request)
Creates a new Spark cluster.
|
Wait<ClusterDetails,Void> |
delete(DeleteCluster request)
Terminates the Spark cluster with the specified ID.
|
Wait<ClusterDetails,Void> |
delete(String clusterId) |
Wait<ClusterDetails,Void> |
edit(EditCluster request)
Updates the configuration of a cluster to match the provided attributes and size.
|
Iterable<ClusterEvent> |
events(GetEvents request)
Retrieves a list of events about the activity of a cluster.
|
ClusterDetails |
get(GetClusterRequest request)
Retrieves the information for a cluster given its identifier.
|
ClusterDetails |
get(String clusterId) |
GetClusterPermissionLevelsResponse |
getPermissionLevels(GetClusterPermissionLevelsRequest request)
Gets the permission levels that a user can have on an object.
|
GetClusterPermissionLevelsResponse |
getPermissionLevels(String clusterId) |
ClusterPermissions |
getPermissions(GetClusterPermissionsRequest request)
Gets the permissions of a cluster.
|
ClusterPermissions |
getPermissions(String clusterId) |
ClustersService |
impl() |
Iterable<ClusterDetails> |
list(ListClustersRequest request)
Return information about all pinned and active clusters, and all clusters terminated within the
last 30 days.
|
ListNodeTypesResponse |
listNodeTypes()
Returns a list of supported Spark node types.
|
ListAvailableZonesResponse |
listZones()
Returns a list of availability zones where clusters can be created in (For example,
us-west-2a).
|
void |
permanentDelete(PermanentDeleteCluster request)
Permanently deletes a Spark cluster.
|
void |
permanentDelete(String clusterId) |
void |
pin(PinCluster request)
Pinning a cluster ensures that the cluster will always be returned by the ListClusters API.
|
void |
pin(String clusterId) |
Wait<ClusterDetails,Void> |
resize(ResizeCluster request)
Resizes a cluster to have a desired number of workers.
|
Wait<ClusterDetails,Void> |
restart(RestartCluster request)
Restarts a Spark cluster with the supplied ID.
|
ClusterPermissions |
setPermissions(ClusterPermissionsRequest request)
Sets permissions on an object, replacing existing permissions if they exist.
|
GetSparkVersionsResponse |
sparkVersions()
Returns the list of available Spark versions.
|
Wait<ClusterDetails,Void> |
start(StartCluster request)
Starts a terminated Spark cluster with the supplied ID.
|
Wait<ClusterDetails,Void> |
start(String clusterId) |
void |
unpin(String clusterId) |
void |
unpin(UnpinCluster request)
Unpinning a cluster will allow the cluster to eventually be removed from the ListClusters API.
|
Wait<ClusterDetails,Void> |
update(UpdateCluster request)
Updates the configuration of a cluster to match the partial set of attributes and size.
|
ClusterPermissions |
updatePermissions(ClusterPermissionsRequest request)
Updates the permissions on a cluster.
|
ClusterDetails |
waitGetClusterRunning(String clusterId) |
ClusterDetails |
waitGetClusterRunning(String clusterId,
Duration timeout,
Consumer<ClusterDetails> callback) |
ClusterDetails |
waitGetClusterTerminated(String clusterId) |
ClusterDetails |
waitGetClusterTerminated(String clusterId,
Duration timeout,
Consumer<ClusterDetails> callback) |
public ClustersAPI(ApiClient apiClient)
public ClustersAPI(ClustersService mock)
public ClusterDetails waitGetClusterRunning(String clusterId) throws TimeoutException
TimeoutExceptionpublic ClusterDetails waitGetClusterRunning(String clusterId, Duration timeout, Consumer<ClusterDetails> callback) throws TimeoutException
TimeoutExceptionpublic ClusterDetails waitGetClusterTerminated(String clusterId) throws TimeoutException
TimeoutExceptionpublic ClusterDetails waitGetClusterTerminated(String clusterId, Duration timeout, Consumer<ClusterDetails> callback) throws TimeoutException
TimeoutExceptionpublic void changeOwner(ChangeClusterOwner request)
public Wait<ClusterDetails,CreateClusterResponse> create(CreateCluster request)
If Databricks acquires at least 85% of the requested on-demand nodes, cluster creation will succeed. Otherwise the cluster will terminate with an informative error message.
Rather than authoring the cluster's JSON definition from scratch, Databricks recommends filling out the [create compute UI] and then copying the generated JSON definition from the UI.
[create compute UI]: https://docs.databricks.com/compute/configure.html
public Wait<ClusterDetails,Void> delete(String clusterId)
public Wait<ClusterDetails,Void> delete(DeleteCluster request)
public Wait<ClusterDetails,Void> edit(EditCluster request)
If a cluster is updated while in a `RUNNING` state, it will be restarted so that the new attributes can take effect.
If a cluster is updated while in a `TERMINATED` state, it will remain `TERMINATED`. The next time it is started using the `clusters/start` API, the new attributes will take effect. Any attempt to update a cluster in any other state will be rejected with an `INVALID_STATE` error code.
Clusters created by the Databricks Jobs service cannot be edited.
public Iterable<ClusterEvent> events(GetEvents request)
public ClusterDetails get(String clusterId)
public ClusterDetails get(GetClusterRequest request)
public GetClusterPermissionLevelsResponse getPermissionLevels(String clusterId)
public GetClusterPermissionLevelsResponse getPermissionLevels(GetClusterPermissionLevelsRequest request)
public ClusterPermissions getPermissions(String clusterId)
public ClusterPermissions getPermissions(GetClusterPermissionsRequest request)
public Iterable<ClusterDetails> list(ListClustersRequest request)
public ListNodeTypesResponse listNodeTypes()
public ListAvailableZonesResponse listZones()
public void permanentDelete(String clusterId)
public void permanentDelete(PermanentDeleteCluster request)
In addition, users will no longer see permanently deleted clusters in the cluster list, and API users can no longer perform any action on permanently deleted clusters.
public void pin(String clusterId)
public void pin(PinCluster request)
public Wait<ClusterDetails,Void> resize(ResizeCluster request)
public Wait<ClusterDetails,Void> restart(RestartCluster request)
public ClusterPermissions setPermissions(ClusterPermissionsRequest request)
public GetSparkVersionsResponse sparkVersions()
public Wait<ClusterDetails,Void> start(String clusterId)
public Wait<ClusterDetails,Void> start(StartCluster request)
public void unpin(String clusterId)
public void unpin(UnpinCluster request)
public Wait<ClusterDetails,Void> update(UpdateCluster request)
public ClusterPermissions updatePermissions(ClusterPermissionsRequest request)
public ClustersService impl()
Copyright © 2026. All rights reserved.