Search in sources :

Example 36 with PoolImpl

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

the class CacheServerTestUtil method createCacheClient.

public static void createCacheClient(Pool poolAttr, String regionName, Properties dsProperties, Boolean addControlListener, Properties javaSystemProperties) throws Exception {
    new CacheServerTestUtil().createCache(dsProperties);
    IgnoredException.addIgnoredException("java.net.ConnectException||java.net.SocketException");
    if (javaSystemProperties != null && javaSystemProperties.size() > 0) {
        Enumeration e = javaSystemProperties.propertyNames();
        while (e.hasMoreElements()) {
            String key = (String) e.nextElement();
            System.setProperty(key, javaSystemProperties.getProperty(key));
        }
    }
    PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory();
    pf.init(poolAttr);
    PoolImpl p = (PoolImpl) pf.create("CacheServerTestUtil");
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.LOCAL);
    factory.setPoolName(p.getName());
    if (addControlListener.booleanValue()) {
        factory.addCacheListener(new ControlListener());
    }
    RegionAttributes attrs = factory.create();
    cache.createRegion(regionName, attrs);
    pool = p;
}
Also used : Enumeration(java.util.Enumeration) AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl) PoolFactoryImpl(org.apache.geode.internal.cache.PoolFactoryImpl)

Example 37 with PoolImpl

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

the class CacheServerTransactionsDUnitTest method createClientCache.

public static void createClientCache(String host, Integer port) throws Exception {
    Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "");
    new CacheServerTransactionsDUnitTest().createCache(props);
    PoolImpl p = (PoolImpl) PoolManager.createFactory().addServer(host, port.intValue()).setSubscriptionEnabled(true).create("CacheServerTransctionDUnitTestPool2");
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.LOCAL);
    factory.setPoolName(p.getName());
    factory.setCacheListener(new CacheListenerAdapter() {

        public void afterDestroy(EntryEvent event) {
            synchronized (CacheServerTransactionsDUnitTest.class) {
                destroyed = true;
                CacheServerTransactionsDUnitTest.class.notify();
            }
        }

        public void afterInvalidate(EntryEvent event) {
            synchronized (CacheServerTransactionsDUnitTest.class) {
                invalidated = true;
                CacheServerTransactionsDUnitTest.class.notifyAll();
            }
        }
    });
    Region region1 = cache.createRegion(REGION_NAME, factory.create());
    assertNotNull(region1);
    pool = p;
    registerKeys();
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) CacheListenerAdapter(org.apache.geode.cache.util.CacheListenerAdapter) EntryEvent(org.apache.geode.cache.EntryEvent) Region(org.apache.geode.cache.Region) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl)

Example 38 with PoolImpl

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

the class ClearPropagationDUnitTest method acquireConnectionsAndClear.

public static void acquireConnectionsAndClear(String host) {
    try {
        Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
        assertNotNull(r1);
        String poolName = r1.getAttributes().getPoolName();
        assertNotNull(poolName);
        PoolImpl pool = (PoolImpl) PoolManager.find(poolName);
        assertNotNull(pool);
        Connection conn1 = pool.acquireConnection(new ServerLocation(host, PORT2));
        assertNotNull(conn1);
        assertEquals(PORT2, conn1.getServer().getPort());
        ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool);
        srp.clearOnForTestsOnly(conn1, new EventID(new byte[] { 1 }, 1, 1), null);
    } catch (Exception ex) {
        ex.printStackTrace();
        fail("while setting acquireConnections  " + ex);
    }
}
Also used : ServerLocation(org.apache.geode.distributed.internal.ServerLocation) ServerRegionProxy(org.apache.geode.cache.client.internal.ServerRegionProxy) Connection(org.apache.geode.cache.client.internal.Connection) Region(org.apache.geode.cache.Region) EventID(org.apache.geode.internal.cache.EventID) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl) CacheException(org.apache.geode.cache.CacheException)

Example 39 with PoolImpl

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

the class BackwardCompatibilityHigherVersionClientDUnitTest method createClientCache.

public static void createClientCache(String host, Integer port1) throws Exception {
    new BackwardCompatibilityHigherVersionClientDUnitTest();
    Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "");
    new BackwardCompatibilityHigherVersionClientDUnitTest().createCache(props);
    PoolImpl p = (PoolImpl) PoolManager.createFactory().addServer(host, port1.intValue()).setSubscriptionEnabled(true).setSubscriptionRedundancy(1).setThreadLocalConnections(true).setMinConnections(1).setFreeConnectionTimeout(200000).setReadTimeout(200000).setPingInterval(10000).setRetryAttempts(1).setSubscriptionAckInterval(CLIENT_ACK_INTERVAL).create("BackwardCompatibilityHigherVersionClientDUnitTest");
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    factory.setPoolName(p.getName());
    RegionAttributes attrs = factory.create();
    cache.createRegion(REGION_NAME, attrs);
}
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)

Example 40 with PoolImpl

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

the class Bug36269DUnitTest method createClientCache.

public static void createClientCache() throws Exception {
    Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "");
    new Bug36269DUnitTest().createCache(props);
    CacheServerTestUtil.disableShufflingOfEndpoints();
    PoolImpl p;
    String host = NetworkUtils.getServerHostName(Host.getHost(0));
    try {
        p = (PoolImpl) PoolManager.createFactory().addServer(host, PORT1).addServer(host, PORT2).setSubscriptionEnabled(true).setReadTimeout(2000).setSocketBufferSize(1000).setMinConnections(4).create("Bug36269DUnitTestPool");
    } finally {
        CacheServerTestUtil.enableShufflingOfEndpoints();
    }
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    factory.setPoolName(p.getName());
    pool = p;
    assertNotNull(pool);
    cache.createRegion(REGION_NAME, factory.create());
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl)

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