public class BulkDataPersisterContext extends Object
BulkDataPersisterContext
an operation context that is accessible on mirror in BulkDataPersister
.executeBulk(ListBulkDataPersisterContext
is not accessible on any other space except mirror and not in any other method except BulkDataPersister
.executeBulk(List
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)
....
}
}
Constructor and Description |
---|
BulkDataPersisterContext(TransactionParticipantDataImpl transactionData,
String sourceMemberSpaceName) |
Modifier and Type | Method and Description |
---|---|
ConsolidatedDistributedTransactionMetaData |
getConsolidatedDistributedTransactionMetaData() |
static BulkDataPersisterContext |
getCurrentContext() |
String |
getSourceSpaceMemberName()
Get the source space member name that sent this bulk.
|
TransactionParticipantData |
getTransactionData()
Deprecated.
since 9.0.1 - use
getTransactionParticipantMetaData() instead. |
TransactionParticipantMetaData |
getTransactionParticipantMetaData() |
boolean |
isConsolidatedDistributedTransaction() |
boolean |
isTransactional() |
static void |
resetContext()
Resets the current context
|
static void |
setContext(BulkDataPersisterContext context)
Set the context for the current thread
|
public BulkDataPersisterContext(TransactionParticipantDataImpl transactionData, String sourceMemberSpaceName)
transactionData
- public static BulkDataPersisterContext getCurrentContext()
public static void setContext(BulkDataPersisterContext context)
public static void resetContext()
@Deprecated public TransactionParticipantData getTransactionData()
getTransactionParticipantMetaData()
instead.public TransactionParticipantMetaData getTransactionParticipantMetaData()
isConsolidatedDistributedTransaction()
method.public ConsolidatedDistributedTransactionMetaData getConsolidatedDistributedTransactionMetaData()
isConsolidatedDistributedTransaction()
method.public String getSourceSpaceMemberName()
public boolean isTransactional()
public boolean isConsolidatedDistributedTransaction()
Copyright © GigaSpaces.