Search in sources :

Example 6 with CacheService

use of com.hazelcast.cache.impl.CacheService in project hazelcast by hazelcast.

the class CacheGetInvalidationMetaDataOperation method getPartitionMetaDataGenerator.

private MetaDataGenerator getPartitionMetaDataGenerator() {
    CacheService cacheService = getService();
    CacheEventHandler cacheEventHandler = cacheService.getCacheEventHandler();
    return cacheEventHandler.getMetaDataGenerator();
}
Also used : CacheEventHandler(com.hazelcast.cache.impl.CacheEventHandler) CacheService(com.hazelcast.cache.impl.CacheService)

Example 7 with CacheService

use of com.hazelcast.cache.impl.CacheService in project hazelcast by hazelcast.

the class CacheAddNearCacheInvalidationListenerTask method call.

@Override
protected Object call() {
    ClientEndpoint endpoint = getEndpoint();
    CacheService cacheService = getService(CacheService.SERVICE_NAME);
    CacheContext cacheContext = cacheService.getOrCreateCacheContext(parameters.name);
    NearCacheInvalidationListener listener = new NearCacheInvalidationListener(endpoint, cacheContext, nodeEngine.getLocalMember().getUuid());
    String registrationId = cacheService.addInvalidationListener(parameters.name, listener, parameters.localOnly);
    endpoint.addListenerDestroyAction(CacheService.SERVICE_NAME, parameters.name, registrationId);
    return registrationId;
}
Also used : ClientEndpoint(com.hazelcast.client.ClientEndpoint) CacheContext(com.hazelcast.cache.impl.CacheContext) CacheService(com.hazelcast.cache.impl.CacheService)

Example 8 with CacheService

use of com.hazelcast.cache.impl.CacheService in project hazelcast by hazelcast.

the class CacheAddPartitionLostListenerMessageTask method call.

@Override
protected Object call() {
    final ClientEndpoint endpoint = getEndpoint();
    CachePartitionLostListener listener = new CachePartitionLostListener() {

        @Override
        public void partitionLost(CachePartitionLostEvent event) {
            if (endpoint.isAlive()) {
                ClientMessage eventMessage = CacheAddPartitionLostListenerCodec.encodeCachePartitionLostEvent(event.getPartitionId(), event.getMember().getUuid());
                sendClientMessage(null, eventMessage);
            }
        }
    };
    InternalCachePartitionLostListenerAdapter listenerAdapter = new InternalCachePartitionLostListenerAdapter(listener);
    EventFilter filter = new CachePartitionLostEventFilter();
    CacheService service = getService(CacheService.SERVICE_NAME);
    EventService eventService = service.getNodeEngine().getEventService();
    EventRegistration registration;
    if (parameters.localOnly) {
        registration = eventService.registerLocalListener(ICacheService.SERVICE_NAME, parameters.name, filter, listenerAdapter);
    } else {
        registration = eventService.registerListener(ICacheService.SERVICE_NAME, parameters.name, filter, listenerAdapter);
    }
    String registrationId = registration.getId();
    endpoint.addListenerDestroyAction(CacheService.SERVICE_NAME, parameters.name, registrationId);
    return registrationId;
}
Also used : CachePartitionLostListener(com.hazelcast.cache.impl.event.CachePartitionLostListener) EventRegistration(com.hazelcast.spi.EventRegistration) CachePartitionLostEvent(com.hazelcast.cache.impl.event.CachePartitionLostEvent) EventService(com.hazelcast.spi.EventService) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientEndpoint(com.hazelcast.client.ClientEndpoint) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) EventFilter(com.hazelcast.spi.EventFilter) InternalCachePartitionLostListenerAdapter(com.hazelcast.cache.impl.event.InternalCachePartitionLostListenerAdapter) CacheService(com.hazelcast.cache.impl.CacheService) ICacheService(com.hazelcast.cache.impl.ICacheService)

Example 9 with CacheService

use of com.hazelcast.cache.impl.CacheService in project hazelcast by hazelcast.

the class CacheSizeMessageTask method reduce.

@Override
protected Object reduce(Map<Integer, Object> map) {
    int total = 0;
    CacheService service = getService(getServiceName());
    for (Object result : map.values()) {
        Integer size = (Integer) service.toObject(result);
        total += size;
    }
    return total;
}
Also used : CacheService(com.hazelcast.cache.impl.CacheService)

Example 10 with CacheService

use of com.hazelcast.cache.impl.CacheService in project hazelcast by hazelcast.

the class Pre38CacheAddInvalidationListenerTask method call.

@Override
protected Object call() {
    ClientEndpoint endpoint = getEndpoint();
    CacheService cacheService = getService(CacheService.SERVICE_NAME);
    CacheContext cacheContext = cacheService.getOrCreateCacheContext(parameters.name);
    Pre38NearCacheInvalidationListener listener = new Pre38NearCacheInvalidationListener(endpoint, cacheContext, nodeEngine.getLocalMember().getUuid());
    String registrationId = cacheService.addInvalidationListener(parameters.name, listener, parameters.localOnly);
    endpoint.addListenerDestroyAction(CacheService.SERVICE_NAME, parameters.name, registrationId);
    return registrationId;
}
Also used : ClientEndpoint(com.hazelcast.client.ClientEndpoint) CacheContext(com.hazelcast.cache.impl.CacheContext) CacheService(com.hazelcast.cache.impl.CacheService)

Aggregations

CacheService (com.hazelcast.cache.impl.CacheService)21 CacheEventHandler (com.hazelcast.cache.impl.CacheEventHandler)6 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)6 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)5 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)5 ParallelTest (com.hazelcast.test.annotation.ParallelTest)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 CacheManager (javax.cache.CacheManager)5 Test (org.junit.Test)5 ClientEndpoint (com.hazelcast.client.ClientEndpoint)4 CacheConfig (com.hazelcast.config.CacheConfig)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 Data (com.hazelcast.nio.serialization.Data)4 CachingProvider (javax.cache.spi.CachingProvider)4 CacheContext (com.hazelcast.cache.impl.CacheContext)3 ICacheService (com.hazelcast.cache.impl.ICacheService)3 IPartitionLostEvent (com.hazelcast.spi.partition.IPartitionLostEvent)3 ICache (com.hazelcast.cache.ICache)2 CacheOperationProvider (com.hazelcast.cache.impl.CacheOperationProvider)2 CachePartitionSegment (com.hazelcast.cache.impl.CachePartitionSegment)2