Search in sources :

Example 1 with ReplicationOperation

use of com.hazelcast.ringbuffer.impl.operations.ReplicationOperation in project hazelcast by hazelcast.

the class RingbufferService method prepareReplicationOperation.

@Override
public Operation prepareReplicationOperation(PartitionReplicationEvent event) {
    Map<String, RingbufferContainer> migrationData = new HashMap<String, RingbufferContainer>();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    for (Map.Entry<String, RingbufferContainer> entry : containers.entrySet()) {
        String name = entry.getKey();
        int partitionId = partitionService.getPartitionId(getPartitionKey(name));
        RingbufferContainer container = entry.getValue();
        int backupCount = container.getConfig().getTotalBackupCount();
        if (partitionId == event.getPartitionId() && backupCount >= event.getReplicaIndex()) {
            migrationData.put(name, container);
        }
    }
    if (migrationData.isEmpty()) {
        return null;
    }
    return new ReplicationOperation(migrationData, event.getPartitionId(), event.getReplicaIndex());
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) IPartitionService(com.hazelcast.spi.partition.IPartitionService) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ReplicationOperation(com.hazelcast.ringbuffer.impl.operations.ReplicationOperation)

Aggregations

ReplicationOperation (com.hazelcast.ringbuffer.impl.operations.ReplicationOperation)1 IPartitionService (com.hazelcast.spi.partition.IPartitionService)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1