use of javax.cache.CacheManager 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 javax.cache.CacheManager in project hazelcast by hazelcast.
the class CacheListenerTest method cacheEntryListenerCountIncreasedAndDecreasedCorrectly.
@Test
public void cacheEntryListenerCountIncreasedAndDecreasedCorrectly() {
final CachingProvider provider = getCachingProvider();
CacheManager cacheManager = provider.getCacheManager();
CompleteConfiguration<String, String> config = new MutableConfiguration<String, String>().addCacheEntryListenerConfiguration(new MutableCacheEntryListenerConfiguration<String, String>(FactoryBuilder.factoryOf(new TestListener(new AtomicInteger())), null, true, true));
final Cache<String, String> cache = cacheManager.createCache("MyCache", config);
}
use of javax.cache.CacheManager in project hazelcast by hazelcast.
the class CachePartitionIteratorMigrationTest method getCacheProxy.
private <K, V> CacheProxy<K, V> getCacheProxy(CachingProvider cachingProvider) {
String cacheName = randomString();
CacheManager cacheManager = cachingProvider.getCacheManager();
CacheConfig<K, V> config = new CacheConfig<K, V>();
config.getEvictionConfig().setMaximumSizePolicy(EvictionConfig.MaxSizePolicy.ENTRY_COUNT).setSize(10000000);
return (CacheProxy<K, V>) cacheManager.createCache(cacheName, config);
}
use of javax.cache.CacheManager in project hazelcast by hazelcast.
the class CachePartitionIteratorTest method getCacheProxy.
private <K, V> CacheProxy<K, V> getCacheProxy() {
String cacheName = randomString();
CacheManager cacheManager = cachingProvider.getCacheManager();
CacheConfig<K, V> config = new CacheConfig<K, V>();
config.getEvictionConfig().setMaximumSizePolicy(EvictionConfig.MaxSizePolicy.ENTRY_COUNT).setSize(10000000);
return (CacheProxy<K, V>) cacheManager.createCache(cacheName, config);
}
use of javax.cache.CacheManager in project hazelcast by hazelcast.
the class CachePartitionLostListenerConfigTest method testCachePartitionLostListener_registeredViaImplementationInConfigObject.
@Test
public void testCachePartitionLostListener_registeredViaImplementationInConfigObject() {
final String cacheName = "myCache";
Config config = new Config();
CacheSimpleConfig cacheConfig = config.getCacheConfig(cacheName);
CachePartitionLostListener listener = mock(CachePartitionLostListener.class);
cacheConfig.addCachePartitionLostListenerConfig(new CachePartitionLostListenerConfig(listener));
cacheConfig.setBackupCount(0);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance instance = factory.newHazelcastInstance(config);
HazelcastServerCachingProvider cachingProvider = createCachingProvider(instance);
CacheManager cacheManager = cachingProvider.getCacheManager();
cacheManager.getCache(cacheName);
final EventService eventService = getNode(instance).getNodeEngine().getEventService();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
Collection<EventRegistration> registrations = eventService.getRegistrations(CacheService.SERVICE_NAME, cacheName);
assertFalse(registrations.isEmpty());
}
});
}
Aggregations