Class ODatabaseWrapperAbstract<DB extends ODatabaseInternal,T>
java.lang.Object
com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract<DB,T>
- All Implemented Interfaces:
ODatabase<T>,ODatabaseInternal<T>,OBackupable,Closeable,AutoCloseable
- Direct Known Subclasses:
OObjectDatabaseTx
public abstract class ODatabaseWrapperAbstract<DB extends ODatabaseInternal,T>
extends Object
implements ODatabaseInternal<T>
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.orientechnologies.orient.core.db.ODatabase
ODatabase.ATTRIBUTES, ODatabase.STATUS -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionActivate current database instance on current thread.intaddCluster(String iClusterName, int iRequestedId) Adds a new cluster.intaddCluster(String iClusterName, Object... iParameters) Adds a new cluster.backup(OutputStream out, Map<String, Object> options, Callable<Object> callable, OCommandOutputListener iListener, int compressionLevel, int bufferSize) Executes a backup of the database.protected voidvoidclose()Closes an opened database, if the database is already closed does nothing, if a transaction is active will be rollback.longcountClusterElements(int iClusterId) Counts all the entities in the specified cluster id.longcountClusterElements(int[] iClusterIds) Counts all the entities in the specified cluster ids.longcountClusterElements(String iClusterName) Counts all the entities in the specified cluster name.booleandropCluster(int iClusterId) Drops a cluster by its id.booleandropCluster(String iClusterName) Drops a cluster by its name.booleanbooleanexistsCluster(String iClusterName) Returns true if the cluster exists, otherwise false.voidfreeze()Flush cached storage content to the disk.voidfreeze(boolean throwException) Flush cached storage content to the disk.get(ODatabase.ATTRIBUTES iAttribute) Returns a database attribute valueintgetClusterIdByName(String iClusterName) Returns the cluster id by name.getClusterNameById(int iClusterId) Returns the cluster name by id.Returns all the names of the clusters.longgetClusterRecordSizeById(int iClusterId) Returns the total size of records contained in the cluster defined by its id.longgetClusterRecordSizeByName(String iClusterName) Returns the total size of records contained in the cluster defined by its name.intReturns the number of clusters.Returns the database configuration settings.Returns the database owner.intReturns the default cluster id.Returns the level1 cache.getName()Returns the database name.Returns an iterator of the property entriesgetProperty(String iName) Gets the property value.getRecordMetadata(ORID rid) longgetSize()Returns the total size of the records in the database.Returns the current status of database.Returns the underlying storage implementation.<DBTYPE extends ODatabase>
DBTYPEReturn the underlying database.getURL()Returns the database URL.booleanReturns true if the current database instance is active on current thread, otherwise false.booleanisClosed()Checks if the database is closed.voidregisterListener(ODatabaseListener iListener) Registers a listener to the database events.voidrelease()Allows to execute write-related commands on DB.voidreload()Reloads the database information like the cluster list.voidreplaceStorage(OStorage iNewStorage) Internal only: replace the storage with a new one.voidrestore(InputStream in, Map<String, Object> options, Callable<Object> callable, OCommandOutputListener iListener) Executes a restore of a database backup.<THISDB extends ODatabase>
THISDBset(ODatabase.ATTRIBUTES attribute, Object iValue) Sets a database attribute valuesetDatabaseOwner(ODatabaseInternal<?> iOwner) Internal.setProperty(String iName, Object iValue) Sets a property value<THISDB extends ODatabase>
THISDBsetStatus(ODatabase.STATUS iStatus) Set the current status of database. deprecated since 2.2toString()voidtruncateCluster(String clusterName) Removes all data in the cluster with given name.voidunregisterListener(ODatabaseListener iListener) Unregisters a listener to the database events.Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.orientechnologies.orient.core.db.ODatabase
addBlobCluster, begin, begin, command, command, commit, commit, createClass, delete, delete, delete, execute, execute, executeWithRetry, getBlobClusterIds, getClass, getConflictStrategy, getDictionary, getHooks, getListeners, getMetadata, getTransaction, getType, getUser, incrementalBackup, live, live, load, load, load, load, load, load, lock, lock, newInstance, query, query, registerHook, registerHook, reload, reload, rollback, rollback, save, save, setConflictStrategy, setConflictStrategy, unlock, unregisterHookMethods inherited from interface com.orientechnologies.orient.core.db.ODatabaseInternal
addRidbagPrefetchStats, createInterruptTimerTask, getActiveDataCenterMap, getEnterpriseEndpoint, getLocalNodeName, getSharedContext, getStats, getStorageInfo, isSharded, resetInitialization, resetRecordLoadStats, save, setInternal, setUser
-
Field Details
-
underlying
-
databaseOwner
-
-
Constructor Details
-
ODatabaseWrapperAbstract
-
-
Method Details
-
activateOnCurrentThread
Description copied from interface:ODatabaseActivate current database instance on current thread. Call this method before using the database if you switch between multiple databases instances on the same thread or if you pass them across threads.- Specified by:
activateOnCurrentThreadin interfaceODatabase<DB extends ODatabaseInternal>
-
isActiveOnCurrentThread
public boolean isActiveOnCurrentThread()Description copied from interface:ODatabaseReturns true if the current database instance is active on current thread, otherwise false.- Specified by:
isActiveOnCurrentThreadin interfaceODatabase<DB extends ODatabaseInternal>
-
reload
public void reload()Description copied from interface:ODatabaseReloads the database information like the cluster list.- Specified by:
reloadin interfaceODatabase<DB extends ODatabaseInternal>
-
getConfiguration
Description copied from interface:ODatabaseReturns the database configuration settings. If defined, any database configuration overwrites the global one.- Specified by:
getConfigurationin interfaceODatabase<DB extends ODatabaseInternal>- Returns:
- OContextConfiguration
-
backup
public List<String> backup(OutputStream out, Map<String, Object> options, Callable<Object> callable, OCommandOutputListener iListener, int compressionLevel, int bufferSize) throws IOExceptionExecutes a backup of the database. During the backup the database will be frozen in read-only mode.- Specified by:
backupin interfaceOBackupable- 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 0 (no compression) 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:
-
restore
public void restore(InputStream in, Map<String, Object> options, Callable<Object> callable, OCommandOutputListener iListener) throws IOExceptionExecutes a restore of a database backup. During the restore the database will be frozen in read-only mode.- Specified by:
restorein interfaceOBackupable- Parameters:
in- InputStream used to read the backup content. Use a FileInputStream to read a backup on a diskoptions- Backup options as Map<String, Object> objectcallable- Callback to execute when the database is lockediListener- Listener called for backup messages- Throws:
IOException- See Also:
-
close
public void close()Description copied from interface:ODatabaseCloses an opened database, if the database is already closed does nothing, if a transaction is active will be rollback.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceODatabase<DB extends ODatabaseInternal>
-
replaceStorage
Description copied from interface:ODatabaseInternalInternal only: replace the storage with a new one.- Specified by:
replaceStoragein interfaceODatabaseInternal<DB extends ODatabaseInternal>- Parameters:
iNewStorage- The new storage to use. Usually it's a wrapped instance of the current cluster.
-
getStatus
Description copied from interface:ODatabaseReturns the current status of database.- Specified by:
getStatusin interfaceODatabase<DB extends ODatabaseInternal>
-
setStatus
Description copied from interface:ODatabaseSet the current status of database. deprecated since 2.2- Specified by:
setStatusin interfaceODatabase<DB extends ODatabaseInternal>
-
getName
Description copied from interface:ODatabaseReturns the database name.- Specified by:
getNamein interfaceODatabase<DB extends ODatabaseInternal>- Returns:
- Name of the database
-
getURL
Description copied from interface:ODatabaseReturns the database URL.- Specified by:
getURLin interfaceODatabase<DB extends ODatabaseInternal>- Returns:
- URL of the database
-
getStorage
Description copied from interface:ODatabaseInternalReturns the underlying storage implementation.- Specified by:
getStoragein interfaceODatabaseInternal<DB extends ODatabaseInternal>- Returns:
- The underlying storage implementation
- See Also:
-
getLocalCache
Description copied from interface:ODatabaseReturns the level1 cache. Cannot be null.- Specified by:
getLocalCachein interfaceODatabase<DB extends ODatabaseInternal>- Returns:
- Current cache.
-
isClosed
public boolean isClosed()Description copied from interface:ODatabaseChecks if the database is closed.- Specified by:
isClosedin interfaceODatabase<DB extends ODatabaseInternal>- Returns:
- true if is closed, otherwise false.
-
countClusterElements
public long countClusterElements(int iClusterId) Description copied from interface:ODatabaseCounts all the entities in the specified cluster id.- Specified by:
countClusterElementsin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iClusterId- Cluster id- Returns:
- Total number of entities contained in the specified cluster
-
truncateCluster
Removes all data in the cluster with given name. As result indexes for this class will be rebuilt.- Specified by:
truncateClusterin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
clusterName- Name of cluster to be truncated.
-
countClusterElements
public long countClusterElements(int[] iClusterIds) Description copied from interface:ODatabaseCounts all the entities in the specified cluster ids.- Specified by:
countClusterElementsin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iClusterIds- Array of cluster ids Cluster id- Returns:
- Total number of entities contained in the specified clusters
-
countClusterElements
Description copied from interface:ODatabaseCounts all the entities in the specified cluster name.- Specified by:
countClusterElementsin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iClusterName- Cluster name- Returns:
- Total number of entities contained in the specified cluster
-
getClusters
public int getClusters()Description copied from interface:ODatabaseReturns the number of clusters.- Specified by:
getClustersin interfaceODatabase<DB extends ODatabaseInternal>- Returns:
- Number of the clusters
-
existsCluster
Description copied from interface:ODatabaseReturns true if the cluster exists, otherwise false.- Specified by:
existsClusterin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iClusterName- Cluster name- Returns:
- true if the cluster exists, otherwise false
-
getClusterNames
Description copied from interface:ODatabaseReturns all the names of the clusters.- Specified by:
getClusterNamesin interfaceODatabase<DB extends ODatabaseInternal>- Returns:
- Collection of cluster names.
-
getClusterIdByName
Description copied from interface:ODatabaseReturns the cluster id by name.- Specified by:
getClusterIdByNamein interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iClusterName- Cluster name- Returns:
- The id of searched cluster.
-
getClusterNameById
Description copied from interface:ODatabaseReturns the cluster name by id.- Specified by:
getClusterNameByIdin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iClusterId- Cluster id- Returns:
- The name of searched cluster.
-
getClusterRecordSizeById
public long getClusterRecordSizeById(int iClusterId) Description copied from interface:ODatabaseReturns the total size of records contained in the cluster defined by its id.- Specified by:
getClusterRecordSizeByIdin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iClusterId- Cluster id- Returns:
- The name of searched cluster.
-
getClusterRecordSizeByName
Description copied from interface:ODatabaseReturns the total size of records contained in the cluster defined by its name.- Specified by:
getClusterRecordSizeByNamein interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iClusterName- Cluster name- Returns:
- Total size of records contained.
-
addCluster
Description copied from interface:ODatabaseAdds a new cluster.- Specified by:
addClusterin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iClusterName- Cluster nameiRequestedId- requested id of the cluster- Returns:
- Cluster id
-
addCluster
Description copied from interface:ODatabaseAdds a new cluster.- Specified by:
addClusterin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iClusterName- Cluster nameiParameters- Additional parameters to pass to the factories- Returns:
- Cluster id
-
dropCluster
Description copied from interface:ODatabaseDrops a cluster by its name. Physical clusters will be completely deleted- Specified by:
dropClusterin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iClusterName- the name of the cluster- Returns:
- true if has been removed, otherwise false
-
dropCluster
public boolean dropCluster(int iClusterId) Description copied from interface:ODatabaseDrops a cluster by its id. Physical clusters will be completely deleted.- Specified by:
dropClusterin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iClusterId- id of cluster to delete- Returns:
- true if has been removed, otherwise false
-
getDefaultClusterId
public int getDefaultClusterId()Description copied from interface:ODatabaseReturns the default cluster id. If not specified all the new entities will be stored in the default cluster.- Specified by:
getDefaultClusterIdin interfaceODatabase<DB extends ODatabaseInternal>- Returns:
- The default cluster id
-
getUnderlying
Description copied from interface:ODatabaseInternalReturn the underlying database. Used in wrapper instances to know the down level ODatabase instance.- Specified by:
getUnderlyingin interfaceODatabaseInternal<DB extends ODatabaseInternal>- Returns:
- The underlying ODatabase implementation.
-
getDatabaseOwner
Description copied from interface:ODatabaseInternalReturns the database owner. Used in wrapped instances to know the up level ODatabase instance.- Specified by:
getDatabaseOwnerin interfaceODatabaseInternal<DB extends ODatabaseInternal>- Returns:
- Returns the database owner.
-
setDatabaseOwner
Description copied from interface:ODatabaseInternalInternal. Sets the database owner.- Specified by:
setDatabaseOwnerin interfaceODatabaseInternal<DB extends ODatabaseInternal>
-
equals
-
toString
-
setProperty
Description copied from interface:ODatabaseSets a property value- Specified by:
setPropertyin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iName- Property nameiValue- new value to set- Returns:
- The previous value if any, otherwise null
-
getProperty
Description copied from interface:ODatabaseGets the property value.- Specified by:
getPropertyin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iName- Property name- Returns:
- The previous value if any, otherwise null
-
getProperties
Description copied from interface:ODatabaseReturns an iterator of the property entries- Specified by:
getPropertiesin interfaceODatabase<DB extends ODatabaseInternal>
-
get
Description copied from interface:ODatabaseReturns a database attribute value- Specified by:
getin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iAttribute- Attributes between #ATTRIBUTES enum- Returns:
- The attribute value
-
set
Description copied from interface:ODatabaseSets a database attribute value- Specified by:
setin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
attribute- Attributes between #ATTRIBUTES enumiValue- Value to set- Returns:
- underlying
-
registerListener
Description copied from interface:ODatabaseRegisters a listener to the database events.- Specified by:
registerListenerin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iListener- the listener to register
-
unregisterListener
Description copied from interface:ODatabaseUnregisters a listener to the database events.- Specified by:
unregisterListenerin interfaceODatabase<DB extends ODatabaseInternal>- Parameters:
iListener- the listener to unregister
-
getRecordMetadata
- Specified by:
getRecordMetadatain interfaceODatabase<DB extends ODatabaseInternal>
-
getSize
public long getSize()Description copied from interface:ODatabaseReturns the total size of the records in the database.- Specified by:
getSizein interfaceODatabase<DB extends ODatabaseInternal>
-
freeze
public void freeze(boolean throwException) Description copied from interface:ODatabaseFlush cached storage content to the disk.After this call users can perform only select queries. All write-related commands will queued till
ODatabase.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<DB extends ODatabaseInternal>- Parameters:
throwException- IftrueOModificationOperationProhibitedExceptionexception will be thrown in case of write command will be performed.
-
freeze
public void freeze()Description copied from interface:ODatabaseFlush cached storage content to the disk.After this call users can perform only idempotent calls like read records and select/traverse queries. All write-related operations will queued till
ODatabase.release()command will be called.Given command waits till all on going modifications in indexes or DB will be finished.
IMPORTANT: This command is not reentrant.
- Specified by:
freezein interfaceODatabase<DB extends ODatabaseInternal>- See Also:
-
release
public void release()Description copied from interface:ODatabaseAllows to execute write-related commands on DB. Called afterODatabase.freeze()command.- Specified by:
releasein interfaceODatabase<DB extends ODatabaseInternal>- See Also:
-
checkOpenness
protected void checkOpenness()
-