use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.
the class ClusterMembershipTest method testMembershipListenerSequentialInvocation.
@Test
public void testMembershipListenerSequentialInvocation() throws Exception {
final int nodeCount = 10;
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
final CountDownLatch eventLatch = new CountDownLatch(nodeCount - 1);
final CountDownLatch nodeLatch = new CountDownLatch(nodeCount - 1);
Config config = new Config().addListenerConfig(new ListenerConfig().setImplementation(newAddMemberListener(eventLatch)));
// first node has listener
factory.newHazelcastInstance(config);
for (int i = 1; i < nodeCount; i++) {
executorService.execute(new Runnable() {
public void run() {
factory.newHazelcastInstance(new Config());
nodeLatch.countDown();
}
});
}
assertOpenEventually(nodeLatch);
assertOpenEventually(eventLatch);
}
use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.
the class TransactionListTest method testMigrationSerializationNotFails_whenTransactionsAreUsed.
@Test
public void testMigrationSerializationNotFails_whenTransactionsAreUsed() throws Exception {
Config config = new Config();
config.setProperty("hazelcast.partition.count", "2");
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = factory.newHazelcastInstance(config);
String listName = randomString();
TransactionContext tr = instance1.newTransactionContext();
tr.beginTransaction();
TransactionalList<Object> list = tr.getList(listName);
for (int i = 0; i < 10; i++) {
list.add(i);
}
tr.commitTransaction();
HazelcastInstance instance2 = factory.newHazelcastInstance(config);
Member owner = instance1.getPartitionService().getPartition(listName).getOwner();
HazelcastInstance aliveInstance;
if (instance1.getCluster().getLocalMember().equals(owner)) {
instance1.shutdown();
aliveInstance = instance2;
} else {
instance2.shutdown();
aliveInstance = instance1;
}
IList<Object> l = aliveInstance.getList(listName);
for (int i = 0; i < 10; i++) {
assertEquals(i, l.get(i));
}
}
use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.
the class TransactionQueueTest method testIssue859And863_WhenInQueueOnSecondInstance_OutQueueOnFirstInstance.
@Test
public void testIssue859And863_WhenInQueueOnSecondInstance_OutQueueOnFirstInstance() throws Exception {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = factory.newHazelcastInstance();
HazelcastInstance instance2 = factory.newHazelcastInstance();
String inQueueName = generateKeyOwnedBy(instance2);
String outQueueName = generateKeyOwnedBy(instance1);
testIssue859And863(instance1, instance2, inQueueName, outQueueName);
}
use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.
the class QueueStoreTest method testQueueStore.
@Test
public void testQueueStore() throws Exception {
Config config = new Config();
int maxSize = 2000;
QueueConfig queueConfig = config.getQueueConfig("testQueueStore");
queueConfig.setMaxSize(maxSize);
TestQueueStore queueStore = new TestQueueStore(1000, 0, 2000, 0, 0, 0, 1);
QueueStoreConfig queueStoreConfig = new QueueStoreConfig();
queueStoreConfig.setStoreImplementation(queueStore);
queueConfig.setQueueStoreConfig(queueStoreConfig);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance = factory.newHazelcastInstance(config);
for (int i = 0; i < maxSize / 2; i++) {
queueStore.store.put((long) i, i);
}
IQueue<Object> queue = instance.getQueue("testQueueStore");
for (int i = 0; i < maxSize / 2; i++) {
queue.offer(i + maxSize / 2);
}
instance.shutdown();
HazelcastInstance instance2 = factory.newHazelcastInstance(config);
IQueue<Object> queue2 = instance2.getQueue("testQueueStore");
assertEquals(maxSize, queue2.size());
assertEquals(maxSize, queueStore.store.size());
for (int i = 0; i < maxSize; i++) {
assertEquals(i, queue2.poll());
}
queueStore.assertAwait(3);
}
use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.
the class QueueStoreTest method testStoreId_whenNodeDown.
@Test
public void testStoreId_whenNodeDown() {
Config config = new Config();
QueueConfig queueConfig = config.getQueueConfig("default");
IdCheckerQueueStore idCheckerQueueStore = new IdCheckerQueueStore();
QueueStoreConfig queueStoreConfig = new QueueStoreConfig();
queueStoreConfig.setEnabled(true).setStoreImplementation(idCheckerQueueStore);
queueConfig.setQueueStoreConfig(queueStoreConfig);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = factory.newHazelcastInstance(config);
HazelcastInstance instance2 = factory.newHazelcastInstance(config);
String name = generateKeyOwnedBy(instance1);
IQueue<Object> queue = instance2.getQueue(name);
queue.offer(randomString());
queue.offer(randomString());
queue.offer(randomString());
instance1.shutdown();
queue.offer(randomString());
}
Aggregations