package main;
|
import java.sql.Connection;
|
import java.sql.SQLException;
|
import java.util.Date;
|
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.Logger;
|
import com.base.Com;
|
import com.config.AppConfig;
|
import com.sql.MysqlConnPool;
|
|
public class main_Central_Monitor {
|
/**************************************************************************/
|
/**************************************************************************/
|
/**************************************************************************/
|
/**************************************************************************/
|
/**************************************************************************/
|
public final static double m_VersionNum = 1.101;
|
public final static String m_Version = "Welcome To Use main_Central_Monitor V"
|
+ m_VersionNum ;
|
/**************************************************************************/
|
/**************************************************************************/
|
public static final int MysqlServer_Port = 3360;
|
|
private static AppConfig m_AppConfig;
|
|
private static MysqlConnPool GB_MysqlConnPool;
|
|
private static Logger logger = null;
|
|
static{
|
System.setProperty("log4j.configurationFile", "log4j2_central_monitor.xml");
|
}
|
|
/*********************************************************************************************/
|
/*********************************************************************************************/
|
public static void main(String[] args) {
|
|
logger = LogManager.getLogger(main_Central_Monitor.class);
|
String ver = m_Version;
|
logger.info("main_MonitorServer_Motor Server Started At DateTime: " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "\t V"+ver);
|
//´´½¨config.xmlÎļþ
|
m_AppConfig = new AppConfig();
|
|
logger.info("SQLserver IP£º" + m_AppConfig.getMysqlServerIp() + ", port: "+MysqlServer_Port);
|
checkingMySQLServerStart(); //¼ì²âÊý¾Ý¿â·þÎñÊÇ·ñÆô¶¯
|
|
|
//³õʼ»¯Á¬½Ó³ØÖеĸ÷ÖÖ²ÎÊýÐÅÏ¢
|
GB_MysqlConnPool = new MysqlConnPool(m_AppConfig.getMysqlServerIp(), MysqlServer_Port,m_AppConfig.getMysqlConnCountMax());
|
|
|
/*********************************************************************************/
|
/*********************************************************************************/
|
|
|
|
|
while(true) {
|
try {
|
Thread.sleep(5000);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
/*********************************************************************************/
|
}
|
|
public static void checkingMySQLServerStart(){
|
int MysqlServer_Port = 3360;
|
logger.info("IP:"+m_AppConfig.getMysqlServerIp()+"\t port:"+MysqlServer_Port);
|
//³õʼ»¯Á¬½Ó³ØÖеĸ÷ÖÖ²ÎÊýÐÅÏ¢ m_AppConfig.getMysqlServerIp()
|
GB_MysqlConnPool = new MysqlConnPool(m_AppConfig.getMysqlServerIp(), MysqlServer_Port, 5);
|
while(true){
|
Connection conn = null;
|
try {
|
logger.info(" ¿ªÊ¼¼ì²âÊý¾Ý¿âÁ¬½Ó "+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
conn = GB_MysqlConnPool.getConn();
|
if(conn != null){
|
logger.info("¼ì²âÊý¾Ý¿âÁ¬½Ó³É¹¦");
|
break;
|
}
|
} catch (Exception e) {
|
try {
|
Thread.sleep(1000);
|
} catch (InterruptedException e1) {
|
logger.error(e.toString(), e);
|
}
|
logger.info(" MySQL_FBSDEV not Start ... ");
|
} finally {
|
if(conn != null) {
|
try {
|
conn.close();
|
} catch (SQLException e) {
|
logger.error(e.toString(), e);
|
}
|
}
|
}
|
}
|
}
|
}
|