GigaSpaces XAP 9.7.2 API

com.j_spaces.sadapter.datasource
Class BulkDataPersisterContext

java.lang.Object
  extended by com.j_spaces.sadapter.datasource.BulkDataPersisterContext

public class BulkDataPersisterContext
extends Object

BulkDataPersisterContext an operation context that is accessible on mirror in BulkDataPersister.executeBulk(List) method.
BulkDataPersisterContext is not accessible on any other space except mirror and not in any other method except BulkDataPersister.executeBulk(List)

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

Constructor Summary
BulkDataPersisterContext(TransactionParticipantDataImpl transactionData, String sourceMemberSpaceName)
           
 
Method Summary
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BulkDataPersisterContext

public BulkDataPersisterContext(TransactionParticipantDataImpl transactionData,
                                String sourceMemberSpaceName)
Parameters:
transactionData -
Method Detail

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.

GigaSpaces XAP 9.7.2 API

Copyright © GigaSpaces.