Search in sources :

Example 16 with HazelcastServerCachingProvider

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

the class CacheCreationTest method creatingASingleCacheFromMultiProviders.

@Test
public void creatingASingleCacheFromMultiProviders() throws URISyntaxException, InterruptedException {
    ExecutorService executorService = Executors.newFixedThreadPool(THREAD_COUNT);
    final CountDownLatch latch = new CountDownLatch(THREAD_COUNT);
    for (int i = 0; i < THREAD_COUNT; i++) {
        executorService.execute(new Runnable() {

            @Override
            public void run() {
                HazelcastServerCachingProvider cachingProvider = createCachingProvider(hzConfig);
                Cache<Object, Object> cache = cachingProvider.getCacheManager().getCache("xmlCache");
                cache.get(1);
                latch.countDown();
            }
        });
    }
    HazelcastTestSupport.assertOpenEventually(latch);
    executorService.shutdown();
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) CountDownLatch(java.util.concurrent.CountDownLatch) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) Cache(javax.cache.Cache) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 17 with HazelcastServerCachingProvider

use of com.hazelcast.cache.impl.HazelcastServerCachingProvider 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());
        }
    });
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) EventCollectingCachePartitionLostListener(com.hazelcast.cache.CachePartitionLostListenerTest.EventCollectingCachePartitionLostListener) CachePartitionLostListener(com.hazelcast.cache.impl.event.CachePartitionLostListener) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) Config(com.hazelcast.config.Config) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) EventService(com.hazelcast.spi.EventService) IOException(java.io.IOException) HazelcastInstance(com.hazelcast.core.HazelcastInstance) CacheManager(javax.cache.CacheManager) AssertTask(com.hazelcast.test.AssertTask) Collection(java.util.Collection) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)17 Test (org.junit.Test)16 HazelcastInstance (com.hazelcast.core.HazelcastInstance)14 QuickTest (com.hazelcast.test.annotation.QuickTest)12 ParallelTest (com.hazelcast.test.annotation.ParallelTest)11 CacheManager (javax.cache.CacheManager)9 CountDownLatch (java.util.concurrent.CountDownLatch)8 CacheConfig (com.hazelcast.config.CacheConfig)6 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)6 Config (com.hazelcast.config.Config)6 QuorumConfig (com.hazelcast.config.QuorumConfig)5 QuorumListenerConfig (com.hazelcast.config.QuorumListenerConfig)5 QuorumEvent (com.hazelcast.quorum.QuorumEvent)5 QuorumException (com.hazelcast.quorum.QuorumException)5 QuorumListener (com.hazelcast.quorum.QuorumListener)5 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)5 AssertTask (com.hazelcast.test.AssertTask)4 SlowTest (com.hazelcast.test.annotation.SlowTest)4 ICache (com.hazelcast.cache.ICache)3 CacheService (com.hazelcast.cache.impl.CacheService)3