use of org.apache.geode.cache.server.ClientSubscriptionConfig in project geode by apache.
the class CacheServerImpl method getConfig.
private String getConfig() {
ClientSubscriptionConfig csc = this.getClientSubscriptionConfig();
String str = "port=" + getPort() + " max-connections=" + getMaxConnections() + " max-threads=" + getMaxThreads() + " notify-by-subscription=" + getNotifyBySubscription() + " socket-buffer-size=" + getSocketBufferSize() + " maximum-time-between-pings=" + getMaximumTimeBetweenPings() + " maximum-message-count=" + getMaximumMessageCount() + " message-time-to-live=" + getMessageTimeToLive() + " eviction-policy=" + csc.getEvictionPolicy() + " capacity=" + csc.getCapacity() + " overflow directory=";
if (csc.getDiskStoreName() != null) {
str += csc.getDiskStoreName();
} else {
str += csc.getOverflowDirectory();
}
str += " groups=" + Arrays.asList(getGroups()) + " loadProbe=" + loadProbe + " loadPollInterval=" + loadPollInterval + " tcpNoDelay=" + tcpNoDelay;
return str;
}
use of org.apache.geode.cache.server.ClientSubscriptionConfig in project geode by apache.
the class CacheServerImpl method toString.
@Override
public String toString() {
ClientSubscriptionConfig csc = this.getClientSubscriptionConfig();
String str = "CacheServer on port=" + getPort() + " client subscription config policy=" + csc.getEvictionPolicy() + " client subscription config capacity=" + csc.getCapacity();
if (csc.getDiskStoreName() != null) {
str += " client subscription config overflow disk store=" + csc.getDiskStoreName();
} else {
str += " client subscription config overflow directory=" + csc.getOverflowDirectory();
}
return str;
}
use of org.apache.geode.cache.server.ClientSubscriptionConfig in project geode by apache.
the class CacheServerImpl method start.
@Override
public synchronized void start() throws IOException {
Assert.assertTrue(this.cache != null);
this.serialNumber = createSerialNumber();
if (DynamicRegionFactory.get().isOpen()) {
// from servers to clients instead of invalidates.
if (!this.notifyBySubscription) {
logger.info(LocalizedMessage.create(LocalizedStrings.CacheServerImpl_FORCING_NOTIFYBYSUBSCRIPTION_TO_SUPPORT_DYNAMIC_REGIONS));
this.notifyBySubscription = true;
}
}
this.advisor = CacheServerAdvisor.createCacheServerAdvisor(this);
this.loadMonitor = new LoadMonitor(loadProbe, maxConnections, loadPollInterval, FORCE_LOAD_UPDATE_FREQUENCY, advisor);
List overflowAttributesList = new LinkedList();
ClientSubscriptionConfig csc = this.getClientSubscriptionConfig();
overflowAttributesList.add(0, csc.getEvictionPolicy());
overflowAttributesList.add(1, valueOf(csc.getCapacity()));
overflowAttributesList.add(2, valueOf(this.port));
String diskStoreName = csc.getDiskStoreName();
if (diskStoreName != null) {
overflowAttributesList.add(3, diskStoreName);
// indicator to use diskstore
overflowAttributesList.add(4, true);
} else {
overflowAttributesList.add(3, csc.getOverflowDirectory());
overflowAttributesList.add(4, false);
}
this.acceptor = new AcceptorImpl(getPort(), getBindAddress(), getNotifyBySubscription(), getSocketBufferSize(), getMaximumTimeBetweenPings(), this.cache, getMaxConnections(), getMaxThreads(), getMaximumMessageCount(), getMessageTimeToLive(), this.loadMonitor, overflowAttributesList, this.isGatewayReceiver, this.gatewayTransportFilters, this.tcpNoDelay);
this.acceptor.start();
this.advisor.handshake();
this.loadMonitor.start(new ServerLocation(getExternalAddress(), getPort()), acceptor.getStats());
// TODO : Need to provide facility to enable/disable client health monitoring.
// Creating ClientHealthMonitoring region.
// Force initialization on current cache
ClientHealthMonitoringRegion.getInstance(this.cache);
this.cache.getLoggerI18n().config(LocalizedStrings.CacheServerImpl_CACHESERVER_CONFIGURATION___0, getConfig());
/*
* If the stopped bridge server is restarted, we'll need to re-register the client membership
* listener. If the listener is already registered it won't be registered as would the case when
* start() is invoked for the first time.
*/
ClientMembershipListener[] membershipListeners = ClientMembership.getClientMembershipListeners();
boolean membershipListenerRegistered = false;
for (ClientMembershipListener membershipListener : membershipListeners) {
// just checking by reference as the listener instance is final
if (listener == membershipListener) {
membershipListenerRegistered = true;
break;
}
}
if (!membershipListenerRegistered) {
ClientMembership.registerClientMembershipListener(listener);
}
if (!isGatewayReceiver) {
InternalDistributedSystem system = this.cache.getInternalDistributedSystem();
system.handleResourceEvent(ResourceEvent.CACHE_SERVER_START, this);
}
}
use of org.apache.geode.cache.server.ClientSubscriptionConfig in project geode by apache.
the class CacheClientNotifierDUnitTest method createCacheServerWithCSC.
private int createCacheServerWithCSC(VM vm, final boolean withCSC, final int capacity, final String policy, final String diskStoreName) {
final int serverPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
SerializableRunnable createCacheServer = new SerializableRunnable() {
@Override
public void run() throws Exception {
CacheServerImpl server = (CacheServerImpl) cache.addCacheServer();
server.setPort(serverPort);
if (withCSC) {
if (diskStoreName != null) {
DiskStore ds = cache.findDiskStore(diskStoreName);
if (ds == null) {
ds = cache.createDiskStoreFactory().create(diskStoreName);
}
}
ClientSubscriptionConfig csc = server.getClientSubscriptionConfig();
csc.setCapacity(capacity);
csc.setEvictionPolicy(policy);
csc.setDiskStoreName(diskStoreName);
server.setHostnameForClients("localhost");
// server.setGroups(new String[]{"serv"});
}
try {
server.start();
} catch (IOException e) {
org.apache.geode.test.dunit.Assert.fail("Failed to start server ", e);
}
}
};
vm.invoke(createCacheServer);
return serverPort;
}
use of org.apache.geode.cache.server.ClientSubscriptionConfig in project geode by apache.
the class CacheXml66DUnitTest method testBridgeAttributesRelatedToHAOverFlow65.
@Test
public void testBridgeAttributesRelatedToHAOverFlow65() 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());
File overflowDirectory = new File("overFlow");
overflowDirectory.mkdirs();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File[] dirs1 = new File[] { overflowDirectory };
DiskStore ds1 = dsf.setDiskDirs(dirs1).create(getUniqueName());
csc.setDiskStoreName(getUniqueName());
try {
csc.setOverflowDirectory("overFlow");
} catch (IllegalStateException e) {
assertTrue(e.getMessage().contains(LocalizedStrings.DiskStore_Deprecated_API_0_Cannot_Mix_With_DiskStore_1.toLocalizedString("setOverflowDirectory", getUniqueName())));
}
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());
DiskStore dsi = cache.findDiskStore(chaqf.getDiskStoreName());
assertEquals("overFlow", dsi.getDiskDirs()[0].toString());
}
Aggregations