Class ODatabaseDocumentDistributed
java.lang.Object
com.orientechnologies.common.listener.OListenerManger<ODatabaseListener>
com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract
com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded
com.orientechnologies.orient.server.distributed.impl.ODatabaseDocumentDistributed
- All Implemented Interfaces:
ODatabaseDocument,OQueryLifecycleListener,ODatabase<ORecord>,ODatabaseDocumentInternal,ODatabaseInternal<ORecord>,ODatabaseSession,OBackupable,Closeable,AutoCloseable
- Direct Known Subclasses:
ODatabaseDocumentDistributedPooled
Created by tglman on 30/03/17.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.orientechnologies.orient.core.db.ODatabase
ODatabase.ATTRIBUTES, ODatabase.STATUS -
Field Summary
Fields inherited from class com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract
activeQueries, componentsFactory, currentTx, databaseOwner, hooks, hooksByScope, inHook, initialized, loadedRecordsCount, localCache, maxRecordLoadMs, maxRidbagPrefetchMs, metadata, minRecordLoadMs, minRidbagPrefetchMs, properties, queryState, recordType, retainRecords, ridbagPrefetchCount, serializer, sharedContext, status, totalRecordLoadMs, totalRidbagPrefetchMs, unmodifiableHooks, url, userFields inherited from interface com.orientechnologies.orient.core.db.document.ODatabaseDocument
TYPE -
Constructor Summary
ConstructorsConstructorDescriptionODatabaseDocumentDistributed(OStorage storage, ODistributedPlugin distributedPlugin) -
Method Summary
Modifier and TypeMethodDescriptionvoidacquireLocksForTx(OTransactionInternal tx, ODistributedTxContext txContext, boolean isCoordinator, boolean force) intaddCluster(String iClusterName, int iRequestedId) Adds a new cluster.intaddCluster(String iClusterName, Object... iParameters) Adds a new cluster.intassignAndCheckCluster(ORecord record, String iClusterName) backup(OutputStream out, Map<String, Object> options, Callable<Object> callable, OCommandOutputListener iListener, int compressionLevel, int bufferSize) Executes a backup of the database.booleanbeginDistributedTx(ODistributedRequestId requestId, OTransactionIdPromise id, OTransactionInternal tx, boolean isCoordinator, int retryCount) protected voidcheckNodeIsMaster(String localNodeName, ODistributedConfiguration dbCfg, String operation) booleancommit2pc(ODistributedRequestId transactionId, boolean isCoordinator, ODistributedRequestId requestId) voidcommit2pcLocal(ODistributedRequestId transactionId) The Local commit is different from a remote commit due to local rid pre-allocationcopy()Returns a copy of current database if it's open.protected voidvoidbooleandropClusterInternal(int clusterId) protected booleandropClusterInternal(String clusterName) executeTaskOnNode(ORemoteTask task, String nodeName) firstPhaseDDL(String query, OTransactionIdPromise preChangeId, OTransactionIdPromise afterChangeId, ODistributedRequestId requestId) voidvoidfreeze(boolean throwException) Flush all indexes and cached storage content to the disk.returns the data center map for current deploy.getHaStatus(boolean servers, boolean db, boolean latency, boolean messages) getInvolvedClusters(Iterable<ORecordOperation> uResult) return the name of local node in the clustergetViewFromCluster(int cluster) protected voidhandleDistributedException(String iMessage, Exception e, Object... iParams) voidinit(OrientDBConfig config, OSharedContext sharedContext) voidinternalBegin2pc(ONewDistributedTxContextImpl txContext, boolean isCoordinator) voidinternalBegin2pc(ONewDistributedTxContextImpl txContext, boolean isCoordinator, boolean force) voidExecuted the commit on the storage hiding away storage concepts from the transactionvoidinternalCommit2pc(ONewDistributedTxContextImpl txContext) voidbooleanbooleanbooleanchecks the cluster map and tells whether this is a sharded database (ie. a distributed DB where at least two nodes contain distinct subsets of data) or notqueryOnNode(String nodeName, OInternalExecutionPlan executionPlan, Map<Object, Object> inputParameters) sends an execution plan to a remote node for a remote query executionvoidregister(ODistributedRequestId requestId, ODistributedDatabase localDistributedDatabase, ODistributedTxContext txContext) voidrelease()Allows to execute write-related commands on DB.booleanremoveHaServer(String serverName) booleanrollback2pc(ODistributedRequestId transactionId) voidsecondPhaseDDL(ODistributedRequestId confirmSentRequest, boolean apply) voidsendDDLCommand(String command, boolean excludeLocal) <T> TsendSequenceAction(OSequenceAction action) booleansync(boolean forceDeployment, boolean tryWithDelta) synchronizes current database instance with the rest of the cluster (if in distributed mode).voidsyncCommit(OTransactionData data) voidtwoPhaseDDL(String command) Methods inherited from class com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded
addBlobCluster, addRidbagPrefetchStats, afterCommitOperations, afterCreateOperations, afterDeleteOperations, afterReadOperations, afterRollbackOperations, afterUpdateOperations, beforeCreateOperations, beforeDeleteOperations, beforeReadOperations, beforeUpdateOperations, callOnCreateListeners, ceilingPhysicalPositions, checkSecurity, checkSecurity, checkSecurity, command, command, commandLikeLegacy, commitPreallocate, countClusterElements, countClusterElements, countClusterElements, countRecords, createSBTree, delete, directRead, dropCluster, dropCluster, endEsclusiveMetadataChange, execute, execute, executeDeleteRecord, executeLikeLegacy, executeReadRecord, floorPhysicalPositions, freeze, getClusterDataRange, getClusterName, getClusterRecordConflictStrategy, getClusterRecordSizeById, getClusterRecordSizeByName, getClustersIds, getConfig, getConflictStrategy, getLastClusterPosition, getRecordMetadata, getSbTreeCollectionManager, getSize, getStats, getStorage, getStorageInfo, higherPhysicalPositions, incrementalBackup, installHooksEmbedded, internalClose, internalCreate, internalLockRecord, internalLockRecord, internalOpen, internalOpen, internalOpen, internalUnlockRecord, isClosed, isReusable, live, live, loadMetadata, lock, lock, lowerPhysicalPositions, query, query, query, queryLikeLegacy, queryStarted, queryStartUsingViewCluster, queryStartUsingViewIndex, readIfVersionIsNotLatest, rebuildIndexes, reload, replaceStorage, resetRecordLoadStats, restore, saveAll, set, setConflictStrategy, setConflictStrategy, setCustom, setDefaultClusterId, startEsclusiveMetadataChange, truncateClass, truncateClass, truncateCluster, truncateClusterInternal, unlockMethods inherited from class com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract
activateOnCurrentThread, beforeCommitOperations, beforeRollbackOperations, begin, begin, browseClass, browseClass, browseCluster, browseCluster, browseCluster, callbackHookFailure, callbackHookFinalize, callbackHooks, callbackHookSuccess, callOnCloseListeners, callOnDropListeners, callOnOpenListeners, checkForClusterPermissions, checkIfActive, checkOpenness, checkRecordClass, checkSecurity, cleanOutRecord, clearDocumentTracking, close, closeActiveQueries, commit, commit, countClass, countClass, countClass, countView, delete, delete, executeWithRetries, executeWithRetries, executeWithRetries, existsCluster, get, getActiveQueries, getActiveQuery, getBlobClusterIds, getClusterIdByName, getClusterNameById, getClusterNames, getClusters, getCollectionsChanges, getConfiguration, getDatabaseOwner, getDefaultClusterId, getDefaultSerializer, getDictionary, getHooks, getListeners, getLocalCache, getMetadata, getName, getProperties, getProperty, getRecord, getRecordType, getSerializer, getSerializerFactory, getSharedContext, getStatus, getStorageVersions, getTransaction, getType, getUnderlying, getURL, getUser, init, isActiveOnCurrentThread, isClusterEdge, isClusterVertex, isClusterView, isPooled, isPrefetchRecords, isUseLightweightEdges, isValidationEnabled, load, load, load, load, load, load, loadIfVersionIsNotLatest, newBlob, newBlob, newEdge, newEdge, newElement, newElement, newElement, newEmbeddedElement, newEmbeddedElement, newInstance, newInstance, newLightweightEdge, newRegularEdge, newVertex, newVertex, pessimisticLockChecks, queryClosed, queryStarted, rawBegin, registerHook, registerHook, reload, reload, reload, reload, reloadUser, resetInitialization, rollback, rollback, save, save, save, setCurrentDatabaseInThreadLocal, setDatabaseOwner, setDefaultSerializer, setDefaultTransactionMode, setInternal, setPrefetchRecords, setProperty, setSerializer, setStatus, setStatusInternal, setUseLightweightEdges, setUser, setValidationEnabled, swapTx, unregisterHookMethods inherited from class com.orientechnologies.common.listener.OListenerManger
browseListeners, getListenersCopy, registerListener, resetListeners, unregisterListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.orientechnologies.orient.core.db.ODatabase
createClass, executeWithRetry, getClass, registerListener, unregisterListenerMethods inherited from interface com.orientechnologies.orient.core.db.document.ODatabaseDocument
createClassIfNotExist, createEdgeClass, createVertexClass, newEdge, newVertex, reloadMethods inherited from interface com.orientechnologies.orient.core.db.ODatabaseDocumentInternal
indexQuery, isRemote, realClose, remoteRollback, reuseMethods inherited from interface com.orientechnologies.orient.core.db.ODatabaseInternal
createInterruptTimerTaskMethods inherited from interface com.orientechnologies.orient.core.db.document.OQueryLifecycleListener
queryClosed
-
Constructor Details
-
ODatabaseDocumentDistributed
-
-
Method Details
-
getLocalNodeName
return the name of local node in the cluster- Returns:
- the name of local node in the cluster
-
getActiveDataCenterMap
returns the data center map for current deploy. The keys are data center names, the values are node names per data center- Returns:
- data center map for current deploy
-
isSharded
public boolean isSharded()Description copied from interface:ODatabaseInternalchecks the cluster map and tells whether this is a sharded database (ie. a distributed DB where at least two nodes contain distinct subsets of data) or not- Returns:
- true if the database is sharded, false otherwise
-
isDistributed
public boolean isDistributed() -
copy
Description copied from class:ODatabaseDocumentEmbeddedReturns a copy of current database if it's open. The returned instance can be used by another thread without affecting current instance. The database copy is not set in thread local.- Specified by:
copyin interfaceODatabaseDocumentInternal- Overrides:
copyin classODatabaseDocumentEmbedded
-
sync
public boolean sync(boolean forceDeployment, boolean tryWithDelta) Description copied from interface:ODatabaseDocumentInternalsynchronizes current database instance with the rest of the cluster (if in distributed mode).- Returns:
- true if the database was synchronized, false otherwise
-
getHaStatus
-
removeHaServer
-
queryOnNode
public OExecutionStream queryOnNode(String nodeName, OInternalExecutionPlan executionPlan, Map<Object, Object> inputParameters) Description copied from interface:ODatabaseDocumentInternalsends an execution plan to a remote node for a remote query execution- Parameters:
nodeName- the node nameexecutionPlan- the execution planinputParameters- the input parameters for execution- Returns:
- an OResultSet to fetch the results of the query execution
-
executeTaskOnNode
-
assignAndCheckCluster
- Specified by:
assignAndCheckClusterin interfaceODatabaseDocumentInternal- Overrides:
assignAndCheckClusterin classODatabaseDocumentAbstract
-
internalCommit
Description copied from interface:ODatabaseDocumentInternalExecuted the commit on the storage hiding away storage concepts from the transaction- Specified by:
internalCommitin interfaceODatabaseDocumentInternal- Overrides:
internalCommitin classODatabaseDocumentEmbedded
-
internalCommitPreallocate
- Specified by:
internalCommitPreallocatein interfaceODatabaseDocumentInternal- Overrides:
internalCommitPreallocatein classODatabaseDocumentEmbedded
-
sendSequenceAction
public <T> T sendSequenceAction(OSequenceAction action) throws ExecutionException, InterruptedException - Specified by:
sendSequenceActionin interfaceODatabaseDocumentInternal- Overrides:
sendSequenceActionin classODatabaseDocumentEmbedded- Throws:
ExecutionExceptionInterruptedException
-
distributedCommitV1
-
acquireLocksForTx
public void acquireLocksForTx(OTransactionInternal tx, ODistributedTxContext txContext, boolean isCoordinator, boolean force) - Parameters:
tx-txContext-isCoordinator- specifies whether this node is the tx coordinatorforce- whether to use the force flag for acquiring the promises required for this tx.
-
beginDistributedTx
public boolean beginDistributedTx(ODistributedRequestId requestId, OTransactionIdPromise id, OTransactionInternal tx, boolean isCoordinator, int retryCount) -
register
public void register(ODistributedRequestId requestId, ODistributedDatabase localDistributedDatabase, ODistributedTxContext txContext) -
commit2pcLocal
The Local commit is different from a remote commit due to local rid pre-allocation- Parameters:
transactionId-
-
commit2pc
public boolean commit2pc(ODistributedRequestId transactionId, boolean isCoordinator, ODistributedRequestId requestId) - Parameters:
transactionId-- Returns:
- null returned means that commit failed
-
forceRsync
public void forceRsync() -
rollback2pc
-
internalCommit2pc
-
internalBegin2pc
-
internalBegin2pc
public void internalBegin2pc(ONewDistributedTxContextImpl txContext, boolean isCoordinator, boolean force) - Parameters:
txContext-isCoordinator- specifies whether this node is the tx coordinatorforce- whether to use the force flag for acquiring the promises required for this tx.
-
getViewFromCluster
- Specified by:
getViewFromClusterin interfaceODatabaseDocumentInternal- Overrides:
getViewFromClusterin classODatabaseDocumentEmbedded
-
getEnterpriseEndpoint
- Returns:
- an endpoint for Enterprise features. Null in Community Edition
-
getDistributedManager
-
getDistributedConfiguration
-
sendDDLCommand
-
twoPhaseDDL
-
addCluster
Description copied from interface:ODatabaseAdds a new cluster.- Specified by:
addClusterin interfaceODatabase<ORecord>- Overrides:
addClusterin classODatabaseDocumentEmbedded- Parameters:
iClusterName- Cluster nameiParameters- Additional parameters to pass to the factories- Returns:
- Cluster id
-
addCluster
Description copied from interface:ODatabaseAdds a new cluster.- Specified by:
addClusterin interfaceODatabase<ORecord>- Overrides:
addClusterin classODatabaseDocumentEmbedded- Parameters:
iClusterName- Cluster nameiRequestedId- requested id of the cluster- Returns:
- Cluster id
-
dropClusterInternal
- Overrides:
dropClusterInternalin classODatabaseDocumentEmbedded
-
dropClusterInternal
public boolean dropClusterInternal(int clusterId) - Specified by:
dropClusterInternalin interfaceODatabaseDocumentInternal- Overrides:
dropClusterInternalin classODatabaseDocumentEmbedded
-
isLocalEnv
public boolean isLocalEnv() -
freeze
public void freeze(boolean throwException) Flush all indexes and cached storage content to the disk.After this call users can perform only select queries. All write-related commands will queued till
ODatabaseDocument.release()command will be called or exception will be thrown on attempt to modify DB data. Concrete behaviour depends onthrowExceptionparameter.IMPORTANT: This command is not reentrant.
- Specified by:
freezein interfaceODatabase<ORecord>- Specified by:
freezein interfaceODatabaseDocument- Overrides:
freezein classODatabaseDocumentEmbedded- Parameters:
throwException- IftrueOModificationOperationProhibitedExceptionexception will be thrown in case of write command will be performed.
-
release
public void release()Description copied from class:ODatabaseDocumentEmbeddedAllows to execute write-related commands on DB. Called afterODatabaseDocument.freeze()command.- Specified by:
releasein interfaceODatabase<ORecord>- Specified by:
releasein interfaceODatabaseDocument- Overrides:
releasein classODatabaseDocumentEmbedded- See Also:
-
backup
public List<String> backup(OutputStream out, Map<String, Object> options, Callable<Object> callable, OCommandOutputListener iListener, int compressionLevel, int bufferSize) throws IOExceptionDescription copied from interface:OBackupableExecutes a backup of the database. During the backup the database will be frozen in read-only mode.- Specified by:
backupin interfaceOBackupable- Overrides:
backupin classODatabaseDocumentEmbedded- Parameters:
out- OutputStream used to write the backup content. Use a FileOutputStream to make the backup persistent on diskoptions- Backup options as Map<String, Object> objectcallable- Callback to execute when the database is lockediListener- Listener called for backup messagescompressionLevel- ZIP Compression level between 1 (the minimum) and 9 (maximum). The bigger is the compression, the smaller will be the final backup content, but will consume more CPU and time to executebufferSize- Buffer size in bytes, the bigger is the buffer, the more efficient will be the compression- Throws:
IOException- See Also:
-
checkNodeIsMaster
protected void checkNodeIsMaster(String localNodeName, ODistributedConfiguration dbCfg, String operation) -
handleDistributedException
-
getStorageId
-
getInvolvedClusters
-
syncCommit
-
firstPhaseDDL
public OTransactionResultPayload firstPhaseDDL(String query, OTransactionIdPromise preChangeId, OTransactionIdPromise afterChangeId, ODistributedRequestId requestId) -
secondPhaseDDL
-