package com.nms.server.common;

import java.io.File;
import java.net.SocketException;
import javax.net.ssl.SSLServerSocket;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;

import com.nms.server.util.LocalAddress;
import com.zhtelecom.common.snmp.SNMPTarget;


/**
 *  DataController 公共常量和配置文件参数信息类
 *  @date Jan 5, 2012 11:38:45 AM
 *	@author ZhangGang
 *
 */
public class Constants {
	private static final Logger logger = Logger.getLogger(Constants.class);
//	private static ResourceBundle resource = ResourceBundle.getBundle(DefaultConfig.class.getName());
	// #---Common-------
	/**
	 * DC初始化标识
	 */
	public static boolean flag_init = false;
	/**
	 * 全局 邮件信息保存参数
	 *  1保存 0 不保存 DC端默认为0 缺省配置为1
	 *  PS:当同步web端邮件功能配置时，可以创建发送通讯，变更该变量信息
	 */
	public static int flag_email = 0;		//Email 信息创建标示 1创建 0 不创建 DC端默认为0 
	public static final String ERROR_INFO_RESOVE_MANAGER = "errorInfoResoveManager";		//错误信息解析入库管理线程 标识, futureMap 中的Key值
	public static final String ERROR_INFO_RESOVE = "errorInfoResove";		//错误信息解析入库操作线程 标识, futureMap 中的Key值	
	public static final Integer ERROR_INFO_RESOVE_PERIOD;		//监测数据解析周期（秒）

	public static final String MAILING_MANAGER = "errorInfoResoveManager";		//错误信息解析入库管理线程 标识, futureMap 中的Key值
	public static final String MAILING_THREAD = "errorInfoResove";		//错误信息解析入库操作线程 标识, futureMap 中的Key值	
//	public static final Integer MAILING_PERIOD;		//监测数据解析周期（秒）
	
	public static final String DETEC_DATA_RESOVE_MANAGER = "detecDataResoveManager";
//	public static final String DETEC_DATA_COLLECT_MANAGER = "detecDataCollectManager";//DC端主动收集监测数据
	public static final String DATA_COLLECT_MANAGER = "dataCollectManager";//DC端主动收集数据：监测数据、任务结果、回传文件
	public static final String ERROR_NODE_DATA_COLLECT_MANAGER = "errorNodeDataCollectManager";//异常节点管理线程
	public static final String NO_DETECT_DATA_NODE_DATA_COLLECT_MANAGER = "noDetectDataNodeDataCollectManager";//无监测数据节点管理线程
	public static final String EMAIL_START_THREAD = "emailStartThread";//DC端刷新邮件启动标识线程
	public static final String NONRLTTASK_RESULT_COLLECT_MANAGER = "nonRltTaskResultCollectManager";//DC端主动收集数据：执行完成，但无任务结果的任务的结果信息
	public static final String DETEC_DATA_RESOVE = "detecDataResove";		//监测数据解析线程 标识, futureMap 中的Key值	
	public static final String OVERRUN_DATA_RESOVE_MANAGER = "overrunDataResove";		//硬盘数据解析入库管理线程 标识, futureMap 中的Key值
	
	public static final String OVRERUN_DETEC_DATA_RESOVE = "overrunDetecDataResove";		//硬盘监测数据解析线程 标识, futureMap 中的Key值
	public static final String OVRERUN_WARNING_DATA_RESOVE = "overrunWarningDataResove";		//硬盘告警数据解析线程 标识, futureMap 中的Key值
	public static final String OVRERUN_RESULT_DATA_RESOVE = "overrunResultDataResove";		//硬盘任务结果数据解析线程 标识, futureMap 中的Key值
	
	public static final String DELETE_TMP_FILES_MANAGER = "deteleTmpFilesManager";//删除log等临时文件
	
	public static final String DETEC_DATA_COLLECT = "detecDataCollect";		//监测数据主动收集线程 标识, futureMap 中的Key值-暂未使用
	public static final String DATA_COLLECT = "dataCollect";		//监测数据主动收集线程 标识, futureMap 中的Key值
	public static final String NO_DETECT_DATA_COLLECT = "noDetectDataCollect";		//异常监测数据主动收集线程 标识, futureMap 中的Key值
	public static final String NONRLTTASK_RESULT_COLLECT = "nonRltTaskResultCollect";		//无任务结果的任务的结果数据的主动收集线程 标识, futureMap 中的Key值
	public static final String ALARM_DATA_RESOVE_MANAGER = "alarmDataResoveManager";
	public static final String ALARM_DATA_RESOVE = "alarmDataResove";		//告警数据解析线程 标识, futureMap 中的Key值
	public static final String MISSION_THREAD = "missionThread";

	public static final String DELETE_TMP_FILES = "deleteTmpFiles";		//删除log等文件线程 标识, futureMap 中的Key值
	
	public static final String UNZIP_FILE_MANAGER = "unZipFileManager";
	public static final String UNZIP_FILE = "unZipFile";
	
	public static final String SUCCESS = "success";

	
	public static final String MISSION_RESULT_RESOVE_MANAGER = "missionResultResoveManager";
	public static final String MISSION_RESULT_RESOVE = "missionResultResove";
	public static final String MISSION_FILE_UPLOAD = "missionFileUpload";
	
	public static final String CHANGE_OPERATIONS_MANAGER = "changeOperationsManager";
	public static final String CHANGE_OPERATIONS = "changeOperations";
	
	public static final String DETECTION_INFO_TABLE_NAME = "detection_info_new";//监测数据表名
	public static final String DETECTION_WARNING_TABLE_NAME = "detection_info_warning";//告警数据表名

	public static final Boolean DETECSELFTHREAD_FLAG ;//DetecSelfThread 开关
	public static final String DETECTI_SELF_THREAD_NAME = "DetecSelfThread";//监测数据表名
	public static final Long DETECSELFTHREAD_PERIOD;//监测间隔，单位：秒
	public static final Long DETECSELFTHREAD_INITIALDELAY;//监测延迟启动时间，单位：秒
	public static final String DETECTI_DATA_COLLECT_THREAD_NAME = "DetecDataCollectThread";//监测数据收集线程是否正常运行
	public static final String RESET_SERVER_THREAD_NAME = "ResetServerThread";//告警数据表名
	
	public static final String DB_CONNECTION_THREAD_NAME = "DbConnectionThreadName";//数据库连接线程名
	
	public static final String EMAIL_TYPE_IDENTITY = "emailflag";//是否发送邮件的参数配置标识
	
//	public static final String NO_DETECTDATA_STATUS_INFO = "数据收集超时，未获取监测数据";//DC收集数据，无监测数据时默认的提示信息
//	public static final String NO_DETECTDATA_STATUS_INFO = "Data collection is out of time and no monitoring data is obtained";//DC收集数据，无监测数据时默认的提示信息
	public static final String NO_DETECTDATA_STATUS_INFO = "i18n_server.Constants.NO_DETECTDATA_STATUS_INFO_n81i";//DC收集数据，无监测数据时默认的提示信息
	

	// #---Common-------
	public static final String COMMON_CONFIG_EXE_NAME ;		//参数配置程序名称
	public static final String COMMON_TEXT_CODING ;		//公用字符流编码格式
	public static final String COMMON_DATE_FORMAT;		//公用日期格式化标准格式DEFAULT_DATE_FORMAT
	public static final String COMMON_DATAS_DIR;
	public static final Integer COMMON_SNMP_VERSION = SNMPTarget.VERSION2C ;		//公用字符流编码格式
	public static final String COMMON_DATA_SPLIT = "\\$@\\$";		//主动告警信息解析标识串-用于分隔字符
	public static final String COMMON_DATA_POINT = "$@$";		//主动告警信息解析标识串-用于连接字符
	public static final String COMMON_TEMP_DIR ; 				//安装程序下临时目录
	public static final String COMMON_RUNTIME_PID_FILE ;				//程序运行时PID文件
	public static final String SYSTEM_PATH;		//DataController应用启动主目录
	public static final String SYSTEM_INET_ADDRESS;
	public static final Integer SYSTEM_CLEAR_PERIOD = 24;	// [1,99999999]hours 每SYSTEM_CLEAR_PERIOD系统清理一次
	public static final Integer SYSTEM_CLEAR_TIME = 20;	// [00:00:00,24:00:00]	每天某时间（精确到小时），执行系统数据清理
	public static final Integer MAX_NETWORK_BANDWIDTH;		//证书有效期（天）
	
	// #---Executor /ThreadPool-------
	public static final Integer EXECUTOR_SOCKET_THREAD_SIZE ;	//线程池 通讯线程最大数
	public static final Integer EXECUTOR_DATA_RESOVE_THREAD_SIZE ;
	public static final Integer EXECUTOR_SCHEDULED_THREAD_SIZE ;	//线程池 周期性线程最大数
	// #---Change Operations-------
	public static final Integer CHANGE_OPERATIONS_PERIOD ;
	public static final Integer CHANGE_RELEASE_SEMAPHORE_MAX ;
	
	// #---Detection Resolve-------
//	public static final Integer DETEC_TIMEOUT_ALARM_PERIOD_TIMES;		//监测数据告警周期数
	public static final Integer DETEC_DATA_RESOLVE_PERIOD;		//缓存监测数据解析周期(秒)
	public static final Integer DISK_DATA_RESOLVE_PERIOD;		//硬盘监测数据解析周期(秒)
	public static final int CHECK_DETEC_DATA_OVERRUN = 5;		//检查 监测数据量是否过大（导致无法及时、完整的入库） 的次数，即5*DETEC_DATA_RESOLVE_PERIOD
	public static final int CHECK_WARNING_DATA_OVERRUN = 5;		//检查 告警数据量是否过大（导致无法及时、完整的入库） 的次数，即5*告警数据解析周期
	public static final int CHECK_RESULT_DATA_OVERRUN = 5;		//检查 任务结果数据量是否过大（导致无法及时、完整的入库） 的次数，即5*任务结果解析周期
	
	public static final int REFRESH_EMAIL_FLAG_PEROID = 300;		//刷新邮件功能启用标示周期:5分钟
//	public static final Integer DETEC_DATA_COLLECT_PERIOD;		//监测数据主动收集周期
	public static final Integer DATA_COLLECT_PERIOD;		//DC端主动收集数据（监测数据、任务结果、回传文件）周期
	public static final Integer ERROR_NODE_DATA_COLLECT_PERIOD;		//DC端主动收集数据（监测数据、任务结果、回传文件）周期(针对异常节点)
	public static final Integer DATA_COLLECT_DAILY;		//DC端主动收集数据：等待时间
	public static final Integer ERROR_NODE_DATA_COLLECT_DAILY;		//DC端主动收集数据：等待时间(针对问题节点)
	public static final Integer SINGLE_NODE_DETECT_TIMEOUT;		//DC端主动监测，单节点超时时间
	public static final Integer DETEC_RELEASE_SEMAPHORE_MAX;
	public static final String  DETEC_PING_STR;		//ping配置名称 与数据库监测类别表 ping对应 谨慎一致修改
	public static final String  DETEC_NMSC_STR;		//NMSClient端通信握手配置名称 与数据库监测类别表 NMSClient对 应谨慎一致修改
	public static final String  DETEC_SNMP_STR;
	public static final String  DETEC_SWITCH_STR;
	public static final String  DETEC_SYSTEMINFO_STR;
	public static final String  DETEC_SYSTEM_STR;
	public static final String  DETEC_SYSTEMDATE_STR;
	public static final String  DETEC_IFXTABLE_STR;
	
	public static final String  ALARM_SNMP_TRAP_STR;	
	
	public static final Integer DELETE_TMP_FILES_PERIOD;		//删除log等临时文件的线程执行间隔时间
	public static final Integer KEEP_FILE_DAYS;		//保留log等临时文件的天数
	
	// #---Alarm Resolve-------
	public static final Integer ALARM_DATA_RESOLVE_PERIOD;		//告警数据解析周期
	
	public static final Integer NONRLTTASK_RESULT_COLLECT_PERIOD;		//DC端主动收集数据（执行完成，但无任务结果的任务的结果信息）周期
	
	// #---Web-------
//	public static final String  WEB_DOWNLOAD_URL;		//NMSWeb 文件下载路径
	public static final String  WEB_SOCKET_IP;			//指定非加密通讯通信IP
	public static final Integer WEB_SOCKET_PORT;			//指定非加密通讯通信端口
	
	// #---Mission Control-------
	public static final Integer MISSION_FIRST_START = 0;//10;	//任务下发线程启动时间 计算式：（agent任务结果上传周期+MISSION_RESULTS_SAVE_PERIOD）/MISSION_RESULTS_SAVE_PERIOD ，取其进1整数*MISSION_RESULTS_SAVE_PERIOD+MISSION_RESULTS_SAVE_START+1
	public static final Integer MISSION_RESULTS_SAVE_START = 60; 	//任务结果入库线程启动时间 秒
	public static final Integer MISSION_RESULTS_SAVE_PERIOD = 120;	//任务结果入库线程循环周期 秒
	public static final Integer MISSION_CHECK_NEW_START = 10;//10;	//新任务检查线程启动在first_start之后
	public static final Integer MISSION_CHECK_NEW_PERIOD = 300;	//周期间隔可以稍长
	public static final Integer TASK_RLT_COLLECT_RESERVED_PERIOD = 600;	//任务结果收集估计预留时间,单位秒
	public static final Integer MISSION_LOOP_PRESET_NUMBER;	//周期预置数
//	public static final String  MISSION_LOOP_FINISHING_DAILY;		//周期任务 完成状态变更时间（未使用）
	public static final Integer MISSION_UPGRADE_DAILY;		//DataController应用启动主目录
	
	// #---Mission release-------
	public static final Integer MISSION_RELEASE_SEMAPHORE_MAX;		////信号计数，每申请一个信号，创建两个线程，一个任务执行线程，一个结果接收线程
	public static final Integer MISSION_RELEASE_TIMES;		//下发任务尝试次数
	public static final Integer MISSION_RELEASE_PERIOD;		//下发任务间隔周期
	
	// #---Mission File-------
	public static final String  MISSION_FILE_DOWNLOAD_DIR ;		//下发任务文件目录（推送文件用）
	public static final Integer MISSION_FILE_DOWNLOAD_DELAY;	//上传最大等待时间（秒）
	public static final String  MISSION_FILE_UPLOAD_DIR ;		//上传回传文件目录（推送文件用）
	public static final Integer MISSION_FILE_UPLOAD_PERIOD;		//上传周期（分）

	// #---Email-------
//	public static final String EMAIL_ADDRESS ;
//	public static final String EMAIL_USERNAME ;
//	public static final String EMAIL_PASSWORD;
//	public static final String EMAIL_HOST ;
	
	// #---DataBase-------
	public static final String  DB_POOL_TYPE;//连接池类型
	public static final String  DB_DRIVER;			//数据库链接驱动
	public static final String  DB_USER_NAME;		//数据库链接用户名
	public static final String  DB_PASSWORD;			//数据库链接密码
	public static final String  DB_URL;			//数据库链接地址
	public static final String  DB_DATE_FORMAT;		//数据库日期格式化格式
	public static final Integer DB_EXECUTE_BATCH;	//数据库批处理更新操作单次最大处理量
	public static final Integer DB_STATEMENT_EXECUTE_TIMEOUT ;
	public static final Integer DB_POOL_PARTITION_COUNT ;	//连接池 设置分区 缺省值 3
	public static final Integer DB_POOL_CONNECTIONS_PER_PARTITION_MAX;	//设置每个分区中的最大连接数 缺省值 30
	public static final Integer DB_POOL_CONNECTIONS_PER_PARTITION_MIN ;	//设置每个分区中的最小连接数 缺省值 10
	public static final Integer DB_POOL_ACQUIRE_INCREMENT;	//当连接池中的连接耗尽的时候 BoneCP一次同时获取的连接数 缺省值3
	public static final Integer DB_POOL_IDLE_CONNECTION_TEST_PERIOD ;	//设置每60秒检查数据库中的空闲连接数 单位 秒  缺省值 60 
	public static final Integer DB_POOL_IDLE_MAX_AGE ;	//设置连接空闲时间 单位 分钟  缺省值 240
	public static final Integer DB_GET_CONNECTION_TIMEOUT ;	//设置获取连接超时时间，默认30秒
	public static final Integer DB_POOL_MAX_CONNECTION_AGE;
	public static final Integer DB_POOL_RELEASE_HELPER_THREADS ;	//连接释放处理 缺省值3
	public static final Integer DB_POOL_STATEMENT_RELEASE_HELPER_THREADS;
	public static final Integer DB_POOL_QUERY_EXECUTE_TIME_LIMIT ;	//sql执行超时时间
	public static final boolean DB_POOL_LOG_STATEMENT_ENABLE;
	// #---DATA-------
	/*
	public static final String DATA_DIR;				//DataController端未解析数据文件存放目录
	public static final String DATA_BACKUP_RIGHT_DIR;		//DataController端解析正确的数据文件备份目录
	public static final String DATA_BACKUP_WRONG_DIR;		//DataController端解析错误的数据文件备份目录
	*/
	// #---ZIP File-------
	public static final String ZIP_FILE_DETECT_DATA_DIR;
	public static final String ZIP_FILE_TASK_RESULT_DIR;
	public static final String ZIP_FILE_TASK_RETURN_DIR;

	// #---ZIP File Resove-------
	public static final String ZIP_RESOVE_DETECT_DATA_DIR;
	public static final String ZIP_RESOVE_TASK_RESULT_DIR;
	public static final String ZIP_RESOVE_TASK_RETURN_DIR;
	public static final String ERROR_DETEC_FILE_DIR;
	public static final int ERROR_DETEC_FILE_DIR_FILE_SIZES = 500;
	public static final String DEFAULT_NODE_GROUP_NAME;
	
	//20160909 单个节点默认收集后加入监测数据列表的最大监测数据条数，如果一次收集超过设置的条数，则存入dc_overrun/detect/zip_resove中（避免解析时数据过多导致内存溢出）
	public static final int MAX_COLLECT_RESOVE_DETECT_DATA_NUM;
	//20160912 内存中监测数据的条数超过MAX_DETECT_DATA_RESOVE_LIMIT_NUM，则不再向内存中添加监测数据，而是暂存硬盘，待之后解析入库，避免内存溢出,默认10万
	public static final int MAX_DETECT_DATA_RESOVE_LIMIT_NUM;	
	
	// #---overrun detect data file path-------
	public static final String OVERRUN_DETEC_FILE_DIR;//超出处理能力的监测数据文件存放路径
	// #---overrun warning data file path-------
	public static final String OVERRUN_WARNING_FILE_DIR;//超出处理能力的告警数据文件存放路径
	// #---overrun result data file path-------
	public static final String OVERRUN_RESULT_FILE_DIR;//超出处理能力的任务结果数据文件存放路径
	
	// 第三方监测脚本
	public static final String PLUGIN_SCRIPT_FILE_DIR; // 第三方检测脚本存储路径
	
	
	// #---SNMP-------
	public static final Integer  SNMP_TRAP_THREAD_POOL_SIZE;		//指定SNMP 共同体名称
	public static final Integer SNMP_CLIENT_PORT;		//指定SNMP client get端口
	public static final Integer SNMP_TRAP_PORT;			//指定SNMP trap get端口
	public static final String  SNMP_COMMUNITY;		//指定SNMP 共同体名称
/*	public static final String  SNMP_MIB_DIR ;		//
	public static final String  SNMP_CLASS_PATH ;
	public static final String  SNMP_CLASS_DIR ;
 */
	public static final String  SNMP_CLASS_PACKAGE ;
	public static final Integer  SNMP_V3_SECURITY_LEVEL ;		//	##--SNMP 加密认证等级
	public static final String  SNMP_V3_SECURITY_NAME ;		//	##--SNMP 加密认证用户 用户名
	public static final String  SNMP_V3_AUTH_PROTOCOL ;		//	##--SNMP 认证协议方式
	public static final String  SNMP_V3_PRIV_PROTOCOL ;		//	##--SNMP 加密协议方式
	public static final String  SNMP_V3_AUTH_PASSPHRASE ;		//	##--SNMP 认证密码明文
	public static final String  SNMP_V3_PRIV_PASSPHRASE ;		//	##--SNMP 加密密码明文

	// #---SSL Init-------
	public static final Integer  SSL_SO_TIMEOUT;			//SSL加密通信类型
	public static final String  SSL_TYPE;			//SSL加密通信类型
	public static final String  SSL_KEYSTORE_TYPE;		//SSL加密通信加密密匙库类型
	public static final Integer SSL_SERVER_PORT;		//SSL加密通信接收端口
	public static final Integer SSL_CLIENT_PORT;		//SSL加密通信请求端口
	public static final String  SSL_DIR ;			//证书存放目录
	public static final String  SSL_SERVER_EXPORT ;		//程序初始化服务端证书导出名称
	public static final String  SSL_CLIENT_EXPORT ;		//程序初始化客户端通用证书导出名称

//	public static final String SSL_INIT_SERVER_KEY;		//程序初始化服务端证书 （安装时用）
//	public static final String SSL_INIT_SERVER_KEY_PSW ;		//程序初始化服务端证书密码
//	public static final String SSL_INIT_CLIENT_KEY ;		//程序初始化客户端通用证书 （安装时用）
//	public static final String SSL_INIT_CLIENT_KEY_PSW ;		//程序初始化客户端证书密码
	// #---SSL Server-------
	public static final String SSL_SERVER_STORE ;		//通讯接收端证书密匙库
	public static final String SSL_CLIENT_STORE ;		//通讯请求端证书密匙库
	public static final String SSL_SERVER_STORE_PSW ;		//通讯接收端证书密匙库密码
	public static final String SSL_SERVER_TRUST;		//通讯接收端证书公钥库
	public static final String SSL_CLIENT_TRUST;		//通讯请求端证书公钥库
	public static final String SSL_SERVER_TRUST_PSW;		//通讯接收端证书公钥库密码
	public static final String SSL_SERVER_KEY_NEW;		//通讯接收端新密匙
	public static final String SSL_SERVER_KEY_NEW_PSW;
	public static final String SSL_SERVER_KEY_OLD ;		//通讯接收端旧密匙
	public static final String SSL_SERVER_KEY_OLD_PSW;	//通讯接收端旧密匙密码
	public static final String SSL_CLIENT_KEY ;			//通讯请求端密匙
	public static final String SSL_CLIENT_KEY_PSW ;		//通讯请求端密匙密码
	public static final Integer SSL_KEY_VALIDITY;		//证书有效期（天）
	// #---SSL Bat-------
//	public static final String SSL_BAT_IMPORT ;
//	public static final String SSL_BAT_GENKEY_EXPORT ;
//	public static final String SSL_BAT_SERVER_INIT ;
	
	//监测执行失败时，握手监测-默认的告警级别:0
	public static final int DETECT_FAIL_NMSC_POLICE_LEVEL;//0
	//监测执行失败时，握手监测-默认的紧急状态:0紧急
	public static final int DETECT_FAIL_NMSC_POLICE_EMERGENT;//0
	//监测执行失败时，非握手监测-默认的告警级别：1级
	public static final int DETECT_FAIL_NON_NMSC_POLICE_LEVEL;//1
	//监测执行失败时，非握手监测-默认的紧急状态：非紧急
	public static final int DETECT_FAIL_NON_NMSC_POLICE_EMERGENT;//1
	//NC主动告警（默认为紧急），state=-2时，默认的告警级别:0级，
	public static final String NC_ALARM_POLICE_LEVEL;//1

	/**监测信息状态集合
	 * [0] -2 监测线程异常 
	 * [1] -1 监测任务失败 
	 * [2]  0 监测信息异常 
	 * [3]  1 监测信息正常 
	 * [4]  2 监测线程正常
	 * */
	private static final Integer [] DETECTION_INFO_STATE = new Integer[]{-2,-1,0,1,2};
	/**监测线程异常 -2*/
	public static final Integer DETECTION_INFO_ALARM_WRONG = DETECTION_INFO_STATE[1];
	/**监测线程正常  2*/
	public static final Integer DETECTION_INFO_ALARM_RIGHT = DETECTION_INFO_STATE[3];
	/**监测任务失败 -1*/
	public static final Integer DETECTION_INFO_DETEC_ERROR = DETECTION_INFO_STATE[1];
	/**监测信息异常  0*/
	public static final Integer DETECTION_INFO_DETEC_WRONG = DETECTION_INFO_STATE[2];
	/**监测信息正常  1*/
	public static final Integer DETECTION_INFO_DETEC_RIGHT = DETECTION_INFO_STATE[3];
	
//	public static final String ERROR_CODE_CREATE_SOCKET_ERROR= "CreateSocketError";
//	public static final String ERROR_CODE_CREATE_SOCKET_ERROR= "CreateSocketError";
//	public static final String ERROR_CODE_CREATE_SOCKET_ERROR= "CreateSocketError";
//	public static final String ERROR_CODE_CREATE_SOCKET_ERROR= "CreateSocketError";
//	public static final String ERROR_CODE_CREATE_SOCKET_ERROR= "CreateSocketError";
//	public static final String ERROR_CODE_CREATE_SOCKET_ERROR= "CreateSocketError";
	public static final String ERROR_CODE_CREATE_SOCKET= "CreateSocketError";
	public static final String ERROR_CODE_SOCKET_RUNTIME= "DCSocketRuntimeError";
	public static final String ERROR_CODE_SOCKET_SERVER_START = "DCSocketServerStartError";
	public static final String ERROR_CODE_SOCKET_SERVER_RUNTIME = "DCSocketServerRuntimeError";
	public static final String ERROR_CODE_DB_CONNECT= "DBConnectError";
	public static final String ERROR_CODE_DATA_COLLECT= "DataCollectError";
//	public static final String ERROR_DESC_DATA_COLLECT= "数据收集管理线程停止运行";
//	public static final String ERROR_DESC_DATA_COLLECT= "The data collection management thread stopped running";
	public static final String ERROR_DESC_DATA_COLLECT= "i18n_server.Constants.ERROR_DESC_DATA_COLLECT_n81i";
//	public static final String ERROR_DESC_DATA_COLLECT_NO_RUN= "数据收集管理线程未启动";
//	public static final String ERROR_DESC_DATA_COLLECT_NO_RUN= "Data Collection Management thread did not start";
	public static final String ERROR_DESC_DATA_COLLECT_NO_RUN= "i18n_server.Constants.ERROR_DESC_DATA_COLLECT_NO_RUN_n81i";
	
	public static final long ERROR_INFO_SATAE_ERROR = 1;//异常
	public static final long ERROR_INFO_SATAE_RIGHT = 0;//已解决,手动置为已解决的
	public static final long ERROR_INFO_SATAE_RIGHT_AUTO = 2;//已恢复,自己恢复的
	
	public static final int PORT_ALARM_LEVEL;//端口异常，默认的告警级别：5
	public static final int PORT_ALARM_EMERGENT;//端口异常，默认的紧急状态：1，非紧急
	
	// #---Test Flag-------
	public static final Integer FLAG_ZIP;
//	public static final Integer FLAG_DETEC_TIMEOUT;
	public static final Integer FLAG_DETEC_RESOVE;
	public static final Integer FLAG_ERROR_INFO;
	public static final Integer FLAG_FILES_READER_RESOVE;
	public static final Integer FLAG_DATA_COLLECT;//数据收集标志(是否启动数据收集管理线程)
	public static final Integer FLAG_HANDWALK_SSH;//握手时，是否进行ssh判断
	public static final Integer FLAG_DATA_COLLECT_ONLY_HANDSHAKE;//数据收集线程里只握手，不收集数据
	public static final Integer FLAG_NONRLTTASK_RESULT_COLLECT;//执行完成，但无任务结果的任务的结果信息的收集标志
	public static final Integer FLAG_DELETE_TMP_FILES;//删除日志等文件标识
	public static final Integer FLAG_FILE_UPLOAD;
	public static final Integer FLAG_CHANGE_OPERATIONS;
	public static final Integer FLAG_PING;
	public static final Integer FLAG_NMSC;
	public static final Integer FLAG_SNMP;
	public static final Integer FLAG_SWITCH;
	public static final Integer FLAG_SYSTEMDATE;
	public static final Integer FLAG_MISSION;
	public static final Integer FLAG_MISSION_RESULT;
	/*public static final Integer FLAG_RESOVE_READ_FILE;
	public static final Integer FLAG_RESOVE_RESOVE_FILE;
	public static final Integer FLAG_MOVE_FILE;*/
	public static final Integer FLAG_RESOVE_COMMIT_DB;
	public static final Integer FLAG_ALARM_RESOVE;
	public static final Integer FLAG_TRAP;
	
	public static final Integer FLAG_EMAIL_START;//是否启用邮件发送功能
	
	
	//20151229  hyx
	public static final Integer FLAG_DETECT_DATA_SAVE_DISK_RESOVE;//监测数据过多时是否保存硬盘:1保存
	public static final Integer FLAG_WARN_DATA_SAVE_DISK_RESOVE;//告警数据过多时是否保存硬盘:1保存
	public static final Integer FLAG_ERROR_DATA_SAVE_DISK_RESOVE;//错误数据过多时是否保存硬盘:1保存
	public static final Integer FLAG_TASK_RLT_SAVE_DISK_RESOVE;//任务结果过多时是否保存硬盘:1保存
	
	public static final String OS_WIN = "win";
	public static final String OS_LINUX = "linux";
	
	public static SSLServerSocket sslServer = null;
	
	public static int LEVEL_OF_EMERGENCY = 0;//紧急级别对应的level（0：紧急；1-5：非紧急）
	
	public static int VARCHAR_MAX_LENGTH = 4000-1;//oracle中varchar2类型的最大长度为4000个字节
	
	public static Integer DETECTION_INFO_DATA_MAX_ROWS;//监测数据每多少条数据入库一次
	
	public static int FETCH_SIZE;//如果不设置自动取的是10，当网络情况不好的时候，一次查询的数据较多的时候（批量监测数据入库就会一次查出new表和端口表等的数据，多达几万条），就会多次从数据库取数据，在网络上浪费时间，因此这个值需要设置的大一些,但是这个值设置的越大，占用的内存就越大，所以一般设置50或者100是比较合适的
	
	public static int SSH_CONNECT_TIMEOUT;
	
	public static boolean IS_HANDEL_EXCEPTION_NODE = false;//正常收集线程是否处理异常节点的具体异常原因
	
	
	//批量解析数据限制数量
	public static final int BATCH_RESOVE_COUNT;
//	public static final Integer FLAG_TEST;
//	public static final Integer TEST_COMPUTER;
//	public static final Integer TEST_SWITCH;
	//static final 自变量的初始化
	
	public static final String DB_TYPE;
	public static final boolean IS_MYSQL;
	//dc监测数据入库模式，1：由web 主控控制入库，2：自己主动入库，3，智能模式，4，数据上传
	public static final Integer DETECT_INSERT_MODE;
	public static final Integer WEB_NOTICE_INSERT_DETECT_OVER_TIMES ;// web通知监测入库超时次数，只有 配置 DETECT_INSERT_MODE = 3 有效
	
	
	
	/**
	 * 监测数据入库线程模式，1：单线程，2：双线程（info,detail）
	 */
	public static final int DETECT_INSERT_THREAD_MODE;
	/**
	 * INFO入库线程运行模式，1：每隔 N秒 运行一次，2：间隔 N 秒运行一次
	 */
	public static final	int DETECT_INFO_THREAD_MODE;
	/**
	 * INFO入库线程 每隔 或间隔 时间 ，单位：S
	 */
	public static final int DETECT_INFO_THREAD_TIME;
	public static final int DETECT_INFO_THREAD_DELAY;
	/**
	 * DETAIL入库线程运行模式，1：每隔 N秒 运行一次，2：间隔 N 秒运行一次
	 */
	public static final int DETECT_DETAIL_THREAD_MODE;
	/**
	 * DETAIL入库线程 每隔 或间隔 时间 ，单位：S
	 */
	public static final int DETECT_DETAIL_THREAD_TIME;
	public static final int DETECT_DETAIL_THREAD_DELAY;
	/**
	 * future key
	 */
	public static final String DETECT_INFO_THREAD_KEY = "DETECT_INFO_THREAD_KEY" ;
	public static final String DETECT_DETAIL_THREAD_KEY = "DETECT_DETAIL_THREAD_KEY" ;
	/**
	 * 监测数据解析线程
	 */
	public static final String DETECT_RESOVE_THREAD_KEY = "DETECT_RESOVE_THREAD_KEY" ;
	
	public static final int  NETTY_SERVER_FLAG;
	public static final int  NETTY_SERVER_PORT;
	public static final boolean  NETTY_SERVER_SSL;//是否使用加密通信
	public static final int  NETTY_IDLE_TIME;
	public static final int  NETTY_SO_BACKLOG;
	
	/**
	 * 服务器握手监测 周期时间
	 */
	public static final int  SERVER_NMSC_THREAD_INTERVAL;
	
	public static final String NEXTVAL_FUNCTION_NAME ;
	public static final String CURRVAL_FUNCTION_NAME ;
	
	public static final Long HANDSHANK_DELAY_TIME;
	

	
	static {
		
//		InetAddress inetAddress = null;
//		try {
//			inetAddress = InetAddress.getLocalHost();
//		} catch (UnknownHostException e) {
//			logger.error("LocalHost InetAddress 获取失败",e);
//		}
		BATCH_RESOVE_COUNT=Config.getInteger("batch.resove.count",500);
		// #---Common-------
		SYSTEM_PATH = formatPath(Config.getSystemDir());
		COMMON_CONFIG_EXE_NAME = Config.getString("common.config.exe.name","DCConfig.exe");
		COMMON_TEXT_CODING = Config.getString("common.text.coding","UTF-8");
		COMMON_DATE_FORMAT = Config.getString("common.date.format","yyyy-MM-dd HH:mm:ss");
		COMMON_DATAS_DIR = Config.getString("common.datas.dir",SYSTEM_PATH+"/nmsdata");
		
		COMMON_TEMP_DIR  = Config.getString("common.temp.dir","temp"); 
		COMMON_RUNTIME_PID_FILE  = Config.getString("common.Runtime.pid","DataControllerPid.temp"); 
		
//		if(inetAddress!= null){
//			SYSTEM_INET_ADDRESS = StringUtils.isEmpty(Config.getString("system.inet.address"))
//									?inetAddress.getHostAddress().toString()
//										:Config.getString("system.inet.address");
//		}else {
		String localIP = Config.getString("system.inet.address",null);
		try {
			String localIP2 = LocalAddress.getRealIp();
//			if(StringUtils.isEmpty(localIP)){
//				localIP = localIP2;
//				logger.warn("配置IP【"+localIP+"】为空 程序获取IP【"+localIP2+"】将使用程序获取IP");
//			}
			
			if(!localIP.equals(localIP2)){
				logger.warn("Local IP exception configuration IP【"+localIP+"】 Program to get IP【"+localIP2+"】 will use the configuration IP");
			}
		} catch (SocketException e1) {
			logger.error("Program gets IP failure", e1);
		}
		SYSTEM_INET_ADDRESS = localIP;
//		}
		MAX_NETWORK_BANDWIDTH = Config.getInteger("max.network.bandwidth",0);
		// #---Executor /ThreadPool-------
		EXECUTOR_SOCKET_THREAD_SIZE = Config.getInteger("executor.socket.thread.size",120);
		EXECUTOR_SCHEDULED_THREAD_SIZE = Config.getInteger("executor.scheduled.thread.size",30);
		EXECUTOR_DATA_RESOVE_THREAD_SIZE = Config.getInteger("executor.data.resove.thread.size",3);
		
		// #---Change Operations-------
		CHANGE_OPERATIONS_PERIOD = Config.getInteger("change.operations.period",120);
		CHANGE_RELEASE_SEMAPHORE_MAX = Config.getInteger("change.release.semaphore.max",20);
		// #---Detection Resolve-------
//		String outTimes = Config.getString("detec.timeout.alarm.period.times");
//		
//		int outT = 1;
//		if(outTimes != null ){
//			try {
//				outT = Integer.parseInt(outTimes);
//			} catch (Exception e) {
//				logger.error("detec.timeout.alarm.period.times 取值失败",e);
//			}
//		}
//		DETEC_TIMEOUT_ALARM_PERIOD_TIMES = Config.getInteger("detec.timeout.alarm.period.times");;
		DETEC_RELEASE_SEMAPHORE_MAX  = Config.getInteger("detec.release.semaphore.max",(int)(EXECUTOR_SOCKET_THREAD_SIZE*0.8));
		
		DETEC_DATA_RESOLVE_PERIOD = Config.getInteger("detec.data.resovle.period",60);
		DISK_DATA_RESOLVE_PERIOD = Config.getInteger("disk.data.resovle.period",600);
		ERROR_INFO_RESOVE_PERIOD = Config.getInteger("error.info.resovle.period",60);
//		MAILING_PERIOD = Config.getInteger("mailing.period",120);
//		DETEC_DATA_COLLECT_PERIOD = Config.getInteger("detec.data.collect.period");
		DATA_COLLECT_PERIOD = Config.getInteger("data.collect.period",300);
		ERROR_NODE_DATA_COLLECT_PERIOD = Config.getInteger("error.node.data.collect.period",600);
		NONRLTTASK_RESULT_COLLECT_PERIOD = Config.getInteger("nonRltTask.result.collect.period",600);
		DETEC_PING_STR = Config.getString("detec.ping.str","ping");
		DETEC_NMSC_STR = Config.getString("detec.nmsc.str","nmsclient");
		DETEC_SNMP_STR = Config.getString("detec.snmp.str","SNMP");
		DETEC_SWITCH_STR = Config.getString("detec.switch.str","switchport");
		DETEC_SYSTEMINFO_STR = Config.getString("detec.systeminfo.str","systeminfo");
		DETEC_SYSTEM_STR = Config.getString("detec.system.str","system");
		DETEC_SYSTEMDATE_STR = Config.getString("detec.systemdate.str","systemdate");
		DETEC_IFXTABLE_STR = Config.getString("detec.ifxtable.str","ifXTable");
		DELETE_TMP_FILES_PERIOD = Config.getInteger("delete.files.period",24);
		KEEP_FILE_DAYS = Config.getInteger("keep.file.days",7);
		
		ALARM_SNMP_TRAP_STR = Config.getString("alarm.snmp.trap.str","SNMP_TRAP");
		
		// #---Alarm Resolve-------
		ALARM_DATA_RESOLVE_PERIOD = Config.getInteger("alarm.data.resovle.period",60);
		
		// #---Web-------
//		WEB_DOWNLOAD_URL = formatPath(Config.getValue("web.download.url"));		//指定IP通信
		WEB_SOCKET_IP = Config.getString("web.socket.ip",null);		//指定IP通信
		WEB_SOCKET_PORT = Config.getInteger("web.socket.port",60703) ;		//指定IP通信端口
		
		// #---Mission  Control-------
		MISSION_LOOP_PRESET_NUMBER = Config.getInteger("mission.loop.preset.number",10);
//		MISSION_LOOP_FINISHING_DAILY = Config.getString("mission.loop.finishing.daily");
		
		// #---Mission release-------
		MISSION_RELEASE_SEMAPHORE_MAX  = Config.getInteger("mission.release.semaphore.max",(int)(EXECUTOR_SOCKET_THREAD_SIZE*0.3));
		MISSION_RELEASE_TIMES = Config.getInteger("mission.release.times",3);
		MISSION_RELEASE_PERIOD = Config.getInteger("mission.release.period",180);
		
		// #---Mission File-------
		MISSION_FILE_DOWNLOAD_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("mission.file.download.dir","dc_downLoad"));
		
//		int downloadDelay = (int)Config.getInteger("mission.file.download.delay");
		MISSION_FILE_DOWNLOAD_DELAY = Config.getInteger("mission.file.download.delay",60);
		MISSION_FILE_UPLOAD_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("mission.file.upload.dir","dc_upload"));
		MISSION_FILE_UPLOAD_PERIOD = Config.getInteger("mission.file.upload.period",120);
		MISSION_UPGRADE_DAILY = Config.getInteger("mission.update.daily",300);
		
		// #---Email-------
		/*
		FLAG_EMAIL = Config.getInteger("email.flag",0);
		if(FLAG_EMAIL==1){
			EMAIL_ADDRESS = Config.getString("email.address");
			EMAIL_USERNAME = Config.getString("email.userName");
			EMAIL_PASSWORD = Config.getString("email.password");
			EMAIL_HOST = Config.getString("email.host");
		}else{
			EMAIL_ADDRESS = null;
			EMAIL_USERNAME = null;
			EMAIL_PASSWORD = null;
			EMAIL_HOST = null;
		}*/
		
		// #---DataBase-------
		DB_POOL_TYPE = Config.getString("db.pool.type", "bonecp");//默认 bonecp
		DB_URL = Config.getString("db.url",null);
		DB_USER_NAME = Config.getString("db.username",null);
		DB_PASSWORD = Config.getString("db.password",null);
		DB_DRIVER = Config.getString("db.driver","oracle.jdbc.driver.OracleDriver");
		DB_DATE_FORMAT = Config.getString("db.date.format","yyyy-MM-dd HH24:mi:ss");
		DB_EXECUTE_BATCH = Config.getInteger("db.execute.batch",1000);
		
//		Integer partitionCount = (Integer) resource.getObject("db.pool.partitionCount");
		DB_STATEMENT_EXECUTE_TIMEOUT = Config.getInteger("db.statement.execute.timeout",60);
		DB_POOL_PARTITION_COUNT = Config.getInteger("db.pool.partitionCount",3);
		DB_POOL_CONNECTIONS_PER_PARTITION_MAX = Config.getInteger("db.pool.maxConnectionsPerPartition",5);
		DB_POOL_CONNECTIONS_PER_PARTITION_MIN = Config.getInteger("db.pool.minConnectionsPerPartition",3);
		DB_POOL_ACQUIRE_INCREMENT = Config.getInteger("db.pool.acquireIncrement",3);
		
		DB_POOL_IDLE_CONNECTION_TEST_PERIOD = Config.getInteger("db.pool.idleConnectionTestPeriod",15);
		DB_POOL_IDLE_MAX_AGE = Config.getInteger("db.pool.idleMaxAge",30);
		DB_GET_CONNECTION_TIMEOUT = Config.getInteger("db.get.connection.timeout",30);
		DB_POOL_MAX_CONNECTION_AGE = Config.getInteger("db.pool.max.connection.age",DB_POOL_IDLE_MAX_AGE*2);
		
		DB_POOL_RELEASE_HELPER_THREADS = Config.getInteger("db.pool.releaseHelperThreads",DB_POOL_PARTITION_COUNT);
		DB_POOL_STATEMENT_RELEASE_HELPER_THREADS = Config.getInteger("db.pool.statement.releaseHelperThreads",DB_POOL_PARTITION_COUNT);
		
		DB_POOL_QUERY_EXECUTE_TIME_LIMIT = Config.getInteger("db.pool.queryExecuteTimeLimit",60);
		
		DB_POOL_LOG_STATEMENT_ENABLE = Config.getBoolan("db.pool.logStatementEnable",true);

		// #---DATA-------
		/*
		DATA_DIR = formatPath(Config.getString("data.dir"));
		DATA_BACKUP_RIGHT_DIR = formatPath(Config.getString("data.backup.right.dir"));
		DATA_BACKUP_WRONG_DIR = formatPath(Config.getString("data.backup.wrong.dir"));
		*/
		// #---ZIP File-------
		ZIP_FILE_DETECT_DATA_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("zip.file.detect.data.dir","dc_zip/detect"));
		ZIP_FILE_TASK_RESULT_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("zip.file.task.result.dir","dc_zip/result"));
		ZIP_FILE_TASK_RETURN_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("zip.file.task.return.dir","dc_zip/return"));

		// #---ZIP File Resove-------
//		ZIP_RESOVE_DETECT_DATA_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("zip.resove.detect.data.dir","dc_zip/resove/detect"));
		ZIP_RESOVE_DETECT_DATA_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("zip.resove.detect.data.dir","dc_overrun/detect/zip_resove"));//为了避免因长时间未收集数据，导致一次性收集大量的数据（nc端默认1000csv打包zip，所以如果监测数据打包发送，表明数据较多），如果全部进行解析入库，会导致内存溢出，所以存入dc_overrun等待之后慢慢解析
		ZIP_RESOVE_TASK_RESULT_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("zip.resove.task.result.dir","dc_zip/resove/result"));
		ZIP_RESOVE_TASK_RETURN_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("zip.resove.task.return.dir","dc_zip/resove/return"));
		
		ERROR_DETEC_FILE_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("error.detect.file.dir","dc_error/detect"));
		
		OVERRUN_DETEC_FILE_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("overrun.detect.file.dir","dc_overrun/detect"));		
		OVERRUN_WARNING_FILE_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("overrun.warning.file.dir","dc_overrun/warning"));		
		OVERRUN_RESULT_FILE_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("overrun.result.file.dir","dc_overrun/result"));		
		
    	// TODO
		PLUGIN_SCRIPT_FILE_DIR = formatPath(COMMON_DATAS_DIR+File.separator+Config.getString("detecScript","dc_detecScript"));
		
		

//		DEFAULT_NODE_GROUP_NAME = Config.getString("default.node.group.name","默认节点组");
//		DEFAULT_NODE_GROUP_NAME = Config.getString("default.node.group.name","Default Node Group");
		DEFAULT_NODE_GROUP_NAME = Config.getString("default.node.group.name","i18n_server.Constants.defaultNodeGroup_n81i");
		MAX_COLLECT_RESOVE_DETECT_DATA_NUM = Config.getInteger("max.collect.resove.detect.data.num",60);
		MAX_DETECT_DATA_RESOVE_LIMIT_NUM = Config.getInteger("max.detect.data.resove.limit.num",60000);
		

		// #---SNMP-------
		SNMP_CLIENT_PORT = Config.getInteger("snmp.client.port",161);
		SNMP_TRAP_THREAD_POOL_SIZE = Config.getInteger("snmp.trap.thread.pool.size",10);
		SNMP_TRAP_PORT = Config.getInteger("snmp.trap.port",162);
		SNMP_COMMUNITY = Config.getString("snmp.community","public");
		/*SNMP_MIB_DIR = formatPath(Config.getString("snmp.mib.dir"));
		SNMP_CLASS_PATH = formatPath(Config.getString("snmp.class.path"));
		SNMP_CLASS_DIR = SNMP_CLASS_PATH+SNMP_CLASS_PACKAGE.replaceAll("\\.", "/")+"/";*/
		SNMP_CLASS_PACKAGE = Config.getString("snmp.class.package","osDomains");
		
		/*##--SNMP 加密认证级别 0 不认证 不加密'zg' 1 认证 不加密'hckings' ,2认证 且 加密'dxy'*/
		SNMP_V3_SECURITY_LEVEL = Config.getInteger("snmp.v3.security.level",0);
		SNMP_V3_SECURITY_NAME = Config.getString("snmp.v3.security.name","zg");
		SNMP_V3_AUTH_PROTOCOL = Config.getString("snmp.v3.auth.protocol","MD5");
		SNMP_V3_PRIV_PROTOCOL = Config.getString("snmp.v3.priv.protocol","DES");
		SNMP_V3_AUTH_PASSPHRASE = Config.getString("snmp.v3.auth.passphrase","12345678");
		SNMP_V3_PRIV_PASSPHRASE = Config.getString("snmp.v3.priv.passphrase","12345678");
		
		// #---SSL Init-------
		SSL_SO_TIMEOUT = Config.getInteger("ssl.so.timeout",600);
		SSL_TYPE = Config.getString("ssl.type","TLS");
		SSL_DIR =  formatPath(Config.getString("ssl.dir","cer"));
		SSL_SERVER_PORT = Config.getInteger("ssl.server.port",60702);
		SSL_CLIENT_PORT = Config.getInteger("ssl.client.port",60701);
		SSL_KEYSTORE_TYPE = Config.getString("ssl.keystore.type","jceks");
		SSL_SERVER_STORE = Config.getString("ssl.server.store","server_ks");
		SSL_SERVER_STORE_PSW = Config.getString("ssl.server.store.psw","client");
		SSL_SERVER_TRUST = Config.getString("ssl.server.trust","server_ts");
		SSL_SERVER_TRUST_PSW = Config.getString("ssl.server.trust.psw","client");
		SSL_SERVER_EXPORT = Config.getString("ssl.server.export","server.cer");
		SSL_CLIENT_EXPORT = Config.getString("ssl.client.export","client.cer");
		SSL_SERVER_KEY_NEW = Config.getString("ssl.server.key.new","serverks20110828");
		SSL_SERVER_KEY_OLD = Config.getString("ssl.server.key.old","serverks20110828");
		SSL_SERVER_KEY_NEW_PSW = Config.getString("ssl.server.key.new.psw","123456");
		SSL_SERVER_KEY_OLD_PSW = Config.getString("ssl.server.key.old.psw","123456");
		SSL_CLIENT_KEY = Config.getString("ssl.client.key","serverks20110828");
		SSL_CLIENT_KEY_PSW = Config.getString("ssl.client.key.psw","123456");
		SSL_CLIENT_STORE = Config.getString("ssl.client.store","client_ks");
		SSL_CLIENT_TRUST= Config.getString("ssl.client.trust","client_ts");
		SSL_KEY_VALIDITY= Config.getInteger("ssl.key.validity",90);
		
		
		// #---Test Flag-------
		FLAG_ZIP = Config.getInteger("zip.flag",1);
//		FLAG_DETEC_TIMEOUT = Config.getInteger("detec.timeout.flag");
		FLAG_FILE_UPLOAD= Config.getInteger("file.upload.flag",1);
		FLAG_DETEC_RESOVE= Config.getInteger("file.resove.flag",1);
		FLAG_ERROR_INFO= Config.getInteger("error.info.flag",1);
		FLAG_FILES_READER_RESOVE= Config.getInteger("data.files.reader.flag",1);
		FLAG_DATA_COLLECT= Config.getInteger("data.collect.flag",1);
		FLAG_HANDWALK_SSH= Config.getInteger("handwalk.ssh.flag",1);
		FLAG_DATA_COLLECT_ONLY_HANDSHAKE= Config.getInteger("data.collect.flag.only.handshake",1);
		FLAG_EMAIL_START= Config.getInteger("email.start.flag",1);
		FLAG_NONRLTTASK_RESULT_COLLECT= Config.getInteger("nonRltTask.result.collect.flag",1);
		FLAG_DELETE_TMP_FILES= Config.getInteger("delete.files.flag",1);
		FLAG_CHANGE_OPERATIONS=  Config.getInteger("change.operations.flag",1);
		FLAG_PING= Config.getInteger("ping.flag",1);
		FLAG_NMSC= Config.getInteger("nmsc.flag",1);
		FLAG_SNMP= Config.getInteger("snmp.flag",1);
		FLAG_SWITCH= Config.getInteger("switch.flag",1);
		FLAG_SYSTEMDATE = Config.getInteger("systemdate.flag",1);
		
		FLAG_MISSION= Config.getInteger("mission.flag",1);
		FLAG_MISSION_RESULT= Config.getInteger("result.flag",1);
		/*FLAG_RESOVE_READ_FILE= Config.getInteger("file.resove.readFile.flag");
		FLAG_RESOVE_RESOVE_FILE= Config.getInteger("file.resove.resoveFile.flag");
		FLAG_MOVE_FILE= Config.getInteger("file.moveFile.flag");*/
		FLAG_RESOVE_COMMIT_DB= Config.getInteger("file.resove.commitDB.flag",1);
		FLAG_ALARM_RESOVE = Config.getInteger("alarm.resove.flag",1);
		FLAG_TRAP = Config.getInteger("trap.flag",1);
//		FLAG_TEST = Config.getInteger("test.flag");
//		TEST_COMPUTER = Config.getInteger("computer.size");
//		TEST_SWITCH = Config.getInteger("switch.size");
//		SSL_INIT_SERVER_KEY = Config.getValue("ssl.init.server.key");
//		SSL_INIT_CLIENT_KEY = Config.getValue("ssl.init.client.key");
//		SSL_INIT_SERVER_KEY_PSW = Config.getValue("ssl.init.server.key.psw");
//		SSL_INIT_CLIENT_KEY_PSW = Config.getValue("ssl.init.client.key.psw");
		
		// #---SSL Bat-------
//		SSL_BAT_IMPORT = Config.getValue("ssl.bat.import");
//		SSL_BAT_GENKEY_EXPORT = Config.getValue("ssl.bat.genkey.export");
//		SSL_BAT_SERVER_INIT = Config.getValue("ssl.bat.server.init");
//		SYSTEM_INET_ADDRESS = Common.getLocalIp();
		
		PORT_ALARM_LEVEL = Config.getInteger("port.alarm.level",5);
		PORT_ALARM_EMERGENT = Config.getInteger("port.alarm.level",1);
		
		DETECT_FAIL_NMSC_POLICE_LEVEL  = Config.getInteger("detect.fail.nmsc.police.level",0);
		DETECT_FAIL_NMSC_POLICE_EMERGENT  = Config.getInteger("detect.fail.nmsc.police.emergent",0);
		DETECT_FAIL_NON_NMSC_POLICE_LEVEL  = Config.getInteger("detect.fail.non.nmsc.police.level",1);
		DETECT_FAIL_NON_NMSC_POLICE_EMERGENT  = Config.getInteger("detect.fail.non.nmsc.police.emergent",1);
		NC_ALARM_POLICE_LEVEL  = Config.getString("nc.alarm.police.level","0");
		
		SINGLE_NODE_DETECT_TIMEOUT = Config.getInteger("single.node.detect.timeout", 180);
		
		VARCHAR_MAX_LENGTH = Config.getInteger("varchar.max.length",4000)-1;
		
		
		FLAG_DETECT_DATA_SAVE_DISK_RESOVE = Config.getInteger("flag.detect.data.save.disk.resove",1);
		FLAG_WARN_DATA_SAVE_DISK_RESOVE = Config.getInteger("flag.warn.data.save.disk.resove",1);
		FLAG_ERROR_DATA_SAVE_DISK_RESOVE = Config.getInteger("flag.error.data.save.disk.resove",1);
		FLAG_TASK_RLT_SAVE_DISK_RESOVE = Config.getInteger("flag.task.rlt.save.disk.resove",1);
		
		DETECTION_INFO_DATA_MAX_ROWS = Config.getInteger("detection_info_data_max_rows", 500);
		FETCH_SIZE = Config.getInteger("fetch.size", 100);
		DATA_COLLECT_DAILY = Config.getInteger("data.collect.daily", 120);
		ERROR_NODE_DATA_COLLECT_DAILY = Config.getInteger("error.node.data.collect.daily", 540);
		
		SSH_CONNECT_TIMEOUT = Config.getInteger("ssh.connect.timeout", 2000);
		
		IS_HANDEL_EXCEPTION_NODE = Config.getBoolan("is.handel.exception.node", false);
		/**
		 * 数据库类型
		 */
		DB_TYPE = Config.getString("db.type", "oracle");
		/**
		 * 是否是 mysql 数据库
		 */
		IS_MYSQL = "mysql".equalsIgnoreCase(DB_TYPE);
		/**
		 * //dc监测数据入库模式，1：由web 主控控制入库，2：自己主动入库
		 */
		DETECT_INSERT_MODE = Config.getInteger("detect.insert.mode", 2);
		WEB_NOTICE_INSERT_DETECT_OVER_TIMES = Config.getInteger("web.notice.insert.detect.over.times", 3);
		
		DETECSELFTHREAD_FLAG = Config.getBoolan("DETECSELFTHREAD_FLAG", true);//DETECSELFTHREAD 开关
		DETECSELFTHREAD_PERIOD = Long.valueOf(Config.getInteger("DETECSELFTHREAD_PERIOD", 30));//监测间隔，单位：秒
		DETECSELFTHREAD_INITIALDELAY = Long.valueOf(Config.getInteger("DETECSELFTHREAD_PERIOD", 30));//监测延迟启动时间，单位：秒
		
		/**
		 * 监测数据入库线程模式，1：单线程，2：双线程（info,detail）
		 */
		DETECT_INSERT_THREAD_MODE = Config.getInteger("detect.insert.thread.mode", 1);
		/**
		 * INFO入库线程运行模式，1：每隔 N秒 运行一次，2：间隔 N 秒运行一次
		 */
		DETECT_INFO_THREAD_MODE = Config.getInteger("detect.info.thread.mode", 1);
		/**
		 * INFO入库线程 每隔 或间隔 时间 ，单位：S
		 */
		DETECT_INFO_THREAD_TIME = Config.getInteger("detect.info.thread.time", 60);
		DETECT_INFO_THREAD_DELAY = Config.getInteger("detect.INFO.thread.delay", 5);
		/**
		 * DETAIL入库线程运行模式，1：每隔 N秒 运行一次，2：间隔 N 秒运行一次
		 */
		DETECT_DETAIL_THREAD_MODE = Config.getInteger("detect.detail.thread.mode", 1);
		/**
		 * DETAIL入库线程 每隔 或间隔 时间 ，单位：S
		 */
		DETECT_DETAIL_THREAD_TIME = Config.getInteger("detect.detail.thread.time", 60);
		DETECT_DETAIL_THREAD_DELAY = Config.getInteger("detect.detail.thread.delay", 5);
	
		
		/**
		 * netty server
		 * 
		 */
		//0：启用
		NETTY_SERVER_FLAG = Config.getInteger("netty.server.flag", 1);
		NETTY_SERVER_PORT = Config.getInteger("netty.server.port", 9527);
		NETTY_SERVER_SSL = Config.getBoolan("netty.server.ssl", true);
		NETTY_IDLE_TIME = Config.getInteger("netty.idle.time", 15);
		NETTY_SO_BACKLOG = Config.getInteger("netty.so.backlog", 6000);
		SERVER_NMSC_THREAD_INTERVAL = Config.getInteger("server.nmsc.thread.interval", 300);
		
		NEXTVAL_FUNCTION_NAME = Config.getString("nextval_function_name", "nextval");
		CURRVAL_FUNCTION_NAME  = Config.getString("currval_function_name", "currval");
		HANDSHANK_DELAY_TIME = Long.parseLong(Config.getString("handshank.delay.time", 15000+""));
		
	}
	
	//文件传输 临时文件命名后缀
	public static final String TEMP_SUFFIX = ".tp";
	
	private static String formatPath(String path){
		if(StringUtils.isNotEmpty(path)){
			path = path.replaceAll("\\\\", "/");
			if(!path.endsWith("/") && !path.endsWith("=")){
				path = path+"/";
			}
		}
		return path;
	}
}
