use of com.hazelcast.cache.impl.CacheService in project hazelcast by hazelcast.
the class InvalidationMetadataDistortionTest method distortRandomPartitionUuid.
private void distortRandomPartitionUuid(HazelcastInstance member) {
NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(member);
int partitionCount = nodeEngineImpl.getPartitionService().getPartitionCount();
CacheService service = nodeEngineImpl.getService(CacheService.SERVICE_NAME);
CacheEventHandler cacheEventHandler = service.getCacheEventHandler();
MetaDataGenerator metaDataGenerator = cacheEventHandler.getMetaDataGenerator();
UUID uuid = UuidUtil.newSecureUUID();
int randomPartition = getInt(partitionCount);
metaDataGenerator.setUuid(randomPartition, uuid);
}
use of com.hazelcast.cache.impl.CacheService in project hazelcast by hazelcast.
the class ClientCachePartitionLostListenerTest method test_cachePartitionLostListener_invoked.
@Test
public void test_cachePartitionLostListener_invoked() {
final String cacheName = randomName();
HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
final HazelcastInstance client = hazelcastFactory.newHazelcastClient();
final HazelcastServerCachingProvider cachingProvider = createCachingProvider(instance);
final CacheManager cacheManager = cachingProvider.getCacheManager();
final CacheConfig<Integer, String> config = new CacheConfig<Integer, String>();
config.setBackupCount(0);
cacheManager.createCache(cacheName, config);
final CachingProvider clientCachingProvider = HazelcastClientCachingProvider.createCachingProvider(client);
final CacheManager clientCacheManager = clientCachingProvider.getCacheManager();
final Cache<Integer, String> cache = clientCacheManager.getCache(cacheName);
final ICache iCache = cache.unwrap(ICache.class);
final EventCollectingCachePartitionLostListener listener = new EventCollectingCachePartitionLostListener();
iCache.addPartitionLostListener(listener);
final CacheService cacheService = getNode(instance).getNodeEngine().getService(CacheService.SERVICE_NAME);
final int partitionId = 5;
cacheService.onPartitionLost(new IPartitionLostEvent(partitionId, 0, null));
assertCachePartitionLostEventEventually(listener, partitionId);
}
use of com.hazelcast.cache.impl.CacheService in project hazelcast by hazelcast.
the class CacheAddEntryListenerMessageTask method call.
@Override
protected Object call() {
ClientEndpoint endpoint = getEndpoint();
final CacheService service = getService(CacheService.SERVICE_NAME);
CacheEntryListener cacheEntryListener = new CacheEntryListener(endpoint, this);
final String registrationId = service.registerListener(parameters.name, cacheEntryListener, cacheEntryListener, parameters.localOnly);
endpoint.addDestroyAction(registrationId, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return service.deregisterListener(parameters.name, registrationId);
}
});
return registrationId;
}
use of com.hazelcast.cache.impl.CacheService in project hazelcast by hazelcast.
the class CacheAssignAndGetUuidsOperation method getMetaDataGenerator.
private MetaDataGenerator getMetaDataGenerator() {
CacheService service = getService();
CacheEventHandler cacheEventHandler = service.getCacheEventHandler();
return cacheEventHandler.getMetaDataGenerator();
}
use of com.hazelcast.cache.impl.CacheService in project hazelcast by hazelcast.
the class CacheEntryProcessorMessageTask method prepareOperation.
@Override
protected Operation prepareOperation() {
CacheService service = getService(getServiceName());
CacheOperationProvider operationProvider = getOperationProvider(parameters.name);
EntryProcessor entryProcessor = (EntryProcessor) service.toObject(parameters.entryProcessor);
ArrayList argumentsList = new ArrayList(parameters.arguments.size());
for (Data data : parameters.arguments) {
argumentsList.add(service.toObject(data));
}
return operationProvider.createEntryProcessorOperation(parameters.key, parameters.completionId, entryProcessor, argumentsList.toArray());
}
Aggregations