Package com.hazelcast.test

Examples of com.hazelcast.test.TestHazelcastInstanceFactory


    private static HazelcastInstance local;
    private static HazelcastInstance remote;

    @BeforeClass
    public static void setUp() {
        instances = new TestHazelcastInstanceFactory(2).newInstances();
        warmUpPartitions(instances);
        local = instances[0];
        remote = instances[1];
    }
View Full Code Here


    @Test
    public void testEntryAdapterMapEvicted() {
        String mapName = randomMapName();
        Config cfg = new Config();

        TestHazelcastInstanceFactory instanceFactory = createHazelcastInstanceFactory(1);
        HazelcastInstance instance = instanceFactory.newHazelcastInstance(cfg);

        IMap map = instance.getMap(mapName);
        map.put(1, 1);
        map.put(2, 2);
View Full Code Here

    @Test
    public void testEntryAdapterMapCleared() {
        String mapName = randomMapName();
        Config cfg = new Config();
        TestHazelcastInstanceFactory instanceFactory = createHazelcastInstanceFactory(1);
        HazelcastInstance instance = instanceFactory.newHazelcastInstance(cfg);

        IMap map = instance.getMap(mapName);
        map.put(1, 1);
        map.put(2, 2);
View Full Code Here

        public ClientTestResource(Config config) {
            this.config = config;
        }

        protected void before() throws Throwable {
            instance = new TestHazelcastInstanceFactory(1).newHazelcastInstance(config);
            client = newClient(TestUtil.getNode(instance));
            client.auth();
        }
View Full Code Here

public class AdvancedSemaphoreTest extends HazelcastTestSupport {

    @Test(timeout = 120000)
    public void testSemaphoreWithFailures() throws InterruptedException {
        final int k = 4;
        final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(k + 1);
        final HazelcastInstance[] instances = factory.newInstances();
        final ISemaphore semaphore = instances[k].getSemaphore("test");
        int initialPermits = 20;

        semaphore.init(initialPermits);
View Full Code Here

        }
    }

    @Test(timeout = 120000)
    public void testSemaphoreWithFailuresAndJoin() {
        final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
        final HazelcastInstance instance1 = factory.newHazelcastInstance();
        final HazelcastInstance instance2 = factory.newHazelcastInstance();
        final ISemaphore semaphore = instance1.getSemaphore("test");
        final CountDownLatch countDownLatch = new CountDownLatch(1);

        assertTrue(semaphore.init(0));

        final Thread thread = new Thread() {
            public void run() {
                for (int i = 0; i < 2; i++) {
                    try {
                        semaphore.acquire();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                countDownLatch.countDown();
            }
        };
        thread.start();

        instance2.shutdown();
        semaphore.release();

        HazelcastInstance instance3 = factory.newHazelcastInstance();
        ISemaphore semaphore1 = instance3.getSemaphore("test");
        semaphore1.release();

        try {
            assertTrue(countDownLatch.await(15, TimeUnit.SECONDS));
View Full Code Here

    @Test
    public void testGracefulShutdown2() throws Exception {
        Config config = new Config();
        config.getMapConfig(MAP_NAME).setBackupCount(2);

        TestHazelcastInstanceFactory f = createHazelcastInstanceFactory(8);
        final HazelcastInstance hz = f.newHazelcastInstance(config);

        final IMap<Integer, Integer> map = hz.getMap(MAP_NAME);
        final int size = 50000;
        for (int i = 0; i < size; i++) {
            map.put(i, i);
        }

        final HazelcastInstance hz2 = f.newHazelcastInstance(config);
        final IMap<Integer, Integer> map2 = hz2.getMap(MAP_NAME);

        checkSizeEventually(size, map2);

        final HazelcastInstance hz3 = f.newHazelcastInstance(config);
        final IMap<Integer, Integer> map3 = hz3.getMap(MAP_NAME);

        final HazelcastInstance hz4 = f.newHazelcastInstance(config);
        final IMap<Integer, Integer> map4 = hz4.getMap(MAP_NAME);

        checkSizeEventually(size, map3);
        checkSizeEventually(size, map4);

        final HazelcastInstance hz5 = f.newHazelcastInstance(config);
        final IMap<Integer, Integer> map5 = hz5.getMap(MAP_NAME);

        final HazelcastInstance hz6 = f.newHazelcastInstance(config);
        final IMap<Integer, Integer> map6 = hz6.getMap(MAP_NAME);

        final HazelcastInstance hz7 = f.newHazelcastInstance(config);
        final IMap<Integer, Integer> map7 = hz7.getMap(MAP_NAME);

        final HazelcastInstance hz8 = f.newHazelcastInstance(config);
        final IMap<Integer, Integer> map8 = hz8.getMap(MAP_NAME);

        checkSizeEventually(size, map5);
        checkSizeEventually(size, map6);
        checkSizeEventually(size, map7);
View Full Code Here

        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());
View Full Code Here

        final IdCheckerQueueStore idCheckerQueueStore = new IdCheckerQueueStore();
        final QueueStoreConfig queueStoreConfig = new QueueStoreConfig();
        queueStoreConfig.setEnabled(true).setStoreImplementation(idCheckerQueueStore);
        queueConfig.setQueueStoreConfig(queueStoreConfig);

        final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
        final HazelcastInstance instance1 = factory.newHazelcastInstance(config);
        final HazelcastInstance instance2 = factory.newHazelcastInstance(config);

        final String name = generateKeyOwnedBy(instance1);
        final IQueue<Object> queue = instance2.getQueue(name);
        queue.offer(randomString());
        queue.offer(randomString());
View Full Code Here

    @Test
    public void testGracefulShutdown3() throws Exception {
        Config config = new Config();
        config.getMapConfig(MAP_NAME).setBackupCount(1);

        TestHazelcastInstanceFactory f = createHazelcastInstanceFactory(8);
        final HazelcastInstance hz = f.newHazelcastInstance(config);

        final IMap<Integer, Integer> map = hz.getMap(MAP_NAME);
        final int size = 50000;
        for (int i = 0; i < size; i++) {
            map.put(i, i);
        }

        final HazelcastInstance hz2 = f.newHazelcastInstance(config);
        final IMap<Integer, Integer> map2 = hz2.getMap(MAP_NAME);

        final HazelcastInstance hz3 = f.newHazelcastInstance(config);
        final IMap<Integer, Integer> map3 = hz3.getMap(MAP_NAME);

        final HazelcastInstance hz4 = f.newHazelcastInstance(config);
        final IMap<Integer, Integer> map4 = hz4.getMap(MAP_NAME);

        final HazelcastInstance hz5 = f.newHazelcastInstance(config);
        final IMap<Integer, Integer> map5 = hz5.getMap(MAP_NAME);

        final HazelcastInstance hz6 = f.newHazelcastInstance(config);
        final IMap<Integer, Integer> map6 = hz6.getMap(MAP_NAME);

        final HazelcastInstance hz7 = f.newHazelcastInstance(config);
        final IMap<Integer, Integer> map7 = hz7.getMap(MAP_NAME);

        final HazelcastInstance hz8 = f.newHazelcastInstance(config);
        final IMap<Integer, Integer> map8 = hz8.getMap(MAP_NAME);

        checkSizeEventually(size, map2);
        checkSizeEventually(size, map3);
        checkSizeEventually(size, map4);
View Full Code Here

TOP

Related Classes of com.hazelcast.test.TestHazelcastInstanceFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.