Search in sources :

Example 1 with QueueStoreConfig

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

the class QueueSplitBrainTest method config.

@Override
protected Config config() {
    MergePolicyConfig mergePolicyConfig = new MergePolicyConfig().setPolicy(mergePolicyClass.getName()).setBatchSize(10);
    Config config = super.config();
    config.getQueueConfig(queueNameA).setMergePolicyConfig(mergePolicyConfig).setQueueStoreConfig(new QueueStoreConfig().setStoreImplementation(queueStoreA)).setBackupCount(1).setAsyncBackupCount(0);
    config.getQueueConfig(queueNameB).setMergePolicyConfig(mergePolicyConfig).setQueueStoreConfig(new QueueStoreConfig().setStoreImplementation(queueStoreB)).setBackupCount(1).setAsyncBackupCount(0);
    return config;
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) Config(com.hazelcast.config.Config) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) MergePolicyConfig(com.hazelcast.config.MergePolicyConfig)

Example 2 with QueueStoreConfig

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

the class QueueStoreTest method testIssue1401QueueStoreWithTxnPoll.

@Test
public void testIssue1401QueueStoreWithTxnPoll() {
    QueueStoreConfig queueStoreConfig = new QueueStoreConfig().setStoreImplementation(new MyQueueStore()).setEnabled(true).setProperty("binary", "false").setProperty("memory-limit", "0").setProperty("bulk-load", "100");
    Config config = getConfig();
    config.getQueueConfig("test").setMaxSize(10).setQueueStoreConfig(queueStoreConfig);
    HazelcastInstance instance = createHazelcastInstance(config);
    for (int i = 0; i < 10; i++) {
        TransactionContext context = instance.newTransactionContext();
        context.beginTransaction();
        TransactionalQueue<VersionedObject<String>> queue = context.getQueue("test");
        VersionedObject<String> queueData = queue.poll();
        assertNotNull(queueData);
        context.commitTransaction();
    }
}
Also used : QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) VersionedObject(com.hazelcast.collection.impl.queue.model.VersionedObject) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) TransactionContext(com.hazelcast.transaction.TransactionContext) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with QueueStoreConfig

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

the class QueueStoreTest method testQueueStoreFactoryIsNotInitialized_whenDisabledInQueueStoreConfig.

@Test
public void testQueueStoreFactoryIsNotInitialized_whenDisabledInQueueStoreConfig() {
    String queueName = randomString();
    Config config = getConfig();
    QueueStoreFactory<VersionedObject<Integer>> queueStoreFactory = new SimpleQueueStoreFactory();
    QueueStoreConfig queueStoreConfig = new QueueStoreConfig().setEnabled(false).setFactoryImplementation(queueStoreFactory);
    config.getQueueConfig(queueName).setQueueStoreConfig(queueStoreConfig);
    HazelcastInstance instance = createHazelcastInstance(config);
    instance.getQueue(queueName).add(new VersionedObject<>(1));
    TestQueueStore testQueueStore = (TestQueueStore) queueStoreFactory.newQueueStore(queueName, null);
    int size = testQueueStore.store.size();
    assertEquals("Expected no queue store operation since we disabled it in QueueStoreConfig, but found initialized ", 0, size);
}
Also used : VersionedObject(com.hazelcast.collection.impl.queue.model.VersionedObject) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with QueueStoreConfig

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

the class QueueStoreTest method testQueueStore.

@Test
public void testQueueStore() throws Exception {
    Config config = getConfig();
    int maxSize = 2000;
    TestQueueStore queueStore = new TestQueueStore(1000, 0, 2000, 0, 0, 0, 1);
    QueueStoreConfig queueStoreConfig = new QueueStoreConfig().setStoreImplementation(queueStore);
    config.getQueueConfig("testQueueStore").setMaxSize(maxSize).setQueueStoreConfig(queueStoreConfig);
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    HazelcastInstance instance = factory.newHazelcastInstance(config);
    for (int i = 0; i < maxSize / 2; i++) {
        queueStore.store.put((long) i, new VersionedObject<>(i, i));
    }
    IQueue<VersionedObject<Integer>> queue = instance.getQueue("testQueueStore");
    for (int i = 0; i < maxSize / 2; i++) {
        int id = i + maxSize / 2;
        queue.offer(new VersionedObject<>(id, id));
    }
    instance.shutdown();
    HazelcastInstance instance2 = factory.newHazelcastInstance(config);
    IQueue<VersionedObject<Integer>> queue2 = instance2.getQueue("testQueueStore");
    assertEquals(maxSize, queue2.size());
    assertEquals(maxSize, queueStore.store.size());
    for (int i = 0; i < maxSize; i++) {
        assertEquals(new VersionedObject<>(i, i), queue2.poll());
    }
    queueStore.assertAwait(3);
}
Also used : QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) VersionedObject(com.hazelcast.collection.impl.queue.model.VersionedObject) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with QueueStoreConfig

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

the class QueueStoreTest method testStoreId_whenNodeDown.

@Test
public void testStoreId_whenNodeDown() {
    Config config = getConfig();
    IdCheckerQueueStore idCheckerQueueStore = new IdCheckerQueueStore();
    QueueStoreConfig queueStoreConfig = new QueueStoreConfig().setEnabled(true).setStoreImplementation(idCheckerQueueStore);
    config.getQueueConfig("default").setQueueStoreConfig(queueStoreConfig);
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    HazelcastInstance instance1 = factory.newHazelcastInstance(config);
    HazelcastInstance instance2 = factory.newHazelcastInstance(config);
    String name = generateKeyOwnedBy(instance1);
    IQueue<VersionedObject<String>> queue = instance2.getQueue(name);
    queue.offer(new VersionedObject<>(randomString()));
    queue.offer(new VersionedObject<>(randomString()));
    queue.offer(new VersionedObject<>(randomString()));
    instance1.shutdown();
    queue.offer(new VersionedObject<>(randomString()));
}
Also used : QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) VersionedObject(com.hazelcast.collection.impl.queue.model.VersionedObject) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

QueueStoreConfig (com.hazelcast.config.QueueStoreConfig)24 Test (org.junit.Test)13 Config (com.hazelcast.config.Config)11 QuickTest (com.hazelcast.test.annotation.QuickTest)9 VersionedObject (com.hazelcast.collection.impl.queue.model.VersionedObject)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)8 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)8 MergePolicyConfig (com.hazelcast.config.MergePolicyConfig)7 QueueConfig (com.hazelcast.config.QueueConfig)6 ItemListenerConfig (com.hazelcast.config.ItemListenerConfig)4 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