Search in sources :

Example 1 with XaReplicationOperation

use of com.hazelcast.transaction.impl.xa.operations.XaReplicationOperation in project hazelcast by hazelcast.

the class XAService method prepareReplicationOperation.

//Migration related methods
@Override
public Operation prepareReplicationOperation(PartitionReplicationEvent event) {
    if (event.getReplicaIndex() > 1) {
        return null;
    }
    List<XATransactionDTO> migrationData = new ArrayList<XATransactionDTO>();
    InternalPartitionService partitionService = nodeEngine.getPartitionService();
    for (Map.Entry<SerializableXID, List<XATransaction>> entry : transactions.entrySet()) {
        SerializableXID xid = entry.getKey();
        int partitionId = partitionService.getPartitionId(xid);
        List<XATransaction> xaTransactionList = entry.getValue();
        for (XATransaction xaTransaction : xaTransactionList) {
            if (partitionId == event.getPartitionId()) {
                migrationData.add(new XATransactionDTO(xaTransaction));
            }
        }
    }
    if (migrationData.isEmpty()) {
        return null;
    } else {
        return new XaReplicationOperation(migrationData, event.getPartitionId(), event.getReplicaIndex());
    }
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) XaReplicationOperation(com.hazelcast.transaction.impl.xa.operations.XaReplicationOperation) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) MigrationEndpoint(com.hazelcast.spi.partition.MigrationEndpoint)

Aggregations

InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)1 MigrationEndpoint (com.hazelcast.spi.partition.MigrationEndpoint)1 XaReplicationOperation (com.hazelcast.transaction.impl.xa.operations.XaReplicationOperation)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1