use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class RaftSessionService method provideDynamicMetrics.
@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
MetricDescriptor root = descriptor.withPrefix("cp.session");
for (RaftSessionRegistry registry : registries.values()) {
CPGroupId groupId = registry.groupId();
for (CPSession session : registry.getSessions()) {
MetricDescriptor desc = root.copy().withDiscriminator("id", session.id() + "@" + groupId.getName()).withTag("sessionId", String.valueOf(session.id())).withTag("group", groupId.getName());
context.collect(desc.copy().withTag("endpoint", session.endpoint().toString()).withMetric("endpoint"), 0);
context.collect(desc.copy().withTag("endpointType", session.endpointType().toString()).withMetric("endpointType"), 0);
context.collect(desc.copy().withMetric("version"), session.version());
context.collect(desc.copy().withUnit(ProbeUnit.MS).withMetric("creationTime"), session.creationTime());
context.collect(desc.copy().withUnit(ProbeUnit.MS).withMetric("expirationTime"), session.expirationTime());
}
}
}
use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class RaftSessionService method getInactiveSessions.
private Map<CPGroupId, Collection<Long>> getInactiveSessions() {
Map<CPGroupId, Collection<Long>> response = new ConcurrentHashMap<>();
Semaphore semaphore = new Semaphore(0);
OperationServiceImpl operationService = nodeEngine.getOperationService();
Collection<RaftSessionRegistry> registries = new ArrayList<>(this.registries.values());
for (RaftSessionRegistry registry : registries) {
CPGroupId groupId = registry.groupId();
operationService.execute(new PartitionSpecificRunnableAdaptor(() -> {
Set<Long> activeSessionIds = new HashSet<>();
for (SessionAwareService service : nodeEngine.getServices(SessionAwareService.class)) {
activeSessionIds.addAll(service.getAttachedSessions(groupId));
}
Set<Long> inactiveSessionIds = new HashSet<>();
for (CPSession session : registry.getSessions()) {
if (!activeSessionIds.contains(session.id()) && session.creationTime() + getSessionTTLMillis() < Clock.currentTimeMillis()) {
inactiveSessionIds.add(session.id());
}
}
if (inactiveSessionIds.size() > 0) {
response.put(groupId, inactiveSessionIds);
}
semaphore.release();
}, nodeEngine.getPartitionService().getPartitionId(groupId)));
}
try {
semaphore.tryAcquire(registries.size(), COLLECT_INACTIVE_SESSIONS_TASK_TIMEOUT_SECONDS, SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return response;
}
use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class TerminateRaftNodesOp method readInternal.
@Override
protected void readInternal(ObjectDataInput in) throws IOException {
super.readInternal(in);
int count = in.readInt();
groupIds = new ArrayList<>();
for (int i = 0; i < count; i++) {
CPGroupId groupId = in.readObject();
groupIds.add(groupId);
}
}
use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class AbstractSessionMessageTask method processMessage.
@Override
protected final void processMessage() {
CPGroupId groupId = getGroupId();
RaftOp raftOp = getRaftOp();
invoke(groupId, raftOp);
}
use of com.hazelcast.cp.CPGroupId in project hazelcast by hazelcast.
the class CompleteRaftGroupMembershipChangesOp method readData.
@Override
public void readData(ObjectDataInput in) throws IOException {
int count = in.readInt();
changedGroups = new HashMap<>(count);
for (int i = 0; i < count; i++) {
CPGroupId groupId = in.readObject();
long currMembersCommitIndex = in.readLong();
long newMembersCommitIndex = in.readLong();
changedGroups.put(groupId, BiTuple.of(currMembersCommitIndex, newMembersCommitIndex));
}
}
Aggregations