use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class CacheDestroyTest method test_cacheDestroyOperation.
@Test
public void test_cacheDestroyOperation() throws ExecutionException, InterruptedException {
final String CACHE_NAME = "MyCache";
final String FULL_CACHE_NAME = HazelcastCacheManager.CACHE_MANAGER_PREFIX + CACHE_NAME;
CachingProvider cachingProvider = HazelcastServerCachingProvider.createCachingProvider(getHazelcastInstance());
CacheManager cacheManager = cachingProvider.getCacheManager();
cacheManager.createCache(CACHE_NAME, new CacheConfig());
NodeEngineImpl nodeEngine1 = getNode(getHazelcastInstance()).getNodeEngine();
final ICacheService cacheService1 = nodeEngine1.getService(ICacheService.SERVICE_NAME);
InternalOperationService operationService1 = nodeEngine1.getOperationService();
NodeEngineImpl nodeEngine2 = getNode(hazelcastInstances[1]).getNodeEngine();
final ICacheService cacheService2 = nodeEngine2.getService(ICacheService.SERVICE_NAME);
assertNotNull(cacheService1.getCacheConfig(FULL_CACHE_NAME));
assertNotNull(cacheService2.getCacheConfig(FULL_CACHE_NAME));
// Invoke on single node and the operation is also forward to others nodes by the operation itself
operationService1.invokeOnTarget(ICacheService.SERVICE_NAME, new CacheDestroyOperation(FULL_CACHE_NAME), nodeEngine1.getThisAddress());
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertNull(cacheService1.getCacheConfig(FULL_CACHE_NAME));
assertNull(cacheService2.getCacheConfig(FULL_CACHE_NAME));
}
});
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class CountDownLatchAdvancedTest method testDestroy.
@Test
public void testDestroy() {
HazelcastInstance instance = createHazelcastInstance();
ICountDownLatch latch = instance.getCountDownLatch(randomString());
NodeEngineImpl nodeEngine = getNode(instance).getNodeEngine();
CountDownLatchService service = nodeEngine.getService(CountDownLatchService.SERVICE_NAME);
latch.destroy();
assertFalse(service.containsLatch(latch.getName()));
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class MemberImpl method invokeOnAllMembers.
private void invokeOnAllMembers(Operation operation) {
NodeEngineImpl nodeEngine = instance.node.nodeEngine;
OperationService os = nodeEngine.getOperationService();
String uuid = nodeEngine.getLocalMember().getUuid();
operation.setCallerUuid(uuid).setNodeEngine(nodeEngine);
try {
for (Member member : nodeEngine.getClusterService().getMembers()) {
if (!member.localMember()) {
os.send(operation, member.getAddress());
} else {
os.execute(operation);
}
}
} catch (Throwable t) {
throw ExceptionUtil.rethrow(t);
}
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class SetKeyValueSource method open.
@Override
public boolean open(NodeEngine nodeEngine) {
NodeEngineImpl nei = (NodeEngineImpl) nodeEngine;
ss = nei.getSerializationService();
Address thisAddress = nei.getThisAddress();
InternalPartitionService ps = nei.getPartitionService();
Data data = ss.toData(setName, StringAndPartitionAwarePartitioningStrategy.INSTANCE);
int partitionId = ps.getPartitionId(data);
Address partitionOwner = ps.getPartitionOwner(partitionId);
if (partitionOwner == null) {
return false;
}
if (thisAddress.equals(partitionOwner)) {
SetService setService = nei.getService(SetService.SERVICE_NAME);
SetContainer setContainer = setService.getOrCreateContainer(setName, false);
List<CollectionItem> items = new ArrayList<CollectionItem>(setContainer.getCollection());
iterator = items.iterator();
}
return true;
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class CacheSerializationTest method test_CacheReplicationOperation_serialization.
@Test
public void test_CacheReplicationOperation_serialization() throws Exception {
TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();
try {
CachingProvider provider = HazelcastServerCachingProvider.createCachingProvider(hazelcastInstance);
CacheManager manager = provider.getCacheManager();
CompleteConfiguration configuration = new MutableConfiguration();
Cache cache1 = manager.createCache("cache1", configuration);
Cache cache2 = manager.createCache("cache2", configuration);
Cache cache3 = manager.createCache("cache3", configuration);
for (int i = 0; i < 1000; i++) {
cache1.put("key" + i, i);
cache2.put("key" + i, i);
cache3.put("key" + i, i);
}
HazelcastInstanceProxy proxy = (HazelcastInstanceProxy) hazelcastInstance;
Field original = HazelcastInstanceProxy.class.getDeclaredField("original");
original.setAccessible(true);
HazelcastInstanceImpl impl = (HazelcastInstanceImpl) original.get(proxy);
NodeEngineImpl nodeEngine = impl.node.nodeEngine;
CacheService cacheService = nodeEngine.getService(CacheService.SERVICE_NAME);
int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
CachePartitionSegment segment = cacheService.getSegment(partitionId);
CacheReplicationOperation operation = new CacheReplicationOperation(segment, 1);
Data serialized = service.toData(operation);
try {
service.toObject(serialized);
} catch (Exception e) {
throw new Exception("Partition: " + partitionId, e);
}
}
} finally {
factory.shutdownAll();
}
}
Aggregations