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();
}
}
}
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class Bug43684DUnitTest method createServerCache.
@SuppressWarnings("rawtypes")
public static Integer createServerCache(Boolean isReplicated, Boolean isPrimaryEmpty) throws Exception {
disconnectFromDS();
Properties props = new Properties();
props.setProperty(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
props.setProperty(STATISTIC_ARCHIVE_FILE, "server_" + OSProcess.getId() + ".gfs");
props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
CacheFactory cf = new CacheFactory(props);
cache = (GemFireCacheImpl) cf.create();
RegionFactory rf;
if (isReplicated) {
RegionShortcut rs = isPrimaryEmpty ? RegionShortcut.REPLICATE_PROXY : RegionShortcut.REPLICATE;
rf = cache.createRegionFactory(rs);
} else {
RegionShortcut rs = isPrimaryEmpty ? RegionShortcut.PARTITION_PROXY : RegionShortcut.PARTITION;
rf = cache.createRegionFactory(rs);
rf.setPartitionAttributes(new PartitionAttributesFactory().setTotalNumBuckets(numBuckets).create());
}
rf.create(REGION_NAME);
CacheServerImpl server = (CacheServerImpl) cache.addCacheServer();
server.setPort(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
server.start();
return server.getPort();
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class OperationsPropagationDUnitTest method createServerCache.
/**
* Create the server
*/
public static Integer createServerCache() throws Exception {
new OperationsPropagationDUnitTest().createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
RegionAttributes attrs = factory.create();
region = cache.createRegion(REGION_NAME, attrs);
CacheServerImpl server = (CacheServerImpl) cache.addCacheServer();
assertNotNull(server);
int port = AvailablePort.getRandomAvailablePort(AvailablePort.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 ClientServerMiscDUnitTest method verifyNoCacheClientProxyOnServer.
public static void verifyNoCacheClientProxyOnServer() {
try {
Cache cache = new ClientServerMiscDUnitTest().getCache();
assertEquals("More than one BridgeServer", 1, cache.getCacheServers().size());
CacheServerImpl bs = (CacheServerImpl) cache.getCacheServers().iterator().next();
assertNotNull(bs);
assertNotNull(bs.getAcceptor());
final CacheClientNotifier ccn = bs.getAcceptor().getCacheClientNotifier();
assertNotNull(ccn);
WaitCriterion wc = new WaitCriterion() {
String excuse;
public boolean done() {
return ccn.getClientProxies().size() == 0;
}
public String description() {
return excuse;
}
};
Wait.waitForCriterion(wc, 40 * 1000, 1000, true);
} catch (Exception ex) {
ex.printStackTrace();
fail("while setting verifyNoCacheClientProxyOnServer " + ex);
}
}
Aggregations