use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class HADispatcherDUnitTest method createServerCache.
private Integer createServerCache(Boolean isListenerPresent) throws IOException {
createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
if (isListenerPresent.booleanValue() == true) {
CacheListener serverListener = new HAServerListener();
factory.setCacheListener(serverListener);
}
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME, attrs);
CacheServerImpl server = (CacheServerImpl) cache.addCacheServer();
assertNotNull(server);
int port = getRandomAvailablePort(SOCKET);
server.setPort(port);
server.setNotifyBySubscription(true);
server.start();
return new Integer(server.getPort());
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class CQListGIIDUnitTest method VerifyCUMCQList.
public static void VerifyCUMCQList(Integer numOfKeys, Integer numOfClients) {
try {
Iterator iter = cache.getCacheServers().iterator();
if (iter.hasNext()) {
CacheServerImpl server = (CacheServerImpl) iter.next();
Map haContainer = server.getAcceptor().getCacheClientNotifier().getHaContainer();
Object[] keys = haContainer.keySet().toArray();
logger.fine("### numOfKeys :" + numOfKeys.intValue() + " keys.length : " + keys.length + " haContainer size : " + haContainer.size());
assertEquals(numOfKeys.intValue(), keys.length);
for (int i = 0; i < numOfKeys.intValue(); i++) {
logger.fine("i=: " + i);
ClientUpdateMessageImpl cum = (ClientUpdateMessageImpl) haContainer.get(keys[i]);
assertNotNull(cum);
assertNotNull(cum.getClientCqs());
assertEquals("This test may fail if the image provider gets an ack from client before providing image", numOfClients.intValue(), cum.getClientCqs().size());
}
}
} catch (Exception e) {
Assert.fail("failed in VerifyCUMCQList()" + e, e);
}
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class DeltaToRegionRelationCQRegistrationDUnitTest method getBridgeServer.
/*
* get cache server / bridge server attacted to cache
*/
private static CacheServerImpl getBridgeServer() {
CacheServerImpl bridgeServer = (CacheServerImpl) cache.getCacheServers().iterator().next();
assertNotNull(bridgeServer);
return bridgeServer;
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class TestFunction method executeHAAndNonHAOnRegion.
public void executeHAAndNonHAOnRegion(FunctionContext context) {
List<CacheServer> servers = CacheFactory.getAnyInstance().getCacheServers();
ArrayList<String> args = (ArrayList<String>) context.getArguments();
RegionFunctionContext rfContext = (RegionFunctionContext) context;
rfContext.getDataSet().getCache().getLogger().info("Executing function : executeHAAndNonHAOnRegion " + rfContext);
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("regionExecutionHATwoServerDown")) {
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("regionExecutionHAOneServerDown")) {
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();
}
}
context.getResultSender().lastResult(args.get(0));
}
}
use of org.apache.geode.internal.cache.CacheServerImpl 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();
}
}
}
}
Aggregations