)
Example of mirror implementation:
public void executeBulk(List bulk) throws DataSourceException {
BulkDataPersisterContext context = BulkDataPersisterContext.getCurrentContext();
if (context.isConsolidatedDistributedTransaction()) {
// Built-in consolidation using multi-source replication mode
ConsolidatedDistributedTransactionMetaData metadata = getConsolidatedDistributedTransactionMetaData();
TransactionUniqueId transactionId = metadata.getTransactionUniqueId();
int participantsCount = metadata.getParticipantsCount();
} else if (context.isTransactional()) {
// Single participant transaction or distributed transaction failed to be consolidated
TransactionParticipantMetaData metadata getTransactionParticipantMetaData();
TransactionUniqueId transactionId = metadata.getTransactionUniqueId();
int participantsCount = metadata.getParticipantsCount();
int participantId = metadata.getParticipantId();
// Identify failed to consolidate transaction
if (participantsCount > 1) {
...
} else {
// Single participant transaction...
}
} else {
// Regular execution (no transaction)
....
}
}
- Since:
- 7.1
- Author:
- anna
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BulkDataPersisterContext
public BulkDataPersisterContext(TransactionParticipantDataImpl transactionData,
String sourceMemberSpaceName)
- Parameters:
transactionData
-
getCurrentContext
public static BulkDataPersisterContext getCurrentContext()
- Returns:
- the context of the current thread
setContext
public static void setContext(BulkDataPersisterContext context)
- Set the context for the current thread
resetContext
public static void resetContext()
- Resets the current context
getTransactionData
@Deprecated
public TransactionParticipantData getTransactionData()
- Deprecated. since 9.0.1 - use
getTransactionParticipantMetaData()
instead.
- Gets transaction participant data if exists.
getTransactionParticipantMetaData
public TransactionParticipantMetaData getTransactionParticipantMetaData()
- Returns:
- The transaction participant meta data. Before calling this method one should check if the
context does not contain a consolidated distributed transaction using the
isConsolidatedDistributedTransaction()
method.
getConsolidatedDistributedTransactionMetaData
public ConsolidatedDistributedTransactionMetaData getConsolidatedDistributedTransactionMetaData()
- Returns:
- The consolidated transaction meta data. Before calling this method one should check if the
context contains a consolidated distributed transaction using the
isConsolidatedDistributedTransaction()
method.
getSourceSpaceMemberName
public String getSourceSpaceMemberName()
- Get the source space member name that sent this bulk.
isTransactional
public boolean isTransactional()
- Returns:
- Whether the current context is transactional.
isConsolidatedDistributedTransaction
public boolean isConsolidatedDistributedTransaction()
- Returns:
- Whether the current context is transactional and contains a consolidated distributed transaction.
Copyright © GigaSpaces.