Search in sources :

Example 31 with PoolFactory

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

the class CQListGIIDUnitTest method createClientCache.

public static void createClientCache(Integer port1, Integer port2, Integer port3, String rLevel, Boolean addListener) throws Exception {
    CacheServerTestUtil.disableShufflingOfEndpoints();
    String host = NetworkUtils.getIPLiteral();
    Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "");
    new CQListGIIDUnitTest().createCache(props);
    PoolFactory pf = PoolManager.createFactory();
    int endPointCount = 1;
    pf.addServer(host, port1);
    if (port2.intValue() != -1) {
        pf.addServer(host, port2);
        endPointCount++;
    }
    if (port3.intValue() != -1) {
        pf.addServer(host, port3);
        endPointCount++;
    }
    pf.setRetryAttempts(5);
    pf.setReadTimeout(2500);
    pf.setSocketBufferSize(32768);
    pf.setPingInterval(1000);
    pf.setMinConnections(endPointCount * 2);
    pf.setSubscriptionRedundancy(Integer.parseInt(rLevel));
    pf.setSubscriptionEnabled(true).create("clientPool");
    try {
        cache.getQueryService();
    } catch (Exception cqe) {
        Assert.fail("Failed to getCQService.", cqe);
    }
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.LOCAL);
    factory.setPoolName("clientPool");
    RegionAttributes attrs = factory.create();
    createRegion(regions[0], "root", attrs);
    createRegion(regions[1], "root", attrs);
    logger = cache.getLogger();
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) CqAttributesFactory(org.apache.geode.cache.query.CqAttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException)

Example 32 with PoolFactory

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

the class QueryUsingPoolDUnitTest method createPool.

public void createPool(final String poolName, final String[] servers, final int[] ports, final boolean subscriptionEnabled) {
    // Create Cache.
    getCache(true);
    PoolFactory poolFactory = PoolManager.createFactory();
    poolFactory.setSubscriptionEnabled(subscriptionEnabled);
    for (int i = 0; i < servers.length; i++) {
        logger.info("### Adding to Pool. ### Server : " + servers[i] + " Port : " + ports[i]);
        poolFactory.addServer(servers[i], ports[i]);
    }
    poolFactory.setMinConnections(1);
    poolFactory.setMaxConnections(5);
    poolFactory.setRetryAttempts(5);
    poolFactory.create(poolName);
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory)

Example 33 with PoolFactory

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

the class CacheXml66DUnitTest method testExplicitConnectionPool.

/**
   * test for enabling PRsingleHop feature. Test for enabling multiuser-authentication attribute.
   */
@Test
public void testExplicitConnectionPool() throws Exception {
    getSystem();
    CacheCreation cache = new CacheCreation();
    PoolFactory f = cache.createPoolFactory();
    f.addServer(ALIAS2, 3777).addServer(ALIAS1, 3888);
    f.setFreeConnectionTimeout(12345).setLoadConditioningInterval(12345).setSocketBufferSize(12345).setThreadLocalConnections(true).setPRSingleHopEnabled(true).setReadTimeout(12345).setMinConnections(12346).setMaxConnections(12347).setRetryAttempts(12348).setIdleTimeout(12349).setPingInterval(12350).setStatisticInterval(12351).setServerGroup("mygroup").setSubscriptionRedundancy(12345).setSubscriptionMessageTrackingTimeout(12345).setSubscriptionAckInterval(333).setMultiuserAuthentication(true);
    f.create("mypool");
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setPoolName("mypool");
    // required for multiuser mode
    attrs.setDataPolicy(DataPolicy.EMPTY);
    cache.createVMRegion("rootNORMAL", attrs);
    IgnoredException.addIgnoredException("Connection refused: connect");
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    Region r = c.getRegion("rootNORMAL");
    assertNotNull(r);
    assertEquals("mypool", r.getAttributes().getPoolName());
    Pool cp = PoolManager.find("mypool");
    assertNotNull(cp);
    assertEquals(0, cp.getLocators().size());
    assertEquals(2, cp.getServers().size());
    assertEquals(createINSA(ALIAS2, 3777), cp.getServers().get(0));
    assertEquals(createINSA(ALIAS1, 3888), cp.getServers().get(1));
    assertEquals(12345, cp.getFreeConnectionTimeout());
    assertEquals(12345, cp.getLoadConditioningInterval());
    assertEquals(12345, cp.getSocketBufferSize());
    assertEquals(true, cp.getThreadLocalConnections());
    assertEquals(true, cp.getPRSingleHopEnabled());
    assertEquals(12345, cp.getReadTimeout());
    assertEquals(12346, cp.getMinConnections());
    assertEquals(12347, cp.getMaxConnections());
    assertEquals(12348, cp.getRetryAttempts());
    assertEquals(12349, cp.getIdleTimeout());
    assertEquals(12350, cp.getPingInterval());
    assertEquals(12351, cp.getStatisticInterval());
    assertEquals("mygroup", cp.getServerGroup());
    // TODO: commented this out until queues are implemented
    // assertIndexDetailsEquals(true, cp.getQueueEnabled());
    assertEquals(12345, cp.getSubscriptionRedundancy());
    assertEquals(12345, cp.getSubscriptionMessageTrackingTimeout());
    assertEquals(333, cp.getSubscriptionAckInterval());
    assertEquals(true, cp.getMultiuserAuthentication());
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) Pool(org.apache.geode.cache.client.Pool) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) Test(org.junit.Test)

Example 34 with PoolFactory

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

the class LauncherLifecycleCommandsDUnitTest method setupClientCache.

private ClientCache setupClientCache(final String durableClientId, final int serverPort) {
    ClientCache clientCache = new ClientCacheFactory().set(DURABLE_CLIENT_ID, durableClientId).create();
    PoolFactory poolFactory = PoolManager.createFactory();
    poolFactory.setMaxConnections(10);
    poolFactory.setMinConnections(1);
    poolFactory.setReadTimeout(5000);
    poolFactory.addServer("localhost", serverPort);
    Pool pool = poolFactory.create("serverConnectionPool");
    assertNotNull("The 'serverConnectionPool' was not properly configured and initialized!", pool);
    ClientRegionFactory<Long, String> regionFactory = clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
    regionFactory.setPoolName(pool.getName());
    regionFactory.setKeyConstraint(Long.class);
    regionFactory.setValueConstraint(String.class);
    Region<Long, String> exampleProxy = regionFactory.create("Example");
    assertNotNull("The 'Example' Client Region was not properly configured and initialized", exampleProxy);
    return clientCache;
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) Pool(org.apache.geode.cache.client.Pool) ClientCache(org.apache.geode.cache.client.ClientCache) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory)

Example 35 with PoolFactory

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

the class CacheXmlParser method startPool.

/**
   * @since GemFire 5.7
   */
private void startPool(Attributes atts) {
    PoolFactory f = this.cache.createPoolFactory();
    String name = atts.getValue(NAME).trim();
    stack.push(name);
    stack.push(f);
    String v;
    v = atts.getValue(FREE_CONNECTION_TIMEOUT);
    if (v != null) {
        f.setFreeConnectionTimeout(parseInt(v));
    }
    v = atts.getValue(LOAD_CONDITIONING_INTERVAL);
    if (v != null) {
        f.setLoadConditioningInterval(parseInt(v));
    }
    v = atts.getValue(MIN_CONNECTIONS);
    if (v != null) {
        f.setMinConnections(parseInt(v));
    }
    v = atts.getValue(MAX_CONNECTIONS);
    if (v != null) {
        f.setMaxConnections(parseInt(v));
    }
    v = atts.getValue(RETRY_ATTEMPTS);
    if (v != null) {
        f.setRetryAttempts(parseInt(v));
    }
    v = atts.getValue(IDLE_TIMEOUT);
    if (v != null) {
        f.setIdleTimeout(parseLong(v));
    }
    v = atts.getValue(PING_INTERVAL);
    if (v != null) {
        f.setPingInterval(parseLong(v));
    }
    v = atts.getValue(SUBSCRIPTION_ENABLED);
    if (v != null) {
        f.setSubscriptionEnabled(parseBoolean(v));
    }
    v = atts.getValue(PR_SINGLE_HOP_ENABLED);
    if (v != null) {
        f.setPRSingleHopEnabled(parseBoolean(v));
    }
    v = atts.getValue(SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT);
    if (v != null) {
        f.setSubscriptionMessageTrackingTimeout(parseInt(v));
    }
    v = atts.getValue(SUBSCRIPTION_ACK_INTERVAL);
    if (v != null) {
        f.setSubscriptionAckInterval(parseInt(v));
    }
    v = atts.getValue(SUBSCRIPTION_REDUNDANCY);
    if (v != null) {
        f.setSubscriptionRedundancy(parseInt(v));
    }
    v = atts.getValue(READ_TIMEOUT);
    if (v != null) {
        f.setReadTimeout(parseInt(v));
    }
    v = atts.getValue(SERVER_GROUP);
    if (v != null) {
        f.setServerGroup(v.trim());
    }
    v = atts.getValue(SOCKET_BUFFER_SIZE);
    if (v != null) {
        f.setSocketBufferSize(parseInt(v));
    }
    v = atts.getValue(STATISTIC_INTERVAL);
    if (v != null) {
        f.setStatisticInterval(parseInt(v));
    }
    v = atts.getValue(THREAD_LOCAL_CONNECTIONS);
    if (v != null) {
        f.setThreadLocalConnections(parseBoolean(v));
    }
    v = atts.getValue(MULTIUSER_SECURE_MODE_ENABLED);
    if (v != null) {
        f.setMultiuserAuthentication(parseBoolean(v));
    }
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory)

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