Search in sources :

Example 11 with RingbufferStoreConfig

use of com.hazelcast.config.RingbufferStoreConfig in project hazelcast by hazelcast.

the class RingbufferStoreTest method testRingbufferStoreFactory.

@Test
public void testRingbufferStoreFactory() {
    final String ringbufferName = randomString();
    final SimpleRingbufferStoreFactory rbStoreFactory = new SimpleRingbufferStoreFactory();
    final RingbufferStoreConfig rbStoreConfig = new RingbufferStoreConfig().setEnabled(true).setFactoryImplementation(rbStoreFactory);
    final Config config = getConfig(ringbufferName, DEFAULT_CAPACITY, OBJECT, rbStoreConfig);
    final HazelcastInstance instance = createHazelcastInstance(config);
    final Ringbuffer<Object> ringbuffer = instance.getRingbuffer(ringbufferName);
    ringbuffer.add(1);
    assertEquals(1, rbStoreFactory.stores.size());
    final TestRingbufferStore ringbufferStore = (TestRingbufferStore) rbStoreFactory.stores.get(ringbufferName);
    int size = ringbufferStore.store.size();
    assertEquals("Ring buffer store size should be 1 but found " + size, 1, size);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Config(com.hazelcast.config.Config) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 12 with RingbufferStoreConfig

use of com.hazelcast.config.RingbufferStoreConfig in project hazelcast by hazelcast.

the class RingbufferStoreTest method testRingbufferStore_addThrowsException.

@Test(expected = HazelcastException.class)
public void testRingbufferStore_addThrowsException() throws InterruptedException {
    final String ringbufferName = randomString();
    final RingbufferStoreConfig rbStoreConfig = new RingbufferStoreConfig().setStoreImplementation(new ExceptionThrowingRingbufferStore()).setEnabled(true);
    final Config config = getConfig(ringbufferName, DEFAULT_CAPACITY, OBJECT, rbStoreConfig);
    final HazelcastInstance node = createHazelcastInstance(config);
    final Ringbuffer<Object> ringbuffer = node.getRingbuffer(ringbufferName);
    ringbuffer.add(1);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Config(com.hazelcast.config.Config) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 13 with RingbufferStoreConfig

use of com.hazelcast.config.RingbufferStoreConfig in project hazelcast by hazelcast.

the class RingbufferStoreTest method testRingbufferStoreFactoryIsNotInitialized_whenDisabledInRingbufferStoreConfig.

@Test
public void testRingbufferStoreFactoryIsNotInitialized_whenDisabledInRingbufferStoreConfig() {
    final String ringbufferName = randomString();
    final SimpleRingbufferStoreFactory rbStoreFactory = new SimpleRingbufferStoreFactory();
    final RingbufferStoreConfig rbStoreConfig = new RingbufferStoreConfig().setEnabled(false).setFactoryImplementation(rbStoreFactory);
    final Config config = getConfig(ringbufferName, DEFAULT_CAPACITY, OBJECT, rbStoreConfig);
    final HazelcastInstance instance = createHazelcastInstance(config);
    final Ringbuffer<Object> ringbuffer = instance.getRingbuffer(ringbufferName);
    ringbuffer.add(1);
    assertEquals("Expected that the ring buffer store would not be initialized" + " since we disabled it in the ring buffer store config but found initialized ", 0, rbStoreFactory.stores.size());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) Config(com.hazelcast.config.Config) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

RingbufferConfig (com.hazelcast.config.RingbufferConfig)13 RingbufferStoreConfig (com.hazelcast.config.RingbufferStoreConfig)13 Config (com.hazelcast.config.Config)12 QuickTest (com.hazelcast.test.annotation.QuickTest)12 Test (org.junit.Test)12 HazelcastInstance (com.hazelcast.core.HazelcastInstance)11 ParallelTest (com.hazelcast.test.annotation.ParallelTest)11 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ArrayList (java.util.ArrayList)1