public abstract class ODatabaseDocumentAbstract extends OListenerManger<ODatabaseListener> implements ODatabaseDocumentInternal
ODatabase.ATTRIBUTES, ODatabase.OPERATION_MODE, ODatabase.STATUS
Modifier and Type | Field and Description |
---|---|
protected Map<String,OResultSet> |
activeQueries |
protected OCurrentStorageComponentsFactory |
componentsFactory |
protected OIntent |
currentIntent |
protected OTransaction |
currentTx |
protected ODatabaseInternal<?> |
databaseOwner |
protected Map<ORecordHook,ORecordHook.HOOK_POSITION> |
hooks |
protected ORecordHook[][] |
hooksByScope |
protected Set<OIdentifiable> |
inHook |
protected boolean |
initialized |
protected OLocalRecordCache |
localCache |
protected OMetadataDefault |
metadata |
protected OMicroTransaction |
microTransaction |
protected Map<String,Object> |
properties |
protected byte |
recordType |
protected boolean |
retainRecords |
protected ORecordSerializer |
serializer |
protected OSharedContext |
sharedContext |
protected ODatabase.STATUS |
status |
protected Map<ORecordHook,ORecordHook.HOOK_POSITION> |
unmodifiableHooks |
protected String |
url |
protected OImmutableUser |
user |
TYPE
Modifier | Constructor and Description |
---|---|
protected |
ODatabaseDocumentAbstract() |
Modifier and Type | Method and Description |
---|---|
ODatabaseDocumentAbstract |
activateOnCurrentThread()
Activates 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.
|
protected void |
afterCommitOperations() |
protected void |
afterRollbackOperations() |
int |
assignAndCheckCluster(ORecord record,
String iClusterName) |
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 |
beforeCommitOperations() |
protected void |
beforeRollbackOperations() |
ODatabaseDocumentAbstract |
begin()
Begins a new transaction.
|
ODatabaseDocumentAbstract |
begin(OTransaction.TXTYPE iType)
Begins a new transaction specifying the transaction type.
|
ODatabaseDocument |
begin(OTransaction iTx)
Deprecated.
|
ORecordIteratorClass<ODocument> |
browseClass(String iClassName)
Browses all the records of the specified class and also all the subclasses.
|
ORecordIteratorClass<ODocument> |
browseClass(String iClassName,
boolean iPolymorphic)
Browses all the records of the specified class and if iPolymorphic is true also all the
subclasses.
|
ORecordIteratorCluster<ODocument> |
browseCluster(String iClusterName)
Browses all the records of the specified cluster.
|
<REC extends ORecord> |
browseCluster(String iClusterName,
Class<REC> iClass)
Browses all the records of the specified cluster of the passed record type.
|
<REC extends ORecord> |
browseCluster(String iClusterName,
Class<REC> iRecordClass,
long startClusterPosition,
long endClusterPosition) |
<REC extends ORecord> |
browseCluster(String iClusterName,
Class<REC> iRecordClass,
long startClusterPosition,
long endClusterPosition,
boolean loadTombstones)
Deprecated.
|
ORecordIteratorCluster<ODocument> |
browseCluster(String iClusterName,
long startClusterPosition,
long endClusterPosition,
boolean loadTombstones)
Deprecated.
|
protected void |
callbackHookFailure(ORecord record,
boolean wasNew,
byte[] stream) |
protected void |
callbackHookFinalize(ORecord record,
boolean wasNew,
byte[] stream) |
ORecordHook.RESULT |
callbackHooks(ORecordHook.TYPE type,
OIdentifiable id)
Callback the registered hooks if any.
|
protected void |
callbackHookSuccess(ORecord record,
boolean wasNew,
byte[] stream,
OStorageOperationResult<Integer> operationResult) |
void |
callOnCloseListeners() |
void |
callOnDropListeners() |
void |
callOnOpenListeners() |
void |
checkClusterSecurity(int operation,
OIdentifiable record,
String cluster) |
void |
checkForClusterPermissions(String iClusterName) |
void |
checkIfActive() |
protected void |
checkOpenness() |
protected void |
checkRecordClass(OClass recordClass,
String iClusterName,
ORecordId rid) |
ODatabaseDocumentInternal |
cleanOutRecord(ORID iRecord,
int iVersion) |
protected void |
clearDocumentTracking(ORecord record) |
void |
close()
Closes an opened database, if the database is already closed does nothing, if a transaction is
active will be rollback.
|
protected void |
closeActiveQueries() |
OCommandRequest |
command(OCommandRequest iCommand)
Creates a command request to run a command against the database (you have to invoke
.execute(parameters) to actually execute it).
|
ODatabase<ORecord> |
commit()
Commits the current transaction.
|
ODatabaseDocument |
commit(boolean force) |
protected long |
countClass(OClass cls,
boolean iPolymorphic) |
long |
countClass(String iClassName)
Returns the number of the records of the class iClassName.
|
long |
countClass(String iClassName,
boolean iPolymorphic)
Returns the number of the records of the class iClassName considering also sub classes if
polymorphic is true.
|
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.
|
long |
countView(String viewName)
Returns the number of the records of the class iClassName.
|
boolean |
declareIntent(OIntent iIntent)
Declares an intent to the database.
|
ODatabaseDocument |
delete(ORID iRecord)
Deletes the record without checking the version.
|
ODatabase<ORecord> |
delete(ORID iRecord,
int iVersion)
Deletes the record checking the version.
|
boolean |
dropCluster(int clusterId)
Drops a cluster by its id.
|
boolean |
dropCluster(String iClusterName)
Drops a cluster by its name.
|
protected boolean |
dropClusterInternal(int clusterId) |
protected boolean |
dropClusterInternal(String iClusterName) |
abstract <RET extends ORecord> |
executeReadRecord(ORecordId rid,
ORecord iRecord,
int recordVersion,
String fetchPlan,
boolean ignoreCache,
boolean iUpdateCache,
boolean loadTombstones,
OStorage.LOCKING_STRATEGY lockingStrategy,
RecordReader recordReader)
This method is internal, it can be subject to signature change or be removed, do not
use.
|
static Object |
executeWithRetries(OCallable<Object,Integer> callback,
int maxRetry) |
static Object |
executeWithRetries(OCallable<Object,Integer> callback,
int maxRetry,
int waitBetweenRetry) |
static Object |
executeWithRetries(OCallable<Object,Integer> callback,
int maxRetry,
int waitBetweenRetry,
ORecord[] recordToReloadOnRetry) |
boolean |
existsCluster(String iClusterName)
Returns true if the cluster exists, otherwise false.
|
void |
freeze()
Flush all indexes and cached storage content to the disk.
|
void |
freeze(boolean throwException)
Flush all indexes and 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.
|
Map<String,OResultSet> |
getActiveQueries() |
OResultSet |
getActiveQuery(String id) |
Set<Integer> |
getBlobClusterIds()
Retrieve the set of defined blob cluster.
|
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 clusterId)
Returns the total size of records contained in the cluster defined by its id.
|
long |
getClusterRecordSizeByName(String clusterName)
Returns the total size of records contained in the cluster defined by its name.
|
int |
getClusters()
Returns the number of clusters.
|
Map<UUID,OBonsaiCollectionPointer> |
getCollectionsChanges() |
OContextConfiguration |
getConfiguration()
Returns the database configuration settings.
|
ORecordConflictStrategy |
getConflictStrategy()
Returns the current record conflict strategy.
|
ODatabaseInternal<?> |
getDatabaseOwner()
Returns the database owner.
|
int |
getDefaultClusterId()
Returns the default cluster id.
|
static ORecordSerializer |
getDefaultSerializer() |
ODictionary<ORecord> |
getDictionary()
Deprecated.
|
Map<ORecordHook,ORecordHook.HOOK_POSITION> |
getHooks()
Retrieves all the registered hooks.
|
Iterable<ODatabaseListener> |
getListeners()
Retrieves all the registered listeners.
|
OLocalRecordCache |
getLocalCache()
Returns the level1 cache.
|
OMetadataDefault |
getMetadata()
Return the OMetadata instance.
|
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.
|
<RET extends ORecord> |
getRecord(OIdentifiable iIdentifiable)
Returns the record for a OIdentifiable instance.
|
ORecordMetadata |
getRecordMetadata(ORID rid) |
byte |
getRecordType()
Returns the default record type for this kind of database.
|
OSBTreeCollectionManager |
getSbTreeCollectionManager()
Internal.
|
ORecordSerializer |
getSerializer() |
OBinarySerializerFactory |
getSerializerFactory() |
OSharedContext |
getSharedContext() |
long |
getSize()
Returns the total size of database as used space.
|
ODatabase.STATUS |
getStatus()
Returns the current status of database.
|
OCurrentStorageComponentsFactory |
getStorageVersions()
Internal.
|
OTransaction |
getTransaction()
Return active transaction.
|
String |
getType() |
<DB extends ODatabase> |
getUnderlying()
This method is internal, it can be subject to signature change or be removed, do not
use.
|
String |
getURL()
Returns the database URL.
|
OSecurityUser |
getUser()
Returns the current user logged into the database.
|
OView |
getViewFromCluster(int cluster) |
String |
incrementalBackup(String path)
Performs incremental backup of database content to the selected folder.
|
protected void |
init() |
void |
internalClose(boolean recycle) |
void |
internalCommit(OTransactionInternal transaction)
Executed the commit on the storage hiding away storage concepts from the transaction
|
boolean |
isActiveOnCurrentThread()
Returns true if the current database instance is active on current thread, otherwise false.
|
boolean |
isClosed()
Checks if the database is closed.
|
boolean |
isClusterEdge(int cluster) |
boolean |
isClusterVertex(int cluster) |
boolean |
isClusterView(int cluster) |
boolean |
isMVCC()
Returns if the Multi Version Concurrency Control is enabled or not.
|
boolean |
isPooled() |
boolean |
isPrefetchRecords() |
boolean |
isRetainRecords()
Returns true if current configuration retains objects, otherwise false
|
boolean |
isUseLightweightEdges() |
boolean |
isValidationEnabled()
Tells if validation of record is active.
|
<RET extends ORecord> |
load(ORecord iRecord)
Loads the entity and return it.
|
<RET extends ORecord> |
load(ORecord iRecord,
String iFetchPlan)
Loads a record using a fetch plan.
|
<RET extends ORecord> |
load(ORecord iRecord,
String iFetchPlan,
boolean iIgnoreCache)
Loads a record using a fetch plan.
|
<RET extends ORecord> |
load(ORID recordId)
Loads the entity by the Record ID.
|
<RET extends ORecord> |
load(ORID iRecordId,
String iFetchPlan)
Loads the entity by the Record ID using a fetch plan.
|
<RET extends ORecord> |
load(ORID iRecordId,
String iFetchPlan,
boolean iIgnoreCache)
Loads the entity by the Record ID using a fetch plan and specifying if the cache must be
ignored.
|
<RET extends ORecord> |
loadIfVersionIsNotLatest(ORID rid,
int recordVersion,
String fetchPlan,
boolean ignoreCache) |
protected abstract void |
loadMetadata() |
protected abstract void |
loadMetadata(OSharedContext ctx) |
OBlob |
newBlob()
Create a new empty instance of a blob.
|
OBlob |
newBlob(byte[] bytes)
Create a new instance of a blob containing the given bytes.
|
OEdge |
newEdge(OVertex from,
OVertex to,
OClass type)
Creates a new Edge
|
OEdge |
newEdge(OVertex from,
OVertex to,
String type)
Creates a new Edge
|
OElement |
newElement() |
OElement |
newElement(OClass clazz) |
OElement |
newElement(String className) |
OElement |
newEmbeddedElement() |
OElement |
newEmbeddedElement(String className) |
ODocument |
newInstance()
Creates a new ODocument.
|
ODocument |
newInstance(String iClassName)
Creates a document with specific class.
|
OEdge |
newLightweightEdge(String iClassName,
OVertex from,
OVertex to) |
OEdge |
newRegularEdge(String iClassName,
OVertex from,
OVertex to) |
OVertex |
newVertex(OClass type)
Creates a new Vertex
|
OVertex |
newVertex(String iClassName)
Creates a new Vertex
|
protected void |
pessimisticLockChecks(ORID recordId) |
<RET extends List<?>> |
query(OQuery<?> iCommand,
Object... iArgs)
Execute a query against the database.
|
void |
queryClosed(String id) |
void |
queryStarted(String id,
OResultSet rs) |
void |
rawBegin(OTransaction iTx) |
<DB extends ODatabase<?>> |
registerHook(ORecordHook iHookImpl)
Registers a hook to listen all events for Records.
|
<DB extends ODatabase<?>> |
registerHook(ORecordHook iHookImpl,
ORecordHook.HOOK_POSITION iPosition) |
void |
release()
Allows to execute write-related commands on DB.
|
void |
reload()
Reloads the database information like the cluster list.
|
<RET extends ORecord> |
reload(ORecord iRecord) |
<RET extends ORecord> |
reload(ORecord iRecord,
String iFetchPlan) |
<RET extends ORecord> |
reload(ORecord iRecord,
String iFetchPlan,
boolean iIgnoreCache)
Force the reloading of the entity.
|
<RET extends ORecord> |
reload(ORecord record,
String fetchPlan,
boolean ignoreCache,
boolean force)
Force the reloading of the entity.
|
void |
reloadUser() |
void |
resetInitialization() |
void |
restore(InputStream in,
Map<String,Object> options,
Callable<Object> callable,
OCommandOutputListener iListener)
Executes a restore of a database backup.
|
ODatabase<ORecord> |
rollback()
Aborts the current running transaction.
|
ODatabaseDocument |
rollback(boolean force) |
<RET extends ORecord> |
save(ORecord iRecord)
Saves a document to the database.
|
<RET extends ORecord> |
save(ORecord iRecord,
ODatabase.OPERATION_MODE iMode,
boolean iForceCreate,
ORecordCallback<? extends Number> iRecordCreatedCallback,
ORecordCallback<Integer> iRecordUpdatedCallback)
Saves a document to the database.
|
<RET extends ORecord> |
save(ORecord iRecord,
String iClusterName)
Saves a document specifying a cluster where to store the record.
|
<RET extends ORecord> |
save(ORecord iRecord,
String iClusterName,
ODatabase.OPERATION_MODE iMode,
boolean iForceCreate,
ORecordCallback<? extends Number> iRecordCreatedCallback,
ORecordCallback<Integer> iRecordUpdatedCallback)
Saves a document specifying a cluster where to store the record.
|
ODatabaseDocumentAbstract |
setConflictStrategy(ORecordConflictStrategy iResolver)
Overrides record conflict strategy.
|
ODatabaseDocumentAbstract |
setConflictStrategy(String iStrategyName)
Overrides record conflict strategy selecting the strategy by name.
|
void |
setCurrentDatabaseInThreadLocal()
Deprecated.
|
ODatabaseInternal<ORecord> |
setDatabaseOwner(ODatabaseInternal<?> iOwner)
Internal.
|
void |
setDefaultClusterIdInternal(int iDefClusterId)
Deprecated.
|
static void |
setDefaultSerializer(ORecordSerializer iDefaultSerializer)
Sets default serializer.
|
void |
setDefaultTransactionMode(Map<ORID,OTransactionAbstract.LockedRecordMetadata> noTxLocks) |
void |
setInternal(ODatabase.ATTRIBUTES iAttribute,
Object iValue)
Internal method.
|
<DB extends ODatabase<?>> |
setMVCC(boolean mvcc)
Enables or disables the Multi-Version Concurrency Control.
|
void |
setPrefetchRecords(boolean prefetchRecords) |
Object |
setProperty(String iName,
Object iValue)
Sets a property value
|
ODatabaseDocument |
setRetainRecords(boolean retainRecords)
Specifies if retain handled objects in memory or not.
|
void |
setSerializer(ORecordSerializer serializer)
Sets serializer for the database which will be used for document serialization.
|
<DB extends ODatabase> |
setStatus(ODatabase.STATUS status)
Set the current status of database.
|
void |
setStatusInternal(ODatabase.STATUS status) |
void |
setUseLightweightEdges(boolean b) |
void |
setUser(OSecurityUser user)
Set user for current database instance.
|
<DB extends ODatabaseDocument> |
setValidationEnabled(boolean iEnabled)
Enables or disables the record validation.
|
OTransaction |
swapTx(OTransaction newTx) |
void |
truncateCluster(String clusterName)
Removes all data in the cluster with given name.
|
<DB extends ODatabase<?>> |
unregisterHook(ORecordHook iHookImpl)
Unregisters a previously registered hook.
|
browseListeners, getListenersCopy, registerListener, resetListeners, unregisterListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
afterCreateOperations, afterDeleteOperations, afterReadOperations, afterUpdateOperations, beforeCreateOperations, beforeDeleteOperations, beforeReadOperations, beforeUpdateOperations, copy, executeDeleteRecord, getClusterName, getHaStatus, indexQuery, internalLockRecord, internalUnlockRecord, isDistributed, isRemote, queryOnNode, realClose, recycle, removeHaServer, reuse, saveAll, sendSequenceAction, setCustom, sync, syncCommit
addBlobCluster, checkSecurity, checkSecurity, checkSecurity, checkSecurity, checkSecurity, checkSecurity, createClassIfNotExist, createEdgeClass, createVertexClass, newEdge, newVertex
command, command, create, create, create, createClass, delete, drop, execute, execute, executeWithRetry, exists, getClass, live, live, lock, lock, open, query, query, registerListener, set, unlock, unregisterListener
getActiveClusterMap, getActiveDataCenterMap, getEnterpriseEndpoint, getLocalNodeName, getStorage, getStorageInfo, isSharded, open, replaceStorage
protected Map<ORecordHook,ORecordHook.HOOK_POSITION> unmodifiableHooks
protected final Set<OIdentifiable> inHook
protected ORecordSerializer serializer
protected String url
protected ODatabase.STATUS status
protected OIntent currentIntent
protected ODatabaseInternal<?> databaseOwner
protected OMetadataDefault metadata
protected OImmutableUser user
protected final byte recordType
protected final Map<ORecordHook,ORecordHook.HOOK_POSITION> hooks
protected boolean retainRecords
protected OLocalRecordCache localCache
protected OCurrentStorageComponentsFactory componentsFactory
protected boolean initialized
protected OTransaction currentTx
protected final ORecordHook[][] hooksByScope
protected OSharedContext sharedContext
protected OMicroTransaction microTransaction
protected Map<String,OResultSet> activeQueries
public static ORecordSerializer getDefaultSerializer()
public static void setDefaultSerializer(ORecordSerializer iDefaultSerializer)
iDefaultSerializer
- new default serializer valuepublic void callOnOpenListeners()
callOnOpenListeners
in interface ODatabaseDocumentInternal
protected abstract void loadMetadata()
protected abstract void loadMetadata(OSharedContext ctx)
public void callOnCloseListeners()
callOnCloseListeners
in interface ODatabaseDocumentInternal
public void callOnDropListeners()
callOnDropListeners
in interface ODatabaseDocumentInternal
public <RET extends ORecord> RET getRecord(OIdentifiable iIdentifiable)
getRecord
in interface ODatabaseDocument
public void reload()
ODatabase
public <RET extends ORecord> RET load(ORID iRecordId, String iFetchPlan, boolean iIgnoreCache)
public ODatabase<ORecord> delete(ORID iRecord, int iVersion)
public ODatabaseDocumentInternal cleanOutRecord(ORID iRecord, int iVersion)
cleanOutRecord
in interface ODatabaseDocumentInternal
public <REC extends ORecord> ORecordIteratorCluster<REC> browseCluster(String iClusterName, Class<REC> iClass)
ODatabaseDocument
browseCluster
in interface ODatabaseDocument
iClusterName
- Cluster name to iterateiClass
- The record class expected@Deprecated public <REC extends ORecord> ORecordIteratorCluster<REC> browseCluster(String iClusterName, Class<REC> iRecordClass, long startClusterPosition, long endClusterPosition, boolean loadTombstones)
browseCluster
in interface ODatabaseDocument
public <REC extends ORecord> ORecordIteratorCluster<REC> browseCluster(String iClusterName, Class<REC> iRecordClass, long startClusterPosition, long endClusterPosition)
browseCluster
in interface ODatabaseDocument
public OCommandRequest command(OCommandRequest iCommand)
public <RET extends List<?>> RET query(OQuery<?> iCommand, Object... iArgs)
public byte getRecordType()
getRecordType
in interface ODatabaseDocument
public long countClusterElements(int[] iClusterIds)
countClusterElements
in interface ODatabase<ORecord>
iClusterIds
- Array of cluster ids Cluster idpublic long countClusterElements(int iClusterId)
countClusterElements
in interface ODatabase<ORecord>
iClusterId
- Cluster idpublic void truncateCluster(String clusterName)
truncateCluster
in interface ODatabase<ORecord>
clusterName
- Name of cluster to be truncated.public long countClusterElements(int iClusterId, boolean countTombstones)
countClusterElements
in interface ODatabase<ORecord>
public long countClusterElements(int[] iClusterIds, boolean countTombstones)
countClusterElements
in interface ODatabase<ORecord>
public long countClusterElements(String iClusterName)
countClusterElements
in interface ODatabase<ORecord>
iClusterName
- Cluster namepublic OMetadataDefault getMetadata()
getMetadata
in interface ODatabase<ORecord>
getMetadata
in interface ODatabaseDocumentInternal
public ODatabaseInternal<?> getDatabaseOwner()
getDatabaseOwner
in interface ODatabaseInternal<ORecord>
public ODatabaseInternal<ORecord> setDatabaseOwner(ODatabaseInternal<?> iOwner)
setDatabaseOwner
in interface ODatabaseInternal<ORecord>
public boolean isRetainRecords()
isRetainRecords
in interface ODatabaseDocument
ODatabaseDocument.setRetainRecords(boolean)
public ODatabaseDocument setRetainRecords(boolean retainRecords)
setRetainRecords
in interface ODatabaseDocument
retainRecords
- True to enable, false to disable it.ODatabaseDocument.isRetainRecords()
public <DB extends ODatabase> DB setStatus(ODatabase.STATUS status)
public void setStatusInternal(ODatabase.STATUS status)
@Deprecated public void setDefaultClusterIdInternal(int iDefClusterId)
public void setInternal(ODatabase.ATTRIBUTES iAttribute, Object iValue)
setInternal
in interface ODatabaseInternal<ORecord>
public OSecurityUser getUser()
public void setUser(OSecurityUser user)
setUser
in interface ODatabaseInternal<ORecord>
public void reloadUser()
reloadUser
in interface ODatabaseDocumentInternal
public boolean isMVCC()
isMVCC
in interface ODatabase<ORecord>
deprecated since 2.2
public <DB extends ODatabase<?>> DB setMVCC(boolean mvcc)
setMVCC
in interface ODatabase<ORecord>
ODatabase.isMVCC()
@Deprecated public ODictionary<ORecord> getDictionary()
getDictionary
in interface ODatabase<ORecord>
public <DB extends ODatabase<?>> DB registerHook(ORecordHook iHookImpl, ORecordHook.HOOK_POSITION iPosition)
registerHook
in interface ODatabase<ORecord>
public <DB extends ODatabase<?>> DB registerHook(ORecordHook iHookImpl)
registerHook
in interface ODatabase<ORecord>
iHookImpl
- ORecordHook implementationpublic <DB extends ODatabase<?>> DB unregisterHook(ORecordHook iHookImpl)
unregisterHook
in interface ODatabase<ORecord>
iHookImpl
- ORecordHook implementationpublic OLocalRecordCache getLocalCache()
getLocalCache
in interface ODatabase<ORecord>
public Map<ORecordHook,ORecordHook.HOOK_POSITION> getHooks()
public ORecordHook.RESULT callbackHooks(ORecordHook.TYPE type, OIdentifiable id)
callbackHooks
in interface ODatabaseDocumentInternal
type
- Hook type. Define when hook is called.id
- Record received in the callbackpublic boolean isValidationEnabled()
isValidationEnabled
in interface ODatabaseDocument
public <DB extends ODatabaseDocument> DB setValidationEnabled(boolean iEnabled)
Since 2.2 this setting is persistent.
setValidationEnabled
in interface ODatabaseDocument
iEnabled
- True to enable, false to disablepublic ORecordConflictStrategy getConflictStrategy()
ODatabase
getConflictStrategy
in interface ODatabase<ORecord>
public ODatabaseDocumentAbstract setConflictStrategy(String iStrategyName)
ODatabase
setConflictStrategy
in interface ODatabase<ORecord>
iStrategyName
- ORecordConflictStrategy strategy namepublic ODatabaseDocumentAbstract setConflictStrategy(ORecordConflictStrategy iResolver)
ODatabase
setConflictStrategy
in interface ODatabase<ORecord>
iResolver
- ORecordConflictStrategy implementationpublic OContextConfiguration getConfiguration()
ODatabase
getConfiguration
in interface ODatabase<ORecord>
public boolean declareIntent(OIntent iIntent)
ODatabase
declareIntent
in interface ODatabase<ORecord>
iIntent
- The intentpublic OIntent getActiveIntent()
ODatabase
getActiveIntent
in interface ODatabase<ORecord>
public void internalClose(boolean recycle)
internalClose
in interface ODatabaseDocumentInternal
public void close()
ODatabase
public ODatabase.STATUS getStatus()
ODatabase
public long getSize()
ODatabase
public String getName()
ODatabase
public String getURL()
ODatabase
public int getDefaultClusterId()
ODatabase
getDefaultClusterId
in interface ODatabase<ORecord>
public int getClusters()
ODatabase
getClusters
in interface ODatabase<ORecord>
public boolean existsCluster(String iClusterName)
ODatabase
existsCluster
in interface ODatabase<ORecord>
iClusterName
- Cluster namepublic Collection<String> getClusterNames()
ODatabase
getClusterNames
in interface ODatabase<ORecord>
public int getClusterIdByName(String iClusterName)
ODatabase
getClusterIdByName
in interface ODatabase<ORecord>
iClusterName
- Cluster namepublic String getClusterNameById(int iClusterId)
ODatabase
getClusterNameById
in interface ODatabase<ORecord>
iClusterId
- Cluster idpublic long getClusterRecordSizeByName(String clusterName)
ODatabase
getClusterRecordSizeByName
in interface ODatabase<ORecord>
clusterName
- Cluster namepublic long getClusterRecordSizeById(int clusterId)
ODatabase
getClusterRecordSizeById
in interface ODatabase<ORecord>
clusterId
- Cluster idpublic boolean isClosed()
ODatabase
public int addCluster(String iClusterName, Object... iParameters)
ODatabase
addCluster
in interface ODatabase<ORecord>
iClusterName
- Cluster nameiParameters
- Additional parameters to pass to the factoriespublic int addCluster(String iClusterName, int iRequestedId)
ODatabase
addCluster
in interface ODatabase<ORecord>
iClusterName
- Cluster nameiRequestedId
- requested id of the clusterpublic boolean dropCluster(String iClusterName)
ODatabase
dropCluster
in interface ODatabase<ORecord>
iClusterName
- the name of the clusterprotected boolean dropClusterInternal(String iClusterName)
public boolean dropCluster(int clusterId)
ODatabase
dropCluster
in interface ODatabase<ORecord>
clusterId
- id of cluster to deleteprotected boolean dropClusterInternal(int clusterId)
public void checkForClusterPermissions(String iClusterName)
checkForClusterPermissions
in interface ODatabaseDocumentInternal
public Object setProperty(String iName, Object iValue)
ODatabase
setProperty
in interface ODatabase<ORecord>
iName
- Property nameiValue
- new value to setpublic Object getProperty(String iName)
ODatabase
getProperty
in interface ODatabase<ORecord>
iName
- Property namepublic Iterator<Map.Entry<String,Object>> getProperties()
ODatabase
getProperties
in interface ODatabase<ORecord>
public Object get(ODatabase.ATTRIBUTES iAttribute)
ODatabase
public ORecordMetadata getRecordMetadata(ORID rid)
getRecordMetadata
in interface ODatabase<ORecord>
public OTransaction getTransaction()
ODatabase
getTransaction
in interface ODatabase<ORecord>
public OBasicTransaction getMicroOrRegularTransaction()
ODatabaseInternal
getMicroOrRegularTransaction
in interface ODatabaseInternal<ORecord>
public <RET extends ORecord> RET load(ORecord iRecord, String iFetchPlan)
ODatabase
public <RET extends ORecord> RET load(ORecord iRecord)
ODatabase
public <RET extends ORecord> RET load(ORID recordId)
ODatabase
public <RET extends ORecord> RET load(ORID iRecordId, String iFetchPlan)
ODatabase
public <RET extends ORecord> RET loadIfVersionIsNotLatest(ORID rid, int recordVersion, String fetchPlan, boolean ignoreCache) throws ORecordNotFoundException
loadIfVersionIsNotLatest
in interface ODatabaseDocumentInternal
ORecordNotFoundException
public <RET extends ORecord> RET reload(ORecord iRecord, String iFetchPlan, boolean iIgnoreCache)
ODatabase
public <RET extends ORecord> RET reload(ORecord record, String fetchPlan, boolean ignoreCache, boolean force)
ODatabase
reload
in interface ODatabase<ORecord>
record
- The entity to load. If the entity was already loaded it will be reloaded and all
the changes will be lost.fetchPlan
- Fetch plan usedignoreCache
- Ignore cache or use itforce
- Force to reload record even if storage has the same record as reloaded record, it
is useful if fetch plan is not null and alongside with root record linked records will be
reloaded.public ODatabaseDocument delete(ORID iRecord)
public OBinarySerializerFactory getSerializerFactory()
getSerializerFactory
in interface ODatabaseDocumentInternal
@Deprecated public ODatabaseDocument begin(OTransaction iTx)
ODatabase
public OTransaction swapTx(OTransaction newTx)
swapTx
in interface ODatabaseDocumentInternal
public void rawBegin(OTransaction iTx)
rawBegin
in interface ODatabaseDocumentInternal
public <RET extends ORecord> RET load(ORecord iRecord, String iFetchPlan, boolean iIgnoreCache)
public void setPrefetchRecords(boolean prefetchRecords)
setPrefetchRecords
in interface ODatabaseDocumentInternal
public boolean isPrefetchRecords()
isPrefetchRecords
in interface ODatabaseDocumentInternal
public abstract <RET extends ORecord> RET executeReadRecord(ORecordId rid, ORecord iRecord, int recordVersion, String fetchPlan, boolean ignoreCache, boolean iUpdateCache, boolean loadTombstones, OStorage.LOCKING_STRATEGY lockingStrategy, RecordReader recordReader)
executeReadRecord
in interface ODatabaseDocumentInternal
public int assignAndCheckCluster(ORecord record, String iClusterName)
assignAndCheckCluster
in interface ODatabaseDocumentInternal
public ODatabaseDocumentAbstract begin()
ODatabase
ODatabase.commit()
or ODatabase.rollback()
.public ODatabaseDocumentAbstract begin(OTransaction.TXTYPE iType)
ODatabase
ODatabase.commit()
or ODatabase.rollback()
.public void setDefaultTransactionMode(Map<ORID,OTransactionAbstract.LockedRecordMetadata> noTxLocks)
setDefaultTransactionMode
in interface ODatabaseDocumentInternal
public void freeze(boolean throwException)
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 on throwException
parameter.
IMPORTANT: This command is not reentrant.
freeze
in interface ODatabaseDocument
freeze
in interface ODatabase<ORecord>
throwException
- If true
OModificationOperationProhibitedException
exception will be thrown in case of write command will be performed.public void freeze()
After this call users can perform only select queries. All write-related commands will
queued till ODatabaseDocument.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 ODatabaseDocument
freeze
in interface ODatabase<ORecord>
ODatabase.release()
public void release()
ODatabaseDocument.freeze()
command.release
in interface ODatabaseDocument
release
in interface ODatabase<ORecord>
ODatabase.freeze()
public ODocument newInstance()
newInstance
in interface ODatabase<ORecord>
public OBlob newBlob(byte[] bytes)
ODatabaseDocument
newBlob
in interface ODatabaseDocument
bytes
- content of the OBlobpublic OBlob newBlob()
ODatabaseDocument
newBlob
in interface ODatabaseDocument
public ODocument newInstance(String iClassName)
newInstance
in interface ODatabaseDocument
iClassName
- the name of class that should be used as a class of created document.public OElement newEmbeddedElement()
newEmbeddedElement
in interface ODatabaseDocument
public OElement newEmbeddedElement(String className)
newEmbeddedElement
in interface ODatabaseDocument
public OElement newElement()
newElement
in interface ODatabaseDocument
public OElement newElement(String className)
newElement
in interface ODatabaseDocument
public OVertex newVertex(String iClassName)
ODatabaseDocument
newVertex
in interface ODatabaseDocument
iClassName
- the vertex type (class name)public OVertex newVertex(OClass type)
ODatabaseDocument
newVertex
in interface ODatabaseDocument
type
- the vertex typepublic OEdge newEdge(OVertex from, OVertex to, String type)
ODatabaseDocument
newEdge
in interface ODatabaseDocument
from
- the starting point vertexto
- the endpoint vertextype
- the edge typepublic OEdge newEdge(OVertex from, OVertex to, OClass type)
ODatabaseDocument
newEdge
in interface ODatabaseDocument
from
- the starting point vertexto
- the endpoint vertextype
- the edge typepublic ORecordIteratorClass<ODocument> browseClass(String iClassName)
browseClass
in interface ODatabaseDocument
iClassName
- Class name to iteratepublic ORecordIteratorClass<ODocument> browseClass(String iClassName, boolean iPolymorphic)
browseClass
in interface ODatabaseDocument
iClassName
- Class name to iterateiPolymorphic
- Consider also the instances of the subclasses or notpublic ORecordIteratorCluster<ODocument> browseCluster(String iClusterName)
browseCluster
in interface ODatabaseDocument
iClusterName
- Cluster name to iteratepublic Iterable<ODatabaseListener> getListeners()
getListeners
in interface ODatabase<ORecord>
@Deprecated public ORecordIteratorCluster<ODocument> browseCluster(String iClusterName, long startClusterPosition, long endClusterPosition, boolean loadTombstones)
browseCluster
in interface ODatabaseDocument
public <RET extends ORecord> RET save(ORecord iRecord)
If MVCC is enabled and the version of the document is different by the version stored in the
database, then a OConcurrentModificationException
exception is thrown.Before to save
the document it must be valid following the constraints declared in the schema if any (can work
also in schema-less mode). To validate the document the ODocument.validate()
is called.
save
in interface ODatabase<ORecord>
iRecord
- Record to save.OConcurrentModificationException
- if the version of the document is different by the
version contained in the database.OValidationException
- if the document breaks some validation constraints defined in the
schema#setMVCC(boolean), {@link #isMVCC()}
public <RET extends ORecord> RET save(ORecord iRecord, ODatabase.OPERATION_MODE iMode, boolean iForceCreate, ORecordCallback<? extends Number> iRecordCreatedCallback, ORecordCallback<Integer> iRecordUpdatedCallback)
If MVCC is enabled and the version of the document is different by the version stored in the
database, then a OConcurrentModificationException
exception is thrown.Before to save
the document it must be valid following the constraints declared in the schema if any (can work
also in schema-less mode). To validate the document the ODocument.validate()
is called.
save
in interface ODatabase<ORecord>
iRecord
- Record to save.iForceCreate
- Flag that indicates that record should be created. If record with current
rid already exists, exception is throwniRecordCreatedCallback
- callback that is called after creation of new recordiRecordUpdatedCallback
- callback that is called after record updateiMode
- Mode of save: synchronous (default) or asynchronousOConcurrentModificationException
- if the version of the document is different by the
version contained in the database.OValidationException
- if the document breaks some validation constraints defined in the
schema#setMVCC(boolean), {@link #isMVCC()}
public <RET extends ORecord> RET save(ORecord iRecord, String iClusterName)
If MVCC is enabled and the version of the document is different by the version stored in the
database, then a OConcurrentModificationException
exception is thrown. Before to save
the document it must be valid following the constraints declared in the schema if any (can work
also in schema-less mode). To validate the document the ODocument.validate()
is called.
save
in interface ODatabase<ORecord>
iRecord
- Record to saveiClusterName
- Cluster name where to save the recordOConcurrentModificationException
- if the version of the document is different by the
version contained in the database.OValidationException
- if the document breaks some validation constraints defined in the
schema#setMVCC(boolean), {@link #isMVCC()}, ODocument#validate()
public <RET extends ORecord> RET save(ORecord iRecord, String iClusterName, ODatabase.OPERATION_MODE iMode, boolean iForceCreate, ORecordCallback<? extends Number> iRecordCreatedCallback, ORecordCallback<Integer> iRecordUpdatedCallback)
If MVCC is enabled and the version of the document is different by the version stored in the
database, then a OConcurrentModificationException
exception is thrown. Before to save
the document it must be valid following the constraints declared in the schema if any (can work
also in schema-less mode). To validate the document the ODocument.validate()
is called.
save
in interface ODatabase<ORecord>
iRecord
- Record to saveiClusterName
- Cluster name where to save the recordiMode
- Mode of save: synchronous (default) or asynchronousiForceCreate
- Flag that indicates that record should be created. If record with current
rid already exists, exception is throwniRecordCreatedCallback
- callback that is called after creation of new recordiRecordUpdatedCallback
- callback that is called after record updateOConcurrentModificationException
- if the version of the document is different by the
version contained in the database.OValidationException
- if the document breaks some validation constraints defined in the
schema#setMVCC(boolean), {@link #isMVCC()}, ODocument#validate()
public long countView(String viewName)
countView
in interface ODatabaseDocument
public long countClass(String iClassName)
countClass
in interface ODatabaseDocument
iClassName
- Class namepublic long countClass(String iClassName, boolean iPolymorphic)
countClass
in interface ODatabaseDocument
iClassName
- Class nameiPolymorphic
- True if consider also the sub classes, otherwise falseprotected long countClass(OClass cls, boolean iPolymorphic)
public ODatabase<ORecord> commit()
public ODatabaseDocument commit(boolean force) throws OTransactionException
commit
in interface ODatabase<ORecord>
OTransactionException
protected void beforeCommitOperations()
protected void afterCommitOperations()
protected void beforeRollbackOperations()
protected void afterRollbackOperations()
public ODatabase<ORecord> rollback()
public ODatabaseDocument rollback(boolean force) throws OTransactionException
rollback
in interface ODatabase<ORecord>
OTransactionException
public <DB extends ODatabase> DB getUnderlying()
getUnderlying
in interface ODatabaseInternal<ORecord>
public List<String> backup(OutputStream out, Map<String,Object> options, Callable<Object> callable, OCommandOutputListener iListener, int compressionLevel, int bufferSize) throws IOException
OBackupable
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 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 compressionIOException
ODatabaseExport
public void restore(InputStream in, Map<String,Object> options, Callable<Object> callable, OCommandOutputListener iListener) throws IOException
OBackupable
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 OSBTreeCollectionManager getSbTreeCollectionManager()
getSbTreeCollectionManager
in interface ODatabaseDocumentInternal
public OCurrentStorageComponentsFactory getStorageVersions()
ODatabaseDocumentInternal
getStorageVersions
in interface ODatabaseDocumentInternal
public ORecordSerializer getSerializer()
getSerializer
in interface ODatabaseDocumentInternal
public void setSerializer(ORecordSerializer serializer)
setSerializer
in interface ODatabaseDocumentInternal
serializer
- the serializer to set.public void resetInitialization()
resetInitialization
in interface ODatabaseInternal<ORecord>
public String incrementalBackup(String path) throws UnsupportedOperationException
ODatabase
If it will be first backup of data full content of database will be copied into folder otherwise only changes after last backup in the same folder will be copied.
incrementalBackup
in interface ODatabase<ORecord>
path
- Path to backup folder.UnsupportedOperationException
public void checkClusterSecurity(int operation, OIdentifiable record, String cluster)
public boolean isPooled()
isPooled
in interface ODatabaseDocument
true
if database is obtained from the pool and false
otherwise.@Deprecated public void setCurrentDatabaseInThreadLocal()
public ODatabaseDocumentAbstract activateOnCurrentThread()
activateOnCurrentThread
in interface ODatabase<ORecord>
public boolean isActiveOnCurrentThread()
ODatabase
isActiveOnCurrentThread
in interface ODatabase<ORecord>
protected void checkOpenness()
protected void callbackHookFailure(ORecord record, boolean wasNew, byte[] stream)
protected void callbackHookSuccess(ORecord record, boolean wasNew, byte[] stream, OStorageOperationResult<Integer> operationResult)
protected void callbackHookFinalize(ORecord record, boolean wasNew, byte[] stream)
protected void clearDocumentTracking(ORecord record)
protected void checkRecordClass(OClass recordClass, String iClusterName, ORecordId rid)
protected void init()
public void checkIfActive()
checkIfActive
in interface ODatabaseDocumentInternal
public Set<Integer> getBlobClusterIds()
ODatabase
getBlobClusterIds
in interface ODatabase<ORecord>
public OSharedContext getSharedContext()
getSharedContext
in interface ODatabaseInternal<ORecord>
public static Object executeWithRetries(OCallable<Object,Integer> callback, int maxRetry)
public static Object executeWithRetries(OCallable<Object,Integer> callback, int maxRetry, int waitBetweenRetry)
public static Object executeWithRetries(OCallable<Object,Integer> callback, int maxRetry, int waitBetweenRetry, ORecord[] recordToReloadOnRetry)
public boolean isUseLightweightEdges()
isUseLightweightEdges
in interface ODatabaseDocumentInternal
public void setUseLightweightEdges(boolean b)
setUseLightweightEdges
in interface ODatabaseDocumentInternal
public OEdge newLightweightEdge(String iClassName, OVertex from, OVertex to)
newLightweightEdge
in interface ODatabaseDocumentInternal
public OEdge newRegularEdge(String iClassName, OVertex from, OVertex to)
newRegularEdge
in interface ODatabaseDocumentInternal
public void queryStarted(String id, OResultSet rs)
public void queryClosed(String id)
protected void closeActiveQueries()
public Map<String,OResultSet> getActiveQueries()
getActiveQueries
in interface ODatabaseDocumentInternal
public OResultSet getActiveQuery(String id)
getActiveQuery
in interface ODatabaseDocumentInternal
public void internalCommit(OTransactionInternal transaction)
ODatabaseDocumentInternal
internalCommit
in interface ODatabaseDocumentInternal
public boolean isClusterEdge(int cluster)
isClusterEdge
in interface ODatabaseDocumentInternal
public boolean isClusterVertex(int cluster)
isClusterVertex
in interface ODatabaseDocumentInternal
public boolean isClusterView(int cluster)
isClusterView
in interface ODatabaseDocumentInternal
public OView getViewFromCluster(int cluster)
getViewFromCluster
in interface ODatabaseDocumentInternal
protected void pessimisticLockChecks(ORID recordId)
public Map<UUID,OBonsaiCollectionPointer> getCollectionsChanges()
getCollectionsChanges
in interface ODatabaseDocumentInternal
Copyright © 2009–2020 OrientDB. All rights reserved.