Search in sources :

Example 61 with PoolFactory

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

the class Tomcat8SessionsClientServerDUnitTest method setupServer.

// Set up the servers we need
public void setupServer(DeltaSessionManager manager) throws Exception {
    Host host = Host.getHost(0);
    vm0 = host.getVM(1);
    String hostName = vm0.getHost().getHostName();
    int cacheServerPort = vm0.invoke(() -> {
        Properties props = new Properties();
        CacheFactory cf = new CacheFactory(props);
        Cache cache = cf.create();
        CacheServer server = cache.addCacheServer();
        server.start();
        return server.getPort();
    });
    port = AvailablePortHelper.getRandomAvailableTCPPort();
    server = new EmbeddedTomcat8("/test", port, "JVM-1");
    ClientServerCacheLifecycleListener listener = new ClientServerCacheLifecycleListener();
    listener.setProperty(MCAST_PORT, "0");
    listener.setProperty(LOG_LEVEL, "config");
    server.addLifecycleListener(listener);
    sessionManager = manager;
    sessionManager.setEnableCommitValve(true);
    server.getRootContext().setManager(sessionManager);
    servlet = server.addServlet("/test/*", "default", CommandServlet.class.getName());
    server.startContainer();
    PoolFactory pf = PoolManager.createFactory();
    pf.addServer(hostName, cacheServerPort);
    pf.create("Pool Connecting to Cache Server");
    /*
     * Can only retrieve the region once the container has started up (and the cache has started
     * too).
     */
    region = sessionManager.getSessionCache().getSessionRegion();
    sessionManager.getTheContext().setSessionTimeout(30);
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) ClientServerCacheLifecycleListener(org.apache.geode.modules.session.catalina.ClientServerCacheLifecycleListener) CacheServer(org.apache.geode.cache.server.CacheServer) Host(org.apache.geode.test.dunit.Host) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) Cache(org.apache.geode.cache.Cache)

Example 62 with PoolFactory

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

the class Bug37805DUnitTest 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 63 with PoolFactory

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

the class Bug36829DUnitTest 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 64 with PoolFactory

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

the class CqDataUsingPoolDUnitTest method getClientPool.

private Pool getClientPool(String host, int serverPort) {
    PoolFactory pf = PoolManager.createFactory();
    pf.addServer(host, serverPort).setSubscriptionAckInterval(1).setSubscriptionEnabled(true);
    return ((PoolFactoryImpl) pf).getPoolAttributes();
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) PoolFactoryImpl(org.apache.geode.internal.cache.PoolFactoryImpl)

Example 65 with PoolFactory

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

the class CqDataUsingPoolDUnitTest method testCQWithEstablishCallBackConnection.

/**
   * Test for CQ with establishCallBackConnection.
   */
@Test
public void testCQWithEstablishCallBackConnection() throws Exception {
    final Host host = Host.getHost(0);
    VM server1 = host.getVM(0);
    VM client = host.getVM(1);
    cqDUnitTest.createServer(server1, 0, false, MirrorType.KEYS_VALUES);
    final int port1 = server1.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
    final String serverHost = NetworkUtils.getServerHostName(server1.getHost());
    final String poolName = "testCQWithEstablishCallBackConnection";
    client.invoke(new CacheSerializableRunnable("createPool :" + poolName) {

        @Override
        public void run2() throws CacheException {
            // Create Cache.
            getCache();
            PoolFactory cpf = PoolManager.createFactory();
            cpf.setSubscriptionEnabled(false);
            cpf.addServer(serverHost, port1);
            cpf.create(poolName);
        }
    });
    // Create CQs.
    cqDUnitTest.createCQ(client, poolName, "testCQWithEstablishCallBackConnection_0", cqDUnitTest.cqs[0]);
    // This should fail.
    try {
        cqDUnitTest.executeCQ(client, "testCQWithEstablishCallBackConnection_0", false, "CqException");
        fail("Test should have failed with connection with establishCallBackConnection not found.");
    } catch (Exception expected) {
    // Expected.
    }
    // Close.
    cqDUnitTest.closeClient(client);
    cqDUnitTest.closeServer(server1);
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) VM(org.apache.geode.test.dunit.VM) Host(org.apache.geode.test.dunit.Host) CqExistsException(org.apache.geode.cache.query.CqExistsException) CqException(org.apache.geode.cache.query.CqException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) CacheException(org.apache.geode.cache.CacheException) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Test(org.junit.Test)

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