Search in sources :

Example 6 with PNCounter

use of com.hazelcast.crdt.pncounter.PNCounter in project hazelcast by hazelcast.

the class AbstractPNCounterConsistencyLostTest method consistencyLostExceptionIsThrownWhenTargetReplicaDisappears.

@Test(expected = ConsistencyLostException.class)
public void consistencyLostExceptionIsThrownWhenTargetReplicaDisappears() {
    final PNCounter driver = getCounter();
    mutate(driver);
    assertState(driver);
    final Address currentTarget = getCurrentTargetReplicaAddress(driver);
    terminateMember(currentTarget);
    mutate(driver);
}
Also used : PNCounter(com.hazelcast.crdt.pncounter.PNCounter) Address(com.hazelcast.cluster.Address) Test(org.junit.Test)

Example 7 with PNCounter

use of com.hazelcast.crdt.pncounter.PNCounter in project hazelcast by hazelcast.

the class ClientPNCounterTest method testClusterRestart.

@Test(expected = ConsistencyLostException.class)
public void testClusterRestart() {
    HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
    HazelcastInstance client = hazelcastFactory.newHazelcastClient();
    PNCounter pnCounter = client.getPNCounter("test");
    pnCounter.incrementAndGet();
    instance.shutdown();
    hazelcastFactory.newHazelcastInstance();
    pnCounter.incrementAndGet();
}
Also used : PNCounter(com.hazelcast.crdt.pncounter.PNCounter) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with PNCounter

use of com.hazelcast.crdt.pncounter.PNCounter in project hazelcast by hazelcast.

the class DistributedDatastructuresMetricsTest method testPnCounter.

@Test
public void testPnCounter() {
    final PNCounter counter = hz.getPNCounter(PN_COUNTER_NAME);
    final PNCounter counterNoStat = hz.getPNCounter(PN_COUNTER_NAME_NO_STAT);
    for (int i = 0; i < EVENT_COUNTER; i++) {
        counter.addAndGet(i);
        counterNoStat.addAndGet(i);
    }
    assertHasStatsEventually(PN_COUNTER_NAME, "pnCounter.");
    assertHasNoStats(PN_COUNTER_NAME_NO_STAT, "pnCounter.");
}
Also used : PNCounter(com.hazelcast.crdt.pncounter.PNCounter) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with PNCounter

use of com.hazelcast.crdt.pncounter.PNCounter in project hazelcast by hazelcast.

the class AbstractPNCounterConsistencyLostTest method driverCanContinueSessionByCallingReset.

@Test
public void driverCanContinueSessionByCallingReset() {
    final PNCounter driver = getCounter();
    mutate(driver);
    assertState(driver);
    final Address currentTarget = getCurrentTargetReplicaAddress(driver);
    terminateMember(currentTarget);
    driver.reset();
    mutate(driver);
}
Also used : PNCounter(com.hazelcast.crdt.pncounter.PNCounter) Address(com.hazelcast.cluster.Address) Test(org.junit.Test)

Example 10 with PNCounter

use of com.hazelcast.crdt.pncounter.PNCounter in project hazelcast by hazelcast.

the class PNCounterConsistencyLostTest method getCounter.

@Override
protected PNCounter getCounter() {
    final PNCounter counter = liteMember.getPNCounter("counter");
    ((PNCounterProxy) counter).setOperationTryCount(1);
    return counter;
}
Also used : PNCounter(com.hazelcast.crdt.pncounter.PNCounter)

Aggregations

PNCounter (com.hazelcast.crdt.pncounter.PNCounter)11 Test (org.junit.Test)7 Address (com.hazelcast.cluster.Address)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 LocalPNCounterStats (com.hazelcast.internal.monitor.LocalPNCounterStats)1 ArrayList (java.util.ArrayList)1 Future (java.util.concurrent.Future)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1