use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class DeltaPropagationDUnitTest 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);
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class OffHeapEvictionDUnitTest method createCache.
@Override
public void createCache() {
try {
Properties props = new Properties();
DistributedSystem ds = getSystem(props);
assertNotNull(ds);
ds.disconnect();
ds = getSystem(getDistributedSystemProperties());
cache = CacheFactory.create(ds);
assertNotNull(cache);
LogWriterUtils.getLogWriter().info("cache= " + cache);
LogWriterUtils.getLogWriter().info("cache closed= " + cache.isClosed());
cache.getResourceManager().setEvictionOffHeapPercentage(85);
((GemFireCacheImpl) cache).getInternalResourceManager().getOffHeapMonitor().stopMonitoring(true);
LogWriterUtils.getLogWriter().info("eviction= " + cache.getResourceManager().getEvictionOffHeapPercentage());
LogWriterUtils.getLogWriter().info("critical= " + cache.getResourceManager().getCriticalOffHeapPercentage());
} catch (Exception e) {
Assert.fail("Failed while creating the cache", e);
}
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class MapInterfaceJUnitTest method testLocalPutAll.
/**
* Make sure putAll works on Scope.LOCAL (see bug 35087)
*/
@Test
public void testLocalPutAll() {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
DistributedSystem ds = DistributedSystem.connect(props);
Cache cache = null;
Region region = null;
AttributesFactory factory = null;
try {
cache = CacheFactory.create(ds);
factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
region = cache.createRegion("testingRegion", factory.create());
} catch (Exception e) {
throw new AssertionError(" failed due to ", e);
}
HashMap m = new HashMap();
m.put("aKey", "aValue");
m.put("bKey", "bValue");
region.putAll(m);
assertEquals("aValue", region.get("aKey"));
assertEquals("bValue", region.get("bKey"));
for (int i = 0; i < 100; i++) {
region.put(new Integer(i), new Integer(i));
}
assertEquals(new Integer(50), region.get(new Integer(50)));
region.localClear();
assertEquals(null, region.get(new Integer(50)));
region.close();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
try {
region = cache.createRegion("testingRegion", factory.create());
} catch (Exception e) {
throw new AssertionError(" failed in creating region due to ", e);
}
boolean exceptionOccurred = false;
try {
region.localClear();
} catch (UnsupportedOperationException e) {
exceptionOccurred = true;
}
if (!exceptionOccurred) {
fail(" exception did not occur when it was supposed to occur");
}
region.close();
cache.close();
ds.disconnect();
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class MapInterfaceJUnitTest method testBeforeRegionClearCallBack.
@Test
public void testBeforeRegionClearCallBack() {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
DistributedSystem ds = DistributedSystem.connect(props);
Cache cache = null;
Region region = null;
AttributesFactory factory = null;
try {
cache = CacheFactory.create(ds);
factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
factory.setCacheWriter(new CacheWriterAdapter() {
@Override
public void beforeRegionClear(RegionEvent event) throws CacheWriterException {
synchronized (this) {
this.notify();
MapInterfaceJUnitTest.this.hasBeenNotified = true;
}
}
});
region = cache.createRegion("testingRegion", factory.create());
DoesClear doesClear = new DoesClear(region);
new Thread(doesClear).start();
synchronized (this) {
if (!this.hasBeenNotified) {
this.wait(3000);
}
}
if (!this.hasBeenNotified) {
fail(" beforeRegionClear call back did not come");
}
} catch (Exception e) {
throw new AssertionError(" failed due to ", e);
}
for (int i = 0; i < 100; i++) {
region.put(new Integer(i), new Integer(i));
}
assertEquals(new Integer(50), region.get(new Integer(50)));
region.localClear();
assertEquals(null, region.get(new Integer(50)));
region.close();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
try {
region = cache.createRegion("testingRegion", factory.create());
} catch (Exception e) {
throw new AssertionError(" failed in creating region due to ", e);
}
boolean exceptionOccurred = false;
try {
region.localClear();
} catch (UnsupportedOperationException e) {
exceptionOccurred = true;
}
if (!exceptionOccurred) {
fail(" exception did not occur when it was supposed to occur");
}
region.close();
cache.close();
ds.disconnect();
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class PartitionedRegionSingleHopWithServerGroupDUnitTest method createClientWith3PoolLocator.
public static void createClientWith3PoolLocator(String host, int port0, String group1, String group2, String group3) {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
PartitionedRegionSingleHopWithServerGroupDUnitTest test = new PartitionedRegionSingleHopWithServerGroupDUnitTest();
DistributedSystem ds = test.getSystem(props);
cache = CacheFactory.create(ds);
assertNotNull(cache);
CacheServerTestUtil.disableShufflingOfEndpoints();
Pool p1, p2, p3;
try {
p1 = PoolManager.createFactory().addLocator(host, port0).setServerGroup(group1).setPingInterval(250).setSubscriptionEnabled(true).setSubscriptionRedundancy(-1).setReadTimeout(2000).setSocketBufferSize(1000).setMinConnections(6).setMaxConnections(10).setRetryAttempts(3).create(PR_NAME);
p2 = PoolManager.createFactory().addLocator(host, port0).setServerGroup(group2).setPingInterval(250).setSubscriptionEnabled(true).setSubscriptionRedundancy(-1).setReadTimeout(2000).setSocketBufferSize(1000).setMinConnections(6).setMaxConnections(10).setRetryAttempts(3).create(PR_NAME2);
p3 = PoolManager.createFactory().addLocator(host, port0).setServerGroup(group3).setPingInterval(250).setSubscriptionEnabled(true).setSubscriptionRedundancy(-1).setReadTimeout(2000).setSocketBufferSize(1000).setMinConnections(6).setMaxConnections(10).setRetryAttempts(3).create(PR_NAME3);
} finally {
CacheServerTestUtil.enableShufflingOfEndpoints();
}
createColocatedRegionsInClientCacheWithDiffPool(p1.getName(), p2.getName(), p3.getName());
}
Aggregations