Search in sources :

Example 46 with DistributedSystem

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

the class HAExpiryDUnitTest method createCache.

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

Example 47 with DistributedSystem

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

the class Bug36853EventsExpiryDUnitTest method createCache.

/**
   * Creates the cache
   * 
   * @param props - distributed system props
   * @throws Exception - thrown in any problem occurs in creating cache
   */
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 48 with DistributedSystem

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

the class Bug48571DUnitTest method createClientCache.

public static void createClientCache(Host host, Integer port) throws Exception {
    Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "");
    props.setProperty(DURABLE_CLIENT_ID, "durable-48571");
    props.setProperty(DURABLE_CLIENT_TIMEOUT, "300000");
    props.setProperty(LOG_FILE, "client_" + OSProcess.getId() + ".log");
    props.setProperty(LOG_LEVEL, "info");
    props.setProperty(STATISTIC_ARCHIVE_FILE, "client_" + OSProcess.getId() + ".gfs");
    props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
    ClientCacheFactory ccf = new ClientCacheFactory(props);
    ccf.setPoolSubscriptionEnabled(true);
    ccf.setPoolSubscriptionAckInterval(50);
    ccf.setPoolSubscriptionRedundancy(0);
    ccf.addPoolServer(host.getHostName(), port);
    DistributedSystem ds = new Bug48571DUnitTest().getSystem(props);
    ds.disconnect();
    cache = (GemFireCacheImpl) ccf.create();
    ClientRegionFactory<String, String> crf = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
    crf.setConcurrencyChecksEnabled(false);
    crf.addCacheListener(new CacheListenerAdapter<String, String>() {

        public void afterInvalidate(EntryEvent<String, String> event) {
            cache.getLoggerI18n().fine("Invalidate Event: " + event.getKey() + ", " + event.getNewValue());
            numOfInvalidates++;
        }

        public void afterCreate(EntryEvent<String, String> event) {
            if (((String) event.getKey()).equals("last_key")) {
                lastKeyReceived = true;
            }
            cache.getLoggerI18n().fine("Create Event: " + event.getKey() + ", " + event.getNewValue());
            numOfCreates++;
        }

        public void afterUpdate(EntryEvent<String, String> event) {
            cache.getLoggerI18n().fine("Update Event: " + event.getKey() + ", " + event.getNewValue());
            numOfUpdates++;
        }
    });
    Region<String, String> r = crf.create(region);
    r.registerInterest("ALL_KEYS", true);
    cache.readyForEvents();
}
Also used : Properties(java.util.Properties) DistributedSystem(org.apache.geode.distributed.DistributedSystem) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory)

Example 49 with DistributedSystem

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

the class Bug48879DUnitTest method createClientCache.

@SuppressWarnings("deprecation")
public static void createClientCache(Host host, Integer[] ports, Boolean doRI) throws Exception {
    Properties props = new Properties();
    props.setProperty(STATISTIC_ARCHIVE_FILE, "client_" + OSProcess.getId() + ".gfs");
    props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
    DistributedSystem ds = new Bug48879DUnitTest().getSystem(props);
    ds.disconnect();
    ClientCacheFactory ccf = new ClientCacheFactory(props);
    ccf.setPoolSubscriptionEnabled(doRI);
    ccf.setPoolSubscriptionAckInterval(50);
    ccf.setPoolSubscriptionRedundancy(1);
    for (int port : ports) {
        ccf.addPoolServer(host.getHostName(), port);
    }
    cache = (GemFireCacheImpl) ccf.create();
    ClientRegionFactory<String, String> crf = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
    Region<String, String> region = crf.create(REGION_NAME);
    if (doRI) {
        region.registerInterest("ALL_KEYS");
    }
}
Also used : ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DistributedSystem(org.apache.geode.distributed.DistributedSystem) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory)

Example 50 with DistributedSystem

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

the class PartitionedRegionLoaderWriterDUnitTest method createCache.

private void createCache(Properties props) {
    try {
        DistributedSystem ds = getSystem(props);
        assertNotNull(ds);
        ds.disconnect();
        ds = getSystem(props);
        cache = CacheFactory.create(ds);
        assertNotNull(cache);
    } catch (Exception e) {
        Assert.fail("Failed while creating the cache", e);
    }
}
Also used : DistributedSystem(org.apache.geode.distributed.DistributedSystem) CacheLoaderException(org.apache.geode.cache.CacheLoaderException)

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