public abstract class

AbstractParticipantService

extends AbstractService
java.lang.Object
   ↳ com.google.common.util.concurrent.AbstractService
     ↳ org.apache.helix.participant.AbstractParticipantService
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

A modeling of a helix participant as a self-contained service.

Summary

Public Constructors
AbstractParticipantService(HelixConnection connection, ClusterId clusterId, ParticipantId participantId)
Initialize the service.
Public Methods
ClusterId getClusterId()
HelixConnection getConnection()
HelixParticipant getParticipant()
Get an instantiated participant instance.
ParticipantId getParticipantId()
Protected Methods
final void doStart()
final void doStop()
abstract void init()
Initialize the participant.
void onReconnect()
Invoked when connection is re-established to zookeeper.
[Expand]
Inherited Methods
From class com.google.common.util.concurrent.AbstractService
From class java.lang.Object
From interface com.google.common.util.concurrent.Service

Public Constructors

public AbstractParticipantService (HelixConnection connection, ClusterId clusterId, ParticipantId participantId)

Initialize the service.

Parameters
connection A live Helix connection
clusterId the cluster to join
participantId a unique identifier that this participant will join with

Public Methods

public ClusterId getClusterId ()

Returns
  • ClusterId
See Also
  • {@link ClusterId}

public HelixConnection getConnection ()

Returns
  • HelixConnection
See Also
  • {@link HelixConnection}

public HelixParticipant getParticipant ()

Get an instantiated participant instance.

Returns
  • HelixParticipant

public ParticipantId getParticipantId ()

See Also
  • {@link ParticipantId}

Protected Methods

protected final void doStart ()

protected final void doStop ()

protected abstract void init ()

Initialize the participant. For example, here is where you can

  • Read configuration of the cluster,resource, node
  • Read configuration of the cluster,resource, node register a state machine:

    HelixParticipant participant = getParticipant(); participant.getStateMachineEngine().registerStateModelFactory(stateModelDefId, factory);

This code is called after connecting to zookeeper but before creating the liveinstance.

protected void onReconnect ()

Invoked when connection is re-established to zookeeper. Typical scenario this is invoked is when there is a long GC pause that causes the node to disconnect from the cluster and reconnects. NOTE: When the service disconnects all its states are reset to initial state.