public class

AtomicClusterAccessor

extends ClusterAccessor
java.lang.Object
   ↳ org.apache.helix.api.accessor.ClusterAccessor
     ↳ org.apache.helix.api.accessor.AtomicClusterAccessor

Class Overview

An atomic version of the ClusterAccessor. If atomic operations are required, use instances of this class. Atomicity is not guaranteed when using instances of ClusterAccessor alongside instances of this class. Furthermore, depending on the semantics of the lock, lock acquisition may fail, in which case users should handle the return value of each function if necessary.

Using this class is quite expensive; it should thus be used sparingly and only in systems where contention on these operations is expected. For most systems running Helix, this is typically not the case.

Summary

Public Constructors
AtomicClusterAccessor(ClusterId clusterId, HelixDataAccessor accessor, HelixLockable lockProvider)
Instantiate the accessor
Public Methods
boolean addParticipantToCluster(ParticipantConfig participant)
add a participant to cluster
boolean addResourceToCluster(ResourceConfig resource)
add a resource to cluster
boolean createCluster(ClusterConfig cluster)
create a new cluster, fail if it already exists
boolean dropCluster()
drop a cluster
boolean dropParticipantFromCluster(ParticipantId participantId)
drop a participant from cluster
boolean dropResourceFromCluster(ResourceId resourceId)
drop a resource from cluster
void initClusterStructure()
Create empty persistent properties to ensure that there is a valid cluster structure
Cluster readCluster()
read entire cluster data
Map<ParticipantIdParticipant> readParticipants()
Read participants atomically.
Map<ResourceIdResource> readResources()
Read resources atomically.
ClusterConfig updateCluster(ClusterConfig.Delta clusterDelta)
Update the cluster configuration
[Expand]
Inherited Methods
From class org.apache.helix.api.accessor.ClusterAccessor
From class java.lang.Object

Public Constructors

public AtomicClusterAccessor (ClusterId clusterId, HelixDataAccessor accessor, HelixLockable lockProvider)

Instantiate the accessor

Parameters
clusterId the cluster to access
accessor a HelixDataAccessor for the physical properties
lockProvider a lock provider

Public Methods

public boolean addParticipantToCluster (ParticipantConfig participant)

add a participant to cluster

Returns
  • true if participant added, false otherwise

public boolean addResourceToCluster (ResourceConfig resource)

add a resource to cluster

Returns
  • true if resource added, false if there was an error

public boolean createCluster (ClusterConfig cluster)

create a new cluster, fail if it already exists

Returns
  • true if created, false if creation failed

public boolean dropCluster ()

drop a cluster

Returns
  • true if the cluster was dropped, false if there was an error

public boolean dropParticipantFromCluster (ParticipantId participantId)

drop a participant from cluster

Returns
  • true if participant dropped, false if there was an error

public boolean dropResourceFromCluster (ResourceId resourceId)

drop a resource from cluster

Returns
  • true if removal succeeded, false otherwise

public void initClusterStructure ()

Create empty persistent properties to ensure that there is a valid cluster structure

public Cluster readCluster ()

read entire cluster data

Returns
  • cluster snapshot or null

public Map<ParticipantIdParticipant> readParticipants ()

Read participants atomically. This is participant-atomic, not cluster-atomic

Returns
  • map of participant id to participant, or empty map

public Map<ResourceIdResource> readResources ()

Read resources atomically. This is resource-atomic, not cluster-atomic

Returns
  • map of resource id to resource

public ClusterConfig updateCluster (ClusterConfig.Delta clusterDelta)

Update the cluster configuration

Parameters
clusterDelta change to the cluster configuration
Returns
  • updated ClusterConfig, or null if there was an error