Search in sources :

Example 66 with CacheServer

use of org.apache.geode.cache.server.CacheServer in project geode by apache.

the class Bug36269DUnitTest method createServerCache.

public static Integer createServerCache() throws Exception {
    new Bug36269DUnitTest().createCache(new Properties());
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    factory.setMirrorType(MirrorType.KEYS_VALUES);
    cache.createRegion(REGION_NAME, factory.create());
    CacheServer server = cache.addCacheServer();
    assertNotNull(server);
    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
    server.setPort(port);
    server.setNotifyBySubscription(true);
    server.start();
    return new Integer(server.getPort());
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) CacheServer(org.apache.geode.cache.server.CacheServer) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties)

Example 67 with CacheServer

use of org.apache.geode.cache.server.CacheServer in project geode by apache.

the class Bug36805DUnitTest method createServerCache.

public static Integer createServerCache() throws Exception {
    new Bug36805DUnitTest().createCache(new Properties());
    // no region is created on server
    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
    CacheServer server1 = cache.addCacheServer();
    server1.setPort(port);
    server1.setNotifyBySubscription(true);
    server1.start();
    return new Integer(server1.getPort());
}
Also used : CacheServer(org.apache.geode.cache.server.CacheServer) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties)

Example 68 with CacheServer

use of org.apache.geode.cache.server.CacheServer in project geode by apache.

the class Bug36995DUnitTest method stopServer.

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);
    }
}
Also used : Iterator(java.util.Iterator) CacheServer(org.apache.geode.cache.server.CacheServer) IgnoredException(org.apache.geode.test.dunit.IgnoredException)

Example 69 with CacheServer

use of org.apache.geode.cache.server.CacheServer in project geode by apache.

the class CacheServerTestUtil method restartCacheServers.

public static void restartCacheServers() {
    Iterator iter = getCache().getCacheServers().iterator();
    if (iter.hasNext()) {
        CacheServer server = (CacheServer) iter.next();
        try {
            server.start();
        } catch (Exception e) {
            Assert.fail("Unexpected exception", e);
        }
        assertTrue(server.isRunning());
    }
}
Also used : Iterator(java.util.Iterator) CacheServer(org.apache.geode.cache.server.CacheServer) URISyntaxException(java.net.URISyntaxException) IgnoredException(org.apache.geode.test.dunit.IgnoredException)

Example 70 with CacheServer

use of org.apache.geode.cache.server.CacheServer in project geode by apache.

the class CacheServerTransactionsDUnitTest method createServerCache.

public static Integer createServerCache(Integer maxThreads) throws Exception {
    new CacheServerTransactionsDUnitTest().createCache(new Properties());
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    factory.setDataPolicy(DataPolicy.REPLICATE);
    factory.setCacheListener(new CacheListenerAdapter() {

        public void afterDestroy(EntryEvent event) {
            synchronized (CacheServerTransactionsDUnitTest.class) {
                destroyed = true;
                CacheServerTransactionsDUnitTest.class.notify();
            }
        }

        public void afterInvalidate(EntryEvent event) {
            synchronized (CacheServerTransactionsDUnitTest.class) {
                invalidated = true;
                CacheServerTransactionsDUnitTest.class.notifyAll();
            }
        }
    });
    Region r1 = cache.createRegion(REGION_NAME, factory.create());
    assertNotNull(r1);
    CacheServer server1 = cache.addCacheServer();
    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
    server1.setPort(port);
    server1.setMaxThreads(maxThreads.intValue());
    server1.setNotifyBySubscription(true);
    server1.start();
    createEntries();
    return new Integer(server1.getPort());
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) CacheListenerAdapter(org.apache.geode.cache.util.CacheListenerAdapter) EntryEvent(org.apache.geode.cache.EntryEvent) Region(org.apache.geode.cache.Region) CacheServer(org.apache.geode.cache.server.CacheServer) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties)

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