Search in sources :

Example 1 with QueueStore

use of com.hazelcast.core.QueueStore in project hazelcast by hazelcast.

the class QueueStoreTest method testQueueStoreFactoryIsNotInitialized_whenDisabledInQueueStoreConfig.

@Test
public void testQueueStoreFactoryIsNotInitialized_whenDisabledInQueueStoreConfig() {
    String queueName = randomString();
    Config config = new Config();
    QueueConfig queueConfig = config.getQueueConfig(queueName);
    QueueStoreConfig queueStoreConfig = new QueueStoreConfig();
    queueStoreConfig.setEnabled(false);
    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("Expected not queue store operation" + " since we disabled it in QueueStoreConfig but found initialized ", 0, 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 2 with QueueStore

use of com.hazelcast.core.QueueStore in project hazelcast by hazelcast.

the class QueueStoreWrapper method create.

/**
     * Factory method that creates a {@link QueueStoreWrapper}
     *
     * @param name                 queue name
     * @param storeConfig          store config of queue
     * @param serializationService serialization service.
     * @return returns a new instance of {@link QueueStoreWrapper}
     */
public static QueueStoreWrapper create(String name, QueueStoreConfig storeConfig, SerializationService serializationService, ClassLoader classLoader) {
    checkNotNull(name, "name should not be null");
    checkNotNull(serializationService, "serializationService should not be null");
    final QueueStoreWrapper storeWrapper = new QueueStoreWrapper(name);
    storeWrapper.setSerializationService(serializationService);
    if (storeConfig == null || !storeConfig.isEnabled()) {
        return storeWrapper;
    }
    // create queue store.
    final QueueStore queueStore = createQueueStore(name, storeConfig, classLoader);
    if (queueStore != null) {
        storeWrapper.setEnabled(storeConfig.isEnabled());
        storeWrapper.setBinary(Boolean.parseBoolean(storeConfig.getProperty(STORE_BINARY)));
        storeWrapper.setMemoryLimit(parseInt(STORE_MEMORY_LIMIT, DEFAULT_MEMORY_LIMIT, storeConfig));
        storeWrapper.setBulkLoad(parseInt(STORE_BULK_LOAD, DEFAULT_BULK_LOAD, storeConfig));
        storeWrapper.setStore(queueStore);
    }
    return storeWrapper;
}
Also used : QueueStore(com.hazelcast.core.QueueStore)

Example 3 with QueueStore

use of com.hazelcast.core.QueueStore in project hazelcast by hazelcast.

the class LatencyTrackingQueueStoreTest method setup.

@Before
public void setup() {
    hz = createHazelcastInstance();
    plugin = new StoreLatencyPlugin(getNodeEngineImpl(hz));
    delegate = mock(QueueStore.class);
    queueStore = new LatencyTrackingQueueStore<String>(delegate, plugin, NAME);
}
Also used : StoreLatencyPlugin(com.hazelcast.internal.diagnostics.StoreLatencyPlugin) QueueStore(com.hazelcast.core.QueueStore) Before(org.junit.Before)

Example 4 with QueueStore

use of com.hazelcast.core.QueueStore 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)

Aggregations

QueueStore (com.hazelcast.core.QueueStore)4 Config (com.hazelcast.config.Config)2 QueueConfig (com.hazelcast.config.QueueConfig)2 QueueStoreConfig (com.hazelcast.config.QueueStoreConfig)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 QueueStoreFactory (com.hazelcast.core.QueueStoreFactory)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Test (org.junit.Test)2 StoreLatencyPlugin (com.hazelcast.internal.diagnostics.StoreLatencyPlugin)1 Before (org.junit.Before)1