Search in sources :

Example 16 with ICacheService

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

the class CacheDestroyOperation method run.

@Override
public void run() throws Exception {
    ICacheService service = getService();
    service.deleteCache(name, getCallerUuid(), true);
    if (!isLocal) {
        destroyCacheOnAllMembers(name, getCallerUuid());
    }
}
Also used : ICacheService(com.hazelcast.cache.impl.ICacheService)

Example 17 with ICacheService

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

the class CacheGetAllOperation method run.

public void run() {
    ICacheService service = getService();
    ICacheRecordStore cache = service.getOrCreateRecordStore(name, getPartitionId());
    int partitionId = getPartitionId();
    Set<Data> partitionKeySet = new HashSet<Data>();
    for (Data key : keys) {
        if (partitionId == getNodeEngine().getPartitionService().getPartitionId(key)) {
            partitionKeySet.add(key);
        }
    }
    response = cache.getAll(partitionKeySet, expiryPolicy);
}
Also used : ICacheService(com.hazelcast.cache.impl.ICacheService) ICacheRecordStore(com.hazelcast.cache.impl.ICacheRecordStore) Data(com.hazelcast.nio.serialization.Data) HashSet(java.util.HashSet)

Example 18 with ICacheService

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

the class CacheReplicationOperation method run.

@Override
public void run() throws Exception {
    ICacheService service = getService();
    for (Map.Entry<String, Map<Data, CacheRecord>> entry : data.entrySet()) {
        ICacheRecordStore cache = service.getOrCreateRecordStore(entry.getKey(), getPartitionId());
        cache.clear();
        Map<Data, CacheRecord> map = entry.getValue();
        Iterator<Map.Entry<Data, CacheRecord>> iterator = map.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<Data, CacheRecord> next = iterator.next();
            Data key = next.getKey();
            CacheRecord record = next.getValue();
            iterator.remove();
            cache.putRecord(key, record);
        }
    }
    data.clear();
    if (getReplicaIndex() == 0) {
        nearCacheStateHolder.applyState();
    }
}
Also used : CacheRecord(com.hazelcast.cache.impl.record.CacheRecord) ICacheService(com.hazelcast.cache.impl.ICacheService) ICacheRecordStore(com.hazelcast.cache.impl.ICacheRecordStore) Data(com.hazelcast.nio.serialization.Data) HashMap(java.util.HashMap) Map(java.util.Map)

Example 19 with ICacheService

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

the class ServiceManagerImpl method registerCacheServiceIfAvailable.

private void registerCacheServiceIfAvailable() {
    //search for jcache api jar on classpath
    if (JCacheDetector.isJCacheAvailable(nodeEngine.getConfigClassLoader(), logger)) {
        ICacheService service = createService(ICacheService.class);
        registerService(ICacheService.SERVICE_NAME, service);
    } else {
        logger.finest("javax.cache api is not detected on classpath. Skipping CacheService...");
    }
}
Also used : ICacheService(com.hazelcast.cache.impl.ICacheService)

Example 20 with ICacheService

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

the class CacheConfigTest method testGetCacheConfigsAtJoin.

@Test
public void testGetCacheConfigsAtJoin() {
    final String cacheName = randomString();
    final String managerPrefix = "hz:";
    final String fullCacheName = managerPrefix + cacheName;
    final Config config = new Config();
    final CacheConfig cacheConfig = new CacheConfig().setName(cacheName).setManagerPrefix(managerPrefix);
    final TestHazelcastInstanceFactory instanceFactory = createHazelcastInstanceFactory(2);
    final HazelcastInstance instance1 = instanceFactory.newHazelcastInstance(config);
    final ICacheService cacheService1 = getCacheService(instance1);
    assertNull(cacheService1.getCacheConfig(fullCacheName));
    cacheService1.putCacheConfigIfAbsent(cacheConfig);
    assertNotNull(cacheService1.getCacheConfig(fullCacheName));
    final HazelcastInstance instance2 = instanceFactory.newHazelcastInstance(config);
    final ICacheService cacheService2 = getCacheService(instance2);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertNotNull(cacheService2.getCacheConfig(fullCacheName));
        }
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ICacheService(com.hazelcast.cache.impl.ICacheService) TimedExpiryPolicyFactoryConfig(com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.TimedExpiryPolicyFactoryConfig) DurationConfig(com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.DurationConfig) ExpiryPolicyFactoryConfig(com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig) AssertTask(com.hazelcast.test.AssertTask) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) URISyntaxException(java.net.URISyntaxException) CacheWriterException(javax.cache.integration.CacheWriterException) CacheEntryListenerException(javax.cache.event.CacheEntryListenerException) CacheLoaderException(javax.cache.integration.CacheLoaderException) IOException(java.io.IOException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ICacheService (com.hazelcast.cache.impl.ICacheService)24 ICacheRecordStore (com.hazelcast.cache.impl.ICacheRecordStore)9 CacheConfig (com.hazelcast.config.CacheConfig)8 Data (com.hazelcast.nio.serialization.Data)8 QuickTest (com.hazelcast.test.annotation.QuickTest)7 Test (org.junit.Test)7 Node (com.hazelcast.instance.Node)5 SerializationService (com.hazelcast.spi.serialization.SerializationService)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 CacheRecord (com.hazelcast.cache.impl.record.CacheRecord)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 AssertTask (com.hazelcast.test.AssertTask)3 CacheNotExistsException (com.hazelcast.cache.CacheNotExistsException)2 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)2 Config (com.hazelcast.config.Config)2 NodeEngine (com.hazelcast.spi.NodeEngine)2 HashSet (java.util.HashSet)2