use of com.hazelcast.config.QueueConfig in project hazelcast by hazelcast.
the class StoreLatencyPlugin_QueueIntegrationTest method setup.
@Before
public void setup() {
Config config = new Config().setProperty("hazelcast.diagnostics.enabled", "true").setProperty("hazelcast.diagnostics.storeLatency.period.seconds", "1");
QueueConfig queueConfig = addQueueConfig(config);
hz = createHazelcastInstance(config);
queue = hz.getQueue(queueConfig.getName());
}
use of com.hazelcast.config.QueueConfig in project hazelcast by hazelcast.
the class QueueListenerTest method testConfigListenerRegistration.
@Test
public void testConfigListenerRegistration() throws Exception {
Config config = new Config();
String name = "queue";
QueueConfig queueConfig = config.getQueueConfig(name);
CountdownItemListener listener = new CountdownItemListener(1, 1);
ItemListenerConfig itemListenerConfig = new ItemListenerConfig(listener, true);
queueConfig.addItemListenerConfig(itemListenerConfig);
HazelcastInstance instance = createHazelcastInstance(config);
IQueue<String> queue = instance.getQueue(name);
queue.offer("item");
queue.poll();
assertTrue(listener.added.await(10, TimeUnit.SECONDS));
}
use of com.hazelcast.config.QueueConfig in project hazelcast by hazelcast.
the class QueueStoreTest method testQueueStoreLoadMoreThanMaxSize.
@Test
public void testQueueStoreLoadMoreThanMaxSize() {
Config config = new Config();
int maxSize = 2000;
QueueConfig queueConfig = config.getQueueConfig("testQueueStore");
queueConfig.setMaxSize(maxSize);
TestQueueStore queueStore = new TestQueueStore();
QueueStoreConfig queueStoreConfig = new QueueStoreConfig();
queueStoreConfig.setStoreImplementation(queueStore);
queueConfig.setQueueStoreConfig(queueStoreConfig);
HazelcastInstance instance = createHazelcastInstance(config);
for (int i = 0; i < maxSize * 2; i++) {
queueStore.store.put((long) i, i);
}
IQueue<Object> queue = instance.getQueue("testQueueStore");
assertEquals("Queue Size should be equal to max size", maxSize, queue.size());
}
use of com.hazelcast.config.QueueConfig in project hazelcast by hazelcast.
the class QueueStoreTest method testQueueStoreFactory.
@Test
public void testQueueStoreFactory() {
String queueName = randomString();
Config config = new Config();
QueueConfig queueConfig = config.getQueueConfig(queueName);
QueueStoreConfig queueStoreConfig = new QueueStoreConfig();
queueStoreConfig.setEnabled(true);
QueueStoreFactory queueStoreFactory = new SimpleQueueStoreFactory();
queueStoreConfig.setFactoryImplementation(queueStoreFactory);
queueConfig.setQueueStoreConfig(queueStoreConfig);
HazelcastInstance instance = createHazelcastInstance(config);
IQueue<Integer> queue = instance.getQueue(queueName);
queue.add(1);
QueueStore queueStore = queueStoreFactory.newQueueStore(queueName, null);
TestQueueStore testQueueStore = (TestQueueStore) queueStore;
int size = testQueueStore.store.size();
assertEquals("Queue store size should be 1 but found " + size, 1, size);
}
use of com.hazelcast.config.QueueConfig in project hazelcast by hazelcast.
the class TestFullApplicationContext method testQueueConfig.
@Test
public void testQueueConfig() {
QueueConfig testQConfig = config.getQueueConfig("testQ");
assertNotNull(testQConfig);
assertEquals("testQ", testQConfig.getName());
assertEquals(1000, testQConfig.getMaxSize());
assertEquals(1, testQConfig.getItemListenerConfigs().size());
assertTrue(testQConfig.isStatisticsEnabled());
ItemListenerConfig listenerConfig = testQConfig.getItemListenerConfigs().get(0);
assertEquals("com.hazelcast.spring.DummyItemListener", listenerConfig.getClassName());
assertTrue(listenerConfig.isIncludeValue());
QueueConfig qConfig = config.getQueueConfig("q");
assertNotNull(qConfig);
assertEquals("q", qConfig.getName());
assertEquals(2500, qConfig.getMaxSize());
assertFalse(qConfig.isStatisticsEnabled());
assertEquals(100, qConfig.getEmptyQueueTtl());
assertEquals("my-quorum", qConfig.getQuorumName());
QueueConfig queueWithStore1 = config.getQueueConfig("queueWithStore1");
assertNotNull(queueWithStore1);
QueueStoreConfig storeConfig1 = queueWithStore1.getQueueStoreConfig();
assertNotNull(storeConfig1);
assertEquals(DummyQueueStore.class.getName(), storeConfig1.getClassName());
QueueConfig queueWithStore2 = config.getQueueConfig("queueWithStore2");
assertNotNull(queueWithStore2);
QueueStoreConfig storeConfig2 = queueWithStore2.getQueueStoreConfig();
assertNotNull(storeConfig2);
assertEquals(DummyQueueStoreFactory.class.getName(), storeConfig2.getFactoryClassName());
QueueConfig queueWithStore3 = config.getQueueConfig("queueWithStore3");
assertNotNull(queueWithStore3);
QueueStoreConfig storeConfig3 = queueWithStore3.getQueueStoreConfig();
assertNotNull(storeConfig3);
assertEquals(dummyQueueStore, storeConfig3.getStoreImplementation());
QueueConfig queueWithStore4 = config.getQueueConfig("queueWithStore4");
assertNotNull(queueWithStore4);
QueueStoreConfig storeConfig4 = queueWithStore4.getQueueStoreConfig();
assertNotNull(storeConfig4);
assertEquals(dummyQueueStoreFactory, storeConfig4.getFactoryImplementation());
}
Aggregations