Search in sources :

Example 71 with CacheFactory

use of org.apache.geode.cache.CacheFactory in project geode by apache.

the class SnapshotPerformanceDUnitTest method createCache.

private void createCache() throws Exception {
    SerializableCallable setup = new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            CacheFactory cf = new CacheFactory().setPdxSerializer(new MyPdxSerializer());
            getCache(cf);
            return null;
        }
    };
    SnapshotDUnitTest.forEachVm(setup, true);
}
Also used : MyPdxSerializer(com.examples.snapshot.MyPdxSerializer) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) CacheFactory(org.apache.geode.cache.CacheFactory)

Example 72 with CacheFactory

use of org.apache.geode.cache.CacheFactory in project geode by apache.

the class SnapshotTestCase method setUp.

@Before
public void setUp() throws Exception {
    store = new File("store-" + Math.abs(new Random().nextInt()));
    store.mkdir();
    snaps = new File("snapshots-" + Math.abs(new Random().nextInt()));
    snaps.mkdir();
    rgen = new RegionGenerator();
    CacheFactory cf = new CacheFactory().set(MCAST_PORT, "0").set(LOG_LEVEL, "error");
    cache = cf.create();
    ds = cache.createDiskStoreFactory().setMaxOplogSize(1).setDiskDirs(new File[] { store }).create("snapshotTest");
}
Also used : Random(java.util.Random) CacheFactory(org.apache.geode.cache.CacheFactory) File(java.io.File) Before(org.junit.Before)

Example 73 with CacheFactory

use of org.apache.geode.cache.CacheFactory in project geode by apache.

the class OffHeapValidationJUnitTest method createCache.

protected GemFireCacheImpl createCache() {
    Properties props = new Properties();
    props.setProperty(LOCATORS, "");
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(ConfigurationProperties.OFF_HEAP_MEMORY_SIZE, getOffHeapMemorySize());
    GemFireCacheImpl result = (GemFireCacheImpl) new CacheFactory(props).create();
    return result;
}
Also used : GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) CacheFactory(org.apache.geode.cache.CacheFactory)

Example 74 with CacheFactory

use of org.apache.geode.cache.CacheFactory in project geode by apache.

the class XmlUtilsAddNewNodeJUnitTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    cache = new CacheFactory().set(MCAST_PORT, "0").create();
    xPathContext.addNamespace(CacheXml.PREFIX, CacheXml.GEODE_NAMESPACE);
    xPathContext.addNamespace(TEST_PREFIX, TEST_NAMESPACE);
}
Also used : CacheFactory(org.apache.geode.cache.CacheFactory) BeforeClass(org.junit.BeforeClass)

Example 75 with CacheFactory

use of org.apache.geode.cache.CacheFactory in project geode by apache.

the class IntegrationJUnitTest method testMemcachedBindAddress.

@Test
public void testMemcachedBindAddress() throws Exception {
    Properties props = new Properties();
    final int port = AvailablePortHelper.getRandomAvailableTCPPort();
    props.setProperty(MEMCACHED_PORT, port + "");
    props.setProperty(MEMCACHED_BIND_ADDRESS, "127.0.0.1");
    props.put(MCAST_PORT, "0");
    CacheFactory cf = new CacheFactory(props);
    Cache cache = cf.create();
    MemcachedClient client = new MemcachedClient(new InetSocketAddress("127.0.0.1", port));
    Future<Boolean> f = client.add("key", 10, "myStringValue");
    assertTrue(f.get());
    Future<Boolean> f1 = client.add("key1", 10, "myStringValue1");
    assertTrue(f1.get());
    assertEquals("myStringValue", client.get("key"));
    assertEquals("myStringValue1", client.get("key1"));
    assertNull(client.get("nonExistentkey"));
    cache.close();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) MemcachedClient(net.spy.memcached.MemcachedClient) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) Cache(org.apache.geode.cache.Cache) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

CacheFactory (org.apache.geode.cache.CacheFactory)125 Properties (java.util.Properties)51 Test (org.junit.Test)51 Cache (org.apache.geode.cache.Cache)44 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)38 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)28 Region (org.apache.geode.cache.Region)21 ClientCacheFactory (org.apache.geode.cache.client.ClientCacheFactory)18 CacheServer (org.apache.geode.cache.server.CacheServer)17 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)17 File (java.io.File)15 Before (org.junit.Before)14 SerializationTest (org.apache.geode.test.junit.categories.SerializationTest)13 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)12 ClientCache (org.apache.geode.cache.client.ClientCache)11 Host (org.apache.geode.test.dunit.Host)11 IOException (java.io.IOException)10 AttributesFactory (org.apache.geode.cache.AttributesFactory)10 PdxType (org.apache.geode.pdx.internal.PdxType)9 MyPdxSerializer (com.examples.snapshot.MyPdxSerializer)8