use of com.hazelcast.collection.impl.queue.model.VersionedObject 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.collection.impl.queue.model.VersionedObject in project hazelcast by hazelcast.
the class QueueTestsFrom2X method testQueuePollRollbackSize.
@Test
public void testQueuePollRollbackSize() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = factory.newHazelcastInstance(getConfig());
HazelcastInstance instance2 = factory.newHazelcastInstance(getConfig());
waitAllForSafeState(instance1, instance2);
TransactionContext context = instance1.newTransactionContext();
IQueue<VersionedObject<String>> queue = instance1.getQueue("testQueuePollRollbackSize");
queue.offer(new VersionedObject<>("item1", 1));
queue.offer(new VersionedObject<>("item2", 2));
assertEquals(2, queue.size());
context.beginTransaction();
TransactionalQueue<VersionedObject<String>> txnQ1 = context.getQueue("testQueuePollRollbackSize");
assertEquals(new VersionedObject<>("item1", 1), txnQ1.poll());
assertEquals(1, txnQ1.size());
assertEquals(1, queue.size());
context.rollbackTransaction();
assertEquals(2, queue.size());
assertEquals(new VersionedObject<>("item1", 1), queue.poll());
assertEquals(new VersionedObject<>("item2", 2), queue.poll());
}
use of com.hazelcast.collection.impl.queue.model.VersionedObject in project hazelcast by hazelcast.
the class QueueTestsFrom2X method testQueuePollCommitSize.
@Test
public void testQueuePollCommitSize() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = factory.newHazelcastInstance(getConfig());
HazelcastInstance instance2 = factory.newHazelcastInstance(getConfig());
waitAllForSafeState(instance1, instance2);
TransactionContext context = instance1.newTransactionContext();
context.beginTransaction();
TransactionalQueue<VersionedObject<String>> txnQ1 = context.getQueue("testQueuePollCommitSize");
TransactionalQueue<VersionedObject<String>> txnQ2 = context.getQueue("testQueuePollCommitSize");
txnQ1.offer(new VersionedObject<>("item1"));
txnQ1.offer(new VersionedObject<>("item2"));
assertEquals(2, txnQ1.size());
assertEquals(2, txnQ2.size());
assertEquals(new VersionedObject<>("item1"), txnQ1.poll());
assertEquals(1, txnQ1.size());
assertEquals(1, txnQ2.size());
context.commitTransaction();
assertEquals(1, instance1.getQueue("testQueuePollCommitSize").size());
assertEquals(1, instance2.getQueue("testQueuePollCommitSize").size());
assertEquals(new VersionedObject<>("item2"), instance1.getQueue("testQueuePollCommitSize").poll());
assertEquals(0, instance1.getQueue("testQueuePollCommitSize").size());
}
use of com.hazelcast.collection.impl.queue.model.VersionedObject in project hazelcast by hazelcast.
the class QueueTestsFrom2X method testQueueOfferCommitSize.
@Test
public void testQueueOfferCommitSize() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = factory.newHazelcastInstance(getConfig());
HazelcastInstance instance2 = factory.newHazelcastInstance(getConfig());
waitAllForSafeState(instance1, instance2);
TransactionContext context = instance1.newTransactionContext();
context.beginTransaction();
TransactionalQueue<VersionedObject<String>> txnQ1 = context.getQueue("testQueueOfferCommitSize");
TransactionalQueue<VersionedObject<String>> txnQ2 = context.getQueue("testQueueOfferCommitSize");
txnQ1.offer(new VersionedObject<>("item"));
assertEquals(1, txnQ1.size());
assertEquals(1, txnQ2.size());
context.commitTransaction();
assertEquals(1, instance1.getQueue("testQueueOfferCommitSize").size());
assertEquals(1, instance2.getQueue("testQueueOfferCommitSize").size());
assertEquals(new VersionedObject<>("item"), instance2.getQueue("testQueueOfferCommitSize").poll());
}
use of com.hazelcast.collection.impl.queue.model.VersionedObject in project hazelcast by hazelcast.
the class QueueTestsFrom2X method testQueueAddAll.
@Test
public void testQueueAddAll() {
HazelcastInstance instance = createHazelcastInstance();
IQueue<VersionedObject<String>> queue = instance.getQueue("testQueueAddAll");
@SuppressWarnings("unchecked") VersionedObject<String>[] items = new VersionedObject[] { new VersionedObject<>("one"), new VersionedObject<>("two"), new VersionedObject<>("three"), new VersionedObject<>("four") };
queue.addAll(asList(items));
assertEquals(4, queue.size());
queue.addAll(asList(items));
assertEquals(8, queue.size());
}
Aggregations