public final class OMicroTransaction extends Object implements OBasicTransaction, OTransactionInternal
DELETED_RECORD
Constructor and Description |
---|
OMicroTransaction(OAbstractPaginatedStorage storage,
ODatabaseDocumentInternal database)
Instantiates a new micro-transaction.
|
Modifier and Type | Method and Description |
---|---|
void |
addChangedDocument(ODocument document)
Adds the given document to a set of changed documents known to this transaction.
|
void |
addIndexEntry(OIndex index,
String indexName,
OTransactionIndexChanges.OPERATION type,
Object key,
OIdentifiable value)
Adds the transactional index entry in this transaction.
|
void |
begin()
Begins the micro-transaction.
|
void |
commit()
Commits the micro-transaction if it's a top-level micro-transaction.
|
void |
deleteRecord(ORecord record,
ODatabase.OPERATION_MODE mode)
Deletes the given record in this transaction.
|
int |
getClientTransactionId() |
Object |
getCustomData(String name)
Obtains the custom value by its name stored in the context of this transaction.
|
ODatabaseDocumentInternal |
getDatabase()
Access to the database of the transaction
|
int |
getId() |
OTransactionIndexChanges |
getIndexChanges(String indexName)
Obtains the index changes done in the context of this transaction.
|
OTransactionIndexChanges |
getIndexChangesInternal(String indexName)
Does the same thing as
OBasicTransaction.getIndexChanges(String) , but handles remote storages in a
special way. |
Map<String,OTransactionIndexChanges> |
getIndexOperations()
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.
|
Set<ORID> |
getLockedRecords() |
Optional<byte[]> |
getMetadata() |
ORecord |
getRecord(ORID rid)
Resolves a record with the given RID in the context of this transaction.
|
ORecordOperation |
getRecordEntry(ORID currentRid)
Extract a single change from a specified record id.
|
Collection<ORecordOperation> |
getRecordOperations()
Extract all the record operations for the current transaction
|
Iterator<byte[]> |
getSerializedOperations() |
ORecordOperation |
internalAddRecord(ORecord record,
byte type,
String clusterName) |
boolean |
isActive() |
boolean |
isUsingLog()
Retrieve if log is enabled for the transaction
|
void |
prepareSerializedOperations() |
void |
rollback()
Rollbacks the micro-transaction if it's a top-level micro-transaction.
|
void |
rollbackAfterFailedCommit()
Rollbacks the micro-transaction after failed commit attempt.
|
ORecord |
saveRecord(ORecord record,
String clusterName,
ODatabase.OPERATION_MODE operationMode,
boolean forceCreation,
ORecordCallback<? extends Number> createdCallback,
ORecordCallback<Integer> updatedCallback)
Saves the given record in this transaction.
|
void |
setCustomData(String name,
Object value)
Sets the custom value by its name stored in the context of this transaction.
|
void |
setDatabase(ODatabaseDocumentInternal database) |
void |
setMetadataHolder(Optional<OTxMetadataHolder> metadata) |
void |
setNoTxLocks(Map<ORID,OTransactionAbstract.LockedRecordMetadata> noTxLocks) |
void |
setStatus(OTransaction.TXSTATUS iStatus)
Change the status of the transaction.
|
void |
storageBegun() |
void |
updateIdentityAfterCommit(ORID oldRID,
ORID rid)
Notify the transaction for the rid change, the changed will be tracked inside the transaction
and used for remapping links.
|
void |
updateIdentityAfterRecordCommit(ORID oldRid,
ORID newRid)
Updates the record identity after its successful commit.
|
void |
updateRecordCacheAfterRollback()
Updates the record cache after unsuccessful micro-transaction commit.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
fill, isSequenceTransaction
public OMicroTransaction(OAbstractPaginatedStorage storage, ODatabaseDocumentInternal database)
storage
- the micro-transaction's storage.database
- the micro-transaction's database.public int getId()
getId
in interface OBasicTransaction
public int getClientTransactionId()
getClientTransactionId
in interface OBasicTransaction
public void updateIdentityAfterCommit(ORID oldRID, ORID rid)
OTransactionInternal
updateIdentityAfterCommit
in interface OTransactionInternal
oldRID
- the id old value.rid
- the id new value.public ODatabaseDocumentInternal getDatabase()
OTransactionInternal
getDatabase
in interface OTransactionInternal
public Collection<ORecordOperation> getRecordOperations()
OTransactionInternal
getRecordOperations
in interface OTransactionInternal
public Map<String,OTransactionIndexChanges> getIndexOperations()
OTransactionInternal
getIndexOperations
in interface OTransactionInternal
public void begin()
public void commit()
public void rollback()
public void rollbackAfterFailedCommit()
public void updateIdentityAfterRecordCommit(ORID oldRid, ORID newRid)
public void updateRecordCacheAfterRollback()
public boolean isActive()
isActive
in interface OBasicTransaction
true
if this transaction is active, false
otherwise.public ORecord saveRecord(ORecord record, String clusterName, ODatabase.OPERATION_MODE operationMode, boolean forceCreation, ORecordCallback<? extends Number> createdCallback, ORecordCallback<Integer> updatedCallback)
OBasicTransaction
saveRecord
in interface OBasicTransaction
record
- the record to save.clusterName
- record's cluster name.operationMode
- the operation mode.forceCreation
- the force creation flag, true
to force the creation of the record,
false
to allow updates.createdCallback
- the callback to invoke when the record save operation triggered the
creation of the record.updatedCallback
- the callback to invoke when the record save operation triggered the
update of the record.public void deleteRecord(ORecord record, ODatabase.OPERATION_MODE mode)
OBasicTransaction
deleteRecord
in interface OBasicTransaction
record
- the record to delete.mode
- the operation mode.public ORecord getRecord(ORID rid)
OBasicTransaction
getRecord
in interface OBasicTransaction
rid
- the record RID.null
if no record is found, or OBasicTransaction.DELETED_RECORD
if the record was deleted in this transaction.public OTransactionIndexChanges getIndexChanges(String indexName)
OBasicTransaction
getIndexChanges
in interface OBasicTransaction
indexName
- the index name.null
if index is not found.public OTransactionIndexChanges getIndexChangesInternal(String indexName)
OBasicTransaction
OBasicTransaction.getIndexChanges(String)
, but handles remote storages in a
special way.getIndexChangesInternal
in interface OBasicTransaction
indexName
- the index name.null
if index is not found or storage is
remote.public Object getCustomData(String name)
OBasicTransaction
getCustomData
in interface OBasicTransaction
name
- the value name.null
if no value found.public void setCustomData(String name, Object value)
OBasicTransaction
setCustomData
in interface OBasicTransaction
name
- the value name.value
- the value to store.public ORecordOperation internalAddRecord(ORecord record, byte type, String clusterName)
public void addIndexEntry(OIndex index, String indexName, OTransactionIndexChanges.OPERATION type, Object key, OIdentifiable value)
OBasicTransaction
addIndexEntry
in interface OBasicTransaction
index
- the index.indexName
- the index name.type
- the index operation to register.key
- the index key.value
- the index key value.public void addChangedDocument(ODocument document)
OBasicTransaction
addChangedDocument
in interface OBasicTransaction
document
- the document to add.public void setStatus(OTransaction.TXSTATUS iStatus)
OTransactionInternal
setStatus
in interface OTransactionInternal
public boolean isUsingLog()
OTransactionInternal
isUsingLog
in interface OTransactionInternal
public ORecordOperation getRecordEntry(ORID currentRid)
OTransactionInternal
getRecordEntry
in interface OTransactionInternal
currentRid
- the record id for the change.public void setNoTxLocks(Map<ORID,OTransactionAbstract.LockedRecordMetadata> noTxLocks)
public Set<ORID> getLockedRecords()
getLockedRecords
in interface OTransactionInternal
public void setDatabase(ODatabaseDocumentInternal database)
setDatabase
in interface OTransactionInternal
public Optional<byte[]> getMetadata()
getMetadata
in interface OTransactionInternal
public void storageBegun()
storageBegun
in interface OTransactionInternal
public void setMetadataHolder(Optional<OTxMetadataHolder> metadata)
setMetadataHolder
in interface OTransactionInternal
public void prepareSerializedOperations() throws IOException
prepareSerializedOperations
in interface OTransactionInternal
IOException
public Iterator<byte[]> getSerializedOperations()
getSerializedOperations
in interface OTransactionInternal
Copyright © 2009–2020 OrientDB. All rights reserved.