All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Alachisoft.NCache.Common.ServicePropValues Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Alachisoft.NCache.Common;

import com.alachisoft.ncache.runtime.util.RuntimeUtil;

import java.io.FileInputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Enumeration;
import java.util.Properties;

/**
 * @author Basit Anwer
 */
public class ServicePropValues {

    public static String LOGS_FOLDER = "log-files"; //Used by logger
    public static String SNMP_PORT;
    public static String JMXServer_PORT;
    public static String HTTP_PORT;
    public static String CACHE_SERVER_PORT = "9800";
    public static String CACHE_MANAGEMENT_PORT = "8250";
    public static String BIND_ToCLUSTER_IP;
    public static String BIND_toClient_IP;
    public static String INSTALLDIR_DIR;
    public static String CACHE_USER_DIR;
    public static String SNMP_POOL;
    public static String JMX__POOL;
    public static String AUTO_START_DELAY;
    public static String CACHE_AUTOSTART_USER;
    public static String CACHE_AUTOSTART_PASSWORD;
    //
    public static String CacheServer_SendBufferSize = "131072";
    public static String CacheServer_ReceiveBufferSize = "131072";
    public static String CacheServer_BulkItemsToReplicate = "300";
    public static String CacheServer_LogClientEvents;
    public static String CacheServer_EnableSnapshotPoolingCacheSize;
    public static String CacheServer_MinimumSnaphotSizeForPooling = "100000";
    public static String CacheServer_MaxNumOfSnapshotsInPool;
    public static String CacheServer_SnapshotPoolSize;
    public static String CacheServer_NewSnapshotCreationTimeInSec;
    public static String CacheServer_SnapshotCreationThreshold;
    public static String CacheServer_BindToIP;
    public static String CacheServer_EnableCacheLastAccessCount;
    public static String CacheServer_EnableCacheLastAccessCountLogging;
    public static String CacheServer_CacheLastAccessCountInterval;
    public static String CacheServer_CacheLastAccessLogInterval;
    public static String CacheServer_ExpirationBulkRemoveDelay = "0";
    public static String CacheServer_ExpirationBulkRemoveSize = "10";
    public static String CacheServer_EnableGCCollection;
    public static String CacheServer_EvictionBulkRemoveDelay = "0";
    public static String CacheServer_EvictionBulkRemoveSize = "10";
    public static String preparedQueryEvictionPercentage;
    public static String CacheServer_SQLNotificationService;
    public static String CacheServer_SQLNotificationQueue;
    public static String CacheServer_EnumeratorChunkSize;
    public static String preparedQueryTableSize;
    public static String Cache_EnableGCCollection;
    public static String Cache_DisableIndexNotDefinedException;
    //
    //
    public static String CacheServer_EnableDebuggingCounters = "false";
    public static String CacheServer_EnableDualSocket = "false";
    public static String CacheServer_EnableNagling = "false";
    public static String CacheServer_NaglingSize = "500";
    public static String CacheServer_SimulateSocketClose;
    public static String CacheServer_SocketCloseInterval;
    public static String CacheServer_AllowRequestEnquiry;
    public static String CacheServer_RequestEnquiryInterval;
    public static String CacheServer_RequestEnquiryRetries;
    public static String useAvgStats;
    public static String asyncTcpUpQueue;
    public static String CacheServer_HeartbeatInterval;
    public static String CacheServer_EventsPersistence;
    public static String CacheServer_EventsPersistenceInterval;
    //
    //
    public static String BridgeServer_Tcp_Port;
    public static String BridgeServer_Http_Port;
    public static String BridgeServer_IPC_PortName;
    public static String IPC_PortName;
    public static String CacheServer_LicenseLogging = "false";
    public static String CacheServer_EnableForcedGC;
    public static String CacheServer_ForcedGCThreshold;
    //
    //
    public static String Cache_MaxPendingConnections;
    public static String Cache_EnableServerCounters;
    public static String CacheServer_ResponseDataSize;
    public static String Enable_Logs;
    public static String Enable_Detailed_Logs;
    public static String Cache_GracefullShutdownTimeout;
    public static String Cache_BlockingActivityTimeout;
    private static InetAddress StatsServerIp;
    private static String Mapping_Properties;
    private static String TGHome = null;

    public static InetAddress getStatsServerIp() {
        try {
            if (StatsServerIp == null) {
                if (BIND_toClient_IP != null) {
                    StatsServerIp = InetAddress.getByName(BIND_toClient_IP);
                } else {
                    StatsServerIp = Alachisoft.NCache.Common.Net.Helper.getFirstNonLoopbackAddress();
                }
            }
        } catch (UnknownHostException uHE) {
            //System.err.print(uHE);
        }
        return StatsServerIp;
    }

    public static String getMapping_Properties() {
        if (Mapping_Properties == null) {
            Mapping_Properties = Common.combinePath(getTGHome(), "config", "server.properties");
        }
        return Mapping_Properties;
    }

    public static String getTGHome() {
        if (TGHome == null) {
            TGHome = Common.getNCHome();
        }
        return TGHome;
    }

    public static boolean loadServicePropFromTGHOME() {
        if (RuntimeUtil.getCurrentOS().equals(RuntimeUtil.OS.Windows)) {
            LOGS_FOLDER = "log-files";
        }


        if (getTGHome() != null && !TGHome.trim().isEmpty()) {
            if (!TGHome.endsWith("/") && !TGHome.endsWith("\\")) {
                TGHome = TGHome.concat("/");
            }
            String filePath = TGHome;
            filePath = filePath.concat("config/server.properties");
            Properties props = new Properties();

            try {
                props.load(new FileInputStream(filePath));
            } catch (IOException iOException) {
            }

            Enumeration enu = props.keys();
            while (enu.hasMoreElements()) {
                String key = (String) enu.nextElement();
                System.setProperty(key, props.getProperty(key).trim());

            }
            ServicePropValues.initialize();
            return true;

        }
        return false;
    }
    //

    public static void initialize() {
        SNMP_PORT = System.getProperty("JmxSnmp.Port");
        JMXServer_PORT = System.getProperty("JmxServer.Port");
        if (System.getProperty("MappingProperties.Path") != null) {
            Mapping_Properties = System.getProperty("MappingProperties.Path");
        }

        HTTP_PORT = System.getProperty("Http.Port");

        String serverPort = System.getProperty("CacheServer.Port");
        if (serverPort != null && serverPort.length() > 0) {
            CACHE_SERVER_PORT = serverPort;
        }

        String managementPort = System.getProperty("CacheManagementServer.Port");
        if (managementPort != null && managementPort.length() > 0) {
            CACHE_MANAGEMENT_PORT = managementPort;
        }

        String sendBufferSize = System.getProperty("CacheServer.SendBufferSize");
        if (sendBufferSize != null && sendBufferSize.length() > 0) {
            CacheServer_SendBufferSize = sendBufferSize;
        }

        String reveiveBufferSize = System.getProperty("ReceiveBufferSize");
        if (reveiveBufferSize != null && reveiveBufferSize.length() > 0) {
            CacheServer_ReceiveBufferSize = reveiveBufferSize;
        }

        BIND_ToCLUSTER_IP = System.getProperty("CacheServer.BindToClusterIP");
        BIND_toClient_IP = System.getProperty("CacheServer.BindToClientServerIP");


        INSTALLDIR_DIR = System.getProperty("Cache.InstallDir");
        CACHE_USER_DIR = System.getProperty("Cache.user.directory");

        SNMP_POOL = System.getProperty("SNMP.Pool");
        JMX__POOL = System.getProperty("JMX.Pool");

        AUTO_START_DELAY = System.getProperty("AutoStartDelay");
        CACHE_AUTOSTART_USER = System.getProperty("CacheAutoStart.User");
        CACHE_AUTOSTART_PASSWORD = System.getProperty("CacheAutoStart.Password");

        //
        String bulkItemsToReplicate = System.getProperty("CacheServer.BulkItemsToReplicate");
        if (bulkItemsToReplicate != null && bulkItemsToReplicate.length() > 0) {
            CacheServer_BulkItemsToReplicate = bulkItemsToReplicate;
        }

        CacheServer_LogClientEvents = System.getProperty("CacheServer.LogClientEvents");
        CacheServer_EnableSnapshotPoolingCacheSize = System.getProperty("CacheServer.EnableSnapshotPoolingCacheSize");
        CacheServer_MinimumSnaphotSizeForPooling = System.getProperty("CacheServer.EnableSnapshotPoolingCacheSize");
        CacheServer_MaxNumOfSnapshotsInPool = System.getProperty("CacheServer.MaxNumOfSnapshotsInPool");
        CacheServer_SnapshotPoolSize = System.getProperty("CacheServer.SnapshotPoolSize");
        CacheServer_NewSnapshotCreationTimeInSec = System.getProperty("CacheServer.NewSnapshotCreationTimeInSec");
        CacheServer_SnapshotCreationThreshold = System.getProperty("CacheServer.SnapshotCreationThreshold");
        CacheServer_BindToIP = System.getProperty("CacheServer.BindToIP");
        CacheServer_EnableCacheLastAccessCount = System.getProperty("CacheServer.EnableCacheLastAccessCount");
        CacheServer_EnableCacheLastAccessCountLogging = System.getProperty("CacheServer.EnableCacheLastAccessCountLogging");
        CacheServer_CacheLastAccessCountInterval = System.getProperty("CacheServer.CacheLastAccessCountInterval");
        CacheServer_CacheLastAccessLogInterval = System.getProperty("CacheServer.CacheLastAccessLogInterval");

        String expiraionBulkRemoveDelay = System.getProperty("CacheServer.ExpirationBulkRemoveDelay");
        if (expiraionBulkRemoveDelay != null && expiraionBulkRemoveDelay.length() > 0) {
            CacheServer_ExpirationBulkRemoveDelay = expiraionBulkRemoveDelay;
        }

        String expirationBulkRemoveSize = System.getProperty("CacheServer.ExpirationBulkRemoveSize");
        if (expirationBulkRemoveSize != null && expirationBulkRemoveSize.length() > 0) {
            CacheServer_ExpirationBulkRemoveSize = expirationBulkRemoveSize;
        }

        CacheServer_EnableGCCollection = System.getProperty("CacheServer.EnableGCCollection");

        String evictionBulkRemoveDelay = System.getProperty("CacheServer.EvictionBulkRemoveDelay");
        if (evictionBulkRemoveDelay != null && evictionBulkRemoveDelay.length() > 0) {
            CacheServer_EvictionBulkRemoveDelay = evictionBulkRemoveDelay;
        }

        String evictionBulkRemoveSize = System.getProperty("CacheServer.EvictionBulkRemoveSize");
        if (evictionBulkRemoveSize != null && evictionBulkRemoveSize.length() > 0) {
            CacheServer_EvictionBulkRemoveSize = evictionBulkRemoveSize;
        }

        preparedQueryEvictionPercentage = System.getProperty("preparedQueryEvictionPercentage");
        CacheServer_SQLNotificationService = System.getProperty("CacheServer.SQLNotificationService");
        CacheServer_SQLNotificationQueue = System.getProperty("CacheServer.SQLNotificationQueue");
        CacheServer_EnumeratorChunkSize = System.getProperty("CacheServer.EnumeratorChunkSize");
        preparedQueryTableSize = System.getProperty("preparedQueryTableSize");
        Cache_EnableGCCollection = System.getProperty("Cache.EnableGCCollection");

        String disableIndexNotDefined = System.getProperty("CacheServer.DisableIndexNotDefinedException");
        if (disableIndexNotDefined != null && disableIndexNotDefined.length() > 0) {
            Cache_DisableIndexNotDefinedException = disableIndexNotDefined;
        }
        //

        //
        String enableDebuggingCounters = System.getProperty("CacheServer.EnableDebuggingCounters");
        if (enableDebuggingCounters != null && enableDebuggingCounters.length() > 0) {
            CacheServer_EnableDebuggingCounters = enableDebuggingCounters;
        }

        String enableDualSocket = System.getProperty("CacheServer.EnableDualSocket");
        if (enableDualSocket != null && enableDualSocket.length() > 0) {
            CacheServer_EnableDualSocket = enableDualSocket;
        }

        String enableNagling = System.getProperty("CacheServer.EnableNagling");
        if (enableNagling != null && enableNagling.length() > 0) {
            CacheServer_EnableNagling = enableNagling;
        }

        String naglingSize = System.getProperty("CacheServer.NaglingSize");
        if (naglingSize != null && naglingSize.length() > 0) {
            CacheServer_NaglingSize = naglingSize;
        }

        CacheServer_SimulateSocketClose = System.getProperty("CacheServer.SimulateSocketClose");
        CacheServer_SocketCloseInterval = System.getProperty("CacheServer.SocketCloseInterval");
        CacheServer_AllowRequestEnquiry = System.getProperty("CacheServer.AllowRequestEnquiry");
        CacheServer_RequestEnquiryInterval = System.getProperty("CacheServer.RequestEnquiryInterval");
        CacheServer_RequestEnquiryRetries = System.getProperty("CacheServer.RequestEnquiryRetries");
        useAvgStats = System.getProperty("useAvgStats");
        asyncTcpUpQueue = System.getProperty("asyncTcpUpQueue");
        CacheServer_HeartbeatInterval = System.getProperty("CacheServer.HeartbeatInterval");

        String eventPersistance = System.getProperty("CacheServer_EventsPersistence");
        if (eventPersistance != null && eventPersistance.length() > 0) {
            CacheServer_EventsPersistence = eventPersistance;
        }
        String eventPersistanceInterval = System.getProperty("CacheServer_EventsPersistenceInterval");
        if (eventPersistanceInterval != null) {
            CacheServer_EventsPersistenceInterval = eventPersistanceInterval;
        }
        //

        //
        BridgeServer_Tcp_Port = System.getProperty("BridgeServer_Tcp.Port");
        BridgeServer_Http_Port = System.getProperty("BridgeServer_Http.Port");
        BridgeServer_IPC_PortName = System.getProperty("BridgeServer_IPC.PortName");
        IPC_PortName = System.getProperty("IPC.PortName");

        String licenseLogging = System.getProperty("CacheServer.LicenseLogging");
        if (licenseLogging != null && licenseLogging.length() > 0) {
            CacheServer_LicenseLogging = licenseLogging;
        }

        CacheServer_EnableForcedGC = System.getProperty("CacheServer.EnableForcedGC");
        CacheServer_ForcedGCThreshold = System.getProperty("CacheServer.ForcedGCThreshold");
        //

        //
        Cache_MaxPendingConnections = System.getProperty("Cache.MaxPendingConnections");
        Cache_EnableServerCounters = System.getProperty("Cache.EnableServerCounters");
        CacheServer_ResponseDataSize = System.getProperty("CacheServer.ResponseDataSize");
        Enable_Logs = System.getProperty("EnableLogs");
        Enable_Detailed_Logs = System.getProperty("EnableDetailedLogs");
        Cache_GracefullShutdownTimeout = System.getProperty("CacheServer.GracefullShutdownTimeout");
        Cache_BlockingActivityTimeout = System.getProperty("CacheServer.BlockingActivityTimeout");
        //
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy