Search in sources :

Example 51 with DistributedSystem

use of org.apache.geode.distributed.DistributedSystem in project geode by apache.

the class DurableClientQueueSizeDUnitTest method createClientCache.

@SuppressWarnings("deprecation")
public static void createClientCache(Host host, Integer[] ports, String timeoutSeconds, Boolean durable, Boolean multiPool, CacheListener cacheListener) throws Exception {
    if (multiPool) {
        System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "SPECIAL_DURABLE", "true");
    }
    Properties props = new Properties();
    if (durable) {
        props.setProperty(DURABLE_CLIENT_ID, MY_DURABLE_CLIENT);
        props.setProperty(DURABLE_CLIENT_TIMEOUT, timeoutSeconds);
    }
    DistributedSystem ds = new DurableClientQueueSizeDUnitTest().getSystem(props);
    ds.disconnect();
    ClientCacheFactory ccf = new ClientCacheFactory(props);
    ccf.setPoolSubscriptionEnabled(true);
    ccf.setPoolSubscriptionAckInterval(50);
    ccf.setPoolSubscriptionRedundancy(1);
    ccf.setPoolMaxConnections(1);
    for (int port : ports) {
        ccf.addPoolServer(host.getHostName(), port);
    }
    cache = (GemFireCacheImpl) ccf.create();
    ClientRegionFactory<String, String> crf = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
    if (cacheListener != null) {
        crf.addCacheListener(cacheListener);
    }
    crf.setPoolName(cache.getDefaultPool().getName());
    crf.create(REGION_NAME);
    if (multiPool) {
        String poolName = POOL_NAME;
        PoolFactory pf = PoolManager.createFactory();
        for (int port : ports) {
            pf.addServer(host.getHostName(), port);
        }
        pf.setSubscriptionEnabled(true);
        pf.create(poolName);
        crf.setPoolName(poolName);
        crf.create(NEW_REGION);
    }
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DistributedSystem(org.apache.geode.distributed.DistributedSystem) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory)

Example 52 with DistributedSystem

use of org.apache.geode.distributed.DistributedSystem in project geode by apache.

the class DestroyEntryPropagationDUnitTest method createCache.

private void createCache(Properties props) throws Exception {
    DistributedSystem ds = getSystem(props);
    cache = CacheFactory.create(ds);
    assertNotNull(cache);
}
Also used : DistributedSystem(org.apache.geode.distributed.DistributedSystem)

Example 53 with DistributedSystem

use of org.apache.geode.distributed.DistributedSystem in project geode by apache.

the class DSObjectLocalOnly method createCache.

private void createCache(Properties props) throws Exception {
    DistributedSystem ds = getSystem(props);
    ds.disconnect();
    ds = getSystem(props);
    assertNotNull(ds);
    cache = CacheFactory.create(ds);
    assertNotNull(cache);
}
Also used : DistributedSystem(org.apache.geode.distributed.DistributedSystem)

Example 54 with DistributedSystem

use of org.apache.geode.distributed.DistributedSystem in project geode by apache.

the class RegionCloseDUnitTest method createCache.

private void createCache(Properties props) throws Exception {
    DistributedSystem ds = getSystem(props);
    assertNotNull(ds);
    ds.disconnect();
    ds = getSystem(props);
    cache = CacheFactory.create(ds);
    assertNotNull(cache);
}
Also used : DistributedSystem(org.apache.geode.distributed.DistributedSystem)

Example 55 with DistributedSystem

use of org.apache.geode.distributed.DistributedSystem in project geode by apache.

the class UnregisterInterestDUnitTest method createCacheAndStartServer.

public static Integer createCacheAndStartServer() throws Exception {
    DistributedSystem ds = new UnregisterInterestDUnitTest().getSystem();
    ds.disconnect();
    Properties props = new Properties();
    props.setProperty(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
    CacheFactory cf = new CacheFactory(props);
    cache = cf.create();
    RegionFactory rf = ((GemFireCacheImpl) cache).createRegionFactory(RegionShortcut.REPLICATE);
    rf.create(regionname);
    CacheServer server = ((GemFireCacheImpl) cache).addCacheServer();
    server.setPort(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
    server.start();
    return server.getPort();
}
Also used : RegionFactory(org.apache.geode.cache.RegionFactory) ClientRegionFactory(org.apache.geode.cache.client.ClientRegionFactory) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) CacheServer(org.apache.geode.cache.server.CacheServer) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory) DistributedSystem(org.apache.geode.distributed.DistributedSystem)

Aggregations

DistributedSystem (org.apache.geode.distributed.DistributedSystem)250 Properties (java.util.Properties)102 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)65 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)61 Test (org.junit.Test)59 Cache (org.apache.geode.cache.Cache)55 AttributesFactory (org.apache.geode.cache.AttributesFactory)34 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)30 Region (org.apache.geode.cache.Region)24 IOException (java.io.IOException)20 CacheServer (org.apache.geode.cache.server.CacheServer)20 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)20 InternalCache (org.apache.geode.internal.cache.InternalCache)16 IgnoredException (org.apache.geode.test.dunit.IgnoredException)16 ArrayList (java.util.ArrayList)15 LogWriter (org.apache.geode.LogWriter)15 DistributedMember (org.apache.geode.distributed.DistributedMember)15 LocalRegion (org.apache.geode.internal.cache.LocalRegion)15 RegionAttributes (org.apache.geode.cache.RegionAttributes)14 Pool (org.apache.geode.cache.client.Pool)14