Search in sources :

Example 1 with ReplicationOperation

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

the class CardinalityEstimatorService method prepareReplicationOperation.

@Override
public Operation prepareReplicationOperation(PartitionReplicationEvent event) {
    final IPartitionService partitionService = nodeEngine.getPartitionService();
    final int roughSize = (int) ((containers.size() * SIZING_FUDGE_FACTOR) / partitionService.getPartitionCount());
    Map<String, CardinalityEstimatorContainer> data = createHashMap(roughSize);
    int partitionId = event.getPartitionId();
    for (Map.Entry<String, CardinalityEstimatorContainer> containerEntry : containers.entrySet()) {
        String name = containerEntry.getKey();
        CardinalityEstimatorContainer container = containerEntry.getValue();
        if (partitionId == getPartitionId(name) && event.getReplicaIndex() <= container.getTotalBackupCount()) {
            data.put(name, containerEntry.getValue());
        }
    }
    return data.isEmpty() ? null : new ReplicationOperation(data);
}
Also used : IPartitionService(com.hazelcast.internal.partition.IPartitionService) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) MigrationEndpoint(com.hazelcast.internal.partition.MigrationEndpoint) ReplicationOperation(com.hazelcast.cardinality.impl.operations.ReplicationOperation)

Aggregations

ReplicationOperation (com.hazelcast.cardinality.impl.operations.ReplicationOperation)1 IPartitionService (com.hazelcast.internal.partition.IPartitionService)1 MigrationEndpoint (com.hazelcast.internal.partition.MigrationEndpoint)1 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1