Search in sources :

Example 11 with ClientSubscriptionConfig

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

the class CacheXml66DUnitTest method testBridgeAttributesRelatedToHAOverFlow.

/**
   * Tests the client subscription attributes ({@code eviction-policy}, {@code capacity} and
   * {@code overflow-directory}) related to client subscription config in gemfire cache-server
   * framework
   *
   * @since GemFire 5.7
   */
@Test
public void testBridgeAttributesRelatedToHAOverFlow() throws Exception {
    CacheCreation cache = new CacheCreation();
    cache.setMessageSyncInterval(3445);
    CacheServer bs = cache.addCacheServer();
    ClientSubscriptionConfig csc = bs.getClientSubscriptionConfig();
    csc.setEvictionPolicy("entry");
    cache.getLogger().config("EvictionPolicy : " + csc.getEvictionPolicy());
    csc.setCapacity(501);
    cache.getLogger().config("EvictionCapacity : " + csc.getCapacity());
    csc.setOverflowDirectory("overFlow");
    cache.getLogger().config("EvictionOverflowDirectory : " + csc.getOverflowDirectory());
    bs.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setDataPolicy(DataPolicy.NORMAL);
    cache.createVMRegion("rootNORMAL", attrs);
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    CacheServer server = (CacheServer) cache.getCacheServers().iterator().next();
    assertNotNull(server);
    ClientSubscriptionConfig chaqf = server.getClientSubscriptionConfig();
    assertEquals("entry", chaqf.getEvictionPolicy());
    assertEquals(501, chaqf.getCapacity());
    assertEquals("overFlow", chaqf.getOverflowDirectory());
}
Also used : ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig) CacheServer(org.apache.geode.cache.server.CacheServer) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) 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 12 with ClientSubscriptionConfig

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

the class CacheServerCreation method sameAs.

/**
   * Returns whether or not this bridge server has the same configuration as another bridge server.
   */
@Override
public boolean sameAs(CacheServer other) {
    ClientSubscriptionConfig cscThis = this.getClientSubscriptionConfig();
    ClientSubscriptionConfig cscOther = other.getClientSubscriptionConfig();
    boolean result = isCacheServerPortEquals(other) && this.getSocketBufferSize() == other.getSocketBufferSize() && this.getMaximumTimeBetweenPings() == other.getMaximumTimeBetweenPings() && this.getNotifyBySubscription() == other.getNotifyBySubscription() && this.getMaxConnections() == other.getMaxConnections() && this.getMaxThreads() == other.getMaxThreads() && this.getMaximumMessageCount() == other.getMaximumMessageCount() && this.getMessageTimeToLive() == other.getMessageTimeToLive() && this.getTcpNoDelay() == other.getTcpNoDelay() && cscThis.getCapacity() == cscOther.getCapacity() && cscThis.getEvictionPolicy().equals(cscOther.getEvictionPolicy());
    String diskStoreName = cscThis.getDiskStoreName();
    if (diskStoreName != null) {
        result = result && diskStoreName.equals(cscOther.getDiskStoreName());
    } else {
        result = result && cscThis.getOverflowDirectory().equals(cscOther.getOverflowDirectory());
    }
    return result;
}
Also used : ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig)

Example 13 with ClientSubscriptionConfig

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

the class CacheXmlParser method endCacheServer.

/**
   * set attributes from clientHaQueue when we finish a cache server
   */
private void endCacheServer() {
    List groups = new ArrayList();
    ServerLoadProbe probe = null;
    ClientHaQueueCreation haCreation = null;
    if (stack.peek() instanceof ServerLoadProbe) {
        probe = (ServerLoadProbe) stack.pop();
    }
    if (stack.peek() instanceof ClientHaQueueCreation) {
        haCreation = (ClientHaQueueCreation) stack.pop();
    }
    while (stack.peek() instanceof String) {
        groups.add(stack.pop());
    }
    CacheServer bs = (CacheServer) stack.pop();
    if (groups.size() > 0) {
        Collections.reverse(groups);
        String[] groupArray = new String[groups.size()];
        groups.toArray(groupArray);
        bs.setGroups(groupArray);
    }
    if (probe != null) {
        bs.setLoadProbe(probe);
    }
    if (haCreation != null) {
        ClientSubscriptionConfig csc = bs.getClientSubscriptionConfig();
        String diskStoreName = haCreation.getDiskStoreName();
        if (diskStoreName != null) {
            csc.setDiskStoreName(diskStoreName);
        } else {
            csc.setOverflowDirectory(haCreation.getOverflowDirectory() == null ? ClientSubscriptionConfig.DEFAULT_OVERFLOW_DIRECTORY : haCreation.getOverflowDirectory());
        }
        csc.setCapacity(haCreation.getCapacity());
        csc.setEvictionPolicy(haCreation.getEvictionPolicy());
    }
}
Also used : ArrayList(java.util.ArrayList) ServerLoadProbe(org.apache.geode.cache.server.ServerLoadProbe) ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig) CacheServer(org.apache.geode.cache.server.CacheServer) ArrayList(java.util.ArrayList) List(java.util.List)

Example 14 with ClientSubscriptionConfig

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

the class CacheXml66DUnitTest method testClientSubscriptionQueueUsingDefaultDS.

@Test
public void testClientSubscriptionQueueUsingDefaultDS() throws Exception {
    CacheCreation cache = new CacheCreation();
    cache.setMessageSyncInterval(3445);
    CacheServer bs = cache.addCacheServer();
    ClientSubscriptionConfig csc = bs.getClientSubscriptionConfig();
    csc.setEvictionPolicy("entry");
    cache.getLogger().config("EvictionPolicy : " + csc.getEvictionPolicy());
    csc.setCapacity(501);
    // don't set diskstore or overflowdir
    cache.getLogger().config("EvictionCapacity : " + csc.getCapacity());
    cache.getLogger().config("Eviction disk store : " + csc.getDiskStoreName());
    bs.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setDataPolicy(DataPolicy.NORMAL);
    cache.createVMRegion("rootNORMAL", attrs);
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    CacheServer server = (CacheServer) cache.getCacheServers().iterator().next();
    assertNotNull(server);
    ClientSubscriptionConfig chaqf = server.getClientSubscriptionConfig();
    assertEquals("entry", chaqf.getEvictionPolicy());
    assertEquals(501, chaqf.getCapacity());
    File curDir = new File(".").getAbsoluteFile();
    File lockFile = new File(curDir, "DRLK_IF" + GemFireCacheImpl.getDefaultDiskStoreName() + ".lk");
    assertTrue(lockFile.exists());
}
Also used : ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig) CacheServer(org.apache.geode.cache.server.CacheServer) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) File(java.io.File) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) Test(org.junit.Test)

Example 15 with ClientSubscriptionConfig

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

the class CacheServerImpl method configureFrom.

/**
   * Sets the configuration of <b>this</b>{@code CacheServer} based on the configuration of
   * <b>another</b>{@code CacheServer}.
   */
public void configureFrom(CacheServer other) {
    setPort(other.getPort());
    setBindAddress(other.getBindAddress());
    setHostnameForClients(other.getHostnameForClients());
    setMaxConnections(other.getMaxConnections());
    setMaxThreads(other.getMaxThreads());
    setNotifyBySubscription(other.getNotifyBySubscription());
    setSocketBufferSize(other.getSocketBufferSize());
    setTcpNoDelay(other.getTcpNoDelay());
    setMaximumTimeBetweenPings(other.getMaximumTimeBetweenPings());
    setMaximumMessageCount(other.getMaximumMessageCount());
    setMessageTimeToLive(other.getMessageTimeToLive());
    setGroups(other.getGroups());
    setLoadProbe(other.getLoadProbe());
    setLoadPollInterval(other.getLoadPollInterval());
    ClientSubscriptionConfig cscOther = other.getClientSubscriptionConfig();
    ClientSubscriptionConfig cscThis = this.getClientSubscriptionConfig();
    // added for configuration of ha overflow
    cscThis.setEvictionPolicy(cscOther.getEvictionPolicy());
    cscThis.setCapacity(cscOther.getCapacity());
    String diskStoreName = cscOther.getDiskStoreName();
    if (diskStoreName != null) {
        cscThis.setDiskStoreName(diskStoreName);
    } else {
        cscThis.setOverflowDirectory(cscOther.getOverflowDirectory());
    }
}
Also used : ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig)

Aggregations

ClientSubscriptionConfig (org.apache.geode.cache.server.ClientSubscriptionConfig)18 CacheServer (org.apache.geode.cache.server.CacheServer)12 Test (org.junit.Test)9 Expectations (org.jmock.Expectations)7 DiskStore (org.apache.geode.cache.DiskStore)6 UnitTest (org.apache.geode.test.junit.categories.UnitTest)6 Cache (org.apache.geode.cache.Cache)4 ClientCache (org.apache.geode.cache.client.ClientCache)3 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)3 ClientCacheCreation (org.apache.geode.internal.cache.xmlcache.ClientCacheCreation)3 RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)3 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)2 UnknownHostException (java.net.UnknownHostException)1 LinkedList (java.util.LinkedList)1 CacheFactory (org.apache.geode.cache.CacheFactory)1 DiskStoreFactory (org.apache.geode.cache.DiskStoreFactory)1