use of com.hazelcast.crdt.pncounter.PNCounter in project hazelcast by hazelcast.
the class AbstractPNCounterBasicIntegrationTest method testSimpleReplication.
@Test
public void testSimpleReplication() {
final PNCounter counter1 = getInstance1().getPNCounter("counter");
final PNCounter counter2 = getInstance2().getPNCounter("counter");
assertEquals(5, counter1.addAndGet(5));
assertCounterValueEventually(5, counter1);
assertCounterValueEventually(5, counter2);
}
use of com.hazelcast.crdt.pncounter.PNCounter in project hazelcast by hazelcast.
the class AbstractPNCounterBasicIntegrationTest method statistics.
@Test
public void statistics() {
final PNCounter counter1 = getInstance1().getPNCounter("counterWithStats");
final PNCounter counter2 = getInstance2().getPNCounter("counterWithStats");
final int parallelism = 5;
final int loopsPerThread = 100;
final AtomicLong finalValue = new AtomicLong();
final ArrayList<Future> futures = new ArrayList<Future>(parallelism);
for (int i = 0; i < parallelism; i++) {
futures.add(spawn(new Runnable() {
@Override
public void run() {
for (int j = 0; j < loopsPerThread; j++) {
counter1.addAndGet(5);
finalValue.addAndGet(5);
counter2.addAndGet(-2);
finalValue.addAndGet(-2);
}
}
}));
}
FutureUtil.waitForever(futures);
assertCounterValueEventually(finalValue.longValue(), counter1);
assertCounterValueEventually(finalValue.longValue(), counter2);
int increments = 0;
int decrements = 0;
for (HazelcastInstance member : getMembers()) {
final PNCounterService service = getNodeEngineImpl(member).getService(PNCounterService.SERVICE_NAME);
for (LocalPNCounterStats stats : service.getStats().values()) {
increments += stats.getTotalIncrementOperationCount();
decrements += stats.getTotalDecrementOperationCount();
}
}
assertEquals(parallelism * loopsPerThread, increments);
assertEquals(parallelism * loopsPerThread, decrements);
}
use of com.hazelcast.crdt.pncounter.PNCounter in project hazelcast by hazelcast.
the class AbstractPNCounterNoDataMemberTest method noDataMemberExceptionIsThrown.
@Test(expected = NoDataMemberInClusterException.class)
public void noDataMemberExceptionIsThrown() {
final PNCounter driver = getCounter();
mutate(driver);
}
use of com.hazelcast.crdt.pncounter.PNCounter in project hazelcast by hazelcast.
the class PNCounterSplitBrainTest method getCounter.
private PNCounter getCounter(HazelcastInstance instance) {
final PNCounter pnCounter = instance.getPNCounter(counterName);
((PNCounterProxy) pnCounter).setOperationTryCount(1);
pnCounter.reset();
return pnCounter;
}
use of com.hazelcast.crdt.pncounter.PNCounter in project hazelcast by hazelcast.
the class PNCounterStatisticsSplitBrainTest method getCounter.
private PNCounter getCounter(HazelcastInstance instance) {
final PNCounter pnCounter = instance.getPNCounter(counterName);
((PNCounterProxy) pnCounter).setOperationTryCount(1);
pnCounter.reset();
return pnCounter;
}
Aggregations