use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class TestFunction method executeFunctionReexecuteException.
private synchronized void executeFunctionReexecuteException(FunctionContext context) {
retryCountForExecuteFunctionReexecuteException++;
DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
LogWriter logger = ds.getLogWriter();
logger.fine("Executing executeException in TestFunction on Member : " + ds.getDistributedMember() + "with Context : " + context);
if (retryCountForExecuteFunctionReexecuteException >= 5) {
logger.fine("Tried Function Execution 5 times. Now Returning after 5 attempts");
context.getResultSender().lastResult(new Integer(retryCountForExecuteFunctionReexecuteException));
retryCountForExecuteFunctionReexecuteException = 0;
return;
}
if (context.getArguments() instanceof Boolean) {
logger.fine("MyFunctionExecutionException is intentionally thrown");
throw new FunctionInvocationTargetException(new MyFunctionExecutionException("I have been thrown from TestFunction"));
}
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class TestFunction method executeHAAndNonHAOnServer.
public void executeHAAndNonHAOnServer(FunctionContext context) {
List<CacheServer> servers = CacheFactory.getAnyInstance().getCacheServers();
ArrayList<String> args = (ArrayList<String>) context.getArguments();
Region r = CacheFactory.getAnyInstance().getRegion(args.get(0));
String testName = args.get(1);
Integer numTimesStopped = (Integer) r.get("stopped");
Integer numTimesSentResult = (Integer) r.get("sentresult");
if (context.isPossibleDuplicate()) {
if (testName.equals("serverExecutionHATwoServerDown")) {
if ((Integer) r.get("stopped") == 2) {
if (numTimesSentResult == null) {
r.put("sentresult", 1);
} else {
r.put("sentresult", ++numTimesSentResult);
}
context.getResultSender().lastResult(args.get(0));
} else {
r.put("stopped", ++numTimesStopped);
for (CacheServer s : servers) {
if (((CacheServerImpl) s).getSystem().getDistributedMember().equals(((GemFireCacheImpl) CacheFactory.getAnyInstance()).getMyId())) {
s.stop();
DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
ds.disconnect();
}
}
}
} else if (testName.equals("serverExecutionHAOneServerDown")) {
if (numTimesSentResult == null) {
r.put("sentresult", 1);
} else {
r.put("sentresult", ++numTimesSentResult);
}
context.getResultSender().lastResult(args.get(0));
} else {
context.getResultSender().lastResult(args.get(0));
}
} else {
if (numTimesStopped == null) {
r.put("stopped", 1);
} else {
r.put("stopped", ++numTimesStopped);
}
for (CacheServer s : servers) {
if (((CacheServerImpl) s).getSystem().getDistributedMember().equals(((GemFireCacheImpl) CacheFactory.getAnyInstance()).getMyId())) {
s.stop();
DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
ds.disconnect();
}
}
}
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class PutAllDUnitTest method createCache.
/** function to create cache **/
private void createCache(Properties props) throws Exception {
DistributedSystem ds = getSystem(props);
assertNotNull(ds);
ds.disconnect();
ds = getSystem(props);
cache = CacheFactory.create(ds);
assertNotNull(cache);
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class StatsBugDUnitTest method createCache.
/**
* Create the cache
*
* @param props - properties for DS
* @return the cache instance
* @throws Exception - thrown if any problem occurs in cache creation
*/
private Cache createCache(Properties props) throws Exception {
DistributedSystem ds = getSystem(props);
ds.disconnect();
ds = getSystem(props);
Cache cache = null;
cache = CacheFactory.create(ds);
if (cache == null) {
throw new Exception("CacheFactory.create() returned null ");
}
return cache;
}
use of org.apache.geode.distributed.DistributedSystem in project geode by apache.
the class HASlowReceiverDUnitTest 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);
}
Aggregations