public class GridCacheTxProxyImpl<K,V> extends Object implements GridCacheTxProxy, Externalizable
| Constructor and Description |
|---|
GridCacheTxProxyImpl()
Empty constructor required for
Externalizable. |
GridCacheTxProxyImpl(GridCacheTx tx,
GridCacheAdapter<K,V> cache,
GridCacheGateway gate) |
| Modifier and Type | Method and Description |
|---|---|
<V> V |
addMeta(String name,
V val)
Adds a new metadata.
|
<V> V |
addMetaIfAbsent(String name,
Callable<V> c)
Adds given metadata value only if it was absent.
|
<V> V |
addMetaIfAbsent(String name,
V val)
Adds given metadata value only if it was absent.
|
<V> Map<String,V> |
allMeta()
Gets all metadata in this entry.
|
void |
close()
Ends the transaction.
|
void |
commit()
Commits this transaction by initiating
two-phase-commit process. |
GridFuture<GridCacheTx> |
commitAsync()
Asynchronously commits this transaction by initiating
two-phase-commit process. |
GridCacheTxConcurrency |
concurrency()
Cache transaction concurrency mode.
|
void |
copyMeta(GridMetadataAware from)
Copies all metadata from another instance.
|
void |
copyMeta(Map<String,?> data)
Copies all metadata from given map.
|
boolean |
hasMeta(String name)
Tests whether or not given metadata is set.
|
<V> boolean |
hasMeta(String name,
V val)
Tests whether or not metadata with given name and value is set.
|
boolean |
implicit()
Flag indicating whether transaction was started automatically by the
system or not.
|
boolean |
isInvalidate()
Get invalidation flag for this transaction.
|
GridCacheTxIsolation |
isolation()
Cache transaction isolation level.
|
boolean |
isRollbackOnly()
If transaction was marked as rollback-only.
|
<V> V |
meta(String name)
Gets metadata by name.
|
UUID |
nodeId()
ID of the node on which this transaction started.
|
<V> V |
putMetaIfAbsent(String name,
Callable<V> c)
Adds given metadata value only if it was absent.
|
<V> V |
putMetaIfAbsent(String name,
V val)
Adds given metadata value only if it was absent.
|
void |
readExternal(ObjectInput in) |
<V> V |
removeMeta(String name)
Removes metadata by name.
|
<V> boolean |
removeMeta(String name,
V val)
Removes metadata only if its current value is equal to
val passed in. |
<V> boolean |
replaceMeta(String name,
V curVal,
V newVal)
Replaces given metadata with new
newVal value only if its current value
is equal to curVal. |
void |
rollback()
Rolls back this transaction.
|
boolean |
setRollbackOnly()
Modify the transaction associated with the current thread such that the
only possible outcome of the transaction is to roll back the
transaction.
|
long |
startTime()
Start time of this transaction.
|
GridCacheTxState |
state()
Gets current transaction state value.
|
long |
threadId()
ID of the thread in which this transaction started.
|
long |
timeout()
Gets timeout value in milliseconds for this transaction.
|
long |
timeout(long timeout)
Sets transaction timeout value.
|
String |
toString() |
void |
writeExternal(ObjectOutput out) |
GridUuid |
xid()
Gets unique identifier for this transaction.
|
public GridCacheTxProxyImpl()
Externalizable.public GridCacheTxProxyImpl(GridCacheTx tx, GridCacheAdapter<K,V> cache, GridCacheGateway gate)
tx - Transaction.gate - Gateway.public GridUuid xid()
xid in interface GridCacheTxpublic UUID nodeId()
nodeId in interface GridCacheTxpublic long threadId()
threadId in interface GridCacheTxpublic long startTime()
startTime in interface GridCacheTxpublic GridCacheTxIsolation isolation()
isolation in interface GridCacheTxpublic GridCacheTxConcurrency concurrency()
concurrency in interface GridCacheTxpublic boolean isInvalidate()
true, then
remote values will be invalidated (set to null) instead
of updated.
Invalidation messages don't carry new values, so they are a lot lighter than update messages. However, when a value is accessed on a node after it's been invalidated, it must be loaded from persistent store.
isInvalidate in interface GridCacheTxpublic boolean implicit()
put(..) or remove(..) operation is invoked
outside of transaction.implicit in interface GridCacheTxTrue if transaction was started implicitly.public long timeout()
GridCacheTxTimeoutException will be thrown.timeout in interface GridCacheTxpublic GridCacheTxState state()
state in interface GridCacheTxpublic long timeout(long timeout)
timeout in interface GridCacheTxtimeout - Transaction timeout value.public boolean setRollbackOnly()
setRollbackOnly in interface GridCacheTxTrue if rollback-only flag was set as a result of this operation,
false if it was already set prior to this call or could not be set
because transaction is already finishing up committing or rolling back.public boolean isRollbackOnly()
isRollbackOnly in interface GridCacheTxTrue if transaction can only be rolled back.public void commit()
throws GridException
two-phase-commit process.commit in interface GridCacheTxGridException - If commit failed.public void close()
throws GridException
close in interface AutoCloseableclose in interface GridCacheTxGridException - If transaction could not be gracefully ended.public GridFuture<GridCacheTx> commitAsync()
two-phase-commit process.commitAsync in interface GridCacheTxpublic void rollback()
throws GridException
rollback in interface GridCacheTxGridException - If rollback failed.public void copyMeta(GridMetadataAware from)
copyMeta in interface GridMetadataAwarefrom - Metadata aware instance to copy metadata from.public void copyMeta(Map<String,?> data)
copyMeta in interface GridMetadataAwaredata - Map to copy metadata from.public <V> V addMeta(String name, V val)
addMeta in interface GridMetadataAwareV - Type of the value.name - Metadata name.val - Metadata value.null if there was none.public <V> V putMetaIfAbsent(String name, V val)
putMetaIfAbsent in interface GridMetadataAwareV - Type of the value.name - Metadata name.val - Value to add if it's not attached already.null if new value was put, or current value if put didn't happen.public <V> V putMetaIfAbsent(String name, Callable<V> c)
putMetaIfAbsent in interface GridMetadataAwareV - Type of the value.name - Metadata name.c - Factory closure to produce value to add if it's not attached already.
Not that unlike GridMetadataAware.addMeta(String, Object) method the factory closure will
not be called unless the value is required and therefore value will only be created
when it is actually needed.null if new value was put, or current value if put didn't happen.@Nullable public <V> V addMetaIfAbsent(String name, V val)
GridMetadataAware.putMetaIfAbsent(String, Callable), this method always returns
the latest value and never previous one.addMetaIfAbsent in interface GridMetadataAwareV - Type of the value.name - Metadata name.val - Value to add if it's not attached already.public <V> V addMetaIfAbsent(String name, @Nullable Callable<V> c)
addMetaIfAbsent in interface GridMetadataAwareV - Type of the value.name - Metadata name.c - Factory closure to produce value to add if it's not attached already.
Not that unlike GridMetadataAware.addMeta(String, Object) method the factory closure will
not be called unless the value is required and therefore value will only be created
when it is actually needed. If null and metadata value is missing - null
will be returned from this method.public <V> V meta(String name)
meta in interface GridMetadataAwareV - Type of the value.name - Metadata name.null.public <V> V removeMeta(String name)
removeMeta in interface GridMetadataAwareV - Type of the value.name - Name of the metadata to remove.null.public <V> boolean removeMeta(String name, V val)
val passed in.removeMeta in interface GridMetadataAwareV - Value type.name - Name of metadata attribute.val - Value to compare.True if value was removed, false otherwise.public <V> Map<String,V> allMeta()
allMeta in interface GridMetadataAwareV - Type of the value.public boolean hasMeta(String name)
hasMeta in interface GridMetadataAwarename - Name of the metadata to test.public <V> boolean hasMeta(String name, V val)
true if
attachment with given name it set and its value is equals to provided value. Otherwise returns
false.hasMeta in interface GridMetadataAwareV - Type of the value.name - Name of the metadata.val - Value to compare. Cannot be null.true if metadata with given name is set and its value is equals to provided value -
otherwise returns false.public <V> boolean replaceMeta(String name, V curVal, V newVal)
newVal value only if its current value
is equal to curVal. Otherwise, it is no-op.replaceMeta in interface GridMetadataAwarename - Name of the metadata.curVal - Current value to check.newVal - New value.true if replacement occurred, false otherwise.public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionCopyright © 2014. All rights reserved.