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());
}
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;
}
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());
}
}
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());
}
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());
}
}
Aggregations