use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class Bug33726JUnitTest method testAfterRegionCreate.
@Test
public void testAfterRegionCreate() {
Properties props = new Properties();
props.put(MCAST_PORT, "0");
DistributedSystem ds = DistributedSystem.connect(props);
AttributesFactory factory = new AttributesFactory();
factory.setCacheListener(new TestCacheListener());
Cache cache = null;
try {
cache = CacheFactory.create(ds);
Region region = cache.createRegion("testRegion", factory.create());
region.createSubregion("testSubRegion", factory.create());
} catch (Exception e) {
fail("Failed to create cache due to " + e);
e.printStackTrace();
}
if (!testFlag()) {
fail("After create sent although region was not initialized");
}
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class Bug34583JUnitTest method testBunchOfInvalidEntries.
@Test
public void testBunchOfInvalidEntries() throws Exception {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
DistributedSystem ds = DistributedSystem.connect(props);
try {
AttributesFactory factory = new AttributesFactory();
Cache cache = null;
cache = CacheFactory.create(ds);
Region r = cache.createRegion("testRegion", factory.create());
final int ENTRY_COUNT = 25000;
{
for (int i = 1; i <= ENTRY_COUNT; i++) {
r.put("key" + i, "value" + i);
}
}
{
// make sure iterator works while values are valid
Collection c = r.values();
assertEquals(ENTRY_COUNT, c.size());
Iterator it = c.iterator();
int count = 0;
while (it.hasNext()) {
it.next();
count++;
}
assertEquals(ENTRY_COUNT, count);
}
r.localInvalidateRegion();
// now we expect iterator to stackOverflow if bug 34583
{
Collection c = r.values();
assertEquals(0, c.size());
Iterator it = c.iterator();
int count = 0;
while (it.hasNext()) {
it.next();
count++;
}
assertEquals(0, count);
}
} finally {
ds.disconnect();
}
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class CacheAdvisorDUnitTest method getDistributionManagerId.
/**
* Accessed via reflection. DO NOT REMOVE
*/
protected InternalDistributedMember getDistributionManagerId() {
Cache cache = getCache();
DistributedSystem ds = cache.getDistributedSystem();
return ((InternalDistributedSystem) ds).getDistributionManager().getId();
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class MyFunctionException method createCache.
private void createCache(Properties props) {
try {
DistributedSystem ds = getSystem(props);
assertNotNull(ds);
ds.disconnect();
ds = getSystem(props);
cache = CacheFactory.create(ds);
LogWriterUtils.getLogWriter().info("Created Cache on peer");
assertNotNull(cache);
FunctionService.registerFunction(function);
} catch (Exception e) {
Assert.fail("DistributedRegionFunctionExecutionDUnitTest#createCache() Failed while creating the cache", e);
}
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class PRClientServerRegionFunctionExecutionFailoverDUnitTest method createServerWithLocator.
public int createServerWithLocator(String locator, boolean isAccessor, ArrayList commonAttrs) {
Properties props = new Properties();
props = new Properties();
props.setProperty(LOCATORS, locator);
DistributedSystem ds = getSystem(props);
cache = new CacheFactory(props).create(ds);
CacheServer server = cache.addCacheServer();
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
server.setPort(port);
server.setHostnameForClients("localhost");
try {
server.start();
} catch (IOException e) {
Assert.fail("Failed to start server ", e);
}
PartitionAttributesFactory paf = new PartitionAttributesFactory();
if (isAccessor) {
paf.setLocalMaxMemory(0);
}
paf.setTotalNumBuckets(((Integer) commonAttrs.get(3)).intValue()).setRedundantCopies(((Integer) commonAttrs.get(2)).intValue());
AttributesFactory attr = new AttributesFactory();
attr.setPartitionAttributes(paf.create());
region = cache.createRegion(regionName, attr.create());
assertNotNull(region);
LogWriterUtils.getLogWriter().info("Partitioned Region " + regionName + " created Successfully :" + region.toString());
return port;
}
Aggregations