public interface

HelixManager

org.apache.helix.HelixManager
Known Indirect Subclasses

Class Overview

Class that represents the Helix Agent. First class Object any process will interact with
General flow

 manager = HelixManagerFactory.getZKHelixManager(
    clusterName, instanceName, ROLE, zkAddr);
    // ROLE can be participant, spectator or a controller
manager.addPreConnectCallback(cb); // cb is invoked after a connection is established, but before the node of type ROLE has // joined the cluster. This is where one can add additional listeners (e.g manager.addSOMEListener(listener);) manager.connect(); After connect is invoked the subsequent interactions will be via listener onChange callbacks There will be 3 scenarios for onChange callback, which can be determined using NotificationContext.type INIT -> will be invoked the first time the listener is added CALLBACK -> will be invoked due to datachange in the property value FINALIZE -> will be invoked when listener is removed or session expires manager.disconnect()
Default implementations available

Summary

Constants
String ALLOW_PARTICIPANT_AUTO_JOIN
Public Methods
abstract void addConfigChangeListener(ConfigChangeListener listener)
This method is deprecated. replaced by addInstanceConfigChangeListener()
abstract void addConfigChangeListener(ScopedConfigChangeListener listener, HelixConfigScope.ConfigScopeProperty scope)
abstract void addControllerListener(ControllerChangeListener listener)
Add listener for controller change Used in distributed cluster controller
abstract void addControllerMessageListener(MessageListener listener)
Add message listener for controller
abstract void addCurrentStateChangeListener(CurrentStateChangeListener listener, String instanceName, String sessionId)
abstract void addExternalViewChangeListener(ExternalViewChangeListener listener)
abstract void addIdealStateChangeListener(IdealStateChangeListener listener)
abstract void addInstanceConfigChangeListener(InstanceConfigChangeListener listener)
abstract void addLiveInstanceChangeListener(LiveInstanceChangeListener listener)
abstract void addMessageListener(MessageListener listener, String instanceName)
abstract void addPreConnectCallback(PreConnectCallback callback)
Add a callback that is invoked before a participant joins the cluster.
abstract void connect()
Start participating in the cluster operations.
abstract void disconnect()
Disconnect from the cluster.
abstract HelixAdmin getClusterManagmentTool()
Provides admin interface to setup and modify cluster.
abstract String getClusterName()
Returns the cluster name associated with this cluster manager
abstract ConfigAccessor getConfigAccessor()
Get config accessor
abstract ParticipantHealthReportCollector getHealthReportCollector()
Participant only component that periodically update participant health report to cluster manager server.
abstract HelixDataAccessor getHelixDataAccessor()
Return the client to perform read/write operations on the cluster data store
abstract ZkHelixPropertyStore<ZNRecord> getHelixPropertyStore()
Get property store
abstract String getInstanceName()
Returns the instanceName used to connect to the cluster
abstract InstanceType getInstanceType()
Get cluster manager instance type
abstract long getLastNotificationTime()
The time stamp is always updated when a notification is received.
abstract ClusterMessagingService getMessagingService()
Messaging service which can be used to send cluster wide messages.
abstract HelixManagerProperties getProperties()
Get helix manager properties read from helix-core/src/main/resources/cluster-manager.properties
abstract String getSessionId()
Get the sessionId associated with the connection to cluster data store.
abstract StateMachineEngine getStateMachineEngine()
abstract String getVersion()
Get cluster manager version
abstract boolean isConnected()
Check if the connection is alive, code depending on cluster manager must always do this if( manager.isConnected()){ //custom code } This will prevent client in doing anything when its disconnected from the cluster.
abstract boolean isLeader()
Check if the cluster manager is the leader
abstract boolean removeListener(PropertyKey key, Object listener)
Removes the listener.
abstract void setLiveInstanceInfoProvider(LiveInstanceInfoProvider liveInstanceInfoProvider)
Add a LiveInstanceInfoProvider that is invoked before creating liveInstance.
abstract void startTimerTasks()
start timer tasks when becomes leader
abstract void stopTimerTasks()
stop timer tasks when becomes standby

Constants

public static final String ALLOW_PARTICIPANT_AUTO_JOIN

Constant Value: "allowParticipantAutoJoin"

Public Methods

public abstract void addConfigChangeListener (ConfigChangeListener listener)

This method is deprecated.
replaced by addInstanceConfigChangeListener()

Throws
Exception

public abstract void addConfigChangeListener (ScopedConfigChangeListener listener, HelixConfigScope.ConfigScopeProperty scope)

public abstract void addControllerListener (ControllerChangeListener listener)

Add listener for controller change Used in distributed cluster controller

public abstract void addControllerMessageListener (MessageListener listener)

Add message listener for controller

public abstract void addCurrentStateChangeListener (CurrentStateChangeListener listener, String instanceName, String sessionId)

public abstract void addExternalViewChangeListener (ExternalViewChangeListener listener)

public abstract void addIdealStateChangeListener (IdealStateChangeListener listener)

public abstract void addInstanceConfigChangeListener (InstanceConfigChangeListener listener)

public abstract void addLiveInstanceChangeListener (LiveInstanceChangeListener listener)

public abstract void addMessageListener (MessageListener listener, String instanceName)

public abstract void addPreConnectCallback (PreConnectCallback callback)

Add a callback that is invoked before a participant joins the cluster.
This zookeeper connection is established at this time and one can read existing cluster data
The purpose of this method is to allow application to have additional logic to validate their existing state and check for any errors. If the validation fails, throw exception/disable the instance. s

See Also

public abstract void connect ()

Start participating in the cluster operations. All listeners will be initialized and will be notified for every cluster state change This method is not re-entrant. One cannot call this method twice.

Throws
Exception

public abstract void disconnect ()

Disconnect from the cluster. All the listeners will be removed and disconnected from the server. Its important for the client to ensure that new manager instance is used when it wants to connect again.

public abstract HelixAdmin getClusterManagmentTool ()

Provides admin interface to setup and modify cluster.

Returns
  • instantiated HelixAdmin

public abstract String getClusterName ()

Returns the cluster name associated with this cluster manager

Returns
  • the associated cluster name

public abstract ConfigAccessor getConfigAccessor ()

Get config accessor

Returns
  • ConfigAccessor

public abstract ParticipantHealthReportCollector getHealthReportCollector ()

Participant only component that periodically update participant health report to cluster manager server.

Returns
  • ParticipantHealthReportCollector

public abstract HelixDataAccessor getHelixDataAccessor ()

Return the client to perform read/write operations on the cluster data store

Returns
  • ClusterDataAccessor

public abstract ZkHelixPropertyStore<ZNRecord> getHelixPropertyStore ()

Get property store

Returns
  • the property store that works with ZNRecord objects

public abstract String getInstanceName ()

Returns the instanceName used to connect to the cluster

Returns
  • the associated instance name

public abstract InstanceType getInstanceType ()

Get cluster manager instance type

Returns
  • instance type (e.g. PARTICIPANT, CONTROLLER, SPECTATOR)

public abstract long getLastNotificationTime ()

The time stamp is always updated when a notification is received. This can be used to check if there was any new notification when previous notification was being processed. This is updated based on the notifications from listeners registered.

Returns
  • UNIX timestamp

public abstract ClusterMessagingService getMessagingService ()

Messaging service which can be used to send cluster wide messages.

Returns
  • messaging service

public abstract HelixManagerProperties getProperties ()

Get helix manager properties read from helix-core/src/main/resources/cluster-manager.properties

Returns
  • deserialized properties

public abstract String getSessionId ()

Get the sessionId associated with the connection to cluster data store.

Returns
  • the session identifier

public abstract StateMachineEngine getStateMachineEngine ()

Returns
  • the state machine engine

public abstract String getVersion ()

Get cluster manager version

Returns
  • the cluster manager version

public abstract boolean isConnected ()

Check if the connection is alive, code depending on cluster manager must always do this if( manager.isConnected()){ //custom code } This will prevent client in doing anything when its disconnected from the cluster. There is no need to invoke connect again if isConnected return false.

Returns
  • true if connected, false otherwise

public abstract boolean isLeader ()

Check if the cluster manager is the leader

Returns
  • true if this is a controller and a leader of the cluster

public abstract boolean removeListener (PropertyKey key, Object listener)

Removes the listener. If the same listener was used for multiple changes, all change notifications will be removed.
This will invoke onChange method on the listener with NotificationContext.type set to FINALIZE. Listener can clean up its state.
The data provided in this callback may not be reliable.
When a session expires all listeners will be removed and re-added automatically.
This provides the ability for listeners to either reset their state or do any cleanup tasks.

Returns
  • true if removed successfully, false otherwise

public abstract void setLiveInstanceInfoProvider (LiveInstanceInfoProvider liveInstanceInfoProvider)

Add a LiveInstanceInfoProvider that is invoked before creating liveInstance.
This allows applications to provide additional metadata that will be published to zk and made available for discovery

public abstract void startTimerTasks ()

start timer tasks when becomes leader

public abstract void stopTimerTasks ()

stop timer tasks when becomes standby