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);
}
Aggregations