Search in sources :

Example 91 with PoolImpl

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

the class ClientCommandsDUnitTest method startNonSubscribedClient.

private void startNonSubscribedClient(VM client, final VM server, final int port) {
    client.invoke("Start client", () -> {
        Cache cache = GemFireCacheImpl.getInstance();
        if (cache == null) {
            Properties props = getNonDurableClientProps();
            props.setProperty(LOG_FILE, "client_" + OSProcess.getId() + ".log");
            props.setProperty(LOG_LEVEL, "fine");
            props.setProperty(STATISTIC_ARCHIVE_FILE, "client_" + OSProcess.getId() + ".gfs");
            props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
            getSystem(props);
            final ClientCacheFactory ccf = new ClientCacheFactory(props);
            ccf.addPoolServer(getServerHostName(server.getHost()), port);
            ccf.setPoolSubscriptionEnabled(false);
            ccf.setPoolPingInterval(1);
            ccf.setPoolStatisticInterval(1);
            ccf.setPoolSubscriptionRedundancy(1);
            ccf.setPoolMinConnections(1);
            ClientCache clientCache = (ClientCache) getClientCache(ccf);
            // Create region
            if (clientCache.getRegion(Region.SEPARATOR + regionName) == null && clientCache.getRegion(regionName) == null) {
                ClientRegionFactory regionFactory = clientCache.createClientRegionFactory(ClientRegionShortcut.LOCAL).setPoolName(clientCache.getDefaultPool().getName());
                Region dataRegion = regionFactory.create(regionName);
                assertNotNull(dataRegion);
                dataRegion.put("k1", "v1");
                dataRegion.put("k2", "v2");
            }
        } else {
            String poolName = "new_pool_" + System.currentTimeMillis();
            try {
                PoolImpl p = (PoolImpl) PoolManager.createFactory().addServer(getServerHostName(server.getHost()), port).setThreadLocalConnections(true).setMinConnections(1).setSubscriptionEnabled(false).setPingInterval(1).setStatisticInterval(1).setMinConnections(1).setSubscriptionRedundancy(1).create(poolName);
                cache.getLogger().info("Created new pool pool " + poolName);
                assertNotNull(p);
            } catch (Exception eee) {
                cache.getLogger().info("Exception in creating pool " + poolName + "    Exception ==" + CliUtil.stackTraceAsString(eee));
            }
        }
    });
}
Also used : DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) 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