Alachisoft.NCache.Common.BridgeServicePropValues Maven / Gradle / Ivy
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Alachisoft.NCache.Common;
import Alachisoft.NCache.Common.Logger.ILogger;
import com.alachisoft.ncache.ncactivate.utils.RegUtil;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
/**
* @author Basit Anwer
*/
public class BridgeServicePropValues {
//Final
private static String[] bridgeServerlocation;
private static String TGHome = null;
private static String BRIDGE_BIND_TOIP;
private static String BRIDGE_PORT = "8700";
private static String BRIDGE_MGMGT_PORT = "1001";
private static String BRIDGE_SEND_BUFFER_SIZE = "131072";
private static String BRIDGE_RECEIVE_BUFFER_SIZE = "131072";
private static String BRIDGE_TRACE_ENABLE = "True";
private static String BRIDGE_TRACE_DEBUG = "True";
private static String BRIDGE_TRACE_ERROR = "True";
private static String BRIDGE_TRACE_NOTICES = "True";
private static String BRIDGE_TRACE_WARNINGS = "True";
private static String BRIDGE_ENABLE_DUAL_SOCKET = "False";
private static String BRIDGE_ENABLE_NAGLING = "False";
private static String BRIDGE_NAGLING_SIZE = "500";
private static String BRIDGE_AUTO_START_BRIDGES;
private static String BRIDGE_CACHE_USER;
private static String BRIDGE_CACHE_PASSWORD;
private static String BRIDGE_DEBUGGING_COUNTERS = "False";
private static String BRIDGE_EXPIRATION_BULK_REMOVE_SIZE = "50";
private static String BRIDGE_EXPIRATION_REMOVEDELAY = "1";
private static String BRIDGE_EVICTION_BULK_REMOVE_SIZE = "900";
private static String BRIDGE_EVICTION_BULK_REMOVE_DELAY = "1";
private static String BRIDGE_CLIENTSETTINGS_PROVIDER_SERVICE_URI;
private static String BRIDGE_ENABLE_DEBUG_LOG = "False";
private static String BRIDGE_WAN_DELAY = "";
private static String bridgeCacheName;
private static String USER_DIR = "";
private static String Bridge_GracefullShutdownTimeout;
private static String Bridge_BlockingActivityTimeout;
private static String BRIDGE_SNMP_PORT;
private static String BRIDGE_JMXServer_PORT;
private static String BRIDGE_SNMP_POOL;
private static String BRIDGE_JMX__POOL;
public static String getJvBRIDGE_SNMP_PORT() {
return BRIDGE_SNMP_PORT;
}
public static String getJvBRIDGE_JMXServer_PORT() {
return BRIDGE_JMXServer_PORT;
}
public static String getJvBRIDGE_SNMP_POOL() {
return BRIDGE_SNMP_POOL;
}
public static String getJvBRIDGE_JMX__POOL() {
return BRIDGE_JMX__POOL;
}
public static String getGracefullShutdownTimeout() {
return Bridge_GracefullShutdownTimeout;
}
public static String getBlockingActivityTimeout() {
return Bridge_BlockingActivityTimeout;
}
public static String getUserDir() {
return USER_DIR;
}
public static String getJvBRIDGE_WAN_DELAY(String cacheName) {
bridgeCacheName = cacheName;
return BRIDGE_WAN_DELAY;
}
public static String getJvBRIDGE_ENABLE_DEBUG_LOG() {
return BRIDGE_ENABLE_DEBUG_LOG;
}
/**
* Bind the service to this IP Management will also have the same ip
*
* @return non validated string
*/
public static String getBIND_TOIP() {
return BRIDGE_BIND_TOIP;
}
/**
* Port to host the bridge on
*
* @return non validated string
*/
public static String getPORT() {
return BRIDGE_PORT;
}
/**
* Server to host management port on
*
* @return non validated string
*/
public static String getMGMGT_PORT() {
return BRIDGE_MGMGT_PORT;
}
/**
* Specify send buffer size of the connected client socket, in bytes.
*
* @return non validated string
*/
public static String getSEND_BUFFER_SIZE() {
return BRIDGE_SEND_BUFFER_SIZE;
}
/**
* Specify receive buffer size of the connected client socket, in bytes.
*
* @return
*/
public static String getRECEIVE_BUFFER_SIZE() {
return BRIDGE_RECEIVE_BUFFER_SIZE;
}
/**
* When your machine has more than one network cards, you can inform NCache
* which interface to use for cluster-wide communication. In order to do so,
* please uncomment the following and provide the Ip Address you want the
* server to bind with.
*
* @return
*/
public static String getTRACE_ENABLE() {
return BRIDGE_TRACE_ENABLE;
}
/**
* When your machine has more than one network cards, you can inform NCache
* which interface to use for cluster-wide communication. In order to do so,
* please uncomment the following and provide the Ip Address you want the
* server to bind with.
*
* @return
*/
public static String getTRACE_DEBUG() {
return BRIDGE_TRACE_DEBUG;
}
/**
* When your machine has more than one network cards, you can inform NCache
* which interface to use for cluster-wide communication. In order to do so,
* please uncomment the following and provide the Ip Address you want the
* server to bind with.
*
* @return
*/
public static String getTRACE_ERROR() {
return BRIDGE_TRACE_ERROR;
}
/**
* When your machine has more than one network cards, you can inform NCache
* which interface to use for cluster-wide communication. In order to do so,
* please uncomment the following and provide the Ip Address you want the
* server to bind with.
*
* @return
*/
public static String getTRACE_NOTICES() {
return BRIDGE_TRACE_NOTICES;
}
/**
* When your machine has more than one network cards, you can inform NCache
* which interface to use for cluster-wide communication. In order to do so,
* please uncomment the following and provide the Ip Address you want the
* server to bind with.
*
* @return
*/
public static String getTRACE_WARNINGS() {
return BRIDGE_TRACE_WARNINGS;
}
/**
* All the nodes in NCache cluster can establish two connections with each
* node. This can increase the TCP throughput and thus improve the overall
* performance. By default single connection is established. To enable the
* use of dual connections, uncomment the following.
*
* @return
*/
public static String getENABLE_DUAL_SOCKET() {
return BRIDGE_ENABLE_DUAL_SOCKET;
}
/**
* To improve the cluster performance NCache takes benefit from Naggling. It
* means that NCache tries to avoid the network trip for each single message
* and instead combines multiple messages together (if waiting for the
* socket IO) to be sent as single network operation. To disable Naggling,
* uncomment the following.
*
* @return
*/
public static String getENABLE_NAGLING() {
return BRIDGE_ENABLE_NAGLING;
}
/**
* Naggling bundles all the available messages waiting for the socket IO
* whose combined size is less than the given Naggling size. The default
* Nagling size is 500 Kb. It can be modified according to the needs.
*
* @return
*/
public static String getNAGLING_SIZE() {
return BRIDGE_NAGLING_SIZE;
}
/**
* You can configure some bridges to start as the JvBridge service starts.
* As, by default JvBridge service starts at the system startup so these
* settings are useful incase you want some caches to autostart at the
* system startup.
*
* @return
*/
public static String getAUTO_START_BRIDGES() {
return BRIDGE_AUTO_START_BRIDGES;
}
/**
* You can configure some bridges to start as the JvBridge service starts.
* As, by default JvBridge service starts at the system startup so these
* settings are useful incase you want some caches to autostart at the
* system startup.
*
* @return
*/
public static String get_CACHE_USER() {
return BRIDGE_CACHE_USER;
}
/**
* You can configure some bridges to start as the JvBridge service starts.
* As, by default JvBridge service starts at the system startup so these
* settings are useful incase you want some caches to autostart at the
* system startup.
*
* @return
*/
public static String getCACHE_PASSWORD() {
return BRIDGE_CACHE_PASSWORD;
}
/**
* Some performance counters are disabled by default but they can be really
* helpful to see the NCache behavior over the network.
*
* These counters include: - 1. socket send time (time taken for the last
* send operation) 2. socket receive time (time taken for the last receive
* operation) 3. bytes sent / second 4. bytes received / second 5. naggling
* message count (number of messages bundled together in the last socket
* send operation)
*
* These counters help find the source of the problem incase we see the
* cluster is not performing as expected. To enable these counters,
* uncomment the following.
*
* @return
*/
public static String getDEBUGGING_COUNTERS() {
return BRIDGE_DEBUGGING_COUNTERS;
}
/**
* Expired items are removed in bulk. Specify the size of the bulk operation
* i.e. how many items should be removed in one bulk operation.
*
* @return
*/
public static String getEXPIRATION_BULK_REMOVE_SIZE() {
return BRIDGE_EXPIRATION_BULK_REMOVE_SIZE;
}
/**
* Expired items are removed in bulk. This may affect the performance of
* user operations during expirations. This delay specified (in seconds)
* causes a delay between two consecutive bulk remove operations.
*
* @return
*/
public static String getEXPIRATION_REMOVEDELAY() {
return BRIDGE_EXPIRATION_REMOVEDELAY;
}
/**
* During eviction items are removed in bulk. Specify the size of the bulk
* operation i.e. how many items should be removed in one bulk operation.
* EvictionBulkRemoveSize should be specified in multiple of 300
*
* @return
*/
public static String getEVICTION_BULK_REMOVE_SIZE() {
return BRIDGE_EVICTION_BULK_REMOVE_SIZE;
}
/**
* During eviction items are removed in bulk. This may affect the
* performance of user operations during expirations. This delay specified
* (in seconds) causes a delay between two consecutive bulk remove
* operations.
*
* @return
*/
public static String getEVICTION_BULK_REMOVE_DELAY() {
return BRIDGE_EVICTION_BULK_REMOVE_DELAY;
}
public static String getCLIENTSETTINGS_PROVIDER_SERVICE_URI() {
return BRIDGE_CLIENTSETTINGS_PROVIDER_SERVICE_URI;
}
//
//
public static String getNCHome() {
if (TGHome == null) {
TGHome = RegUtil.getNCHome();
}
return TGHome;
}
public static String[] init() {
return bridgeServerlocation = new String[]{
getNCHome() + "/config/",
"../config/",
"./"
};
}
public static boolean loadServiceProperties(ILogger _logger, String configPath) {
boolean isLoaded = false;
if (configPath != null && !configPath.isEmpty()) {
try {
if (_logger != null) {
_logger.Info("loading service configuration........");
}
Properties props = new Properties();
try {
props.load(new FileInputStream(configPath));
} catch (IOException iOException) {
if (_logger != null) {
_logger.Error("an error occured while loading server.properties");
_logger.Error(iOException.toString());
}
}
if (props.keys() != null) {
setValues(props);
isLoaded = true;
} else {
if (_logger != null) {
_logger.Error("an error occured while loading server.properties");
}
}
} catch (Exception e) {
if (_logger != null) {
_logger.Error(e.toString());
}
}
}
return isLoaded;
}
public static void setValues(Properties props) {
if (props.getProperty("BridgeServer.BindToIP") != null) {
BRIDGE_BIND_TOIP = props.getProperty("BridgeServer.BindToIP");
}
if (props.getProperty("BridgeServer.Port") != null) {
BRIDGE_PORT = props.getProperty("BridgeServer.Port");
}
if (props.getProperty("BridgeManagementServer.Port") != null) {
BRIDGE_MGMGT_PORT = props.getProperty("BridgeManagementServer.Port");
}
if (props.getProperty("BridgeServer.SendBufferSize") != null) {
BRIDGE_SEND_BUFFER_SIZE = props.getProperty("BridgeServer.SendBufferSize");
}
if (props.getProperty("BridgeServer.ReceiveBufferSize") != null) {
BRIDGE_RECEIVE_BUFFER_SIZE = props.getProperty("BridgeServer.ReceiveBufferSize");
}
if (props.getProperty("BridgeServer.EnableLogs") != null) {
BRIDGE_TRACE_ENABLE = props.getProperty("BridgeServer.EnableLogs");
}
if (props.getProperty("BridgeServer.TraceDebug") != null) {
BRIDGE_TRACE_DEBUG = props.getProperty("BridgeServer.TraceDebug");
}
if (props.getProperty("BridgeServer.TraceErrors") != null) {
BRIDGE_TRACE_ERROR = props.getProperty("BridgeServer.TraceErrors");
}
if (props.getProperty("BridgeServer.TraceNotices") != null) {
BRIDGE_TRACE_NOTICES = props.getProperty("BridgeServer.TraceNotices");
}
if (props.getProperty("BridgeServer.TraceWarnings") != null) {
BRIDGE_TRACE_WARNINGS = props.getProperty("BridgeServer.TraceWarnings");
}
if (props.getProperty("BridgeServer.EnableDualSocket") != null) {
BRIDGE_ENABLE_DUAL_SOCKET = props.getProperty("BridgeServer.EnableDualSocket");
}
if (props.getProperty("BridgeServer.EnableNagling") != null) {
BRIDGE_ENABLE_NAGLING = props.getProperty("BridgeServer.EnableNagling");
}
if (props.getProperty("BridgeServer.NaglingSize") != null) {
BRIDGE_NAGLING_SIZE = props.getProperty("BridgeServer.NaglingSize");
}
if (props.getProperty("BridgeServer.AutoStartBridges") != null) {
BRIDGE_AUTO_START_BRIDGES = props.getProperty("BridgeServer.AutoStartBridges");
}
if (props.getProperty("BridgeServer.CacheUser") != null) {
BRIDGE_CACHE_USER = props.getProperty("BridgeServer.CacheUser");
}
if (props.getProperty("BridgeServer.CachePassword") != null) {
BRIDGE_CACHE_PASSWORD = props.getProperty("BridgeServer.CachePassword");
}
if (props.getProperty("BridgeServer.EnableDebuggingCounters") != null) {
BRIDGE_DEBUGGING_COUNTERS = props.getProperty("BridgeServer.EnableDebuggingCounters");
}
if (props.getProperty("BridgeServer.ExpirationBulkRemoveSize") != null) {
BRIDGE_EXPIRATION_BULK_REMOVE_SIZE = props.getProperty("BridgeServer.ExpirationBulkRemoveSize");
}
if (props.getProperty("BridgeServer.ExpirationBulkRemoveDelay") != null) {
BRIDGE_EXPIRATION_REMOVEDELAY = props.getProperty("BridgeServer.ExpirationBulkRemoveDelay");
}
if (props.getProperty("BridgeServer.EvictionBulkRemoveSize") != null) {
BRIDGE_EVICTION_BULK_REMOVE_SIZE = props.getProperty("BridgeServer.EvictionBulkRemoveSize");
}
if (props.getProperty("BridgeServer.EvictionBulkRemoveDelay") != null) {
BRIDGE_EVICTION_BULK_REMOVE_DELAY = props.getProperty("BridgeServer.EvictionBulkRemoveDelay");
}
if (props.getProperty("ClientSettingsProvider.ServiceUri") != null) {
BRIDGE_CLIENTSETTINGS_PROVIDER_SERVICE_URI = props.getProperty("ClientSettingsProvider.ServiceUri");
}
if (props.getProperty("EnableDebugLog") != null) {
BRIDGE_ENABLE_DEBUG_LOG = props.getProperty("EnableDebugLog");
}
if (props.getProperty("WANDELAY." + bridgeCacheName) != null) {
BRIDGE_WAN_DELAY = props.getProperty("WANDELAY." + bridgeCacheName);
}
if (props.getProperty("BridgeServer.UserDir") != null) {
USER_DIR = props.getProperty("BridgeServer.UserDir");
}
if (props.getProperty("BridgeServer.GracefullShutdownTimeout") != null) {
Bridge_GracefullShutdownTimeout = props.getProperty("BridgeServer.GracefullShutdownTimeout");
}
if (props.getProperty("BridgeServer.BlockingActivityTimeout") != null) {
Bridge_BlockingActivityTimeout = props.getProperty("BridgeServer.BlockingActivityTimeout");
}
if (props.getProperty("BridgeServer.JmxSnmp.Port") != null) {
BRIDGE_SNMP_PORT = props.getProperty("BridgeServer.JmxSnmp.Port");
}
if (props.getProperty("BridgeServer.JmxServer.Port") != null) {
BRIDGE_JMXServer_PORT = props.getProperty("BridgeServer.JmxServer.Port");
}
if (props.getProperty("BridgeServer.SNMP.Pool") != null) {
BRIDGE_SNMP_POOL = props.getProperty("BridgeServer.SNMP.Pool");
}
if (props.getProperty("BridgeServer.JMX.Pool") != null) {
BRIDGE_JMX__POOL = props.getProperty("BridgeServer.JMX.Pool");
}
}
}