Search in sources :

Example 6 with QueueStoreConfig

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

the class QueueStoreTest method testQueueStore_withBinaryModeOn.

@Test
public void testQueueStore_withBinaryModeOn() {
    String queueName = randomString();
    Config config = getConfig();
    QueueStoreConfig queueStoreConfig = getBinaryQueueStoreConfig();
    config.getQueueConfig(queueName).setQueueStoreConfig(queueStoreConfig);
    HazelcastInstance node = createHazelcastInstance(config);
    IQueue<VersionedObject<Integer>> queue = node.getQueue(queueName);
    queue.add(new VersionedObject<>(1));
    queue.add(new VersionedObject<>(2));
    queue.add(new VersionedObject<>(3));
    // this triggers bulk loading
    VersionedObject<Integer> value = queue.peek();
    assertEquals(new VersionedObject<>(1), value);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with QueueStoreConfig

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

the class QueueStoreTest method testRemoveAll.

@Test
public void testRemoveAll() {
    int maxSize = 2000;
    Config config = getConfig();
    QueueStoreConfig queueStoreConfig = new QueueStoreConfig().setStoreImplementation(new TestQueueStore()).setProperty("bulk-load", String.valueOf(200));
    config.getQueueConfig("testQueueStore").setMaxSize(maxSize).setQueueStoreConfig(queueStoreConfig);
    HazelcastInstance instance = createHazelcastInstance(config);
    IQueue<VersionedObject<Integer>> queue = instance.getQueue("testQueueStore");
    for (int i = 0; i < maxSize; i++) {
        queue.add(new VersionedObject<>(i));
    }
    assertEquals(maxSize, queue.size());
    for (VersionedObject<Integer> o : queue) {
        queue.remove(o);
    }
    assertEquals(0, queue.size());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with QueueStoreConfig

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

the class QueueStoreTest method getConfigForDrainToTest.

private Config getConfigForDrainToTest(int maxSize, int bulkLoadSize, QueueStore<VersionedObject<Integer>> queueStore) {
    Config config = getConfig();
    QueueStoreConfig queueStoreConfig = new QueueStoreConfig().setStoreImplementation(queueStore);
    if (bulkLoadSize > 0) {
        queueStoreConfig.setProperty("bulk-load", Integer.toString(bulkLoadSize));
    }
    config.getQueueConfig("testQueueStore").setMaxSize(maxSize).setQueueStoreConfig(queueStoreConfig);
    return config;
}
Also used : QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) Config(com.hazelcast.config.Config) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig)

Example 9 with QueueStoreConfig

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

the class DynamicConfigXmlGenerator method queueXmlGenerator.

public static void queueXmlGenerator(ConfigXmlGenerator.XmlGenerator gen, Config config) {
    Collection<QueueConfig> qCfgs = config.getQueueConfigs().values();
    for (QueueConfig q : qCfgs) {
        gen.open("queue", "name", q.getName()).node("priority-comparator-class-name", q.getPriorityComparatorClassName()).node("statistics-enabled", q.isStatisticsEnabled()).node("max-size", q.getMaxSize()).node("backup-count", q.getBackupCount()).node("async-backup-count", q.getAsyncBackupCount()).node("empty-queue-ttl", q.getEmptyQueueTtl());
        appendItemListenerConfigs(gen, q.getItemListenerConfigs());
        QueueStoreConfig storeConfig = q.getQueueStoreConfig();
        if (storeConfig != null) {
            gen.open("queue-store", "enabled", storeConfig.isEnabled()).node("class-name", classNameOrImplClass(storeConfig.getClassName(), storeConfig.getStoreImplementation())).node("factory-class-name", classNameOrImplClass(storeConfig.getFactoryClassName(), storeConfig.getFactoryImplementation())).appendProperties(storeConfig.getProperties()).close();
        }
        MergePolicyConfig mergePolicyConfig = q.getMergePolicyConfig();
        gen.node("split-brain-protection-ref", q.getSplitBrainProtectionName()).node("merge-policy", mergePolicyConfig.getPolicy(), "batch-size", mergePolicyConfig.getBatchSize()).close();
    }
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) QueueConfig(com.hazelcast.config.QueueConfig)

Example 10 with QueueStoreConfig

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

the class MemberDomConfigProcessor method createQueueStoreConfig.

private QueueStoreConfig createQueueStoreConfig(Node node) {
    QueueStoreConfig queueStoreConfig = new QueueStoreConfig();
    NamedNodeMap attributes = node.getAttributes();
    for (int a = 0; a < attributes.getLength(); a++) {
        Node att = attributes.item(a);
        if (matches(att.getNodeName(), "enabled")) {
            queueStoreConfig.setEnabled(getBooleanValue(getTextContent(att)));
        }
    }
    for (Node n : childElements(node)) {
        String nodeName = cleanNodeName(n);
        if (matches("class-name", nodeName)) {
            queueStoreConfig.setClassName(getTextContent(n));
        } else if (matches("factory-class-name", nodeName)) {
            queueStoreConfig.setFactoryClassName(getTextContent(n));
        } else if (matches("properties", nodeName)) {
            fillProperties(n, queueStoreConfig.getProperties());
        }
    }
    return queueStoreConfig;
}
Also used : QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node)

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