org.apache.ignite.internal.processors.cluster

## Class GridClusterStateProcessor

- java.lang.Object
- - org.apache.ignite.internal.processors.GridProcessorAdapter
  - - org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor

All Implemented Interfaces:
  GridComponent, MetastorageLifecycleListener, IGridClusterStateProcessor, GridProcessor

    public class GridClusterStateProcessor
    extends GridProcessorAdapter
    implements IGridClusterStateProcessor, MetastorageLifecycleListener

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent

`GridComponent.DiscoveryDataExchangeType`

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`ctx, diagnosticLog, log`

### Constructor Summary

Constructors
Constructor and Description
`GridClusterStateProcessor(GridKernalContext ctx)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`protected void` `afterStateChangeFinished(IgniteUuid msgId, boolean success)`
`void` `cacheProcessorStarted()`
`IgniteInternalFuture<?>` `changeGlobalState(boolean activate, Collection<? extends BaselineNode> baselineNodes, boolean forceChangeBaselineTopology)`
`DiscoveryDataClusterState` `clusterState()`
`void` `collectGridNodeData(DiscoveryDataBag dataBag)` Collects discovery data on nodes already in grid on receiving `TcpDiscoveryNodeAddedMessage`.
`void` `collectJoiningNodeData(DiscoveryDataBag dataBag)` Collects discovery data on joining node before sending `TcpDiscoveryJoinRequestMessage` request.
`boolean` `compatibilityMode()`
`protected IgniteCheckedException` `concurrentStateChangeError(boolean activate)`
`GridComponent.DiscoveryDataExchangeType` `discoveryDataType()` Gets unique component type to distinguish components providing discovery data.
`boolean` `evictionsAllowed()`
`protected boolean` `isApplicable(ChangeGlobalStateMessage msg, DiscoveryDataClusterState state)`
`protected static boolean` `isEquivalent(ChangeGlobalStateMessage msg, DiscoveryDataClusterState state)`
`void` `onBaselineTopologyChanged(BaselineTopology blt, BaselineTopologyHistoryItem prevBltHistItem)`
`void` `onExchangeFinishedOnCoordinator(IgniteInternalFuture exchangeFuture, boolean hasMovingPartitions)`
`void` `onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data)` Receives discovery data object from remote nodes (called on new node during discovery process).
`void` `onKernalStop(boolean cancel)` Callback to notify that kernal is about to stop.
`IgniteInternalFuture<Boolean>` `onLocalJoin(DiscoCache discoCache)`
`ChangeGlobalStateFinishMessage` `onNodeLeft(ClusterNode node)`
`void` `onReadyForRead(ReadOnlyMetastorage metastorage)` Is called when metastorage is made ready for read-only operations very early on node startup phase.
`void` `onReadyForReadWrite(ReadWriteMetastorage metastorage)` Fully functional metastore capable of performing reading and writing operations.
`void` `onStateChangeError(Map<UUID,Exception> errs, StateChangeRequest req)`
`void` `onStateChangeExchangeDone(StateChangeRequest req)`
`boolean` `onStateChangeMessage(AffinityTopologyVersion topVer, ChangeGlobalStateMessage msg, DiscoCache discoCache)`
`void` `onStateFinishMessage(ChangeGlobalStateFinishMessage msg)`
`DiscoveryDataClusterState` `pendingState(ChangeGlobalStateMessage stateMsg)`
`boolean` `publicApiActiveState(boolean waitForTransition)`
`void` `resetBranchingHistory(long newBranchingHash)` Resets branching history on current BaselineTopology.
`void` `start()` Starts grid component.
`void` `stop(boolean cancel)` Stops grid component.
`String` `toString()`
`IgniteNodeValidationResult` `validateNode(ClusterNode node, DiscoveryDataBag.JoiningNodeDiscoveryData discoData)`
`protected IgniteInternalFuture<?>` `wrapStateChangeFuture(IgniteInternalFuture fut, ChangeGlobalStateMessage msg)`

### Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`assertParameter, onDisconnected, onJoiningNodeDataReceived, onKernalStart, onReconnected, printMemoryStats, validateNode`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.apache.ignite.internal.GridComponent

`onDisconnected, onJoiningNodeDataReceived, onKernalStart, onReconnected, printMemoryStats, validateNode`

### Constructor Detail

#### GridClusterStateProcessor

    public GridClusterStateProcessor(GridKernalContext ctx)

Parameters:
  `ctx` - Kernal context.

### Method Detail

#### compatibilityMode

    public boolean compatibilityMode()

Returns:
  `True` if `IGridClusterStateProcessor` has detected that cluster is working in compatibility mode (nodes of different versions are joined to the cluster).

#### publicApiActiveState

    public boolean publicApiActiveState(boolean waitForTransition)

Specified by:
  `publicApiActiveState` in interface `IGridClusterStateProcessor`
Returns:
  Cluster state to be used on public API.

#### onReadyForRead

    public void onReadyForRead(ReadOnlyMetastorage metastorage)
                        throws IgniteCheckedException

Is called when metastorage is made ready for read-only operations very early on node startup phase. Reference for read-only metastorage should be used only within this method and shouldn't be stored to any field.

Specified by:
  `onReadyForRead` in interface `MetastorageLifecycleListener`
Parameters:
  `metastorage` - Read-only meta storage.
Throws:
  `IgniteCheckedException`

#### onReadyForReadWrite

    public void onReadyForReadWrite(ReadWriteMetastorage metastorage)
                             throws IgniteCheckedException

Fully functional metastore capable of performing reading and writing operations. Components interested in using metastore are allowed to keep reference passed into the method in their fields.

Specified by:
  `onReadyForReadWrite` in interface `MetastorageLifecycleListener`
Parameters:
  `metastorage` - Fully functional meta storage.
Throws:
  `IgniteCheckedException`

#### resetBranchingHistory

    public void resetBranchingHistory(long newBranchingHash)
                               throws IgniteCheckedException

Resets branching history on current BaselineTopology.

Throws:
  `IgniteCheckedException` - If write to metastore has failed.

#### start

    public void start()
               throws IgniteCheckedException

Starts grid component.

Specified by:
  `start` in interface `GridComponent`
Overrides:
  `start` in class `GridProcessorAdapter`
Throws:
  `IgniteCheckedException` - Throws in case of any errors.

#### onKernalStop

    public void onKernalStop(boolean cancel)

Callback to notify that kernal is about to stop.

Specified by:
  `onKernalStop` in interface `GridComponent`
Overrides:
  `onKernalStop` in class `GridProcessorAdapter`
Parameters:
  `cancel` - Flag indicating whether jobs should be canceled.

#### onLocalJoin

    @Nullable
    public IgniteInternalFuture<Boolean> onLocalJoin(DiscoCache discoCache)

Specified by:
  `onLocalJoin` in interface `IGridClusterStateProcessor`
Parameters:
  `discoCache` - Discovery data cache.
Returns:
  If transition is in progress returns future which is completed when transition finishes.

#### onNodeLeft

    @Nullable
    public ChangeGlobalStateFinishMessage onNodeLeft(ClusterNode node)

Specified by:
  `onNodeLeft` in interface `IGridClusterStateProcessor`
Parameters:
  `node` - Failed node.
Returns:
  Message if cluster state changed.

#### onStateFinishMessage

    public void onStateFinishMessage(ChangeGlobalStateFinishMessage msg)

Specified by:
  `onStateFinishMessage` in interface `IGridClusterStateProcessor`
Parameters:
  `msg` - Message.

#### afterStateChangeFinished

    protected void afterStateChangeFinished(IgniteUuid msgId,
                                            boolean success)

#### onStateChangeMessage

    public boolean onStateChangeMessage(AffinityTopologyVersion topVer,
                                        ChangeGlobalStateMessage msg,
                                        DiscoCache discoCache)

Specified by:
  `onStateChangeMessage` in interface `IGridClusterStateProcessor`
Parameters:
  `topVer` - Current topology version.
  `msg` - Message.
  `discoCache` - Current nodes.
Returns:
  `True` if need start state change process.

#### isApplicable

    protected boolean isApplicable(ChangeGlobalStateMessage msg,
                                   DiscoveryDataClusterState state)

Parameters:
  `msg` - State change message.
  `state` - Current cluster state.
Returns:
  `True` if state change from message can be applied to the current state.

#### isEquivalent

    protected static boolean isEquivalent(ChangeGlobalStateMessage msg,
                                          DiscoveryDataClusterState state)

Parameters:
  `msg` - State change message.
  `state` - Current cluster state.
Returns:
  `True` if states are equivalent.

#### clusterState

    public DiscoveryDataClusterState clusterState()

Specified by:
  `clusterState` in interface `IGridClusterStateProcessor`
Returns:
  Current cluster state, should be called only from discovery thread.

#### pendingState

    public DiscoveryDataClusterState pendingState(ChangeGlobalStateMessage stateMsg)

Specified by:
  `pendingState` in interface `IGridClusterStateProcessor`
Returns:
  Pending cluster state which will be used when state transition is finished.

#### concurrentStateChangeError

    protected IgniteCheckedException concurrentStateChangeError(boolean activate)

Parameters:
  `activate` - New state.
Returns:
  State change error.

#### cacheProcessorStarted

    public void cacheProcessorStarted()

Specified by:
  `cacheProcessorStarted` in interface `IGridClusterStateProcessor`

#### stop

    public void stop(boolean cancel)
              throws IgniteCheckedException

Stops grid component.

Specified by:
  `stop` in interface `GridComponent`
Overrides:
  `stop` in class `GridProcessorAdapter`
Parameters:
  `cancel` - If `true`, then all ongoing tasks or jobs for relevant components need to be cancelled.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### discoveryDataType

    @Nullable
    public GridComponent.DiscoveryDataExchangeType discoveryDataType()

Gets unique component type to distinguish components providing discovery data. Must return non-null value if component implements any of methods `GridComponent.collectJoiningNodeData(DiscoveryDataBag)` or `GridComponent.collectGridNodeData(DiscoveryDataBag)`.

Specified by:
  `discoveryDataType` in interface `GridComponent`
Overrides:
  `discoveryDataType` in class `GridProcessorAdapter`
Returns:
  Unique component type for discovery data exchange.

#### collectJoiningNodeData

    public void collectJoiningNodeData(DiscoveryDataBag dataBag)

Collects discovery data on joining node before sending `TcpDiscoveryJoinRequestMessage` request.

Specified by:
  `collectJoiningNodeData` in interface `GridComponent`
Overrides:
  `collectJoiningNodeData` in class `GridProcessorAdapter`
Parameters:
  `dataBag` - container object to store discovery data in.

#### collectGridNodeData

    public void collectGridNodeData(DiscoveryDataBag dataBag)

Collects discovery data on nodes already in grid on receiving `TcpDiscoveryNodeAddedMessage`.

Specified by:
  `collectGridNodeData` in interface `GridComponent`
Overrides:
  `collectGridNodeData` in class `GridProcessorAdapter`
Parameters:
  `dataBag` - container object to store discovery data in.

#### onGridDataReceived

    public void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data)

Receives discovery data object from remote nodes (called on new node during discovery process).

Specified by:
  `onGridDataReceived` in interface `GridComponent`
Overrides:
  `onGridDataReceived` in class `GridProcessorAdapter`
Parameters:
  `data` - `DiscoveryDataBag.GridDiscoveryData` interface to retrieve discovery data collected on remote nodes (data common for all nodes in grid and specific for each node).

#### changeGlobalState

    public IgniteInternalFuture<?> changeGlobalState(boolean activate,
                                                     Collection<? extends BaselineNode> baselineNodes,
                                                     boolean forceChangeBaselineTopology)

Specified by:
  `changeGlobalState` in interface `IGridClusterStateProcessor`
Parameters:
  `activate` - New cluster state.
Returns:
  State change future.

#### validateNode

    @Nullable
    public IgniteNodeValidationResult validateNode(ClusterNode node,
                                                             DiscoveryDataBag.JoiningNodeDiscoveryData discoData)

Specified by:
  `validateNode` in interface `GridComponent`
Overrides:
  `validateNode` in class `GridProcessorAdapter`

#### wrapStateChangeFuture

    protected IgniteInternalFuture<?> wrapStateChangeFuture(IgniteInternalFuture fut,
                                                            ChangeGlobalStateMessage msg)

Parameters:
  `fut` - Original state change future.
  `msg` - State change message.
Returns:
  Wrapped state change future.

#### onStateChangeError

    public void onStateChangeError(Map<UUID,Exception> errs,
                                   StateChangeRequest req)

Specified by:
  `onStateChangeError` in interface `IGridClusterStateProcessor`
Parameters:
  `errs` - Errors.
  `req` - State change request.

#### onStateChangeExchangeDone

    public void onStateChangeExchangeDone(StateChangeRequest req)

Specified by:
  `onStateChangeExchangeDone` in interface `IGridClusterStateProcessor`
Parameters:
  `req` - State change request.

#### onBaselineTopologyChanged

    public void onBaselineTopologyChanged(BaselineTopology blt,
                                          BaselineTopologyHistoryItem prevBltHistItem)
                                   throws IgniteCheckedException

Specified by:
  `onBaselineTopologyChanged` in interface `IGridClusterStateProcessor`
Parameters:
  `blt` - New baseline topology.
  `prevBltHistItem` - Previous baseline history item.
Throws:
  `IgniteCheckedException`

#### onExchangeFinishedOnCoordinator

    public void onExchangeFinishedOnCoordinator(IgniteInternalFuture exchangeFuture,
                                                boolean hasMovingPartitions)

Specified by:
  `onExchangeFinishedOnCoordinator` in interface `IGridClusterStateProcessor`
Parameters:
  `exchangeFuture` - Exchange future.
  `hasMovingPartitions` - `True` if there are moving partitions.

#### evictionsAllowed

    public boolean evictionsAllowed()

Specified by:
  `evictionsAllowed` in interface `IGridClusterStateProcessor`
Returns:
  `True` if partition evictions are allowed in current state.

#### toString

    public String toString()

Overrides:
  `toString` in class `GridProcessorAdapter`

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.7.0
Release Date | : November 30 2018