public class

HelixConnectionAdaptor

extends Object
implements HelixManager
java.lang.Object
   ↳ org.apache.helix.manager.zk.HelixConnectionAdaptor

Class Overview

Adapt helix-connection to helix-manager, so we can pass to callback-handler and notification-context

Summary

[Expand]
Inherited Constants
From interface org.apache.helix.HelixManager
Public Constructors
HelixConnectionAdaptor(HelixRole role)
Public Methods
void addConfigChangeListener(ConfigChangeListener listener)
void addConfigChangeListener(ScopedConfigChangeListener listener, HelixConfigScope.ConfigScopeProperty scope)
void addControllerListener(ControllerChangeListener listener)
Add listener for controller change Used in distributed cluster controller
void addControllerMessageListener(MessageListener listener)
Add message listener for controller
void addCurrentStateChangeListener(CurrentStateChangeListener listener, String instanceName, String sessionId)
void addExternalViewChangeListener(ExternalViewChangeListener listener)
void addHealthStateChangeListener(HealthStateChangeListener listener, String instanceName)
void addIdealStateChangeListener(IdealStateChangeListener listener)
void addInstanceConfigChangeListener(InstanceConfigChangeListener listener)
void addLiveInstanceChangeListener(LiveInstanceChangeListener listener)
void addMessageListener(MessageListener listener, String instanceName)
void addPreConnectCallback(PreConnectCallback callback)
Add a callback that is invoked before a participant joins the cluster.
void connect()
Start participating in the cluster operations.
void disconnect()
Disconnect from the cluster.
HelixAdmin getClusterManagmentTool()
Provides admin interface to setup and modify cluster.
String getClusterName()
Returns the cluster name associated with this cluster manager
ConfigAccessor getConfigAccessor()
Get config accessor
ParticipantHealthReportCollector getHealthReportCollector()
Participant only component that periodically update participant health report to cluster manager server.
HelixDataAccessor getHelixDataAccessor()
Return the client to perform read/write operations on the cluster data store
ZkHelixPropertyStore<ZNRecord> getHelixPropertyStore()
Get property store
String getInstanceName()
Returns the instanceName used to connect to the cluster
InstanceType getInstanceType()
Get cluster manager instance type
long getLastNotificationTime()
The time stamp is always updated when a notification is received.
ClusterMessagingService getMessagingService()
Messaging service which can be used to send cluster wide messages.
HelixManagerProperties getProperties()
Get helix manager properties read from helix-core/src/main/resources/cluster-manager.properties
String getSessionId()
Get the sessionId associated with the connection to cluster data store.
StateMachineEngine getStateMachineEngine()
String getVersion()
Get cluster manager version
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.
boolean isLeader()
Check if the cluster manager is the leader
boolean removeListener(PropertyKey key, Object listener)
Removes the listener.
void setLiveInstanceInfoProvider(LiveInstanceInfoProvider liveInstanceInfoProvider)
Add a LiveInstanceInfoProvider that is invoked before creating liveInstance.
void startTimerTasks()
start timer tasks when becomes leader
void stopTimerTasks()
stop timer tasks when becomes standby
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.helix.HelixManager

Public Constructors

public HelixConnectionAdaptor (HelixRole role)

Public Methods

public void addConfigChangeListener (ConfigChangeListener listener)

Throws
Exception

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

Throws
Exception

public void addControllerListener (ControllerChangeListener listener)

Add listener for controller change Used in distributed cluster controller

public void addControllerMessageListener (MessageListener listener)

Add message listener for controller

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

Throws
Exception

public void addExternalViewChangeListener (ExternalViewChangeListener listener)

Throws
Exception

public void addHealthStateChangeListener (HealthStateChangeListener listener, String instanceName)

Throws
Exception

public void addIdealStateChangeListener (IdealStateChangeListener listener)

Throws
Exception

public void addInstanceConfigChangeListener (InstanceConfigChangeListener listener)

Throws
Exception

public void addLiveInstanceChangeListener (LiveInstanceChangeListener listener)

Throws
Exception

public void addMessageListener (MessageListener listener, String instanceName)

Throws
Exception

public 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

public 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 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 HelixAdmin getClusterManagmentTool ()

Provides admin interface to setup and modify cluster.

Returns
  • instantiated HelixAdmin

public String getClusterName ()

Returns the cluster name associated with this cluster manager

Returns
  • the associated cluster name

public ConfigAccessor getConfigAccessor ()

Get config accessor

Returns
  • ConfigAccessor

public ParticipantHealthReportCollector getHealthReportCollector ()

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

Returns
  • ParticipantHealthReportCollector

public HelixDataAccessor getHelixDataAccessor ()

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

Returns
  • ClusterDataAccessor

public ZkHelixPropertyStore<ZNRecord> getHelixPropertyStore ()

Get property store

Returns
  • the property store that works with ZNRecord objects

public String getInstanceName ()

Returns the instanceName used to connect to the cluster

Returns
  • the associated instance name

public InstanceType getInstanceType ()

Get cluster manager instance type

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

public 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 ClusterMessagingService getMessagingService ()

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

Returns
  • messaging service

public HelixManagerProperties getProperties ()

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

Returns
  • deserialized properties

public String getSessionId ()

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

Returns
  • the session identifier

public StateMachineEngine getStateMachineEngine ()

public String getVersion ()

Get cluster manager version

Returns
  • the cluster manager version

public 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 boolean isLeader ()

Check if the cluster manager is the leader

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

public 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 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 void startTimerTasks ()

start timer tasks when becomes leader

public void stopTimerTasks ()

stop timer tasks when becomes standby