public class

AtomicResourceAccessor

extends ResourceAccessor
java.lang.Object
   ↳ org.apache.helix.api.accessor.ResourceAccessor
     ↳ org.apache.helix.api.accessor.AtomicResourceAccessor

Class Overview

An atomic version of the ResourceAccessor. If atomic operations are required, use instances of this class. Atomicity is not guaranteed when using instances of ResourceAccessor 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
AtomicResourceAccessor(ClusterId clusterId, HelixDataAccessor accessor, HelixLockable lockProvider)
Instantiate the accessor
Public Methods
boolean generateDefaultAssignment(ResourceId resourceId, int replicaCount, String participantGroupTag)
Generate a default assignment for partitioned resources
Resource readResource(ResourceId resourceId)
Read a single snapshot of a resource
boolean setRebalancerConfig(ResourceId resourceId, RebalancerConfig config)
Set the config of the rebalancer.
boolean setResource(ResourceConfig resourceConfig)
Persist an existing resource's logical configuration
ResourceConfig updateResource(ResourceId resourceId, ResourceConfig.Delta resourceDelta)
Update a resource configuration
Protected Methods
ParticipantAccessor participantAccessor()
Get a ParticipantAccessor instance
[Expand]
Inherited Methods
From class org.apache.helix.api.accessor.ResourceAccessor
From class java.lang.Object

Public Constructors

public AtomicResourceAccessor (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 generateDefaultAssignment (ResourceId resourceId, int replicaCount, String participantGroupTag)

Generate a default assignment for partitioned resources

Parameters
resourceId the resource to update
replicaCount the new replica count (or -1 to use the existing one)
participantGroupTag the new participant group tag (or null to use the existing one)
Returns
  • true if assignment successful, false otherwise

public Resource readResource (ResourceId resourceId)

Read a single snapshot of a resource

Parameters
resourceId the resource id to read
Returns
  • Resource or null if not present

public boolean setRebalancerConfig (ResourceId resourceId, RebalancerConfig config)

Set the config of the rebalancer. This includes all properties required for rebalancing this resource

Parameters
resourceId the resource to update
config the new rebalancer config
Returns
  • true if the config was set, false otherwise

public boolean setResource (ResourceConfig resourceConfig)

Persist an existing resource's logical configuration

Parameters
resourceConfig logical resource configuration
Returns
  • true if resource is set, false otherwise

public ResourceConfig updateResource (ResourceId resourceId, ResourceConfig.Delta resourceDelta)

Update a resource configuration

Parameters
resourceId the resource id to update
resourceDelta changes to the resource
Returns
  • ResourceConfig, or null if the resource is not persisted

Protected Methods

protected ParticipantAccessor participantAccessor ()

Get a ParticipantAccessor instance

Returns
  • ParticipantAccessor