Search in sources :

Example 96 with CacheServer

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());
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) CacheServer(org.apache.geode.cache.server.CacheServer) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties)

Example 97 with CacheServer

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();
        }
    }
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) CacheServer(org.apache.geode.cache.server.CacheServer) EventID(org.apache.geode.internal.cache.EventID) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 98 with CacheServer

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();
        }
    }
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) CacheServer(org.apache.geode.cache.server.CacheServer) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl) Map(java.util.Map) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 99 with CacheServer

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());
}
Also used : RegionAttributes(org.apache.geode.cache.RegionAttributes) CacheServer(org.apache.geode.cache.server.CacheServer) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties)

Example 100 with CacheServer

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;
}
Also used : CacheServer(org.apache.geode.cache.server.CacheServer)

Aggregations

CacheServer (org.apache.geode.cache.server.CacheServer)323 AttributesFactory (org.apache.geode.cache.AttributesFactory)99 Properties (java.util.Properties)97 Test (org.junit.Test)77 Cache (org.apache.geode.cache.Cache)76 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)76 RegionAttributes (org.apache.geode.cache.RegionAttributes)60 IOException (java.io.IOException)53 ClientCache (org.apache.geode.cache.client.ClientCache)53 Region (org.apache.geode.cache.Region)50 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)49 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)33 Iterator (java.util.Iterator)31 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)31 ClientCacheFactory (org.apache.geode.cache.client.ClientCacheFactory)30 Host (org.apache.geode.test.dunit.Host)27 VM (org.apache.geode.test.dunit.VM)25 DistributedSystem (org.apache.geode.distributed.DistributedSystem)20 CacheException (org.apache.geode.cache.CacheException)17 CacheFactory (org.apache.geode.cache.CacheFactory)17