use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class PDXAsyncEventQueueDUnitTest method createSystem.
protected void createSystem(VM vm, final boolean pdxPersistent) {
SerializableCallable createSystem = new SerializableCallable() {
public Object call() throws Exception {
Properties props = new Properties();
// props.setProperty(DistributionConfig.LOCATORS_NAME, "");
getSystem(props);
CacheFactory cf = new CacheFactory();
cf.setPdxPersistent(pdxPersistent);
getCache(cf);
return null;
}
};
vm.invoke(createSystem);
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class PdxAttributesJUnitTest method testNonPersistentRegistryWithOverflowRegion.
@Test
public void testNonPersistentRegistryWithOverflowRegion() throws Exception {
{
CacheFactory cf = new CacheFactory();
cf.set(MCAST_PORT, "0");
Cache cache = cf.create();
cache.createDiskStoreFactory().setDiskDirs(new File[] { diskDir }).setMaxOplogSize(1).create("diskstore1");
cache.createRegionFactory(RegionShortcut.LOCAL_OVERFLOW).setDiskStoreName("diskstore1").create("region");
defineAType();
}
tearDown();
setUp();
{
CacheFactory cf = new CacheFactory();
cf.set(MCAST_PORT, "0");
Cache cache = cf.create();
defineAType();
cache.createDiskStoreFactory().setDiskDirs(new File[] { diskDir }).setMaxOplogSize(1).create("diskstore1");
cache.createRegionFactory(RegionShortcut.LOCAL_OVERFLOW).setDiskStoreName("diskstore1").create("region");
}
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class PdxAttributesJUnitTest method testNonPersistentRegistryWithPersistentRegion.
@Test
public void testNonPersistentRegistryWithPersistentRegion() throws Exception {
{
CacheFactory cf = new CacheFactory();
cf.set(MCAST_PORT, "0");
Cache cache = cf.create();
cache.createDiskStoreFactory().setDiskDirs(new File[] { diskDir }).setMaxOplogSize(1).create("diskstore1");
cache.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT).setDiskStoreName("diskstore1").create("region");
try {
defineATypeNoEnum();
throw new RuntimeException("Should have received an exception");
} catch (PdxInitializationException expected) {
}
}
tearDown();
setUp();
{
CacheFactory cf = new CacheFactory();
cf.set(MCAST_PORT, "0");
Cache cache = cf.create();
defineATypeNoEnum();
cache.createDiskStoreFactory().setDiskDirs(new File[] { diskDir }).setMaxOplogSize(1).create("diskstore1");
try {
cache.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT).setDiskStoreName("diskStore1").create("region");
throw new RuntimeException("Should have received an exception");
} catch (PdxInitializationException expected) {
}
}
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class JSONPdxClientServerDUnitTest method createServerRegionWithPersistence.
private int createServerRegionWithPersistence(VM vm, final boolean persistentPdxRegistry) {
SerializableCallable createRegion = new SerializableCallable() {
public Object call() throws Exception {
CacheFactory cf = new CacheFactory();
if (persistentPdxRegistry) {
cf.setPdxPersistent(true).setPdxDiskStore("store");
}
//
Cache cache = getCache(cf);
cache.createDiskStoreFactory().setDiskDirs(getDiskDirs()).create("store");
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.DISTRIBUTED_ACK);
af.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
af.setDiskStoreName("store");
createRootRegion("testSimplePdx", af.create());
CacheServer server = getCache().addCacheServer();
int port = AvailablePortHelper.getRandomAvailableTCPPort();
server.setPort(port);
server.start();
return port;
}
};
return (Integer) vm.invoke(createRegion);
}
use of org.apache.geode.cache.CacheFactory in project geode by apache.
the class CacheXml66DUnitTest method testPdxAttributes.
@Test
public void testPdxAttributes() throws Exception {
CacheCreation creation = new CacheCreation();
creation.setPdxPersistent(true);
creation.setPdxReadSerialized(true);
creation.setPdxIgnoreUnreadFields(true);
creation.setPdxDiskStore("my_disk_store");
TestPdxSerializer serializer = new TestPdxSerializer();
Properties props = new Properties();
props.setProperty("hello", "there");
serializer.init(props);
creation.setPdxSerializer(serializer);
testXml(creation);
Cache c = getCache();
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
assertEquals("my_disk_store", c.getPdxDiskStore());
assertEquals(serializer, c.getPdxSerializer());
assertEquals(true, c.getPdxPersistent());
assertEquals(true, c.getPdxReadSerialized());
assertEquals(true, c.getPdxIgnoreUnreadFields());
// test that we can override the cache.xml attributes
{
closeCache();
CacheFactory cf = new CacheFactory();
cf.setPdxDiskStore("new disk store");
c = getCache(cf);
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
assertEquals("new disk store", c.getPdxDiskStore());
assertEquals(serializer, c.getPdxSerializer());
assertEquals(true, c.getPdxPersistent());
assertEquals(true, c.getPdxReadSerialized());
assertEquals(true, c.getPdxIgnoreUnreadFields());
}
{
closeCache();
CacheFactory cf = new CacheFactory();
cf.setPdxPersistent(false);
cf.setPdxIgnoreUnreadFields(false);
c = getCache(cf);
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
assertEquals("my_disk_store", c.getPdxDiskStore());
assertEquals(serializer, c.getPdxSerializer());
assertEquals(false, c.getPdxPersistent());
assertEquals(true, c.getPdxReadSerialized());
assertEquals(false, c.getPdxIgnoreUnreadFields());
}
{
closeCache();
CacheFactory cf = new CacheFactory();
cf.setPdxSerializer(null);
c = getCache(cf);
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
assertEquals("my_disk_store", c.getPdxDiskStore());
assertEquals(null, c.getPdxSerializer());
assertEquals(true, c.getPdxPersistent());
assertEquals(true, c.getPdxReadSerialized());
assertEquals(true, c.getPdxIgnoreUnreadFields());
}
{
closeCache();
CacheFactory cf = new CacheFactory();
cf.setPdxReadSerialized(false);
c = getCache(cf);
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
assertEquals("my_disk_store", c.getPdxDiskStore());
assertEquals(serializer, c.getPdxSerializer());
assertEquals(true, c.getPdxPersistent());
assertEquals(false, c.getPdxReadSerialized());
assertEquals(true, c.getPdxIgnoreUnreadFields());
}
}
Aggregations