Search in sources :

Example 11 with QueueConfig

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());
}
Also used : QueueConfig(com.hazelcast.config.QueueConfig) QueueConfig(com.hazelcast.config.QueueConfig) Config(com.hazelcast.config.Config) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) Before(org.junit.Before)

Example 12 with QueueConfig

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));
}
Also used : QueueConfig(com.hazelcast.config.QueueConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) QueueConfig(com.hazelcast.config.QueueConfig) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 13 with QueueConfig

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());
}
Also used : QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) QueueConfig(com.hazelcast.config.QueueConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) QueueConfig(com.hazelcast.config.QueueConfig) Config(com.hazelcast.config.Config) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 14 with QueueConfig

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);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) QueueConfig(com.hazelcast.config.QueueConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) QueueStoreFactory(com.hazelcast.core.QueueStoreFactory) QueueStore(com.hazelcast.core.QueueStore) QueueConfig(com.hazelcast.config.QueueConfig) Config(com.hazelcast.config.Config) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 15 with QueueConfig

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());
}
Also used : QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) QueueConfig(com.hazelcast.config.QueueConfig) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Aggregations

QueueConfig (com.hazelcast.config.QueueConfig)19 Config (com.hazelcast.config.Config)14 HazelcastInstance (com.hazelcast.core.HazelcastInstance)11 Test (org.junit.Test)11 QueueStoreConfig (com.hazelcast.config.QueueStoreConfig)10 QuickTest (com.hazelcast.test.annotation.QuickTest)9 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Before (org.junit.Before)3 ItemListenerConfig (com.hazelcast.config.ItemListenerConfig)2 QuorumConfig (com.hazelcast.config.QuorumConfig)2 QueueStore (com.hazelcast.core.QueueStore)2 QueueStoreFactory (com.hazelcast.core.QueueStoreFactory)2 QueueContainer (com.hazelcast.collection.impl.queue.QueueContainer)1 QueueService (com.hazelcast.collection.impl.queue.QueueService)1 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)1 LockConfig (com.hazelcast.config.LockConfig)1 MapConfig (com.hazelcast.config.MapConfig)1 PartitionedCluster (com.hazelcast.quorum.PartitionedCluster)1 NodeEngine (com.hazelcast.spi.NodeEngine)1