use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class CacheXml66DUnitTest method testDefaultCacheServerBindAddress.
@Test
public void testDefaultCacheServerBindAddress() throws Exception {
CacheCreation cache = new CacheCreation();
CacheServer bs = cache.addCacheServer();
bs.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
testXml(cache);
Cache c = getCache();
assertNotNull(c);
CacheServer server = (CacheServer) cache.getCacheServers().iterator().next();
assertNotNull(server);
assertEquals(CacheServer.DEFAULT_BIND_ADDRESS, server.getBindAddress());
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class CacheXml80DUnitTest method testCacheServerDisableTcpNoDelay.
@Test
public void testCacheServerDisableTcpNoDelay() throws Exception {
CacheCreation cache = new CacheCreation();
CacheServer cs = cache.addCacheServer();
cs.setPort(0);
cs.setTcpNoDelay(false);
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setDataPolicy(DataPolicy.NORMAL);
cache.createVMRegion("rootNORMAL", attrs);
testXml(cache);
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class ClientServerCCEDUnitTest method createServerRegion.
private int createServerRegion(VM vm, final String regionName, final boolean replicatedRegion) {
SerializableCallable createRegion = new SerializableCallable() {
public Object call() throws Exception {
// TombstoneService.VERBOSE = true;
AttributesFactory af = new AttributesFactory();
if (replicatedRegion) {
af.setScope(Scope.DISTRIBUTED_ACK);
af.setDataPolicy(DataPolicy.REPLICATE);
} else {
af.setDataPolicy(DataPolicy.PARTITION);
af.setPartitionAttributes((new PartitionAttributesFactory()).setTotalNumBuckets(2).create());
}
TestRegion = (LocalRegion) createRootRegion(regionName, af.create());
CacheServer server = getCache().addCacheServer();
int port = AvailablePortHelper.getRandomAvailableTCPPort();
server.setPort(port);
server.start();
return port;
}
};
return (Integer) vm.invoke(createRegion);
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class MultiVMRegionTestCase method versionTestGIISendsTombstones.
/*
* This test creates a server cache in vm0 and a peer cache in vm1. It then tests to see if GII
* transferred tombstones to vm1 like it's supposed to. A client cache is created in vm2 and the
* same sort of check is performed for register-interest.
*/
public void versionTestGIISendsTombstones() throws Exception {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
final int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
// create replicated regions in VM 0 and 1, then perform concurrent ops
// on the same key while creating the region in VM2. Afterward make
// sure that all three regions are consistent
final String name = this.getUniqueName() + "-CC";
SerializableRunnable createRegion = new SerializableRunnable("Create Region") {
@Override
public void run() {
try {
RegionFactory f = getCache().createRegionFactory(getRegionAttributes());
CCRegion = (LocalRegion) f.create(name);
if (VM.getCurrentVMNum() == 0) {
CacheServer bridge = CCRegion.getCache().addCacheServer();
bridge.setPort(serverPort);
try {
bridge.start();
} catch (IOException ex) {
fail("While creating bridge", ex);
}
}
} catch (CacheException ex) {
fail("While creating region", ex);
}
}
};
SerializableRunnable asserter = new SerializableRunnable("ensure tombstone has been received") {
@Override
public void run() {
RegionEntry entry = CCRegion.getRegionEntry("object2");
assertTrue(entry != null);
assertTrue(entry.isTombstone());
}
};
vm0.invoke(createRegion);
vm0.invoke(new SerializableRunnable("create some tombstones") {
@Override
public void run() {
CCRegion.put("object1", "value1");
CCRegion.put("object2", "value2");
CCRegion.put("object3", "value3");
CCRegion.destroy("object2");
}
});
try {
vm0.invoke(asserter);
vm1.invoke(createRegion);
vm1.invoke(asserter);
// vm2.invoke(createClientCache);
// vm2.invoke(asserter);
} finally {
disconnectAllFromDS();
}
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class ServerLauncherTest method testStartCacheServerWithExistingCacheServer.
@Test
public void testStartCacheServerWithExistingCacheServer() throws IOException {
final Cache mockCache = mockContext.mock(Cache.class, "Cache");
final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
mockContext.checking(new Expectations() {
{
oneOf(mockCache).getCacheServers();
will(returnValue(Collections.singletonList(mockCacheServer)));
}
});
final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").setDisableDefaultServer(false).build();
assertNotNull(serverLauncher);
assertEquals("serverOne", serverLauncher.getMemberName());
assertFalse(serverLauncher.isDisableDefaultServer());
serverLauncher.startCacheServer(mockCache);
}
Aggregations