Search in sources :

Example 1 with TargetNotReplicaException

use of com.hazelcast.crdt.TargetNotReplicaException in project hazelcast by hazelcast.

the class AbstractPNCounterOperation method getPNCounter.

PNCounterImpl getPNCounter(VectorClock observedTimestamps) {
    if (counter != null) {
        return counter;
    }
    final PNCounterService service = getService();
    if (observedTimestamps != null && !observedTimestamps.isEmpty() && !service.containsCounter(name)) {
        throw new ConsistencyLostException("This replica cannot provide the session guarantees for " + "the PN counter since it's state is stale");
    }
    final int maxConfiguredReplicaCount = getNodeEngine().getConfig().findPNCounterConfig(name).getReplicaCount();
    if (!isCRDTReplica(maxConfiguredReplicaCount)) {
        throw new TargetNotReplicaException("This member is not a CRDT replica for the " + name + " + PN counter");
    }
    this.counter = service.getCounter(name);
    return counter;
}
Also used : TargetNotReplicaException(com.hazelcast.crdt.TargetNotReplicaException) PNCounterService(com.hazelcast.internal.crdt.pncounter.PNCounterService) ConsistencyLostException(com.hazelcast.core.ConsistencyLostException)

Aggregations

ConsistencyLostException (com.hazelcast.core.ConsistencyLostException)1 TargetNotReplicaException (com.hazelcast.crdt.TargetNotReplicaException)1 PNCounterService (com.hazelcast.internal.crdt.pncounter.PNCounterService)1