public abstract class ODatabaseWrapperAbstract<DB extends ODatabaseInternal,T> extends Object implements ODatabaseInternal<T>
ODatabase.ATTRIBUTES, ODatabase.OPERATION_MODE, ODatabase.STATUS
Modifier and Type | Field and Description |
---|---|
protected ODatabaseInternal<?> |
databaseOwner |
protected DB |
underlying |
Constructor and Description |
---|
ODatabaseWrapperAbstract(DB iDatabase) |
Modifier and Type | Method and Description |
---|---|
ODatabase |
activateOnCurrentThread()
Activate current database instance on current thread.
|
int |
addCluster(String iClusterName,
int iRequestedId)
Adds a new cluster.
|
int |
addCluster(String iClusterName,
Object... iParameters)
Adds a new cluster.
|
List<String> |
backup(OutputStream out,
Map<String,Object> options,
Callable<Object> callable,
OCommandOutputListener iListener,
int compressionLevel,
int bufferSize)
Executes a backup of the database.
|
protected void |
checkOpenness() |
void |
close()
Closes an opened database, if the database is already closed does nothing, if a transaction is
active will be rollback.
|
long |
countClusterElements(int iClusterId)
Counts all the entities in the specified cluster id.
|
long |
countClusterElements(int[] iClusterIds)
Counts all the entities in the specified cluster ids.
|
long |
countClusterElements(int[] iClusterIds,
boolean countTombstones) |
long |
countClusterElements(int iClusterId,
boolean countTombstones) |
long |
countClusterElements(String iClusterName)
Counts all the entities in the specified cluster name.
|
<THISDB extends ODatabase> |
create()
Creates a new database.
|
<THISDB extends ODatabase> |
create(Map<OGlobalConfiguration,Object> iInitialSettings)
Creates a new database passing initial settings.
|
<THISDB extends ODatabase> |
create(String incrementalBackupPath)
Creates new database from database backup.
|
boolean |
declareIntent(OIntent iIntent)
Declares an intent to the database.
|
void |
drop()
Drops a database.
|
boolean |
dropCluster(int iClusterId)
Drops a cluster by its id.
|
boolean |
dropCluster(String iClusterName)
Drops a cluster by its name.
|
boolean |
equals(Object iOther) |
boolean |
exists()
Checks if the database exists.
|
boolean |
existsCluster(String iClusterName)
Returns true if the cluster exists, otherwise false.
|
void |
freeze()
Flush cached storage content to the disk.
|
void |
freeze(boolean throwException)
Flush cached storage content to the disk.
|
Object |
get(ODatabase.ATTRIBUTES iAttribute)
Returns a database attribute value
|
OIntent |
getActiveIntent()
Get the active intent in the current session.
|
int |
getClusterIdByName(String iClusterName)
Returns the cluster id by name.
|
String |
getClusterNameById(int iClusterId)
Returns the cluster name by id.
|
Collection<String> |
getClusterNames()
Returns all the names of the clusters.
|
long |
getClusterRecordSizeById(int iClusterId)
Returns the total size of records contained in the cluster defined by its id.
|
long |
getClusterRecordSizeByName(String iClusterName)
Returns the total size of records contained in the cluster defined by its name.
|
int |
getClusters()
Returns the number of clusters.
|
OContextConfiguration |
getConfiguration()
Returns the database configuration settings.
|
ODatabaseInternal<?> |
getDatabaseOwner()
Returns the database owner.
|
int |
getDefaultClusterId()
Returns the default cluster id.
|
OLocalRecordCache |
getLocalCache()
Returns the level1 cache.
|
OBasicTransaction |
getMicroOrRegularTransaction()
The active implicit micro-transaction or active/inactive regular transaction.
|
String |
getName()
Returns the database name.
|
Iterator<Map.Entry<String,Object>> |
getProperties()
Returns an iterator of the property entries
|
Object |
getProperty(String iName)
Gets the property value.
|
ORecordMetadata |
getRecordMetadata(ORID rid) |
long |
getSize()
Returns the total size of database as used space.
|
ODatabase.STATUS |
getStatus()
Returns the current status of database.
|
OStorage |
getStorage()
Returns the underlying storage implementation.
|
<DBTYPE extends ODatabase> |
getUnderlying()
Return the underlying database.
|
String |
getURL()
Returns the database URL.
|
boolean |
isActiveOnCurrentThread()
Returns true if the current database instance is active on current thread, otherwise false.
|
boolean |
isClosed()
Checks if the database is closed.
|
<THISDB extends ODatabase> |
open(OToken iToken)
Opens a database using an authentication token received as an argument.
|
<THISDB extends ODatabase> |
open(String iUserName,
String iUserPassword)
Opens a database using the user and password received as arguments.
|
void |
registerListener(ODatabaseListener iListener)
Registers a listener to the database events.
|
void |
release()
Allows to execute write-related commands on DB.
|
void |
reload()
Reloads the database information like the cluster list.
|
void |
replaceStorage(OStorage iNewStorage)
Internal only: replace the storage with a new one.
|
void |
restore(InputStream in,
Map<String,Object> options,
Callable<Object> callable,
OCommandOutputListener iListener)
Executes a restore of a database backup.
|
<THISDB extends ODatabase> |
set(ODatabase.ATTRIBUTES attribute,
Object iValue)
Sets a database attribute value
|
ODatabaseInternal<?> |
setDatabaseOwner(ODatabaseInternal<?> iOwner)
Internal.
|
Object |
setProperty(String iName,
Object iValue)
Sets a property value
|
<THISDB extends ODatabase> |
setStatus(ODatabase.STATUS iStatus)
Set the current status of database.
|
String |
toString() |
void |
truncateCluster(String clusterName)
Removes all data in the cluster with given name.
|
void |
unregisterListener(ODatabaseListener iListener)
Unregisters a listener to the database events.
|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getActiveClusterMap, getActiveDataCenterMap, getEnterpriseEndpoint, getLocalNodeName, getSharedContext, getStorageInfo, isSharded, resetInitialization, setInternal, setUser
addBlobCluster, begin, begin, begin, command, command, command, commit, commit, createClass, delete, delete, delete, execute, execute, executeWithRetry, getBlobClusterIds, getClass, getConflictStrategy, getDictionary, getHooks, getListeners, getMetadata, getTransaction, getType, getUser, incrementalBackup, isMVCC, live, live, load, load, load, load, load, load, lock, lock, newInstance, query, query, query, registerHook, registerHook, reload, reload, rollback, rollback, save, save, save, save, setConflictStrategy, setConflictStrategy, setMVCC, unlock, unregisterHook
protected DB extends ODatabaseInternal underlying
protected ODatabaseInternal<?> databaseOwner
public ODatabaseWrapperAbstract(DB iDatabase)
public <THISDB extends ODatabase> THISDB open(String iUserName, String iUserPassword)
ODatabase
public <THISDB extends ODatabase> THISDB open(OToken iToken)
ODatabaseInternal
open
in interface ODatabaseInternal<T>
iToken
- Authentication tokenpublic ODatabase activateOnCurrentThread()
ODatabase
activateOnCurrentThread
in interface ODatabase<T>
public boolean isActiveOnCurrentThread()
ODatabase
isActiveOnCurrentThread
in interface ODatabase<T>
public <THISDB extends ODatabase> THISDB create()
ODatabase
public <THISDB extends ODatabase> THISDB create(String incrementalBackupPath)
ODatabase
public <THISDB extends ODatabase> THISDB create(Map<OGlobalConfiguration,Object> iInitialSettings)
ODatabase
public boolean exists()
ODatabase
public void reload()
ODatabase
public OContextConfiguration getConfiguration()
ODatabase
getConfiguration
in interface ODatabase<T>
public List<String> backup(OutputStream out, Map<String,Object> options, Callable<Object> callable, OCommandOutputListener iListener, int compressionLevel, int bufferSize) throws IOException
backup
in interface OBackupable
out
- 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 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 compressionIOException
ODatabaseExport
public void restore(InputStream in, Map<String,Object> options, Callable<Object> callable, OCommandOutputListener iListener) throws IOException
restore
in interface OBackupable
in
- 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 messagesIOException
ODatabaseImport
public void close()
ODatabase
public void replaceStorage(OStorage iNewStorage)
ODatabaseInternal
replaceStorage
in interface ODatabaseInternal<T>
iNewStorage
- The new storage to use. Usually it's a wrapped instance of the current
cluster.public void drop()
ODatabase
public ODatabase.STATUS getStatus()
ODatabase
public <THISDB extends ODatabase> THISDB setStatus(ODatabase.STATUS iStatus)
ODatabase
public String getName()
ODatabase
public String getURL()
ODatabase
public OStorage getStorage()
ODatabaseInternal
getStorage
in interface ODatabaseInternal<T>
OStorage
public OBasicTransaction getMicroOrRegularTransaction()
ODatabaseInternal
getMicroOrRegularTransaction
in interface ODatabaseInternal<T>
public OLocalRecordCache getLocalCache()
ODatabase
getLocalCache
in interface ODatabase<T>
public boolean isClosed()
ODatabase
public long countClusterElements(int iClusterId)
ODatabase
countClusterElements
in interface ODatabase<T>
iClusterId
- Cluster idpublic void truncateCluster(String clusterName)
truncateCluster
in interface ODatabase<T>
clusterName
- Name of cluster to be truncated.public long countClusterElements(int[] iClusterIds)
ODatabase
countClusterElements
in interface ODatabase<T>
iClusterIds
- Array of cluster ids Cluster idpublic long countClusterElements(String iClusterName)
ODatabase
countClusterElements
in interface ODatabase<T>
iClusterName
- Cluster namepublic long countClusterElements(int iClusterId, boolean countTombstones)
countClusterElements
in interface ODatabase<T>
public long countClusterElements(int[] iClusterIds, boolean countTombstones)
countClusterElements
in interface ODatabase<T>
public int getClusters()
ODatabase
getClusters
in interface ODatabase<T>
public boolean existsCluster(String iClusterName)
ODatabase
existsCluster
in interface ODatabase<T>
iClusterName
- Cluster namepublic Collection<String> getClusterNames()
ODatabase
getClusterNames
in interface ODatabase<T>
public int getClusterIdByName(String iClusterName)
ODatabase
getClusterIdByName
in interface ODatabase<T>
iClusterName
- Cluster namepublic String getClusterNameById(int iClusterId)
ODatabase
getClusterNameById
in interface ODatabase<T>
iClusterId
- Cluster idpublic long getClusterRecordSizeById(int iClusterId)
ODatabase
getClusterRecordSizeById
in interface ODatabase<T>
iClusterId
- Cluster idpublic long getClusterRecordSizeByName(String iClusterName)
ODatabase
getClusterRecordSizeByName
in interface ODatabase<T>
iClusterName
- Cluster namepublic int addCluster(String iClusterName, int iRequestedId)
ODatabase
addCluster
in interface ODatabase<T>
iClusterName
- Cluster nameiRequestedId
- requested id of the clusterpublic int addCluster(String iClusterName, Object... iParameters)
ODatabase
addCluster
in interface ODatabase<T>
iClusterName
- Cluster nameiParameters
- Additional parameters to pass to the factoriespublic boolean dropCluster(String iClusterName)
ODatabase
dropCluster
in interface ODatabase<T>
iClusterName
- the name of the clusterpublic boolean dropCluster(int iClusterId)
ODatabase
dropCluster
in interface ODatabase<T>
iClusterId
- id of cluster to deletepublic int getDefaultClusterId()
ODatabase
getDefaultClusterId
in interface ODatabase<T>
public boolean declareIntent(OIntent iIntent)
ODatabase
declareIntent
in interface ODatabase<T>
iIntent
- The intentpublic OIntent getActiveIntent()
ODatabase
getActiveIntent
in interface ODatabase<T>
public <DBTYPE extends ODatabase> DBTYPE getUnderlying()
ODatabaseInternal
getUnderlying
in interface ODatabaseInternal<T>
public ODatabaseInternal<?> getDatabaseOwner()
ODatabaseInternal
getDatabaseOwner
in interface ODatabaseInternal<T>
public ODatabaseInternal<?> setDatabaseOwner(ODatabaseInternal<?> iOwner)
ODatabaseInternal
setDatabaseOwner
in interface ODatabaseInternal<T>
public Object setProperty(String iName, Object iValue)
ODatabase
setProperty
in interface ODatabase<T>
iName
- Property nameiValue
- new value to setpublic Object getProperty(String iName)
ODatabase
getProperty
in interface ODatabase<T>
iName
- Property namepublic Iterator<Map.Entry<String,Object>> getProperties()
ODatabase
getProperties
in interface ODatabase<T>
public Object get(ODatabase.ATTRIBUTES iAttribute)
ODatabase
public <THISDB extends ODatabase> THISDB set(ODatabase.ATTRIBUTES attribute, Object iValue)
ODatabase
public void registerListener(ODatabaseListener iListener)
ODatabase
registerListener
in interface ODatabase<T>
iListener
- the listener to registerpublic void unregisterListener(ODatabaseListener iListener)
ODatabase
unregisterListener
in interface ODatabase<T>
iListener
- the listener to unregisterpublic ORecordMetadata getRecordMetadata(ORID rid)
getRecordMetadata
in interface ODatabase<T>
public long getSize()
ODatabase
public void freeze(boolean throwException)
ODatabase
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 on throwException
parameter.
IMPORTANT: This command is not reentrant.
freeze
in interface ODatabase<T>
throwException
- If true
OModificationOperationProhibitedException
exception will be thrown in case of write command will be performed.public void freeze()
ODatabase
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.
freeze
in interface ODatabase<T>
ODatabase.release()
public void release()
ODatabase
ODatabase.freeze()
command.release
in interface ODatabase<T>
ODatabase.freeze()
protected void checkOpenness()
Copyright © 2009–2020 OrientDB. All rights reserved.