use of com.hazelcast.internal.crdt.CRDTReplicationContainer in project hazelcast by hazelcast.
the class PNCounterService method prepareMigrationOperation.
@Override
public CRDTReplicationContainer prepareMigrationOperation(int maxConfiguredReplicaCount) {
final HashMap<String, VectorClock> currentVectorClocks = new HashMap<>();
final HashMap<String, PNCounterImpl> counters = new HashMap<>();
final Config config = nodeEngine.getConfig();
for (Entry<String, PNCounterImpl> counterEntry : this.counters.entrySet()) {
final String counterName = counterEntry.getKey();
final PNCounterImpl counter = counterEntry.getValue();
if (config.findPNCounterConfig(counterName).getReplicaCount() >= maxConfiguredReplicaCount) {
continue;
}
counters.put(counterName, counter);
currentVectorClocks.put(counterName, counter.getCurrentVectorClock());
}
return counters.isEmpty() ? null : new CRDTReplicationContainer(new PNCounterReplicationOperation(counters), currentVectorClocks);
}
use of com.hazelcast.internal.crdt.CRDTReplicationContainer in project hazelcast by hazelcast.
the class PNCounterService method prepareReplicationOperation.
@Override
public CRDTReplicationContainer prepareReplicationOperation(Map<String, VectorClock> previouslyReplicatedVectorClocks, int targetIndex) {
final HashMap<String, VectorClock> currentVectorClocks = new HashMap<String, VectorClock>();
final HashMap<String, PNCounterImpl> counters = new HashMap<String, PNCounterImpl>();
final Config config = nodeEngine.getConfig();
for (Entry<String, PNCounterImpl> counterEntry : this.counters.entrySet()) {
final String counterName = counterEntry.getKey();
final PNCounterImpl counter = counterEntry.getValue();
if (targetIndex >= config.findPNCounterConfig(counterName).getReplicaCount()) {
continue;
}
final VectorClock counterCurrentVectorClock = counter.getCurrentVectorClock();
final VectorClock counterPreviousVectorClock = previouslyReplicatedVectorClocks.get(counterName);
if (counterPreviousVectorClock == null || counterCurrentVectorClock.isAfter(counterPreviousVectorClock)) {
counters.put(counterName, counter);
}
currentVectorClocks.put(counterName, counterCurrentVectorClock);
}
return counters.isEmpty() ? null : new CRDTReplicationContainer(new PNCounterReplicationOperation(counters), currentVectorClocks);
}
Aggregations