Class ODistributedPlugin
java.lang.Object
com.orientechnologies.orient.server.plugin.OServerPluginAbstract
com.orientechnologies.orient.server.distributed.impl.ODistributedPlugin
- All Implemented Interfaces:
OService,ODistributedServerManager,OServerPlugin
- Direct Known Subclasses:
OHazelcastPlugin
Plugin to manage the distributed environment.
- Author:
- Luca Garulli (l.garulli--at--orientechnologies.com)
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.orientechnologies.orient.server.distributed.ODistributedServerManager
ODistributedServerManager.DB_STATUS -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Fileprotected static final intprotected List<ODistributedLifecycleListener>protected AtomicLongprotected ODistributedMessageServiceImplprotected static final Stringprotected static final Stringprotected ORemoteServerManagerstatic final Stringprotected ODistributedStrategyprotected CountDownLatchprotected OSignalHandler.OSignalListenerprotected Dateprotected ORemoteTaskFactoryManagerFields inherited from class com.orientechnologies.orient.server.plugin.OServerPluginAbstract
enabledFields inherited from interface com.orientechnologies.orient.server.distributed.ODistributedServerManager
FILE_DISTRIBUTED_DB_CONFIG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidbackupCurrentDatabase(String iDatabaseName) protected intcalculateQuorum(OCommandDistributedReplicateRequest.QUORUM_TYPE quorumType, ODistributedConfiguration cfg, int totalServers, int totalMasterServers, int onlineMasters, boolean checkNodesAreOnline, String localNodeName) protected voidcheckForServerOnline(ODistributedRequest iRequest) voidcheckNodeInConfiguration(String databaseName, ODistributedConfiguration cfg) voidcloseRemoteServer(String node) voidconfig(OServer oServer, OServerParameterConfiguration[] iParams) Configures the handler.voidconnectToAllNodes(Set<String> clusterNodes) voiddropConfig(String dbName) voiddropOnAllServers(String dbName) voidAvoids to dump the same configuration twice if it's unchanged since the last time.protected void<T> TexecuteInDistributedDatabaseLock(String databaseName, long timeoutLocking, OModifiableDistributedConfiguration lastCfg, OCallable<T, OModifiableDistributedConfiguration> iCallback) Executes an operation protected by a distributed lock (one per database).<T> TexecuteInDistributedDatabaseLock(String databaseName, long timeoutLocking, Callable<T> iCallback) executeOnLocalNode(ODistributedRequestId reqId, ORemoteTask task, ODatabaseDocumentInternal database) Executes the request on local node.voidgetAvailableNodeNames(String databaseName) getAvailableNodeNotLocalNames(String databaseName) intgetAvailableNodes(String iDatabaseName) getDatabase(String name) getDatabaseConfiguration(String iDatabaseName) getDatabaseStatus(String iNode, String iDatabaseName) com.hazelcast.core.HazelcastInstancelongstatic StringintgetName()longgetNodeConfigurationByUuid(String iNode, boolean useCache) intgetNodeIdByName(String node) getNodeNameById(int id) intgetNodesWithStatus(Collection<String> iNodes, String databaseName, ODistributedServerManager.DB_STATUS... statuses) Returns the nodes with the requested status.getOnlineDatabaseConfiguration(String databaseName) getOnlineNodes(String iDatabaseName) getOnlineNodesNotLocal(String iDatabaseName) getRemoteServer(String rNodeName) Returns the task factory manager.booleaninstallDatabase(boolean iStartup, String databaseName, boolean forceDeployment, boolean tryWithDeltaFirst) protected voidinstallDatabaseFromNetwork(String dbPath, String databaseName, String iNode, ODistributedDatabaseChunk firstChunk) Installs a database from the network.protected voidinstallDatabaseOnLocalNode(String databaseName, String dbPath, String iNode, boolean incremental, OSyncReceiver receiver) voidinternalCheckNodeInConfig(String databaseName, OModifiableDistributedConfiguration lastCfg) internalInstallDatabase(boolean iStartup, String databaseName, boolean forceDeployment, boolean tryWithDeltaFirst) voidinvokeOnDatabaseStatusChange(String iNode, String iDatabaseName, ODistributedServerManager.DB_STATUS iStatus) booleanbooleanisNodeAvailable(String iNodeName) booleanisNodeAvailable(String iNodeName, String databaseName) Available means not OFFLINE, so ONLINE or SYNCHRONIZING.booleanisNodeOnline(String iNodeName, String databaseName) Returns true if the node status is ONLINE.booleanisNodeStatusEqualsTo(String iNodeName, String iDatabaseName, ODistributedServerManager.DB_STATUS... statuses) Checks the node status if it's one of the statuses received as argument.booleanbooleanisSyncronizing(String databaseName) booleanisWriteQuorumPresent(String databaseName) Returns true if the quorum is present in terms of number of available nodes for full replication only.voidInitializes all the available server's databases as distributed.voidmessageAfterOp(String op, ODistributedRequestId request) voidmessageBeforeOp(String op, ODistributedRequestId request) voidmessageCurrentPayload(ODistributedRequestId requestId, Object responsePayload) voidmessageProcessEnd(ODistributedRequest iRequest, Object responsePayload) voidmessageProcessStart(ODistributedRequest message) voidmessageReceived(ODistributedRequest request) voidnotifyClients(String databaseName) voidvoidonDatabaseEvent(String nodeName, String databaseName, ODistributedServerManager.DB_STATUS status) voidonDbConfigUpdated(String databaseName, ODocument config) voidonDbStatusOnline(String databaseName) voidonNodeJoined(String joinedNodeName, com.hazelcast.core.Member member) booleanonNodeJoining(String joinedNodeName) voidonServerRemoved(String nodeName) voidpublishDistributedConfiguration(String iDatabaseName, ODistributedConfiguration cfg) voidreassignClustersOwnership(String iNode, String databaseName, boolean canCreateNewClusters) voidvoidbooleanremoveNodeFromConfiguration(String nodeName, String databaseName, boolean removeOnlyDynamicServers, boolean statusOffline) voidremoveServer(String nodeLeftName, boolean removeOnlyDynamicServers) protected booleanrequestDatabaseFullSync(boolean backupDatabase, String databaseName) protected booleanrequestFullDatabase(String databaseName, boolean backupDatabase) voidrestartNode(String iNode) send2Nodes(ODistributedRequest iRequest, Collection<String> iNodes, ODistributedRequest.EXECUTION_MODE iExecutionMode, Object localResult) send2Nodes(ODistributedRequest iRequest, Collection<String> iNodes, ODistributedRequest.EXECUTION_MODE iExecutionMode, Object localResult, ODistributedResponseManagerFactory responseManagerFactory) sendRequest(String iDatabaseName, Collection<String> iTargetNodes, ORemoteTask iTask) Sends a distributed request against multiple servers.sendRequest(String iDatabaseName, Collection<String> iTargetNodes, ORemoteTask iTask, ODistributedRequestId reqId, Object localResult, ODistributedResponseManagerFactory responseManagerFactory) voidsendSingleRequest(String databaseName, String node, ORemoteTask iTask) Sends a distributed request against multiple servers.voidsetDatabaseStatus(String iNode, String iDatabaseName, ODistributedServerManager.DB_STATUS iStatus) voidvoidsetDistributedStrategy(ODistributedStrategy streatgy) voidsetNodeStatus(NODE_STATUS iStatus) voidshutdown()voidstartup()voidtoString()booleanupdateCachedDatabaseConfiguration(String iDatabaseName, OModifiableDistributedConfiguration cfg) voidprotected booleanwaitForLocalNode(ODistributedConfiguration cfg, Collection<String> iNodes) protected ODistributedResponsewaitForResponse(ODistributedRequest iRequest, ODistributedResponseManager currentResponseMgr) voidvoidwaitUntilNodeOnline(String nodeName, String databaseName) Methods inherited from class com.orientechnologies.orient.server.plugin.OServerPluginAbstract
getContent, onAfterClientRequest, onBeforeClientRequest, onClientConnection, onClientDisconnection, onClientErrorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.orientechnologies.orient.server.plugin.OServerPlugin
onSocketAccepted, onSocketDestroyed
-
Field Details
-
REPLICATOR_USER
- See Also:
-
PAR_DEF_DISTRIB_DB_CONFIG
- See Also:
-
NODE_NAME_ENV
- See Also:
-
defaultDatabaseConfigFile
-
listeners
-
remoteServerManager
-
localMessageIdCounter
-
DEPLOY_DB_MAX_RETRIES
protected static final int DEPLOY_DB_MAX_RETRIES- See Also:
-
installingDatabases
-
messageService
-
startedOn
-
responseManagerFactory
-
taskFactoryManager
-
serverStarted
-
signalListener
-
-
Constructor Details
-
ODistributedPlugin
public ODistributedPlugin()
-
-
Method Details
-
waitUntilNodeOnline
- Specified by:
waitUntilNodeOnlinein interfaceODistributedServerManager- Throws:
InterruptedException
-
waitUntilNodeOnline
- Specified by:
waitUntilNodeOnlinein interfaceODistributedServerManager- Throws:
InterruptedException
-
config
Description copied from interface:OServerPluginConfigures the handler. Called at startup.- Specified by:
configin interfaceOServerPlugin- Overrides:
configin classOServerPluginAbstract
-
getRemoteServerManager
-
getDefaultDatabaseConfigFile
- Specified by:
getDefaultDatabaseConfigFilein interfaceODistributedServerManager
-
executeInDistributedDatabaseLock
public <T> T executeInDistributedDatabaseLock(String databaseName, long timeoutLocking, OModifiableDistributedConfiguration lastCfg, OCallable<T, OModifiableDistributedConfiguration> iCallback) Description copied from interface:ODistributedServerManagerExecutes an operation protected by a distributed lock (one per database).- Specified by:
executeInDistributedDatabaseLockin interfaceODistributedServerManager- Type Parameters:
T- Return type- Parameters:
databaseName- Database nameiCallback- Operation @return The operation's result of type T
-
executeInDistributedDatabaseLock
-
isWriteQuorumPresent
Description copied from interface:ODistributedServerManagerReturns true if the quorum is present in terms of number of available nodes for full replication only. With sharding, instead, the quorum may depend on the involved clusters.- Specified by:
isWriteQuorumPresentin interfaceODistributedServerManager- Returns:
-
setDefaultDatabaseConfigFile
-
startup
public void startup()- Specified by:
startupin interfaceOService- Overrides:
startupin classOServerPluginAbstract
-
registerLifecycleListener
- Specified by:
registerLifecycleListenerin interfaceODistributedServerManager
-
unregisterLifecycleListener
- Specified by:
unregisterLifecycleListenerin interfaceODistributedServerManager
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceOService- Overrides:
shutdownin classOServerPluginAbstract
-
removeDbFromClusterMetadata
-
dropOnAllServers
-
dropConfig
-
getName
-
sendShutdown
public void sendShutdown()- Specified by:
sendShutdownin interfaceOServerPlugin- Overrides:
sendShutdownin classOServerPluginAbstract
-
getServerInstance
- Specified by:
getServerInstancein interfaceODistributedServerManager
-
getLocalNodeConfiguration
- Specified by:
getLocalNodeConfigurationin interfaceODistributedServerManager
-
getDatabaseConfiguration
- Specified by:
getDatabaseConfigurationin interfaceODistributedServerManager
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabledin interfaceODistributedServerManager
-
sendRequest
public ODistributedResponse sendRequest(String iDatabaseName, Collection<String> iTargetNodes, ORemoteTask iTask) Description copied from interface:ODistributedServerManagerSends a distributed request against multiple servers.- Specified by:
sendRequestin interfaceODistributedServerManager- Returns:
-
sendSingleRequest
Description copied from interface:ODistributedServerManagerSends a distributed request against multiple servers.- Specified by:
sendSingleRequestin interfaceODistributedServerManager- Returns:
-
sendRequest
public ODistributedResponse sendRequest(String iDatabaseName, Collection<String> iTargetNodes, ORemoteTask iTask, ODistributedRequestId reqId, Object localResult, ODistributedResponseManagerFactory responseManagerFactory) - Specified by:
sendRequestin interfaceODistributedServerManager
-
checkForServerOnline
- Throws:
ODistributedException
-
send2Nodes
public ODistributedResponse send2Nodes(ODistributedRequest iRequest, Collection<String> iNodes, ODistributedRequest.EXECUTION_MODE iExecutionMode, Object localResult, ODistributedResponseManagerFactory responseManagerFactory) -
waitForResponse
protected ODistributedResponse waitForResponse(ODistributedRequest iRequest, ODistributedResponseManager currentResponseMgr) throws InterruptedException - Throws:
InterruptedException
-
calculateQuorum
protected int calculateQuorum(OCommandDistributedReplicateRequest.QUORUM_TYPE quorumType, ODistributedConfiguration cfg, int totalServers, int totalMasterServers, int onlineMasters, boolean checkNodesAreOnline, String localNodeName) -
send2Nodes
public ODistributedResponse send2Nodes(ODistributedRequest iRequest, Collection<String> iNodes, ODistributedRequest.EXECUTION_MODE iExecutionMode, Object localResult) -
waitForLocalNode
-
executeOnLocalNodeFromRemote
- Specified by:
executeOnLocalNodeFromRemotein interfaceODistributedServerManager
-
executeOnLocalNode
public Object executeOnLocalNode(ODistributedRequestId reqId, ORemoteTask task, ODatabaseDocumentInternal database) Executes the request on local node. In case of error returns the Exception itself- Specified by:
executeOnLocalNodein interfaceODistributedServerManager
-
getManagedDatabases
-
getLocalNodeName
- Specified by:
getLocalNodeNamein interfaceODistributedServerManager
-
getOnlineNodes
- Specified by:
getOnlineNodesin interfaceODistributedServerManager
-
getOnlineNodesNotLocal
- Specified by:
getOnlineNodesNotLocalin interfaceODistributedServerManager
-
reassignClustersOwnership
public void reassignClustersOwnership(String iNode, String databaseName, boolean canCreateNewClusters) - Specified by:
reassignClustersOwnershipin interfaceODistributedServerManager
-
isNodeAvailable
Description copied from interface:ODistributedServerManagerAvailable means not OFFLINE, so ONLINE or SYNCHRONIZING.- Specified by:
isNodeAvailablein interfaceODistributedServerManager
-
isNodeOnline
Description copied from interface:ODistributedServerManagerReturns true if the node status is ONLINE.- Specified by:
isNodeOnlinein interfaceODistributedServerManager
-
isNodeStatusEqualsTo
public boolean isNodeStatusEqualsTo(String iNodeName, String iDatabaseName, ODistributedServerManager.DB_STATUS... statuses) Description copied from interface:ODistributedServerManagerChecks the node status if it's one of the statuses received as argument.- Specified by:
isNodeStatusEqualsToin interfaceODistributedServerManager- Parameters:
iNodeName- Node nameiDatabaseName- Database namestatuses- vararg of statuses- Returns:
- true if the node's status is equals to one of the passed statuses, otherwise false
-
isNodeAvailable
- Specified by:
isNodeAvailablein interfaceODistributedServerManager
-
getAvailableNodeNames
- Specified by:
getAvailableNodeNamesin interfaceODistributedServerManager
-
getAvailableNodeNotLocalNames
- Specified by:
getAvailableNodeNotLocalNamesin interfaceODistributedServerManager
-
isOffline
public boolean isOffline()- Specified by:
isOfflinein interfaceODistributedServerManager
-
getLocalNodeId
public int getLocalNodeId()- Specified by:
getLocalNodeIdin interfaceODistributedServerManager
-
getNodesWithStatus
public int getNodesWithStatus(Collection<String> iNodes, String databaseName, ODistributedServerManager.DB_STATUS... statuses) Returns the nodes with the requested status.- Specified by:
getNodesWithStatusin interfaceODistributedServerManager
-
toString
-
getMessageService
- Specified by:
getMessageServicein interfaceODistributedServerManager
-
getAvailableNodes
- Specified by:
getAvailableNodesin interfaceODistributedServerManager
-
installDatabase
public boolean installDatabase(boolean iStartup, String databaseName, boolean forceDeployment, boolean tryWithDeltaFirst) - Specified by:
installDatabasein interfaceODistributedServerManager
-
isSyncronizing
- Specified by:
isSyncronizingin interfaceODistributedServerManager
-
internalInstallDatabase
-
checkNodeInConfiguration
-
internalCheckNodeInConfig
public Object internalCheckNodeInConfig(String databaseName, OModifiableDistributedConfiguration lastCfg) -
requestFullDatabase
-
requestDatabaseFullSync
-
backupCurrentDatabase
-
installDatabaseFromNetwork
protected void installDatabaseFromNetwork(String dbPath, String databaseName, String iNode, ODistributedDatabaseChunk firstChunk) Installs a database from the network. -
getTaskFactoryManager
Description copied from interface:ODistributedServerManagerReturns the task factory manager. During first connect the minor version of the protocol is used.- Specified by:
getTaskFactoryManagerin interfaceODistributedServerManager
-
getActiveServers
- Specified by:
getActiveServersin interfaceODistributedServerManager
-
getActiveServerNotLocal
- Specified by:
getActiveServerNotLocalin interfaceODistributedServerManager
-
getDistributedStrategy
- Specified by:
getDistributedStrategyin interfaceODistributedServerManager
-
setDistributedStrategy
- Specified by:
setDistributedStrategyin interfaceODistributedServerManager
-
updateCachedDatabaseConfiguration
public boolean updateCachedDatabaseConfiguration(String iDatabaseName, OModifiableDistributedConfiguration cfg) - Specified by:
updateCachedDatabaseConfigurationin interfaceODistributedServerManager
-
publishDistributedConfiguration
- Specified by:
publishDistributedConfigurationin interfaceODistributedServerManager
-
notifyClients
- Specified by:
notifyClientsin interfaceODistributedServerManager
-
onDatabaseEvent
public void onDatabaseEvent(String nodeName, String databaseName, ODistributedServerManager.DB_STATUS status) -
invokeOnDatabaseStatusChange
public void invokeOnDatabaseStatusChange(String iNode, String iDatabaseName, ODistributedServerManager.DB_STATUS iStatus) -
assignNodeName
protected void assignNodeName() -
installDatabaseOnLocalNode
protected void installDatabaseOnLocalNode(String databaseName, String dbPath, String iNode, boolean incremental, OSyncReceiver receiver) -
nextRequestId
- Specified by:
nextRequestIdin interfaceODistributedServerManager
-
stopNode
- Throws:
IOException
-
restartNode
- Throws:
IOException
-
getNextMessageIdCounter
public long getNextMessageIdCounter()- Specified by:
getNextMessageIdCounterin interfaceODistributedServerManager
-
updateLastClusterChange
public void updateLastClusterChange()- Specified by:
updateLastClusterChangein interfaceODistributedServerManager
-
closeRemoteServer
-
dumpServersStatus
public void dumpServersStatus()Avoids to dump the same configuration twice if it's unchanged since the last time. -
getListeningBinaryAddress
-
messageReceived
- Specified by:
messageReceivedin interfaceODistributedServerManager
-
messageBeforeOp
- Specified by:
messageBeforeOpin interfaceODistributedServerManager
-
messageAfterOp
- Specified by:
messageAfterOpin interfaceODistributedServerManager
-
messageCurrentPayload
- Specified by:
messageCurrentPayloadin interfaceODistributedServerManager
-
messageProcessStart
- Specified by:
messageProcessStartin interfaceODistributedServerManager
-
messageProcessEnd
- Specified by:
messageProcessEndin interfaceODistributedServerManager
-
loadLocalDatabases
public void loadLocalDatabases()Initializes all the available server's databases as distributed. -
installNewDatabasesFromCluster
public void installNewDatabasesFromCluster() -
notifyStarted
public void notifyStarted() -
dumpStats
protected void dumpStats() -
getRemoteServer
- Specified by:
getRemoteServerin interfaceODistributedServerManager- Throws:
IOException
-
getLastClusterChangeOn
public long getLastClusterChangeOn()- Specified by:
getLastClusterChangeOnin interfaceODistributedServerManager
-
getNodeStatus
- Specified by:
getNodeStatusin interfaceODistributedServerManager
-
setNodeStatus
- Specified by:
setNodeStatusin interfaceODistributedServerManager
-
onNodeJoined
-
connectToAllNodes
- Throws:
IOException
-
removeServer
- Specified by:
removeServerin interfaceODistributedServerManager
-
getDatabaseStatus
- Specified by:
getDatabaseStatusin interfaceODistributedServerManager
-
setDatabaseStatus
public void setDatabaseStatus(String iNode, String iDatabaseName, ODistributedServerManager.DB_STATUS iStatus) - Specified by:
setDatabaseStatusin interfaceODistributedServerManager
-
onServerRemoved
-
onDbStatusOnline
-
onDbConfigUpdated
-
onNodeJoining
-
getClusterConfiguration
- Specified by:
getClusterConfigurationin interfaceODistributedServerManager
-
getNodeNameById
- Specified by:
getNodeNameByIdin interfaceODistributedServerManager
-
getNodeIdByName
- Specified by:
getNodeIdByNamein interfaceODistributedServerManager
-
getNodeConfigurationByUuid
- Specified by:
getNodeConfigurationByUuidin interfaceODistributedServerManager
-
reloadRegisteredNodes
public void reloadRegisteredNodes() -
removeNodeFromConfiguration
-
getHazelcastInstance
public com.hazelcast.core.HazelcastInstance getHazelcastInstance() -
getOnlineDatabaseConfiguration
- Specified by:
getOnlineDatabaseConfigurationin interfaceODistributedServerManager
-
getDatabase
- Specified by:
getDatabasein interfaceODistributedServerManager
-
getDatabases
- Specified by:
getDatabasesin interfaceODistributedServerManager
-