use of com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl in project hazelcast by hazelcast.
the class CacheDestroyTest method test_cacheDestroyOperation.
@Test
public void test_cacheDestroyOperation() {
final String CACHE_NAME = "MyCache";
final String FULL_CACHE_NAME = HazelcastCacheManager.CACHE_MANAGER_PREFIX + CACHE_NAME;
final CountDownLatch cacheProxyCreatedLatch = new CountDownLatch(INSTANCE_COUNT);
for (HazelcastInstance hz : hazelcastInstances) {
hz.addDistributedObjectListener(new CacheProxyListener(cacheProxyCreatedLatch));
}
CachingProvider cachingProvider = createServerCachingProvider(getHazelcastInstance());
CacheManager cacheManager = cachingProvider.getCacheManager();
cacheManager.createCache(CACHE_NAME, new CacheConfig());
NodeEngineImpl nodeEngine1 = getNode(getHazelcastInstance()).getNodeEngine();
final ICacheService cacheService1 = nodeEngine1.getService(ICacheService.SERVICE_NAME);
OperationServiceImpl 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));
// wait for the latch to ensure proxy registration events have been processed (otherwise
// the cache config may be added on a member after having been removed by CacheDestroyOp)
assertOpenEventually("A cache proxy should have been created on each instance, latch count was " + cacheProxyCreatedLatch.getCount(), cacheProxyCreatedLatch);
// 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.operationservice.impl.OperationServiceImpl in project hazelcast by hazelcast.
the class ClientListenersTest method testEntryMergeListener_withPortableNotRegisteredInNode.
@Test
public void testEntryMergeListener_withPortableNotRegisteredInNode() throws Exception {
final IMap<Object, Object> map = client.getMap(randomMapName());
final CountDownLatch latch = new CountDownLatch(1);
map.addEntryListener(new EntryMergedListener<Object, Object>() {
@Override
public void entryMerged(EntryEvent<Object, Object> event) {
latch.countDown();
}
}, true);
Node node = getNode(server);
NodeEngineImpl nodeEngine = node.nodeEngine;
OperationServiceImpl operationService = nodeEngine.getOperationService();
SerializationService serializationService = getSerializationService(server);
Data key = serializationService.toData(1);
Data value = serializationService.toData(new ClientRegressionWithMockNetworkTest.SamplePortable(1));
SplitBrainMergeTypes.MapMergeTypes mergingEntry = createMergingEntry(serializationService, key, value, Mockito.mock(Record.class), ExpiryMetadata.NULL);
Operation op = new MergeOperation(map.getName(), Collections.singletonList(mergingEntry), new PassThroughMergePolicy<>(), false);
int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
operationService.invokeOnPartition(MapService.SERVICE_NAME, op, partitionId);
assertOpenEventually(latch);
}
use of com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl in project hazelcast by hazelcast.
the class ClientDisconnectTest method assertNonEmptyPendingInvocationAndWaitSet.
private void assertNonEmptyPendingInvocationAndWaitSet(HazelcastInstance server) {
NodeEngineImpl nodeEngine = getNodeEngineImpl(server);
OperationServiceImpl operationService = (OperationServiceImpl) nodeEngine.getOperationService();
final InvocationRegistry invocationRegistry = operationService.getInvocationRegistry();
final OperationParkerImpl operationParker = (OperationParkerImpl) nodeEngine.getOperationParker();
assertTrueEventually(new AssertTask() {
@Override
public void run() {
assertFalse(invocationRegistry.entrySet().isEmpty());
}
});
assertTrueEventually(new AssertTask() {
@Override
public void run() {
assertTrue(operationParker.getTotalParkedOperationCount() > 0);
}
});
}
use of com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl in project hazelcast by hazelcast.
the class OperationFactoryWrapperTest method testOperationSeesActualCallersUUID.
/**
* OperationFactoryWrapper gets a UUID and sets it to its created operations.
* This test ensures UUID doesn't change through the operation system.
*/
@Test
public void testOperationSeesActualCallersUUID() throws Exception {
HazelcastInstance hz = createHazelcastInstance();
OperationServiceImpl operationService = getOperationService(hz);
UUID expectedCallersUUID = UUID.randomUUID();
GetCallersUUIDOperationFactory operationFactory = new GetCallersUUIDOperationFactory();
OperationFactoryWrapper wrapper = new OperationFactoryWrapper(operationFactory, expectedCallersUUID);
int partitionId = 0;
Map<Integer, Object> responses = operationService.invokeOnPartitions(SERVICE_NAME, wrapper, singletonList(partitionId));
UUID actualCallersUUID = (UUID) responses.get(partitionId);
assertEquals("Callers UUID should not be changed", expectedCallersUUID, actualCallersUUID);
}
use of com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl in project hazelcast by hazelcast.
the class AbstractMapQueryMessageTask method createInvocationsForMissingPartitions.
private void createInvocationsForMissingPartitions(PartitionIdSet missingPartitionsList, List<Future> futures, Predicate predicate) {
final OperationServiceImpl operationService = nodeEngine.getOperationService();
MapService mapService = nodeEngine.getService(getServiceName());
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
Query query = buildQuery(predicate);
PrimitiveIterator.OfInt missingPartitionIterator = missingPartitionsList.intIterator();
missingPartitionIterator.forEachRemaining((IntConsumer) partitionId -> {
MapOperation queryPartitionOperation = createQueryPartitionOperation(query, mapServiceContext);
queryPartitionOperation.setPartitionId(partitionId);
try {
Future future = operationService.invokeOnPartition(SERVICE_NAME, queryPartitionOperation, partitionId);
futures.add(future);
} catch (Throwable t) {
throw rethrow(t);
}
});
}
Aggregations