use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class HttpGetCommandProcessor method handleHealthcheck.
private void handleHealthcheck(HttpGetCommand command, String uri) {
Node node = textCommandService.getNode();
NodeState nodeState = node.getState();
ClusterServiceImpl clusterService = node.getClusterService();
ClusterState clusterState = clusterService.getClusterState();
int clusterSize = clusterService.getMembers().size();
InternalPartitionService partitionService = node.getPartitionService();
long migrationQueueSize = partitionService.getMigrationQueueSize();
String healthParameter = uri.substring(URI_HEALTH_URL.length());
if (healthParameter.equals(HEALTH_PATH_PARAM_NODE_STATE)) {
if (NodeState.SHUT_DOWN.equals(nodeState)) {
command.send503();
} else {
prepareResponse(command, Json.value(nodeState.toString()));
}
} else if (healthParameter.equals(HEALTH_PATH_PARAM_CLUSTER_STATE)) {
prepareResponse(command, Json.value(clusterState.toString()));
} else if (healthParameter.equals(HEALTH_PATH_PARAM_CLUSTER_SAFE)) {
if (isClusterSafe()) {
command.send200();
} else {
command.send503();
}
} else if (healthParameter.equals(HEALTH_PATH_PARAM_MIGRATION_QUEUE_SIZE)) {
prepareResponse(command, Json.value(migrationQueueSize));
} else if (healthParameter.equals(HEALTH_PATH_PARAM_CLUSTER_SIZE)) {
prepareResponse(command, Json.value(clusterSize));
} else if (healthParameter.isEmpty()) {
JsonObject response = new JsonObject().add("nodeState", nodeState.toString()).add("clusterState", clusterState.toString()).add("clusterSafe", isClusterSafe()).add("migrationQueueSize", migrationQueueSize).add("clusterSize", clusterSize);
prepareResponse(command, response);
} else {
command.send400();
}
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class InvocationFuture_GetNewInstanceTest method invocationToLocalMember.
@Test
public void invocationToLocalMember() throws ExecutionException, InterruptedException {
Node localNode = getNode(local);
Data response = localNode.nodeEngine.toData(new DummyObject());
Operation op = new OperationWithResponse(response);
OperationService service = getOperationService(local);
Future future = service.createInvocationBuilder(null, op, localNode.address).invoke();
Object instance1 = future.get();
Object instance2 = future.get();
assertNotNull(instance1);
assertNotNull(instance2);
assertTrue(instance1 instanceof DummyObject);
assertTrue(instance2 instanceof DummyObject);
assertNotSame(instance1, instance2);
assertNotSame(instance1, response);
assertNotSame(instance2, response);
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class InvocationFuture_GetNewInstanceTest method invocationToRemoteMember.
@Test
public void invocationToRemoteMember() throws ExecutionException, InterruptedException {
Node localNode = getNode(local);
Data response = localNode.nodeEngine.toData(new DummyObject());
Operation op = new OperationWithResponse(response);
Address remoteAddress = getAddress(remote);
OperationService operationService = getOperationService(local);
Future future = operationService.createInvocationBuilder(null, op, remoteAddress).invoke();
Object instance1 = future.get();
Object instance2 = future.get();
assertNotNull(instance1);
assertNotNull(instance2);
assertTrue(instance1 instanceof DummyObject);
assertTrue(instance2 instanceof DummyObject);
assertNotSame(instance1, instance2);
assertNotSame(instance1, response);
assertNotSame(instance2, response);
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class QueryCacheIMapEventHandlingTest method executeMergeOperation.
private void executeMergeOperation(HazelcastInstance member, String mapName, int key, int mergedValue) throws Exception {
Node node = getNode(member);
NodeEngineImpl nodeEngine = node.nodeEngine;
OperationServiceImpl operationService = nodeEngine.getOperationService();
SerializationService serializationService = getSerializationService(member);
Data keyData = serializationService.toData(key);
Data valueData = serializationService.toData(mergedValue);
SplitBrainMergeTypes.MapMergeTypes mergingEntry = createMergingEntry(serializationService, keyData, valueData, Mockito.mock(Record.class), ExpiryMetadata.NULL);
Operation mergeOperation = new MergeOperation(mapName, singletonList(mergingEntry), new PassThroughMergePolicy<>(), false);
int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
Future<Object> future = operationService.invokeOnPartition(SERVICE_NAME, mergeOperation, partitionId);
future.get();
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class QueryCacheRecoveryUponEventLossTest method getBrokenSequences.
private Map getBrokenSequences(HazelcastInstance instance, String mapName, QueryCache queryCache) {
Node node = getNode(instance);
MapService service = node.getNodeEngine().getService(MapService.SERVICE_NAME);
MapServiceContext mapServiceContext = service.getMapServiceContext();
QueryCacheContext context = mapServiceContext.getQueryCacheContext();
SubscriberContext subscriberContext = context.getSubscriberContext();
MapSubscriberRegistry mapSubscriberRegistry = subscriberContext.getMapSubscriberRegistry();
SubscriberRegistry subscriberRegistry = mapSubscriberRegistry.getOrNull(mapName);
if (subscriberRegistry == null) {
return Collections.emptyMap();
}
String cacheId = ((InternalQueryCache) queryCache).getCacheId();
Accumulator accumulator = subscriberRegistry.getOrNull(cacheId);
if (accumulator == null) {
return Collections.emptyMap();
}
SubscriberAccumulator subscriberAccumulator = (SubscriberAccumulator) accumulator;
return subscriberAccumulator.getBrokenSequences();
}
Aggregations