Search in sources :

Example 36 with CacheServer

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

the class LocatorLoadBalancingDUnitTest method changeLoad.

private void changeLoad(final ServerLoad newLoad) {
    Cache cache = (Cache) remoteObjects.get(CACHE_KEY);
    CacheServer server = cache.getCacheServers().get(0);
    MyLoadProbe probe = (MyLoadProbe) server.getLoadProbe();
    probe.setLoad(newLoad);
}
Also used : CacheServer(org.apache.geode.cache.server.CacheServer) Cache(org.apache.geode.cache.Cache)

Example 37 with CacheServer

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

the class LocatorTestBase method startBridgeServer.

protected int startBridgeServer(final String[] groups, final String locators, final String[] regions, final ServerLoadProbe probe, final boolean useGroupsProperty) throws IOException {
    Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, locators);
    if (useGroupsProperty && groups != null) {
        props.setProperty(GROUPS, StringUtils.join(groups, ","));
    }
    DistributedSystem ds = getSystem(props);
    Cache cache = CacheFactory.create(ds);
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    factory.setEnableBridgeConflation(true);
    factory.setDataPolicy(DataPolicy.REPLICATE);
    RegionAttributes attrs = factory.create();
    for (int i = 0; i < regions.length; i++) {
        cache.createRegion(regions[i], attrs);
    }
    CacheServer server = cache.addCacheServer();
    server.setPort(0);
    if (!useGroupsProperty) {
        server.setGroups(groups);
    }
    server.setLoadProbe(probe);
    server.start();
    remoteObjects.put(CACHE_KEY, cache);
    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) Properties(java.util.Properties) DistributedSystem(org.apache.geode.distributed.DistributedSystem) Cache(org.apache.geode.cache.Cache)

Example 38 with CacheServer

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

the class LocatorTestBase method addCacheServer.

protected int addCacheServer(final String[] groups) throws IOException {
    Cache cache = (Cache) remoteObjects.get(CACHE_KEY);
    CacheServer server = cache.addCacheServer();
    server.setPort(0);
    server.setGroups(groups);
    server.start();
    return new Integer(server.getPort());
}
Also used : CacheServer(org.apache.geode.cache.server.CacheServer) Cache(org.apache.geode.cache.Cache)

Example 39 with CacheServer

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

the class CacheXml66DUnitTest method testCacheServerHostnameForClients.

@Test
public void testCacheServerHostnameForClients() throws Exception {
    CacheCreation cache = new CacheCreation();
    CacheServer bs = cache.addCacheServer();
    bs.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
    final String BA = ALIAS1;
    bs.setBindAddress(BA);
    bs.setHostnameForClients("clientHostName");
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    CacheServer server = (CacheServer) cache.getCacheServers().iterator().next();
    assertNotNull(server);
    assertEquals(BA, server.getBindAddress());
    assertEquals("clientHostName", server.getHostnameForClients());
}
Also used : CacheServer(org.apache.geode.cache.server.CacheServer) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) Test(org.junit.Test)

Example 40 with CacheServer

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

the class CacheXml66DUnitTest method testLoadPollInterval.

@Test
public void testLoadPollInterval() throws Exception {
    CacheCreation cache = new CacheCreation();
    CacheServer server = cache.addCacheServer();
    server.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
    server.setLoadPollInterval(12345);
    testXml(cache);
    Cache c = getCache();
    server = c.getCacheServers().get(0);
    assertEquals(12345, server.getLoadPollInterval());
}
Also used : CacheServer(org.apache.geode.cache.server.CacheServer) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) Test(org.junit.Test)

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