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;
}
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();
}
}
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);
}
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);
}
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()));
}
Aggregations