自测socket通信dc 设置或修改监测配置
This commit is contained in:
@@ -14,6 +14,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jfinal.kit.PropKit;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
||||
@@ -26,6 +27,8 @@ import com.mysql.jdbc.Connection;
|
||||
import com.mysql.jdbc.PreparedStatement;
|
||||
import com.mysql.jdbc.Statement;
|
||||
import com.nms.main.Conn;
|
||||
import com.nms.model.SetInfo;
|
||||
import com.nms.socket.SocketClientServeice;
|
||||
|
||||
public class TestClass {
|
||||
private static Connection getConnection(){
|
||||
@@ -306,4 +309,29 @@ public class TestClass {
|
||||
}
|
||||
Db.batchSave("table_event_log", datas, 500);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void socketTest() {
|
||||
SetInfo o = null;
|
||||
SetInfo n = new SetInfo();
|
||||
n.setId(100009L);
|
||||
n.setCheckTypeId(3L);
|
||||
n.setCheckTypeName("disk");
|
||||
n.setProcessIden("detection100033");
|
||||
n.setNodeGroupsId("100001");
|
||||
n.setNodeIpsId("100006");
|
||||
n.setCheckWay("1");
|
||||
final JSONObject jObject = new JSONObject();
|
||||
jObject.put("old", o);
|
||||
jObject.put("new", n);
|
||||
System.out.println(jObject.toString());
|
||||
System.out.println("------------------");
|
||||
System.out.println(jObject.toJSONString());
|
||||
try {
|
||||
new SocketClientServeice("192.168.10.186").sendInfoToServer("char:setInfoAlert",jObject.toString());
|
||||
} catch (Exception e) {
|
||||
System.out.println("Monitoring setting to change communication anomalies: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public class SyncSlaveToMasterThread implements Runnable{
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String errorTableName=null;
|
||||
try {
|
||||
// 主库向分库同步数据
|
||||
logger.info("开始分库数据同步主库");
|
||||
@@ -43,7 +44,8 @@ public class SyncSlaveToMasterThread implements Runnable{
|
||||
//logger.info("查询分库需要同步到主库的数据信息"+JSON.toJSONString(find));
|
||||
if (find != null && find.size() > 0) {
|
||||
for (final Record record : find) {
|
||||
logger.info("分库数据同步到主库 正在操作的表名为:"+ record.getStr("table_name"));
|
||||
//logger.info("分库数据同步到主库 正在操作的表名为:"+ record.getStr("table_name"));
|
||||
errorTableName=record.getStr("table_name");
|
||||
//如果设定指定字段 则只操作指定字段数据 无则操作全部
|
||||
final StringBuffer columns=new StringBuffer();
|
||||
columns.append("*");
|
||||
@@ -286,6 +288,7 @@ public class SyncSlaveToMasterThread implements Runnable{
|
||||
logger.info("分库数据同步主库结束");
|
||||
logger.info("##################################################");
|
||||
} catch (Exception e) {
|
||||
logger.error("分库同步主库数据当前操作的异常表名为:"+errorTableName);
|
||||
logger.error("分库数据同步主库发生错误 异常信息为:"+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.IAtom;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
import com.nms.interceptor.SyncDataInterceptor;
|
||||
import com.nms.interceptor.SyncSocketInterceptor;
|
||||
import com.nms.model.SyncDbInfo;
|
||||
import com.jfinal.plugin.activerecord.tx.Tx;
|
||||
/**
|
||||
@@ -19,7 +20,7 @@ import com.jfinal.plugin.activerecord.tx.Tx;
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@Before({SyncDataInterceptor.class,Tx.class})
|
||||
@Before({SyncDataInterceptor.class,SyncSocketInterceptor.class,Tx.class})
|
||||
public class SyncThread implements Runnable {
|
||||
private Logger logger = Logger.getLogger(this.getClass());
|
||||
private SyncDbInfo syncDbInfo;
|
||||
@@ -35,6 +36,7 @@ public class SyncThread implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String errorTableName=null;
|
||||
try {
|
||||
logger.info("开始主库数据同步分库任务");
|
||||
// 获取url路径
|
||||
@@ -47,7 +49,8 @@ public class SyncThread implements Runnable {
|
||||
//logger.info("查询主库须向分库同步数据信息"+JSON.toJSONString(find));
|
||||
if (find != null && find.size() > 0) {
|
||||
for (final Record record : find) {
|
||||
logger.info("主库数据同步到分库 正在操作的表名为:"+ record.getStr("table_name"));
|
||||
//logger.info("主库数据同步到分库 正在操作的表名为:"+ record.getStr("table_name"));
|
||||
errorTableName=record.getStr("table_name");
|
||||
//如果设定指定字段 则只操作指定字段数据 无则操作全部
|
||||
final StringBuffer columns=new StringBuffer();
|
||||
columns.append("*");
|
||||
@@ -245,6 +248,7 @@ public class SyncThread implements Runnable {
|
||||
logger.info("主库数据同步分库结束");
|
||||
logger.info("*****************************************************");
|
||||
} catch (Exception e) {
|
||||
logger.error("主库同步分库数据当前操作的异常表名为:"+errorTableName);
|
||||
logger.error("主库数据同步分库发生错误 异常信息为:"+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user