use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class HttpPostCommandProcessor method handlePartialStart.
private void handlePartialStart(HttpPostCommand command) throws UnsupportedEncodingException {
String res;
try {
Node node = textCommandService.getNode();
if (!checkCredentials(command)) {
res = response(ResponseType.FORBIDDEN);
} else {
boolean success = node.getNodeExtension().getInternalHotRestartService().triggerPartialStart();
res = response(success ? ResponseType.SUCCESS : ResponseType.FAIL);
}
} catch (Throwable throwable) {
logger.warning("Error occurred while handling partial start", throwable);
res = exceptionResponse(throwable);
}
sendResponse(command, res);
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class HttpPostCommandProcessor method handleClusterShutdown.
private void handleClusterShutdown(HttpPostCommand command) throws UnsupportedEncodingException {
String res;
try {
Node node = textCommandService.getNode();
ClusterService clusterService = node.getClusterService();
if (!checkCredentials(command)) {
res = response(ResponseType.FORBIDDEN);
} else {
res = response(ResponseType.SUCCESS);
sendResponse(command, res);
clusterService.shutdown();
return;
}
} catch (Throwable throwable) {
logger.warning("Error occurred while shutting down cluster", throwable);
res = exceptionResponse(throwable);
}
sendResponse(command, res);
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class HttpPostCommandProcessor method handleShutdownNode.
private void handleShutdownNode(HttpPostCommand command) throws UnsupportedEncodingException {
String res;
try {
Node node = textCommandService.getNode();
if (!checkCredentials(command)) {
res = response(ResponseType.FORBIDDEN);
} else {
res = response(ResponseType.SUCCESS);
sendResponse(command, res);
node.hazelcastInstance.shutdown();
return;
}
} catch (Throwable throwable) {
logger.warning("Error occurred while shutting down", throwable);
res = exceptionResponse(throwable);
}
sendResponse(command, res);
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class InternalCacheRecordStoreTest method batchEventMapShouldBeCleanedAfterRemoveAll.
/**
* Test for issue: https://github.com/hazelcast/hazelcast/issues/6618
*/
@Test
public void batchEventMapShouldBeCleanedAfterRemoveAll() {
String cacheName = randomString();
CacheConfig<Integer, String> config = createCacheConfig();
CacheFromDifferentNodesTest.SimpleEntryListener<Integer, String> listener = new CacheFromDifferentNodesTest.SimpleEntryListener<Integer, String>();
MutableCacheEntryListenerConfiguration<Integer, String> listenerConfiguration = new MutableCacheEntryListenerConfiguration<Integer, String>(FactoryBuilder.factoryOf(listener), null, true, true);
config.addCacheEntryListenerConfiguration(listenerConfiguration);
Cache<Integer, String> cache = cacheManager.createCache(cacheName, config);
assertNotNull(cache);
Integer key = 1;
String value = "value";
cache.put(key, value);
HazelcastInstance instance = ((HazelcastCacheManager) cacheManager).getHazelcastInstance();
int partitionId = instance.getPartitionService().getPartition(key).getPartitionId();
cache.removeAll();
Node node = getNode(instance);
assertNotNull(node);
ICacheService cacheService = node.getNodeEngine().getService(ICacheService.SERVICE_NAME);
AbstractCacheRecordStore recordStore = (AbstractCacheRecordStore) cacheService.getRecordStore("/hz/" + cacheName, partitionId);
assertEquals(0, recordStore.batchEvent.size());
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class InternalCacheRecordStoreTest method ownerStateShouldBeUpdatedAfterMigration.
/**
* Test for issue: https://github.com/hazelcast/hazelcast/issues/6983
*/
@Test
public void ownerStateShouldBeUpdatedAfterMigration() throws Exception {
HazelcastCacheManager hzCacheManager = (HazelcastCacheManager) cacheManager;
HazelcastInstance instance1 = hzCacheManager.getHazelcastInstance();
Node node1 = TestUtil.getNode(instance1);
NodeEngineImpl nodeEngine1 = node1.getNodeEngine();
InternalPartitionService partitionService1 = nodeEngine1.getPartitionService();
int partitionCount = partitionService1.getPartitionCount();
String cacheName = randomName();
CacheConfig cacheConfig = new CacheConfig().setName(cacheName);
Cache<String, String> cache = cacheManager.createCache(cacheName, cacheConfig);
String fullCacheName = hzCacheManager.getCacheNameWithPrefix(cacheName);
for (int i = 0; i < partitionCount; i++) {
String key = generateKeyForPartition(instance1, i);
cache.put(key, "Value");
}
for (int i = 0; i < partitionCount; i++) {
verifyPrimaryState(node1, fullCacheName, i, true);
}
HazelcastInstance instance2 = getHazelcastInstance();
Node node2 = TestUtil.getNode(instance2);
warmUpPartitions(instance1, instance2);
waitAllForSafeState(instance1, instance2);
for (int i = 0; i < partitionCount; i++) {
boolean ownedByNode1 = partitionService1.isPartitionOwner(i);
if (ownedByNode1) {
verifyPrimaryState(node1, fullCacheName, i, true);
verifyPrimaryState(node2, fullCacheName, i, false);
} else {
verifyPrimaryState(node1, fullCacheName, i, false);
verifyPrimaryState(node2, fullCacheName, i, true);
}
}
}
Aggregations