Search in sources :

Example 91 with CacheServer

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

Example 92 with CacheServer

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

Example 93 with CacheServer

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

Example 94 with CacheServer

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());
}
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 95 with CacheServer

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());
}
Also used : PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) CacheServer(org.apache.geode.cache.server.CacheServer) Properties(java.util.Properties) Cache(org.apache.geode.cache.Cache)

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