Search in sources :

Example 86 with PoolImpl

use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.

the class FailoverDUnitTest method waitForPrimaryAndBackups.

public void waitForPrimaryAndBackups(final int numBackups) {
    final PoolImpl pool = (PoolImpl) PoolManager.find("FailoverPool");
    WaitCriterion ev = new WaitCriterion() {

        public boolean done() {
            if (pool.getPrimary() == null) {
                return false;
            }
            if (pool.getRedundants().size() < numBackups) {
                return false;
            }
            return true;
        }

        public String description() {
            return null;
        }
    };
    Wait.waitForCriterion(ev, 20 * 1000, 200, true);
    assertNotNull(pool.getPrimary());
    assertTrue("backups=" + pool.getRedundants() + " expected=" + numBackups, pool.getRedundants().size() >= numBackups);
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl)

Example 87 with PoolImpl

use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.

the class PRDeltaPropagationDUnitTest method createClientCache.

public static void createClientCache(Integer port1, Integer port2) throws Exception {
    PRDeltaPropagationDUnitTest test = new PRDeltaPropagationDUnitTest();
    Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "");
    test.createCache(props);
    lastKeyReceived = false;
    PoolImpl p = (PoolImpl) PoolManager.createFactory().addServer("localhost", port1).addServer("localhost", port2).setSubscriptionEnabled(true).setSubscriptionRedundancy(1).setThreadLocalConnections(true).setMinConnections(6).setReadTimeout(20000).setPingInterval(10000).setRetryAttempts(5).create("PRDeltaPropagationDUnitTestPool");
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.LOCAL);
    factory.setPoolName(p.getName());
    factory.setCloningEnabled(false);
    factory.setConcurrencyChecksEnabled(true);
    factory.addCacheListener(new CacheListenerAdapter() {

        @Override
        public void afterCreate(EntryEvent event) {
            if (LAST_KEY.equals(event.getKey())) {
                lastKeyReceived = true;
            }
        }
    });
    RegionAttributes attrs = factory.create();
    deltaPR = cache.createRegion(REGION_NAME, attrs);
    // deltaPR.create(DELTA_KEY, new PRDeltaTestImpl());
    deltaPR.registerInterest("ALL_KEYS");
    pool = p;
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) CqAttributesFactory(org.apache.geode.cache.query.CqAttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) CacheListenerAdapter(org.apache.geode.cache.util.CacheListenerAdapter) RegionAttributes(org.apache.geode.cache.RegionAttributes) EntryEvent(org.apache.geode.cache.EntryEvent) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl)

Example 88 with PoolImpl

use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.

the class WANTestBase method verifyPool.

public static void verifyPool(String senderId, boolean poolShouldExist, int expectedPoolLocatorsSize) {
    AbstractGatewaySender sender = (AbstractGatewaySender) cache.getGatewaySender(senderId);
    PoolImpl pool = sender.getProxy();
    if (poolShouldExist) {
        assertNotNull(pool);
        assertEquals(expectedPoolLocatorsSize, pool.getLocators().size());
    } else {
        assertNull(pool);
    }
}
Also used : PoolImpl(org.apache.geode.cache.client.internal.PoolImpl)

Example 89 with PoolImpl

use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.

the class DurableClientReconnectDUnitTest method createCacheClient.

private void createCacheClient(int redundancyLevel, final int durableClientTimeout, boolean queueEnabled) {
    try {
        final String durableClientId = "DurableClientReconnectDUnitTest_client";
        Properties props = getClientDistributedSystemProperties(durableClientId, durableClientTimeout);
        instance = new DurableClientReconnectDUnitTest();
        instance.createCache(props);
        // Host host = Host.getHost(0);
        PoolImpl p = (PoolImpl) getPoolFactory().setSubscriptionEnabled(queueEnabled).setReadTimeout(10000).setSubscriptionRedundancy(redundancyLevel).create("DurableClientReconnectDUnitTestPool");
        AttributesFactory factory = new AttributesFactory();
        factory.setScope(Scope.LOCAL);
        factory.setPoolName(p.getName());
        RegionAttributes attrs = factory.create();
        Region r = cache.createRegion(REGION_NAME, attrs);
        assertNotNull(r);
        pool = p;
        conn = pool.acquireConnection();
        assertNotNull(conn);
        cache.readyForEvents();
    } catch (Exception e) {
        Assert.fail("test failed due to ", e);
    }
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) Region(org.apache.geode.cache.Region) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl) SocketException(java.net.SocketException) IgnoredException(org.apache.geode.test.dunit.IgnoredException)

Example 90 with PoolImpl

use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.

the class TestSubscriptionsDUnitTest method createClientCache.

private Cache createClientCache(String host, int port1) throws Exception {
    Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "");
    Cache cache = createCache(props);
    PoolImpl p = (PoolImpl) PoolManager.createFactory().addServer(host, port1).setSubscriptionEnabled(true).setThreadLocalConnections(true).setMinConnections(1).setReadTimeout(20000).setPingInterval(10000).setRetryAttempts(1).setSubscriptionEnabled(true).setStatisticInterval(1000).create("TestSubscriptionsDUnitTest");
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    factory.setPoolName(p.getName());
    RegionAttributes attrs = factory.create();
    cache.createRegion(REGION_NAME, attrs);
    return cache;
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl) Cache(org.apache.geode.cache.Cache)

Aggregations

PoolImpl (org.apache.geode.cache.client.internal.PoolImpl)91 Properties (java.util.Properties)43 AttributesFactory (org.apache.geode.cache.AttributesFactory)40 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)39 Region (org.apache.geode.cache.Region)30 RegionAttributes (org.apache.geode.cache.RegionAttributes)29 Test (org.junit.Test)17 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)16 IOException (java.io.IOException)14 Pool (org.apache.geode.cache.client.Pool)14 VM (org.apache.geode.test.dunit.VM)14 Host (org.apache.geode.test.dunit.Host)13 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)12 LocalRegion (org.apache.geode.internal.cache.LocalRegion)11 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)11 CacheException (org.apache.geode.cache.CacheException)10 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)9 ClientSubscriptionTest (org.apache.geode.test.junit.categories.ClientSubscriptionTest)9 NoAvailableServersException (org.apache.geode.cache.client.NoAvailableServersException)8 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)8