use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class ClientInterestNotifyDUnitTest method createServerCache.
/**
* create a server cache and start the server
*
* @throws Exception
*/
public static Integer createServerCache() throws Exception {
ClientInterestNotifyDUnitTest test = new ClientInterestNotifyDUnitTest();
Properties props = new Properties();
props.setProperty(DELTA_PROPAGATION, "false");
cacheServer = test.createCache(props);
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
factory.setConcurrencyChecksEnabled(false);
RegionAttributes attrs = factory.create();
cacheServer.createRegion(REGION_NAME1, attrs);
cacheServer.createRegion(REGION_NAME2, attrs);
cacheServer.createRegion(REGION_NAME3, attrs);
CacheServer server = cacheServer.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 ConnectionProxyJUnitTest method testDuplicateSeqIdLesserThanCurrentSeqIdBeingIgnored.
@Test
public void testDuplicateSeqIdLesserThanCurrentSeqIdBeingIgnored() {
int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
CacheServer server = null;
try {
try {
server = this.cache.addCacheServer();
server.setMaximumTimeBetweenPings(10000);
server.setPort(port3);
server.start();
} catch (Exception e) {
e.printStackTrace();
fail("Failed to create server");
}
try {
PoolFactory pf = PoolManager.createFactory();
pf.addServer("localhost", port3);
pf.setSubscriptionEnabled(true);
pf.setSubscriptionRedundancy(-1);
pf.setSubscriptionMessageTrackingTimeout(100000);
proxy = (PoolImpl) pf.create("clientPool");
EventID eid1 = new EventID(new byte[0], 1, 5);
if (proxy.verifyIfDuplicate(eid1)) {
fail(" eid1 can never be duplicate, it is being created for the first time! ");
}
EventID eid2 = new EventID(new byte[0], 1, 2);
if (!proxy.verifyIfDuplicate(eid2)) {
fail(" eid2 should be duplicate, seqId is less than highest (5)");
}
EventID eid3 = new EventID(new byte[0], 1, 3);
if (!proxy.verifyIfDuplicate(eid3)) {
fail(" eid3 should be duplicate, seqId is less than highest (5)");
}
assertTrue(!proxy.getThreadIdToSequenceIdMap().isEmpty());
proxy.destroy();
} catch (Exception ex) {
ex.printStackTrace();
fail("Failed to initialize client");
}
} finally {
if (server != null) {
server.stop();
}
}
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class ConnectionProxyJUnitTest method testTwoClientsHavingDifferentThreadIdMaps.
@Test
public void testTwoClientsHavingDifferentThreadIdMaps() {
int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
CacheServer server = null;
try {
try {
server = this.cache.addCacheServer();
server.setMaximumTimeBetweenPings(10000);
server.setPort(port3);
server.start();
} catch (Exception e) {
e.printStackTrace();
fail("Failed to create server");
}
try {
PoolFactory pf = PoolManager.createFactory();
pf.addServer("localhost", port3);
pf.setSubscriptionEnabled(true);
pf.setSubscriptionRedundancy(-1);
pf.setSubscriptionMessageTrackingTimeout(100000);
PoolImpl proxy1 = (PoolImpl) pf.create("clientPool1");
try {
PoolImpl proxy2 = (PoolImpl) pf.create("clientPool2");
try {
Map map1 = proxy1.getThreadIdToSequenceIdMap();
Map map2 = proxy2.getThreadIdToSequenceIdMap();
assertTrue(!(map1 == map2));
} finally {
proxy2.destroy();
}
} finally {
proxy1.destroy();
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Failed to initialize client");
}
} finally {
if (server != null) {
server.stop();
}
}
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class InterestListEndpointDUnitTest method createServerCache.
public static Integer createServerCache(Integer maxThreads) throws Exception {
new InterestListEndpointDUnitTest().createCache(new Properties());
RegionAttributes attrs = impl.createServerCacheAttributes();
cache.createRegion(REGION_NAME, attrs);
CacheServer server1 = cache.addCacheServer();
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
server1.setPort(port);
server1.setMaxThreads(maxThreads.intValue());
server1.setNotifyBySubscription(true);
server1.start();
return new Integer(server1.getPort());
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class InterestListDUnitTest method addCacheServer.
private static CacheServer addCacheServer() throws Exception {
CacheServer s = cache.addCacheServer();
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
s.setPort(port);
s.start();
return s;
}
Aggregations