Search in sources :

Example 26 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 27 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() {
    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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 28 with RingbufferStoreConfig

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

the class RingbufferSplitBrainTest method config.

@Override
protected Config config() {
    MergePolicyConfig mergePolicyConfig = new MergePolicyConfig().setPolicy(mergePolicyClass.getName()).setBatchSize(10);
    Config config = super.config();
    config.getRingbufferConfig(ringbufferNameA).setInMemoryFormat(inMemoryFormat).setMergePolicyConfig(mergePolicyConfig).setRingbufferStoreConfig(new RingbufferStoreConfig().setStoreImplementation(ringbufferStoreA)).setBackupCount(1).setAsyncBackupCount(0).setTimeToLiveSeconds(0);
    config.getRingbufferConfig(ringbufferNameB).setInMemoryFormat(inMemoryFormat).setMergePolicyConfig(mergePolicyConfig).setRingbufferStoreConfig(new RingbufferStoreConfig().setStoreImplementation(ringbufferStoreB)).setBackupCount(1).setAsyncBackupCount(0).setTimeToLiveSeconds(0);
    return config;
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) Config(com.hazelcast.config.Config) MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig)

Aggregations

RingbufferStoreConfig (com.hazelcast.config.RingbufferStoreConfig)28 RingbufferConfig (com.hazelcast.config.RingbufferConfig)19 Config (com.hazelcast.config.Config)16 Test (org.junit.Test)16 HazelcastInstance (com.hazelcast.core.HazelcastInstance)12 QuickTest (com.hazelcast.test.annotation.QuickTest)12 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)11 MergePolicyConfig (com.hazelcast.config.MergePolicyConfig)7 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 AttributeConfig (com.hazelcast.config.AttributeConfig)2 AwsConfig (com.hazelcast.config.AwsConfig)2 CachePartitionLostListenerConfig (com.hazelcast.config.CachePartitionLostListenerConfig)2 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)2 CacheSimpleEntryListenerConfig (com.hazelcast.config.CacheSimpleEntryListenerConfig)2 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)2 DataPersistenceConfig (com.hazelcast.config.DataPersistenceConfig)2 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)2 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)2 DiskTierConfig (com.hazelcast.config.DiskTierConfig)2