
public class ODistributedStorage extends Object implements OStorage, OFreezableStorage, OAutoshardedStorage
OStorage.LOCKING_STRATEGY, OStorage.SIZE, OStorage.STATUS| Modifier and Type | Field and Description |
|---|---|
protected BlockingQueue<OAsynchDistributedOperation> |
asynchronousOperationsQueue |
protected Thread |
asynchWorker |
protected ODistributedServerManager |
dManager |
protected File |
lastValidBackup |
protected boolean |
running |
protected OServer |
serverInstance |
protected OAbstractPaginatedStorage |
wrapped |
CLUSTER_DEFAULT_NAME| Constructor and Description |
|---|
ODistributedStorage(OServer iServer) |
| Modifier and Type | Method and Description |
|---|---|
protected ODistributedRequestId |
acquireRecordLock(ORecordId rid) |
int |
addCluster(String iClusterName,
boolean forceListBased,
Object... iParameters)
Add a new cluster into the storage.
|
int |
addCluster(String iClusterName,
int iRequestedId,
boolean forceListBased,
Object... iParameters)
Add a new cluster into the storage.
|
protected void |
asynchronousExecution(OAsynchDistributedOperation iOperation) |
List<String> |
backup(OutputStream out,
Map<String,Object> options,
Callable<Object> callable,
OCommandOutputListener iListener,
int compressionLevel,
int bufferSize)
Executes a backup of the database.
|
<V> V |
callInLock(Callable<V> iCallable,
boolean iExclusiveLock) |
OPhysicalPosition[] |
ceilingPhysicalPositions(int clusterId,
OPhysicalPosition physicalPosition) |
void |
checkForClusterPermissions(String iClusterName) |
boolean |
checkForRecordValidity(OPhysicalPosition ppos) |
protected void |
checkLocalNodeIsAvailable() |
protected void |
checkNodeIsMaster(String localNodeName,
ODistributedConfiguration dbCfg) |
boolean |
cleanOutRecord(ORecordId recordId,
int recordVersion,
int iMode,
ORecordCallback<Boolean> callback) |
void |
close() |
void |
close(boolean iForce,
boolean onDelete) |
Object |
command(OCommandRequestText iCommand)
Execute the command request and return the result back.
|
List<ORecordOperation> |
commit(OTransaction iTx,
Runnable callback) |
long |
count(int iClusterId) |
long |
count(int[] iClusterIds) |
long |
count(int[] iClusterIds,
boolean countTombstones) |
long |
count(int iClusterId,
boolean countTombstones) |
long |
countRecords()
Returns the total number of records.
|
void |
create(Map<String,Object> iProperties) |
OStorageOperationResult<OPhysicalPosition> |
createRecord(ORecordId iRecordId,
byte[] iContent,
int iRecordVersion,
byte iRecordType,
int iMode,
ORecordCallback<Long> iCallback) |
void |
delete() |
OStorageOperationResult<Boolean> |
deleteRecord(ORecordId iRecordId,
int iVersion,
int iMode,
ORecordCallback<Boolean> iCallback) |
boolean |
dropCluster(int iId,
boolean iTruncate)
Drops a cluster.
|
boolean |
dropCluster(String iClusterName,
boolean iTruncate) |
protected void |
dropStorageFiles() |
protected boolean |
executeOnlyLocally(String localNodeName,
ODistributedConfiguration dbCfg,
OCommandExecutor exec,
Collection<String> involvedClusters,
Collection<String> nodes)
Only idempotent commands that don't involve any other node can be executed locally.
|
protected Map<String,Object> |
executeOnServers(OCommandRequestText iCommand,
Collection<String> involvedClusters,
Map<String,Collection<String>> nodeClusterMap) |
boolean |
exists() |
boolean |
existsResource(String iName) |
OPhysicalPosition[] |
floorPhysicalPositions(int clusterId,
OPhysicalPosition physicalPosition) |
void |
freeze(boolean throwException)
After this method finished it's execution, all threads that are going to perform data modifications in storage should wait till
OFreezableStorage.release() method will be called. |
protected OAsyncReplicationError |
getAsyncReplicationError() |
OCluster |
getClusterById(int iId) |
OCluster |
getClusterByName(String iName) |
long[] |
getClusterDataRange(int currentClusterId)
Returns a pair of long values telling the begin and end positions of data in the requested cluster.
|
int |
getClusterIdByName(String iClusterName) |
Collection<? extends OCluster> |
getClusterInstances() |
String |
getClusterNameByRID(ORecordId iRid) |
Set<String> |
getClusterNames() |
int |
getClusters() |
OCurrentStorageComponentsFactory |
getComponentsFactory() |
OStorageConfiguration |
getConfiguration() |
ORecordConflictStrategy |
getConflictStrategy() |
int |
getDefaultClusterId() |
ODistributedConfiguration |
getDistributedConfiguration() |
ODistributedServerManager |
getDistributedManager() |
ODistributedStorageEventListener |
getEventListener() |
File |
getLastValidBackup() |
String |
getName() |
String |
getNodeId() |
String |
getPhysicalClusterNameById(int iClusterId) |
ORecordMetadata |
getRecordMetadata(ORID rid) |
<T> T |
getResource(String iName,
Callable<T> iCallback) |
OSBTreeCollectionManager |
getSBtreeCollectionManager() |
OServer |
getServer() |
long |
getSize()
Returns the size of the database.
|
OStorage.STATUS |
getStatus()
Returns the current storage's status
|
String |
getStorageId()
Storage unique id, made by node name + database name
|
String |
getType()
Returns the storage's type.
|
OStorage |
getUnderlying() |
String |
getURL() |
long |
getVersion() |
protected void |
handleDistributedException(String iMessage,
Exception e,
Object... iParams) |
OStorageOperationResult<Boolean> |
hideRecord(ORecordId recordId,
int mode,
ORecordCallback<Boolean> callback) |
OPhysicalPosition[] |
higherPhysicalPositions(int currentClusterId,
OPhysicalPosition entry) |
String |
incrementalBackup(String backupDirectory) |
OUncompletedCommit<List<ORecordOperation>> |
initiateCommit(OTransaction iTx,
Runnable callback) |
boolean |
isAssigningClusterIds() |
boolean |
isClosed() |
boolean |
isDistributed() |
boolean |
isRemote() |
OPhysicalPosition[] |
lowerPhysicalPositions(int currentClusterId,
OPhysicalPosition entry) |
protected Object |
mergeResultByAggregation(OCommandExecutorSQLSelect select,
Map<String,Object> iResults) |
void |
open(String iUserName,
String iUserPassword,
Map<String,Object> iProperties) |
OStorageOperationResult<ORawBuffer> |
readRecord(ORecordId iRecordId,
String iFetchPlan,
boolean iIgnoreCache,
ORecordCallback<ORawBuffer> iCallback) |
OStorageOperationResult<ORawBuffer> |
readRecordIfVersionIsNotLatest(ORecordId rid,
String fetchPlan,
boolean ignoreCache,
int recordVersion) |
OStorageOperationResult<Integer> |
recyclePosition(ORecordId iRecordId,
byte[] iContent,
int iVersion,
byte recordType)
Resurrects a record that was previously deleted, with a new content.
|
void |
release()
After this method finished execution all threads that are waiting to perform data modifications in storage will be awaken and
will be allowed to continue their execution.
|
void |
reload() |
<T> T |
removeResource(String iName) |
void |
restore(InputStream in,
Map<String,Object> options,
Callable<Object> callable,
OCommandOutputListener iListener)
Executes a restore of a database backup.
|
void |
restoreFromIncrementalBackup(String filePath) |
void |
rollback(OTransaction iTx) |
void |
setConflictStrategy(ORecordConflictStrategy iResolver) |
void |
setDefaultClusterId(int defaultClusterId) |
void |
setDistributedConfiguration(ODistributedConfiguration distributedConfiguration) |
void |
setEventListener(ODistributedStorageEventListener eventListener) |
void |
setLastValidBackup(File lastValidBackup) |
void |
shutdown()
This method is called in
Orient.shutdown() method. |
void |
shutdownAsynchronousWorker() |
void |
synch() |
OStorageOperationResult<Integer> |
updateRecord(ORecordId iRecordId,
boolean updateContent,
byte[] iContent,
int iVersion,
byte iRecordType,
int iMode,
ORecordCallback<Integer> iCallback) |
void |
wrap(OAbstractPaginatedStorage wrapped) |
protected final OServer serverInstance
protected final ODistributedServerManager dManager
protected OAbstractPaginatedStorage wrapped
protected BlockingQueue<OAsynchDistributedOperation> asynchronousOperationsQueue
protected Thread asynchWorker
protected volatile boolean running
protected volatile File lastValidBackup
public ODistributedStorage(OServer iServer)
public void wrap(OAbstractPaginatedStorage wrapped)
public boolean isDistributed()
isDistributed in interface OStoragepublic boolean isAssigningClusterIds()
isAssigningClusterIds in interface OStoragepublic Object command(OCommandRequestText iCommand)
OStorageprotected Map<String,Object> executeOnServers(OCommandRequestText iCommand, Collection<String> involvedClusters, Map<String,Collection<String>> nodeClusterMap)
protected Object mergeResultByAggregation(OCommandExecutorSQLSelect select, Map<String,Object> iResults)
protected boolean executeOnlyLocally(String localNodeName, ODistributedConfiguration dbCfg, OCommandExecutor exec, Collection<String> involvedClusters, Collection<String> nodes)
public OStorageOperationResult<OPhysicalPosition> createRecord(ORecordId iRecordId, byte[] iContent, int iRecordVersion, byte iRecordType, int iMode, ORecordCallback<Long> iCallback)
createRecord in interface OStoragepublic OStorageOperationResult<ORawBuffer> readRecord(ORecordId iRecordId, String iFetchPlan, boolean iIgnoreCache, ORecordCallback<ORawBuffer> iCallback)
readRecord in interface OStoragepublic OStorageOperationResult<ORawBuffer> readRecordIfVersionIsNotLatest(ORecordId rid, String fetchPlan, boolean ignoreCache, int recordVersion) throws ORecordNotFoundException
readRecordIfVersionIsNotLatest in interface OStorageORecordNotFoundExceptionpublic OSBTreeCollectionManager getSBtreeCollectionManager()
getSBtreeCollectionManager in interface OStoragepublic OStorageOperationResult<Integer> updateRecord(ORecordId iRecordId, boolean updateContent, byte[] iContent, int iVersion, byte iRecordType, int iMode, ORecordCallback<Integer> iCallback)
updateRecord in interface OStoragepublic OStorageOperationResult<Integer> recyclePosition(ORecordId iRecordId, byte[] iContent, int iVersion, byte recordType)
OStoragerecyclePosition in interface OStoragepublic OStorageOperationResult<Boolean> deleteRecord(ORecordId iRecordId, int iVersion, int iMode, ORecordCallback<Boolean> iCallback)
deleteRecord in interface OStoragepublic OStorageOperationResult<Boolean> hideRecord(ORecordId recordId, int mode, ORecordCallback<Boolean> callback)
hideRecord in interface OStoragepublic ORecordMetadata getRecordMetadata(ORID rid)
getRecordMetadata in interface OStoragepublic boolean cleanOutRecord(ORecordId recordId, int recordVersion, int iMode, ORecordCallback<Boolean> callback)
cleanOutRecord in interface OStoragepublic boolean existsResource(String iName)
existsResource in interface OSharedContainerpublic OCluster getClusterByName(String iName)
getClusterByName in interface OStoragepublic ORecordConflictStrategy getConflictStrategy()
getConflictStrategy in interface OStoragepublic void setConflictStrategy(ORecordConflictStrategy iResolver)
setConflictStrategy in interface OStoragepublic <T> T removeResource(String iName)
removeResource in interface OSharedContainerpublic <T> T getResource(String iName, Callable<T> iCallback)
getResource in interface OSharedContainerpublic String incrementalBackup(String backupDirectory)
incrementalBackup in interface OStoragepublic void restoreFromIncrementalBackup(String filePath)
restoreFromIncrementalBackup in interface OStoragepublic List<ORecordOperation> commit(OTransaction iTx, Runnable callback)
public OUncompletedCommit<List<ORecordOperation>> initiateCommit(OTransaction iTx, Runnable callback)
initiateCommit in interface OStorageprotected ODistributedRequestId acquireRecordLock(ORecordId rid)
public void rollback(OTransaction iTx)
public OStorageConfiguration getConfiguration()
getConfiguration in interface OStoragepublic int getClusters()
getClusters in interface OStoragepublic Set<String> getClusterNames()
getClusterNames in interface OStoragepublic OCluster getClusterById(int iId)
getClusterById in interface OStoragepublic Collection<? extends OCluster> getClusterInstances()
getClusterInstances in interface OStoragepublic int addCluster(String iClusterName, boolean forceListBased, Object... iParameters)
OStorageaddCluster in interface OStorageiClusterName - name of the clusterpublic int addCluster(String iClusterName, int iRequestedId, boolean forceListBased, Object... iParameters)
OStorageaddCluster in interface OStorageiClusterName - name of the clusteriRequestedId - requested id of the clusterpublic boolean dropCluster(String iClusterName, boolean iTruncate)
dropCluster in interface OStoragepublic boolean dropCluster(int iId,
boolean iTruncate)
OStoragedropCluster in interface OStorageiId - id of the cluster to deletepublic long count(int iClusterId,
boolean countTombstones)
public long count(int[] iClusterIds,
boolean countTombstones)
public long getSize()
OStoragepublic long countRecords()
OStoragecountRecords in interface OStoragepublic int getDefaultClusterId()
getDefaultClusterId in interface OStoragepublic void setDefaultClusterId(int defaultClusterId)
setDefaultClusterId in interface OStoragepublic int getClusterIdByName(String iClusterName)
getClusterIdByName in interface OStoragepublic String getPhysicalClusterNameById(int iClusterId)
getPhysicalClusterNameById in interface OStoragepublic boolean checkForRecordValidity(OPhysicalPosition ppos)
checkForRecordValidity in interface OStoragepublic long getVersion()
getVersion in interface OStoragepublic long[] getClusterDataRange(int currentClusterId)
OStoragegetClusterDataRange in interface OStoragecurrentClusterId - Cluster idpublic <V> V callInLock(Callable<V> iCallable, boolean iExclusiveLock)
callInLock in interface OStoragepublic OStorage.STATUS getStatus()
OStoragepublic ODistributedStorageEventListener getEventListener()
public void setEventListener(ODistributedStorageEventListener eventListener)
public void checkForClusterPermissions(String iClusterName)
checkForClusterPermissions in interface OStoragepublic OPhysicalPosition[] higherPhysicalPositions(int currentClusterId, OPhysicalPosition entry)
higherPhysicalPositions in interface OStoragepublic OServer getServer()
public ODistributedServerManager getDistributedManager()
public ODistributedConfiguration getDistributedConfiguration()
public void setDistributedConfiguration(ODistributedConfiguration distributedConfiguration)
public OPhysicalPosition[] ceilingPhysicalPositions(int clusterId, OPhysicalPosition physicalPosition)
ceilingPhysicalPositions in interface OStoragepublic OPhysicalPosition[] floorPhysicalPositions(int clusterId, OPhysicalPosition physicalPosition)
floorPhysicalPositions in interface OStoragepublic OPhysicalPosition[] lowerPhysicalPositions(int currentClusterId, OPhysicalPosition entry)
lowerPhysicalPositions in interface OStoragepublic OStorage getUnderlying()
getUnderlying in interface OStoragepublic OCurrentStorageComponentsFactory getComponentsFactory()
getComponentsFactory in interface OStoragepublic String getType()
OStoragepublic void freeze(boolean throwException)
OFreezableStorageOFreezableStorage.release() method will be called. This method will wait till all ongoing modifications will be finished.freeze in interface OFreezableStoragethrowException - If true OModificationOperationProhibitedException
exception will be thrown on call of methods that requires storage modification. Otherwise other threads will wait for
OFreezableStorage.release() method call.public void release()
OFreezableStoragerelease in interface OFreezableStoragepublic List<String> backup(OutputStream out, Map<String,Object> options, Callable<Object> callable, OCommandOutputListener iListener, int compressionLevel, int bufferSize) throws IOException
OBackupablebackup in interface OBackupableout - OutputStream used to write the backup content. Use a FileOutputStream to make the backup persistent on diskoptions - Backup options as Mapcallable - 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 compressionIOExceptionODatabaseExportpublic void restore(InputStream in, Map<String,Object> options, Callable<Object> callable, OCommandOutputListener iListener) throws IOException
OBackupablerestore in interface OBackupablein - InputStream used to read the backup content. Use a FileInputStream to read a backup on a diskoptions - Backup options as Mapcallable - Callback to execute when the database is lockediListener - Listener called for backup messagesIOExceptionODatabaseImportpublic String getStorageId()
OAutoshardedStoragegetStorageId in interface OAutoshardedStoragepublic String getNodeId()
getNodeId in interface OAutoshardedStoragepublic void shutdown()
OStorageOrient.shutdown() method. For most of the storages it means
that storage will be merely closed, but sometimes additional operations are need to be taken in account.public void shutdownAsynchronousWorker()
protected void checkNodeIsMaster(String localNodeName, ODistributedConfiguration dbCfg)
protected void checkLocalNodeIsAvailable()
public File getLastValidBackup()
public void setLastValidBackup(File lastValidBackup)
protected void asynchronousExecution(OAsynchDistributedOperation iOperation)
protected OAsyncReplicationError getAsyncReplicationError()
protected void handleDistributedException(String iMessage, Exception e, Object... iParams)
protected void dropStorageFiles()
Copyright © 2009–2016 Orient Technologies. All rights reserved.