Class OTransactionOptimistic
java.lang.Object
com.orientechnologies.orient.core.tx.OTransactionAbstract
com.orientechnologies.orient.core.tx.OTransactionOptimistic
- All Implemented Interfaces:
OAllocationTransaction,OStorageTransaction,OTransaction,OTransactionInternal
- Direct Known Subclasses:
OTransactionOptimisticClient,OTransactionOptimisticDistributed,OTransactionOptimisticProxy,OTransactionOptimisticServer
-
Nested Class Summary
Nested classes/interfaces inherited from class com.orientechnologies.orient.core.tx.OTransactionAbstract
OTransactionAbstract.LockedRecordMetadataNested classes/interfaces inherited from interface com.orientechnologies.orient.core.tx.OTransaction
OTransaction.ISOLATION_LEVEL, OTransaction.TXSTATUS, OTransaction.TXTYPE -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<ORID,ORecordOperation> protected booleantoken This set is used to track which documents are changed during tx, if documents are changed but not saved all changes are made during tx will be undone.protected intprotected Map<String,OTransactionIndexChanges> protected intprotected Map<ORID,List<OTransactionRecordIndexOperation>> Fields inherited from class com.orientechnologies.orient.core.tx.OTransactionAbstract
database, DELETED_RECORD, isolationLevel, locks, status -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangedDocument(ODocument document) Adds the given document to a set of changed documents known to this transaction.voidaddIndexEntry(OIndex delegate, String iIndexName, OTransactionIndexChanges.OPERATION iOperation, Object key, OIdentifiable iValue) Adds the transactional index entry in this transaction.voidaddIndexEntry(OIndex delegate, String iIndexName, OTransactionIndexChanges.OPERATION iOperation, Object key, OIdentifiable iValue, boolean clientTrackOnly) Bufferizes index changes to be flushed at commit time.intvoidbegin()protected voidvoidclose()Closes the transaction and releases all the acquired locks.voidcommit()voidcommit(boolean force) The transaction is reentrant.voidvoiddeleteRecord(ORecord iRecord) Deletes the given record in this transaction.voidfill(Iterator<ORecordOperation> operations) getCustomData(String iName) Obtains the custom value by its name stored in the context of this transaction.intintgetId()getIndexChanges(String iIndexName) Bufferizes index changes to be flushed at commit time.getIndexChangesInternal(String indexName) Does the same thing asOTransaction.getIndexChanges(String), but handles remote storages in a special way.Extract all the calculated index operations for the current transaction changes, the key of the map is the index name the value all the changes for the specified index.Optional<byte[]>intgetNewRecordEntriesByClass(OClass iClass, boolean iPolymorphic) Called by class iterator.getNewRecordEntriesByClusterIds(int[] iIds) Called by cluster iterator.Resolves a record with the given RID in the context of this transaction.getRecordEntry(ORID ridPar) Extract a single change from a specified record id.Extract all the record operations for the current transactionbooleanIterator<byte[]>protected intvoidbooleanbooleanloadRecord(ORID rid, ORecord record, String fetchPlan, boolean ignoreCache) loadRecord(ORID rid, ORecord iRecord, String fetchPlan, boolean ignoreCache, boolean iUpdateCache) loadRecordIfVersionIsNotLatest(ORID rid, int recordVersion, String fetchPlan, boolean ignoreCache) voidreloadRecord(ORID rid, ORecord iRecord, String fetchPlan, boolean ignoreCache) reloadRecord(ORID rid, ORecord passedRecord, String fetchPlan, boolean ignoreCache, boolean force) voidvoidprotected voidresolveTracking(ORecordOperation change) voidrollback()voidrollback(boolean force, int commitLevelDiff) saveRecord(ORecord iRecord, String iClusterName, boolean iForceCreate) Saves the given record in this transaction.protected ODocumentserializeIndexChangeEntry(OTransactionIndexChangesPerKey entry, ODocument indexDoc) voidsetCustomData(String iName, Object iValue) Sets the custom value by its name stored in the context of this transaction.voidsetMetadataHolder(Optional<OTxMetadataHolder> metadata) voidsetNoTxLocks(Map<ORID, OTransactionAbstract.LockedRecordMetadata> noTxLocks) voidsetSentToServer(boolean sentToServer) voidsetStatus(OTransaction.TXSTATUS iStatus) Change the status of the transaction.voidtoString()voidupdateCache(boolean keepInCache) voidupdateIdentityAfterCommit(ORID oldRid, ORID newRid) Notify the transaction for the rid change, the changed will be tracked inside the transaction and used for remapping links.Methods inherited from class com.orientechnologies.orient.core.tx.OTransactionAbstract
getDatabase, getInternalLocks, getIsolationLevel, getStatus, isActive, isLockedRecord, lockingStrategy, lockRecord, newOp, setDatabase, setIsolationLevel, setLocks, trackLockedRecord, trackUnlockRecord, unlockRecord, updateCacheFromEntriesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.orientechnologies.orient.core.tx.OTransaction
getClientTransactionId, getIsolationLevel, getStatus, isActive, isLockedRecord, lockingStrategy, lockRecord, setIsolationLevel, unlockRecordMethods inherited from interface com.orientechnologies.orient.core.tx.OTransactionInternal
getDatabase, isSequenceTransaction, setDatabase
-
Field Details
-
updatedRids
-
allEntries
-
indexEntries
-
recordIndexOperations
-
id
protected int id -
newObjectCounter
protected int newObjectCounter -
userData
-
changedDocuments
token This set is used to track which documents are changed during tx, if documents are changed but not saved all changes are made during tx will be undone. -
changed
protected boolean changed
-
-
Constructor Details
-
OTransactionOptimistic
-
-
Method Details
-
begin
public void begin()- Specified by:
beginin interfaceOTransaction
-
commit
public void commit()- Specified by:
commitin interfaceOTransaction
-
commit
public void commit(boolean force) The transaction is reentrant. Ifbegin()has been called several times, the actual commit happens only after the same amount ofcommit()calls- Specified by:
commitin interfaceOTransaction- Parameters:
force- commit transaction even
-
commitPreallocate
public void commitPreallocate() -
amountOfNestedTxs
public int amountOfNestedTxs()- Specified by:
amountOfNestedTxsin interfaceOTransaction
-
rollback
public void rollback()- Specified by:
rollbackin interfaceOTransaction
-
internalRollback
public void internalRollback()- Specified by:
internalRollbackin classOTransactionAbstract
-
rollback
public void rollback(boolean force, int commitLevelDiff) - Specified by:
rollbackin interfaceOTransaction
-
loadRecord
-
loadRecordIfVersionIsNotLatest
public ORecord loadRecordIfVersionIsNotLatest(ORID rid, int recordVersion, String fetchPlan, boolean ignoreCache) throws ORecordNotFoundException - Specified by:
loadRecordIfVersionIsNotLatestin interfaceOTransaction- Throws:
ORecordNotFoundException
-
reloadRecord
- Specified by:
reloadRecordin interfaceOTransaction
-
reloadRecord
public ORecord reloadRecord(ORID rid, ORecord passedRecord, String fetchPlan, boolean ignoreCache, boolean force) - Specified by:
reloadRecordin interfaceOTransaction
-
loadRecord
- Specified by:
loadRecordin interfaceOTransaction
-
deleteRecord
Description copied from interface:OTransactionDeletes the given record in this transaction.- Specified by:
deleteRecordin interfaceOTransaction- Parameters:
iRecord- the record to delete.
-
saveRecord
Description copied from interface:OTransactionSaves the given record in this transaction.- Specified by:
saveRecordin interfaceOTransaction- Parameters:
iRecord- the record to save.iClusterName- record's cluster name.iForceCreate- the force creation flag,trueto force the creation of the record,falseto allow updates.- Returns:
- the record saved.
-
toString
-
setStatus
Description copied from interface:OTransactionInternalChange the status of the transaction.- Specified by:
setStatusin interfaceOTransactionInternal
-
addRecord
-
resetChangesTracking
public void resetChangesTracking() -
isChanged
public boolean isChanged() -
isAlreadyCleared
public boolean isAlreadyCleared() -
getLockedRecords
- Specified by:
getLockedRecordsin interfaceOStorageTransaction- Specified by:
getLockedRecordsin interfaceOTransactionInternal- Overrides:
getLockedRecordsin classOTransactionAbstract
-
setSentToServer
public void setSentToServer(boolean sentToServer) -
getSentToServer
public boolean getSentToServer() -
fill
- Specified by:
fillin interfaceOTransactionInternal
-
resolveTracking
-
getTxStartCounter
protected int getTxStartCounter() -
addChangedDocument
Description copied from interface:OTransactionAdds the given document to a set of changed documents known to this transaction.- Specified by:
addChangedDocumentin interfaceOTransaction- Parameters:
document- the document to add.
-
getId
public int getId()- Specified by:
getIdin interfaceOStorageTransaction- Specified by:
getIdin interfaceOTransaction
-
getEntryCount
public int getEntryCount()- Specified by:
getEntryCountin interfaceOTransaction
-
getRecordOperations
Description copied from interface:OTransactionInternalExtract all the record operations for the current transaction- Specified by:
getRecordOperationsin interfaceOTransaction- Specified by:
getRecordOperationsin interfaceOTransactionInternal- Returns:
- the record operations, the collection should not be modified.
-
getRecordEntry
Description copied from interface:OTransactionInternalExtract a single change from a specified record id.- Specified by:
getRecordEntryin interfaceOTransaction- Specified by:
getRecordEntryin interfaceOTransactionInternal- Parameters:
ridPar- the record id for the change.- Returns:
- the change or null if there is no change for the specified rid
-
getRecord
Description copied from interface:OTransactionResolves a record with the given RID in the context of this transaction.- Specified by:
getRecordin interfaceOTransaction- Parameters:
rid- the record RID.- Returns:
- the resolved record, or
nullif no record is found, orOTransactionAbstract.DELETED_RECORDif the record was deleted in this transaction.
-
getNewRecordEntriesByClass
Called by class iterator.- Specified by:
getNewRecordEntriesByClassin interfaceOTransaction
-
getNewRecordEntriesByClusterIds
Called by cluster iterator.- Specified by:
getNewRecordEntriesByClusterIdsin interfaceOTransaction
-
getInvolvedIndexes
- Specified by:
getInvolvedIndexesin interfaceOTransaction
-
getIndexChanges
- Specified by:
getIndexChangesin interfaceOTransaction
-
getIndexOperations
Description copied from interface:OTransactionInternalExtract all the calculated index operations for the current transaction changes, the key of the map is the index name the value all the changes for the specified index.- Specified by:
getIndexOperationsin interfaceOTransactionInternal- Returns:
- the index changes, the map should not be modified.
-
getIndexChanges
Bufferizes index changes to be flushed at commit time.- Specified by:
getIndexChangesin interfaceOTransaction- Parameters:
iIndexName- the index name.- Returns:
-
getIndexChangesInternal
Description copied from interface:OTransactionDoes the same thing asOTransaction.getIndexChanges(String), but handles remote storages in a special way.- Specified by:
getIndexChangesInternalin interfaceOTransaction- Parameters:
indexName- the index name.- Returns:
- the index changes in question or
nullif index is not found or storage is remote.
-
addIndexEntry
public void addIndexEntry(OIndex delegate, String iIndexName, OTransactionIndexChanges.OPERATION iOperation, Object key, OIdentifiable iValue) Description copied from interface:OTransactionAdds the transactional index entry in this transaction.- Specified by:
addIndexEntryin interfaceOTransaction- Parameters:
delegate- the index.iIndexName- the index name.iOperation- the index operation to register.key- the index key.iValue- the index key value.
-
addIndexEntry
public void addIndexEntry(OIndex delegate, String iIndexName, OTransactionIndexChanges.OPERATION iOperation, Object key, OIdentifiable iValue, boolean clientTrackOnly) Bufferizes index changes to be flushed at commit time. -
updateIdentityAfterCommit
Description copied from interface:OTransactionInternalNotify the transaction for the rid change, the changed will be tracked inside the transaction and used for remapping links.- Specified by:
updateIdentityAfterCommitin interfaceOAllocationTransaction- Specified by:
updateIdentityAfterCommitin interfaceOStorageTransaction- Specified by:
updateIdentityAfterCommitin interfaceOTransaction- Specified by:
updateIdentityAfterCommitin interfaceOTransactionInternal- Parameters:
oldRid- the id old value.newRid- the id new value.
-
checkTransactionValid
protected void checkTransactionValid() -
serializeIndexChangeEntry
protected ODocument serializeIndexChangeEntry(OTransactionIndexChangesPerKey entry, ODocument indexDoc) -
setCustomData
Description copied from interface:OTransactionSets the custom value by its name stored in the context of this transaction.- Specified by:
setCustomDatain interfaceOTransaction- Parameters:
iName- the value name.iValue- the value to store.
-
getCustomData
Description copied from interface:OTransactionObtains the custom value by its name stored in the context of this transaction.- Specified by:
getCustomDatain interfaceOTransaction- Parameters:
iName- the value name.- Returns:
- the obtained value or
nullif no value found.
-
getUpdatedRids
-
getNewObjectCounter
public int getNewObjectCounter() -
setNoTxLocks
-
getNoTxLocks
-
getMetadata
- Specified by:
getMetadatain interfaceOStorageTransaction- Specified by:
getMetadatain interfaceOTransactionInternal
-
startedStorageTransaction
public void startedStorageTransaction()- Specified by:
startedStorageTransactionin interfaceOStorageTransaction- Specified by:
startedStorageTransactionin interfaceOTransactionInternal
-
setMetadataHolder
- Specified by:
setMetadataHolderin interfaceOTransactionInternal
-
prepareSerializedOperations
- Specified by:
prepareSerializedOperationsin interfaceOTransactionInternal- Throws:
IOException
-
getSerializedOperations
- Specified by:
getSerializedOperationsin interfaceOStorageTransaction- Specified by:
getSerializedOperationsin interfaceOTransactionInternal
-
resetAllocatedIds
public void resetAllocatedIds()- Specified by:
resetAllocatedIdsin interfaceOTransactionInternal
-
close
public void close()Description copied from class:OTransactionAbstractCloses the transaction and releases all the acquired locks.- Specified by:
closein interfaceOTransaction- Overrides:
closein classOTransactionAbstract
-
updateCache
public void updateCache(boolean keepInCache) - Specified by:
updateCachein interfaceOStorageTransaction
-
getChangesForIndex
- Specified by:
getChangesForIndexin interfaceOStorageTransaction
-
getRecordChanges
- Specified by:
getRecordChangesin interfaceOAllocationTransaction- Specified by:
getRecordChangesin interfaceOStorageTransaction
-