use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class StatsBugDUnitTest method stopServer.
/**
* Stops the cache server
*
*/
public static void stopServer() {
try {
Iterator iter = cache.getCacheServers().iterator();
if (iter.hasNext()) {
CacheServer server = (CacheServer) iter.next();
server.stop();
}
} catch (Exception e) {
fail("failed while stopServer()" + e);
}
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class ClientServerForceInvalidateDUnitTest method createServerCache.
private static Integer createServerCache(Boolean concurrencyChecksEnabled, Boolean partitioned, Integer maxThreads) throws Exception {
AbstractRegionMap.FORCE_INVALIDATE_EVENT = true;
Properties props = new Properties();
Cache cache = new ClientServerForceInvalidateDUnitTest().createCacheV(props);
RegionFactory<String, String> factory = cache.createRegionFactory();
if (partitioned) {
factory.setDataPolicy(DataPolicy.PARTITION);
factory.setPartitionAttributes(new PartitionAttributesFactory<String, String>().setRedundantCopies(0).setTotalNumBuckets(251).create());
} else {
factory.setDataPolicy(DataPolicy.REPLICATE);
}
factory.setConcurrencyChecksEnabled(concurrencyChecksEnabled);
factory.addCacheListener(new ServerListener());
Region<String, String> r1 = factory.create(REGION_NAME1);
assertNotNull(r1);
CacheServer server = cache.addCacheServer();
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
logger.info("Starting server on port " + port);
server.setPort(port);
server.setMaxThreads(maxThreads.intValue());
server.start();
logger.info("Started server on port " + server.getPort());
return new Integer(server.getPort());
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class ClientHealthMonitorJUnitTest method createServer.
/**
* Creates and starts the server instance
*
*/
private int createServer() {
CacheServer server = null;
try {
Properties p = new Properties();
// make it a loner
p.put(MCAST_PORT, "0");
p.put(LOCATORS, "");
this.system = DistributedSystem.connect(p);
this.cache = CacheFactory.create(system);
server = this.cache.addCacheServer();
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
server.setMaximumTimeBetweenPings(TIME_BETWEEN_PINGS);
server.setMaxThreads(getMaxThreads());
server.setPort(port);
server.start();
} catch (Exception e) {
e.printStackTrace();
fail("Failed to create server");
}
return server.getPort();
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class ConflationDUnitTest method createServerCache.
/**
* create a server cache and start the server
*
* @throws Exception
*/
public static Integer createServerCache() throws Exception {
ConflationDUnitTest test = new ConflationDUnitTest();
cache = test.createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setEnableConflation(true);
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME1, attrs);
cache.createRegion(REGION_NAME2, attrs);
CacheServer server = cache.addCacheServer();
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
server.setPort(port);
server.setNotifyBySubscription(true);
server.setSocketBufferSize(32768);
server.start();
return new Integer(server.getPort());
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class ClientServerMiscDUnitTest method createServerCache.
public static Integer createServerCache(Boolean notifyBySubscription, Integer maxThreads, boolean isHA) throws Exception {
Cache cache = new ClientServerMiscDUnitTest().createCacheV(new Properties());
unsetSlowDispatcherFlag();
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setEnableConflation(true);
factory.setDataPolicy(DataPolicy.REPLICATE);
RegionAttributes myAttrs = factory.create();
Region r1 = cache.createRegion(REGION_NAME1, myAttrs);
Region r2 = cache.createRegion(REGION_NAME2, myAttrs);
factory = new AttributesFactory();
factory.setDataPolicy(DataPolicy.PARTITION);
if (isHA) {
PartitionAttributesFactory paf = new PartitionAttributesFactory().setRedundantCopies(1);
factory.setPartitionAttributes(paf.create());
}
RegionAttributes prAttrs = factory.create();
Region pr = cache.createRegion(PR_REGION_NAME, prAttrs);
assertNotNull(r1);
assertNotNull(r2);
assertNotNull(pr);
CacheServer server = cache.addCacheServer();
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
r1.getCache().getDistributedSystem().getLogWriter().info("Starting server on port " + port);
server.setPort(port);
server.setMaxThreads(maxThreads.intValue());
server.setNotifyBySubscription(notifyBySubscription.booleanValue());
server.start();
r1.getCache().getDistributedSystem().getLogWriter().info("Started server on port " + server.getPort());
return new Integer(server.getPort());
}
Aggregations