use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class AtomicLongBasicTest method testRecreate_afterGroupDestroy.
@Test
public void testRecreate_afterGroupDestroy() throws Exception {
atomicLong.destroy();
CPGroupId groupId = getGroupId(atomicLong);
RaftInvocationManager invocationManager = getRaftInvocationManager(instances[0]);
invocationManager.invoke(getRaftService(instances[0]).getMetadataGroupId(), new TriggerDestroyRaftGroupOp(groupId)).get();
assertTrueEventually(() -> {
CPGroup group = invocationManager.<CPGroup>query(getMetadataGroupId(instances[0]), new GetRaftGroupOp(groupId), LINEARIZABLE).join();
assertEquals(CPGroupStatus.DESTROYED, group.status());
});
try {
atomicLong.incrementAndGet();
fail();
} catch (CPGroupDestroyedException ignored) {
}
atomicLong = createAtomicLong(name);
CPGroupId newGroupId = getGroupId(atomicLong);
assertNotEquals(groupId, newGroupId);
atomicLong.incrementAndGet();
}
use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class CountDownLatchService method provideDynamicMetrics.
@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
MetricDescriptor root = descriptor.withPrefix("cp.countdownlatch");
for (CPGroupId groupId : getGroupIdSet()) {
CountDownLatchRegistry registry = getRegistryOrNull(groupId);
for (CountDownLatch latch : registry.getAllLatches()) {
MetricDescriptor desc = root.copy().withDiscriminator("id", latch.getName() + "@" + groupId.getName()).withTag(CP_TAG_NAME, latch.getName()).withTag("group", groupId.getName());
context.collect(desc.copy().withMetric("round"), latch.getRound());
context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("count"), latch.getCount());
context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("remaining"), latch.getRemainingCount());
}
}
}
use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class LockService method provideDynamicMetrics.
@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
MetricDescriptor root = descriptor.withPrefix("cp.lock");
for (CPGroupId groupId : getGroupIdSet()) {
LockRegistry registry = getRegistryOrNull(groupId);
for (Lock lock : registry.getAllLocks()) {
MetricDescriptor desc = root.copy().withDiscriminator("id", lock.getName() + "@" + groupId.getName()).withTag(CP_TAG_NAME, lock.getName()).withTag("group", groupId.getName());
context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("acquireLimit"), lock.lockCountLimit());
LockInvocationKey owner = lock.owner();
int lockCount = lock.lockCount();
// We may observe a partial update.
if (owner != null && lockCount > 0) {
context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("lockCount"), lockCount);
context.collect(desc.copy().withMetric("ownerSessionId"), owner.sessionId());
context.collect(desc.copy().withTag("owner", owner.callerAddress().toString()).withMetric("owner"), 0);
} else {
context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("lockCount"), 0);
}
}
}
}
use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class LockService method createProxy.
@Override
public FencedLock createProxy(String proxyName) {
proxyName = withoutDefaultGroupName(proxyName);
while (true) {
FencedLockProxy proxy = proxies.get(proxyName);
if (proxy != null) {
CPGroupId groupId = raftService.createRaftGroupForProxy(proxyName);
if (!proxy.getGroupId().equals(groupId)) {
proxies.remove(proxyName, proxy);
} else {
return proxy;
}
}
proxy = doCreateProxy(proxyName);
FencedLockProxy existing = proxies.putIfAbsent(proxyName, proxy);
if (existing == null) {
return proxy;
}
}
}
use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class GetAndAddMessageTask method processMessage.
@Override
protected void processMessage() {
CPGroupId groupId = parameters.groupId;
long delta = parameters.delta;
RaftOp op = new GetAndAddOp(parameters.name, delta);
if (delta == 0) {
query(groupId, op, LINEARIZABLE);
} else {
invoke(groupId, op);
}
}
Aggregations