Search in sources :

Example 51 with CPGroupId

use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.

the class ApplyMessageTask method processMessage.

@Override
protected void processMessage() {
    ReturnValueType returnValueType = ReturnValueType.fromValue(parameters.returnValueType);
    CPGroupId groupId = parameters.groupId;
    RaftOp op = new ApplyOp(parameters.name, parameters.function, returnValueType, parameters.alter);
    if (parameters.alter) {
        invoke(groupId, op);
    } else {
        query(groupId, op, LINEARIZABLE);
    }
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) ReturnValueType(com.hazelcast.cp.internal.datastructures.atomicref.operation.ApplyOp.ReturnValueType) RaftOp(com.hazelcast.cp.internal.RaftOp) ApplyOp(com.hazelcast.cp.internal.datastructures.atomicref.operation.ApplyOp)

Example 52 with CPGroupId

use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.

the class SemaphoreService method provideDynamicMetrics.

@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
    MetricDescriptor root = descriptor.withPrefix("cp.semaphore");
    for (CPGroupId groupId : getGroupIdSet()) {
        SemaphoreRegistry registry = getRegistryOrNull(groupId);
        for (Semaphore sema : registry.getAllSemaphores()) {
            MetricDescriptor desc = root.copy().withDiscriminator("id", sema.getName() + "@" + groupId.getName()).withTag(CP_TAG_NAME, sema.getName()).withTag("group", groupId.getName());
            context.collect(desc.copy().withMetric("initialized"), sema.isInitialized() ? 1 : 0);
            context.collect(desc.copy().withUnit(ProbeUnit.COUNT).withMetric("available"), sema.getAvailable());
        }
    }
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) ISemaphore(com.hazelcast.cp.ISemaphore)

Example 53 with CPGroupId

use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.

the class RaftNodeImpl method printMemberState.

public void printMemberState() {
    CPGroupId groupId = state.groupId();
    StringBuilder sb = new StringBuilder("\n\nCP Group Members {").append("groupId: ").append(groupId.getName()).append("(").append(groupId.getId()).append(")").append(", size:").append(state.memberCount()).append(", term:").append(state.term()).append(", logIndex:").append(state.membersLogIndex()).append("} [");
    for (RaftEndpoint member : state.members()) {
        CPMember cpMember = raftIntegration.getCPMember(member);
        sb.append("\n\t").append(cpMember != null ? cpMember : member);
        if (state.localEndpoint().equals(member)) {
            sb.append(" - ").append(state.role()).append(" this");
        } else if (member.equals(state.leader())) {
            sb.append(" - ").append(LEADER);
        }
    }
    sb.append("\n]\n");
    logger.info(sb.toString());
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) CPMember(com.hazelcast.cp.CPMember)

Example 54 with CPGroupId

use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.

the class UnsafeSnapshotReplicationOp method run.

@Override
public void run() throws Exception {
    SnapshotAwareService service = getService();
    for (Entry<CPGroupId, Object> entry : snapshots.entrySet()) {
        CPGroupId groupId = entry.getKey();
        service.restoreSnapshot(groupId, 0, entry.getValue());
    }
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) SnapshotAwareService(com.hazelcast.cp.internal.raft.SnapshotAwareService)

Example 55 with CPGroupId

use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.

the class TerminateRaftNodesOp method writeInternal.

@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
    super.writeInternal(out);
    out.writeInt(groupIds.size());
    for (CPGroupId groupId : groupIds) {
        out.writeObject(groupId);
    }
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId)

Aggregations

CPGroupId (com.hazelcast.cp.CPGroupId)81 Test (org.junit.Test)50 HazelcastInstance (com.hazelcast.core.HazelcastInstance)42 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)37 QuickTest (com.hazelcast.test.annotation.QuickTest)31 CPGroup (com.hazelcast.cp.CPGroup)14 CPMember (com.hazelcast.cp.CPMember)13 RaftEndpoint (com.hazelcast.cp.internal.raft.impl.RaftEndpoint)11 RaftNodeImpl (com.hazelcast.cp.internal.raft.impl.RaftNodeImpl)9 ArrayList (java.util.ArrayList)8 MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)7 CountDownLatch (java.util.concurrent.CountDownLatch)7 ExecutionException (java.util.concurrent.ExecutionException)7 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)6 SlowTest (com.hazelcast.test.annotation.SlowTest)6 IndeterminateOperationStateException (com.hazelcast.core.IndeterminateOperationStateException)5 MemberLeftException (com.hazelcast.core.MemberLeftException)5 StaleAppendRequestException (com.hazelcast.cp.exception.StaleAppendRequestException)5 DefaultRaftReplicateOp (com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp)5 CallerNotMemberException (com.hazelcast.spi.exception.CallerNotMemberException)5