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