Search in sources :

Example 21 with PoolFactory

use of org.apache.geode.cache.client.PoolFactory in project geode by apache.

the class DurableClientStatsDUnitTest method getClientPool.

private Pool getClientPool(String host, int server1Port, boolean establishCallbackConnection, int redundancyLevel) {
    PoolFactory pf = PoolManager.createFactory();
    pf.addServer(host, server1Port).setSubscriptionEnabled(establishCallbackConnection).setSubscriptionRedundancy(redundancyLevel);
    return ((PoolFactoryImpl) pf).getPoolAttributes();
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) PoolFactoryImpl(org.apache.geode.internal.cache.PoolFactoryImpl)

Example 22 with PoolFactory

use of org.apache.geode.cache.client.PoolFactory in project geode by apache.

the class ConnectionProxyJUnitTest method testCleanCloseOfThreadIdToSeqId.

@Test
public void testCleanCloseOfThreadIdToSeqId() {
    int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
    CacheServer server = null;
    try {
        try {
            server = this.cache.addCacheServer();
            server.setMaximumTimeBetweenPings(10000);
            server.setPort(port3);
            server.start();
        } catch (Exception e) {
            e.printStackTrace();
            fail("Failed to create server");
        }
        try {
            PoolFactory pf = PoolManager.createFactory();
            pf.addServer("localhost", port3);
            pf.setSubscriptionEnabled(true);
            pf.setSubscriptionRedundancy(-1);
            pf.setSubscriptionMessageTrackingTimeout(100000);
            proxy = (PoolImpl) pf.create("clientPool");
            EventID eid1 = new EventID(new byte[0], 1, 2);
            if (proxy.verifyIfDuplicate(eid1)) {
                fail(" eid can never be duplicate, it is being created for the first time! ");
            }
            EventID eid2 = new EventID(new byte[0], 1, 3);
            if (proxy.verifyIfDuplicate(eid2)) {
                fail(" eid can never be duplicate, since sequenceId is greater ");
            }
            if (!proxy.verifyIfDuplicate(eid2)) {
                fail(" eid had to be a duplicate, since sequenceId is equal ");
            }
            EventID eid3 = new EventID(new byte[0], 1, 1);
            if (!proxy.verifyIfDuplicate(eid3)) {
                fail(" eid had to be a duplicate, since sequenceId is lesser ");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            fail("Failed to initialize client");
        }
    } finally {
        if (server != null) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException ie) {
                fail("interrupted");
            }
            server.stop();
        }
    }
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) CacheServer(org.apache.geode.cache.server.CacheServer) EventID(org.apache.geode.internal.cache.EventID) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 23 with PoolFactory

use of org.apache.geode.cache.client.PoolFactory in project geode by apache.

the class ConnectionProxyJUnitTest method testThreadIdToSequenceIdMapConcurrency.

@Test
public void testThreadIdToSequenceIdMapConcurrency() {
    int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
    CacheServer server = null;
    try {
        try {
            server = this.cache.addCacheServer();
            server.setMaximumTimeBetweenPings(10000);
            server.setPort(port3);
            server.start();
        } catch (Exception e) {
            e.printStackTrace();
            fail("Failed to create server");
        }
        try {
            PoolFactory pf = PoolManager.createFactory();
            pf.addServer("localhost", port3);
            pf.setSubscriptionEnabled(true);
            pf.setSubscriptionRedundancy(-1);
            pf.setSubscriptionMessageTrackingTimeout(5000);
            pf.setSubscriptionAckInterval(2000);
            proxy = (PoolImpl) pf.create("clientPool");
            // why 10,000?
            final int EVENT_ID_COUNT = 10000;
            EventID[] eid = new EventID[EVENT_ID_COUNT];
            for (int i = 0; i < EVENT_ID_COUNT; i++) {
                eid[i] = new EventID(new byte[0], i, i);
                if (proxy.verifyIfDuplicate(eid[i])) {
                    fail(" eid can never be duplicate, it is being created for the first time! ");
                }
            }
            verifyExpiry(30 * 1000);
            for (int i = 0; i < EVENT_ID_COUNT; i++) {
                if (proxy.verifyIfDuplicate(eid[i])) {
                    fail(" eid can not be found to be  duplicate since the entry should have expired! " + i);
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            fail("Failed to initialize client");
        }
    } finally {
        if (server != null) {
            server.stop();
        }
    }
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) CacheServer(org.apache.geode.cache.server.CacheServer) EventID(org.apache.geode.internal.cache.EventID) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 24 with PoolFactory

use of org.apache.geode.cache.client.PoolFactory in project geode by apache.

the class ConnectionProxyJUnitTest method testThreadIdToSequenceIdMapCreation.

@Test
public void testThreadIdToSequenceIdMapCreation() {
    int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
    CacheServer server = null;
    try {
        try {
            server = this.cache.addCacheServer();
            server.setMaximumTimeBetweenPings(10000);
            server.setPort(port3);
            server.start();
        } catch (Exception e) {
            e.printStackTrace();
            fail("Failed to create server");
        }
        try {
            PoolFactory pf = PoolManager.createFactory();
            pf.addServer("localhost", port3);
            pf.setSubscriptionEnabled(true);
            pf.setSubscriptionRedundancy(-1);
            proxy = (PoolImpl) pf.create("clientPool");
            if (proxy.getThreadIdToSequenceIdMap() == null) {
                fail(" ThreadIdToSequenceIdMap is null. ");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            fail("Failed to initialize client");
        }
    } finally {
        if (server != null) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException ie) {
                fail("interrupted");
            }
            server.stop();
        }
    }
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) CacheServer(org.apache.geode.cache.server.CacheServer) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 25 with PoolFactory

use of org.apache.geode.cache.client.PoolFactory in project geode by apache.

the class ConnectionProxyJUnitTest method testThreadIdToSequenceIdMapExpiryNegative.

@Test
public void testThreadIdToSequenceIdMapExpiryNegative() {
    int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
    CacheServer server = null;
    try {
        try {
            server = this.cache.addCacheServer();
            server.setMaximumTimeBetweenPings(10000);
            server.setPort(port3);
            server.start();
        } catch (Exception e) {
            e.printStackTrace();
            fail("Failed to create server");
        }
        try {
            PoolFactory pf = PoolManager.createFactory();
            pf.addServer("localhost", port3);
            pf.setSubscriptionEnabled(true);
            pf.setSubscriptionRedundancy(-1);
            pf.setSubscriptionMessageTrackingTimeout(10000);
            proxy = (PoolImpl) pf.create("clientPool");
            final EventID eid = new EventID(new byte[0], 1, 1);
            if (proxy.verifyIfDuplicate(eid)) {
                fail(" eid should not be duplicate as it is a new entry");
            }
            WaitCriterion ev = new WaitCriterion() {

                public boolean done() {
                    return proxy.verifyIfDuplicate(eid);
                }

                public String description() {
                    return null;
                }
            };
            Wait.waitForCriterion(ev, 20 * 1000, 200, true);
        } catch (Exception ex) {
            ex.printStackTrace();
            fail("Failed to initialize client");
        }
    } finally {
        if (server != null) {
            server.stop();
        }
    }
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) CacheServer(org.apache.geode.cache.server.CacheServer) EventID(org.apache.geode.internal.cache.EventID) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

PoolFactory (org.apache.geode.cache.client.PoolFactory)66 Test (org.junit.Test)34 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)21 CacheServer (org.apache.geode.cache.server.CacheServer)16 Properties (java.util.Properties)15 AttributesFactory (org.apache.geode.cache.AttributesFactory)14 Host (org.apache.geode.test.dunit.Host)13 ClientServerTest (org.apache.geode.test.junit.categories.ClientServerTest)12 ClientSubscriptionTest (org.apache.geode.test.junit.categories.ClientSubscriptionTest)12 Cache (org.apache.geode.cache.Cache)11 Pool (org.apache.geode.cache.client.Pool)11 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)11 PoolFactoryImpl (org.apache.geode.internal.cache.PoolFactoryImpl)10 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)10 VM (org.apache.geode.test.dunit.VM)9 Region (org.apache.geode.cache.Region)8 EventID (org.apache.geode.internal.cache.EventID)8 IOException (java.io.IOException)7 ClientCache (org.apache.geode.cache.client.ClientCache)7 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)7