|
@@ -1,27 +1,24 @@
|
|
|
package com.saga.thread.common;
|
|
|
|
|
|
-import java.io.FileReader;
|
|
|
+import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
|
import org.zillion.util.log.LogUtil;
|
|
|
|
|
|
-import com.google.gson.JsonArray;
|
|
|
-import com.google.gson.JsonObject;
|
|
|
-import com.google.gson.JsonParser;
|
|
|
+import com.saga.entity.EntityHbase;
|
|
|
+import com.saga.entity.EntityMysql;
|
|
|
+import com.saga.entity.Server;
|
|
|
import com.saga.util.Constant;
|
|
|
-import com.saga.util.HBaseUtil;
|
|
|
-import com.zillion.database.agent.ZillionAgent;
|
|
|
+import com.saga.util.ExcelUtil;
|
|
|
|
|
|
public class LoadConfigThread extends Thread {
|
|
|
- // ZillionAgent agent;
|
|
|
|
|
|
public LoadConfigThread() {
|
|
|
try {
|
|
|
- // this.agent = Constant.agent;
|
|
|
-
|
|
|
} catch (Exception e) {
|
|
|
// TODO Auto-generated catch block
|
|
|
LogUtil.error("LoadConfigThread.Exception: " + e.toString());
|
|
@@ -31,26 +28,21 @@ public class LoadConfigThread extends Thread {
|
|
|
|
|
|
public void run() {
|
|
|
LogUtil.info("LoadConfigThread" + this.getName() + " Starting ...");
|
|
|
- try {
|
|
|
- Thread.sleep(Constant.Millisecond.MINUTE_3);
|
|
|
- while (true) {
|
|
|
- try {
|
|
|
- // 加载config配置文件
|
|
|
- this.loadConfig();
|
|
|
- // 加载DB点位列表
|
|
|
- this.loadPointList2();
|
|
|
- // 加载采集器配置文件
|
|
|
- // this.loadCJQ();
|
|
|
- Thread.sleep(Constant.Millisecond.MINUTE_5);
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- LogUtil.error("LoadConfigThread.run.Exception: " + e.toString());
|
|
|
- }
|
|
|
+ while (true) {
|
|
|
+ try {
|
|
|
+ // 加载config配置文件
|
|
|
+ // this.loadJsonConfig();
|
|
|
+ loadExcelConfig();
|
|
|
+ // 加载DB点位列表
|
|
|
+ this.loadPointList2();
|
|
|
+ // 加载采集器配置文件
|
|
|
+ // this.loadCJQ();
|
|
|
+ Thread.sleep(Constant.Millisecond.MINUTE_5);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ LogUtil.error("LoadConfigThread.run.Exception: " + e.toString());
|
|
|
}
|
|
|
- } catch (InterruptedException e1) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e1.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -73,19 +65,12 @@ public class LoadConfigThread extends Thread {
|
|
|
// Constant.ps_MeterList.clear();
|
|
|
}
|
|
|
LogUtil.info("Clear Project Point List" + " End...");
|
|
|
- for (ZillionAgent agent : Constant.agents) {
|
|
|
- for (Entry<String, String> bd : Constant.BuildingDB.entrySet()) {
|
|
|
- try {
|
|
|
- String project = bd.getKey();
|
|
|
- String db = bd.getValue();
|
|
|
- HBaseUtil.LoadDB2Cache_dy_pointlist(agent, db, "dy_pointlist", project);
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- LogUtil.error("LoadConfigThread.loadPointList2: " + e.toString());
|
|
|
- }
|
|
|
- }
|
|
|
+ try {
|
|
|
+ Constant.LoadDB2Cache_dy_pointlist(Constant.Database, "dy_pointlist");
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ LogUtil.error("LoadConfigThread.loadPointList2: " + e.toString());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -122,69 +107,482 @@ public class LoadConfigThread extends Thread {
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
- private void loadConfig() {
|
|
|
+ public static void loadExcelConfig() {
|
|
|
// TODO Auto-generated method stub
|
|
|
- String resource = "/config.json";
|
|
|
+ String resource = "/config.xls";
|
|
|
String path = null;
|
|
|
- JsonParser config = new JsonParser();
|
|
|
-
|
|
|
try {
|
|
|
LogUtil.info("System.get " + System.getProperty("user.dir") + resource);
|
|
|
LogUtil.info("LogUtil.get " + LogUtil.GetPath() + resource);
|
|
|
path = LogUtil.GetPath() + resource;
|
|
|
+ File file = new File(path);
|
|
|
+ if (file.exists()) {
|
|
|
+ excuteDbMysql(file);
|
|
|
+ excuteDbHbase(file);
|
|
|
+ excuteNetworkUp(file);
|
|
|
+ excuteNetworkDown(file);
|
|
|
+ excuteRulesGlobal(file);
|
|
|
+ excuteRulesBuildingConvert(file);
|
|
|
+ excuteRulesFuncConvert(file);
|
|
|
+ excuteRulesWhiteList(file);
|
|
|
+ excuteRulesBlackList(file);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void excuteRulesBlackList(File file) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+ // Map<Integer, String> ptyValue = new HashMap<Integer, String>();
|
|
|
+
|
|
|
+ Map<Integer, Map<Integer, Map<Integer, String>>> excelData = ExcelUtil.readExcel(file);
|
|
|
+ for (int k = 0; k < excelData.size(); k++) {
|
|
|
+ Map<Integer, Map<Integer, String>> sheetData = excelData.get(k);
|
|
|
+ for (int i = 0; i < sheetData.size(); i++) {
|
|
|
+ Map<Integer, String> rowData = sheetData.get(i);
|
|
|
+ if ("Rules-BlackList".equalsIgnoreCase(rowData.get(0))) {
|
|
|
+ begin = i;
|
|
|
+ // Constant.info("Rules-BlackList begin: " + i);
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+ // ptyValue.put(j, rowData.get(j));
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Rules-BlackList".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+ // ptyValue = new HashMap<Integer, String>();
|
|
|
+ // Constant.info("Rules-BlackList end: " + i);
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+ // Constant.info("Rules-BlackList add: " + i);
|
|
|
+ if (rowData.get(1) == null || rowData.get(1).length() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ pty = Constant.toLower(pty);
|
|
|
+ String building = rowData.get(pty.get("building"));
|
|
|
+
|
|
|
+ Constant.black_Buildings.put(building, null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void excuteRulesWhiteList(File file) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
|
|
|
- JsonObject object = (JsonObject) config.parse(new FileReader(path));
|
|
|
-
|
|
|
- JsonArray db = object.get("DB").getAsJsonArray();
|
|
|
- for (int i = 0; i < db.size(); i++) {
|
|
|
- JsonObject subObject = db.get(i).getAsJsonObject();
|
|
|
- if (subObject.get("building") != null) {
|
|
|
- String building = subObject.get("building").getAsString();
|
|
|
- // if(Constant.BuildingDB.containsKey(building)){
|
|
|
- // continue;
|
|
|
- // }
|
|
|
- Constant.BuildingDB.put(building, subObject.get("database").getAsString());
|
|
|
-
|
|
|
- if (subObject.get("buildingadds") != null) {
|
|
|
- JsonArray buildingAdds = subObject.get("buildingadds").getAsJsonArray();
|
|
|
- for (int j = 0; j < buildingAdds.size(); j++) {
|
|
|
- JsonObject addObject = buildingAdds.get(j).getAsJsonObject();
|
|
|
- String builing_new = addObject.get("building").getAsString();
|
|
|
- if (!Constant.BuildingAdds.containsKey(building)) {
|
|
|
- Constant.BuildingAdds.put(building, new ArrayList<String>());
|
|
|
- }
|
|
|
- if (!exist(builing_new)) {
|
|
|
- Constant.BuildingAdds.get(building).add(builing_new);
|
|
|
- Constant.BuildingConv.put(builing_new, building);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- } else if (subObject.get("insertthread") != null) {
|
|
|
- Constant.InsertThread = subObject.get("insertthread").getAsInt();
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+ // Map<Integer, String> ptyValue = new HashMap<Integer, String>();
|
|
|
+
|
|
|
+ Map<Integer, Map<Integer, Map<Integer, String>>> excelData = ExcelUtil.readExcel(file);
|
|
|
+ for (int k = 0; k < excelData.size(); k++) {
|
|
|
+ Map<Integer, Map<Integer, String>> sheetData = excelData.get(k);
|
|
|
+ for (int i = 0; i < sheetData.size(); i++) {
|
|
|
+ Map<Integer, String> rowData = sheetData.get(i);
|
|
|
+ if ("Rules-WhiteList".equalsIgnoreCase(rowData.get(0))) {
|
|
|
+ begin = i;
|
|
|
+ // Constant.info("Rules-WhiteList begin: " + i);
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+ // ptyValue.put(j, rowData.get(j));
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Rules-WhiteList".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+ // ptyValue = new HashMap<Integer, String>();
|
|
|
+ // Constant.info("Rules-WhiteList end: " + i);
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+ // Constant.info("Rules-WhiteList add: " + i);
|
|
|
+ if (rowData.get(1) == null || rowData.get(1).length() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ pty = Constant.toLower(pty);
|
|
|
+ String funcid = rowData.get(pty.get("funcid"));
|
|
|
+
|
|
|
+ Constant.whilte_Funcs.put(Integer.valueOf(funcid), null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void excuteRulesFuncConvert(File file) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+ // Map<Integer, String> ptyValue = new HashMap<Integer, String>();
|
|
|
+
|
|
|
+ Map<Integer, Map<Integer, Map<Integer, String>>> excelData = ExcelUtil.readExcel(file);
|
|
|
+ for (int k = 0; k < excelData.size(); k++) {
|
|
|
+ Map<Integer, Map<Integer, String>> sheetData = excelData.get(k);
|
|
|
+ for (int i = 0; i < sheetData.size(); i++) {
|
|
|
+ Map<Integer, String> rowData = sheetData.get(i);
|
|
|
+ if ("Rules-FuncConvert".equalsIgnoreCase(rowData.get(0))) {
|
|
|
+ begin = i;
|
|
|
+ // Constant.info("Rules-FuncConvert begin: " + i);
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+ // ptyValue.put(j, rowData.get(j));
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Rules-FuncConvert".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+ // ptyValue = new HashMap<Integer, String>();
|
|
|
+ // Constant.info("Rules-FuncConvert end: " + i);
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+ // Constant.info("Rules-FuncConvert add: " + i);
|
|
|
+ if (rowData.get(1) == null || rowData.get(1).length() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ pty = Constant.toLower(pty);
|
|
|
+ String buildingOld = rowData.get(pty.get("building"));
|
|
|
+ String funcidOld = rowData.get(pty.get("oldfuncid"));
|
|
|
+ String funcidNew = rowData.get(pty.get("newfuncid"));
|
|
|
+
|
|
|
+ Constant.FunctionConv.put(buildingOld + "-" + funcidOld, funcidNew);
|
|
|
+ Constant.FunctionConvReverse.put(buildingOld + "-" + funcidNew, funcidOld);
|
|
|
}
|
|
|
}
|
|
|
- JsonArray port = object.get("Port").getAsJsonArray();
|
|
|
- for (int i = 0; i < port.size(); i++) {
|
|
|
- JsonObject subObject = port.get(i).getAsJsonObject();
|
|
|
- Constant.TypePort.put(subObject.get("type").getAsString(), subObject.get("port").getAsString());
|
|
|
- Constant.PortCompress.put(Integer.valueOf(subObject.get("port").getAsString()),
|
|
|
- subObject.get("Compress").getAsString());
|
|
|
- Constant.PortHistory.put(Integer.valueOf(subObject.get("port").getAsString()),
|
|
|
- subObject.get("History").getAsString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void excuteRulesBuildingConvert(File file) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+ // Map<Integer, String> ptyValue = new HashMap<Integer, String>();
|
|
|
+
|
|
|
+ Map<Integer, Map<Integer, Map<Integer, String>>> excelData = ExcelUtil.readExcel(file);
|
|
|
+ for (int k = 0; k < excelData.size(); k++) {
|
|
|
+ Map<Integer, Map<Integer, String>> sheetData = excelData.get(k);
|
|
|
+ for (int i = 0; i < sheetData.size(); i++) {
|
|
|
+ Map<Integer, String> rowData = sheetData.get(i);
|
|
|
+ if ("Rules-BuildingConvert".equalsIgnoreCase(rowData.get(0))) {
|
|
|
+ begin = i;
|
|
|
+ // Constant.info("Rules-BuildingConvert begin: " + i);
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+ // ptyValue.put(j, rowData.get(j));
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0)
|
|
|
+ && !("Rules-BuildingConvert".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+ // ptyValue = new HashMap<Integer, String>();
|
|
|
+ // Constant.info("Rules-BuildingConvert end: " + i);
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+ // Constant.info("Rules-BuildingConvert add: " + i);
|
|
|
+ if (rowData.get(1) == null || rowData.get(1).length() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ pty = Constant.toLower(pty);
|
|
|
+ String buildingOld = rowData.get(pty.get("oldbuilding"));
|
|
|
+ String buildingNew = rowData.get(pty.get("newbuilding"));
|
|
|
+ String timeOffset = rowData.get(pty.get("timeoffset"));
|
|
|
+ if (!Constant.BuildingAdds.containsKey(buildingOld)) {
|
|
|
+ Constant.BuildingAdds.put(buildingOld, new ArrayList<String>());
|
|
|
+ }
|
|
|
+ Constant.BuildingAdds.get(buildingOld).add(buildingNew);
|
|
|
+ Constant.BuildingConv.put(buildingNew, buildingOld);
|
|
|
+ Constant.BuildingOffset.put(buildingOld, Boolean.getBoolean(timeOffset));
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- } catch (Exception e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
+ private static void excuteRulesGlobal(File file) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+ // Map<Integer, String> ptyValue = new HashMap<Integer, String>();
|
|
|
+
|
|
|
+ Map<Integer, Map<Integer, Map<Integer, String>>> excelData = ExcelUtil.readExcel(file);
|
|
|
+ for (int k = 0; k < excelData.size(); k++) {
|
|
|
+ Map<Integer, Map<Integer, String>> sheetData = excelData.get(k);
|
|
|
+ for (int i = 0; i < sheetData.size(); i++) {
|
|
|
+ Map<Integer, String> rowData = sheetData.get(i);
|
|
|
+ if ("Rules-Global".equalsIgnoreCase(rowData.get(0))) {
|
|
|
+ begin = i;
|
|
|
+ // Constant.info("Rules-Global begin: " + i);
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+ // ptyValue.put(j, rowData.get(j));
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Rules-Global".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+ // ptyValue = new HashMap<Integer, String>();
|
|
|
+ // Constant.info("Rules-Global end: " + i);
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+ // Constant.info("Rules-Global add: " + i);
|
|
|
+ if (rowData.get(1) == null || rowData.get(1).length() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ pty = Constant.toLower(pty);
|
|
|
+
|
|
|
+ Constant.Disconnect = Constant.getMillisecond(rowData.get(pty.get("disconnect")));
|
|
|
+ Constant.Database = rowData.get(pty.get("database"));
|
|
|
+ Constant.InsertThread = Integer.valueOf(rowData.get(pty.get("insertthread")));
|
|
|
+ for (String upload : rowData.get(pty.get("uploadtable")).split(",")) {
|
|
|
+ Constant.uploadList.add(upload);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void excuteNetworkDown(File file) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+ // Map<Integer, String> ptyValue = new HashMap<Integer, String>();
|
|
|
+ Map<Integer, Map<Integer, Map<Integer, String>>> excelData = ExcelUtil.readExcel(file);
|
|
|
+ for (int k = 0; k < excelData.size(); k++) {
|
|
|
+ Map<Integer, Map<Integer, String>> sheetData = excelData.get(k);
|
|
|
+ for (int i = 0; i < sheetData.size(); i++) {
|
|
|
+ Map<Integer, String> rowData = sheetData.get(i);
|
|
|
+ if ("Network-Down".equalsIgnoreCase(rowData.get(0))) {
|
|
|
+ begin = i;
|
|
|
+ // Constant.info("Network-Down begin: " + i);
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+ // ptyValue.put(j, rowData.get(j));
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Network-Down".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+ // ptyValue = new HashMap<Integer, String>();
|
|
|
+ // Constant.info("Network-Down end: " + i);
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+ // Constant.info("Network-Down add: " + i);
|
|
|
+ if (rowData.get(1) == null || rowData.get(1).length() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ pty = Constant.toLower(pty);
|
|
|
+ Server server = new Server();
|
|
|
+ server.IP = rowData.get(pty.get("ip"));
|
|
|
+ server.Port = Integer.valueOf(rowData.get(pty.get("port")));
|
|
|
+ server.compress = Boolean.getBoolean(rowData.get(pty.get("compress")));
|
|
|
+
|
|
|
+ Constant.TypeServer.put("Down", server);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void excuteNetworkUp(File file) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+ // Map<Integer, String> ptyValue = new HashMap<Integer, String>();
|
|
|
+ Map<Integer, Map<Integer, Map<Integer, String>>> excelData = ExcelUtil.readExcel(file);
|
|
|
+ for (int k = 0; k < excelData.size(); k++) {
|
|
|
+ Map<Integer, Map<Integer, String>> sheetData = excelData.get(k);
|
|
|
+ for (int i = 0; i < sheetData.size(); i++) {
|
|
|
+ Map<Integer, String> rowData = sheetData.get(i);
|
|
|
+ if ("Network-Up".equalsIgnoreCase(rowData.get(0))) {
|
|
|
+ begin = i;
|
|
|
+ // Constant.info("Network-Up begin: " + i);
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+ // ptyValue.put(j, rowData.get(j));
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Network-Up".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+ // ptyValue = new HashMap<Integer, String>();
|
|
|
+ // Constant.info("Network-Up end: " + i);
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+ // Constant.info("Network-Up add: " + i);
|
|
|
+ if (rowData.get(1) == null || rowData.get(1).length() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ pty = Constant.toLower(pty);
|
|
|
+ Server server = new Server();
|
|
|
+ server.IP = rowData.get(pty.get("ip"));
|
|
|
+ server.Port = Integer.valueOf(rowData.get(pty.get("port")));
|
|
|
+ server.compress = Boolean.getBoolean(rowData.get(pty.get("compress")));
|
|
|
+
|
|
|
+ Constant.TypeServer.put("Up", server);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void excuteDbHbase(File file) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+ // Map<Integer, String> ptyValue = new HashMap<Integer, String>();
|
|
|
+
|
|
|
+ Map<Integer, Map<Integer, Map<Integer, String>>> excelData = ExcelUtil.readExcel(file);
|
|
|
+ for (int k = 0; k < excelData.size(); k++) {
|
|
|
+ Map<Integer, Map<Integer, String>> sheetData = excelData.get(k);
|
|
|
+ for (int i = 0; i < sheetData.size(); i++) {
|
|
|
+ Map<Integer, String> rowData = sheetData.get(i);
|
|
|
+ if ("Db-Hbase".equalsIgnoreCase(rowData.get(0))) {
|
|
|
+ begin = i;
|
|
|
+ // Constant.info("Db-Hbase begin: " + i);
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+ // ptyValue.put(j, rowData.get(j));
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Db-Hbase".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+ // ptyValue = new HashMap<Integer, String>();
|
|
|
+ // Constant.info("Db-Hbase end: " + i);
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+ // Constant.info("Db-Hbase add: " + i);
|
|
|
+ if (rowData.get(1) == null || rowData.get(1).length() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ pty = Constant.toLower(pty);
|
|
|
+ EntityHbase entityHbase = new EntityHbase();
|
|
|
+ entityHbase.Address = rowData.get(pty.get("address"));
|
|
|
+
|
|
|
+ Constant.DbConnection.put("Db-Hbase", entityHbase);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private boolean exist(String builing_new) {
|
|
|
+ private static void excuteDbMysql(File file) {
|
|
|
// TODO Auto-generated method stub
|
|
|
- if (Constant.BuildingConv.containsKey(builing_new)) {
|
|
|
- return true;
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+ // Map<Integer, String> ptyValue = new HashMap<Integer, String>();
|
|
|
+
|
|
|
+ Map<Integer, Map<Integer, Map<Integer, String>>> excelData = ExcelUtil.readExcel(file);
|
|
|
+ for (int k = 0; k < excelData.size(); k++) {
|
|
|
+ Map<Integer, Map<Integer, String>> sheetData = excelData.get(k);
|
|
|
+ for (int i = 0; i < sheetData.size(); i++) {
|
|
|
+ Map<Integer, String> rowData = sheetData.get(i);
|
|
|
+ if ("Db-Mysql".equalsIgnoreCase(rowData.get(0))) {
|
|
|
+ begin = i;
|
|
|
+ // Constant.info("Db-Mysql begin: " + i);
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+ // ptyValue.put(j, rowData.get(j));
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Db-Mysql".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+ // ptyValue = new HashMap<Integer, String>();
|
|
|
+ // Constant.info("Db-Mysql end: " + i);
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+ // Constant.info("Db-Mysql add: " + i);
|
|
|
+ if (rowData.get(1) == null || rowData.get(1).length() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ pty = Constant.toLower(pty);
|
|
|
+ EntityMysql entityMysql = new EntityMysql();
|
|
|
+ entityMysql.Ip = rowData.get(pty.get("ip"));
|
|
|
+ entityMysql.Port = Integer.valueOf(rowData.get(pty.get("port")));
|
|
|
+ entityMysql.User = rowData.get(pty.get("user"));
|
|
|
+ entityMysql.Password = rowData.get(pty.get("password"));
|
|
|
+
|
|
|
+ Constant.DbConnection.put("Db-Mysql", entityMysql);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- return false;
|
|
|
}
|
|
|
+
|
|
|
+ // private void loadJsonConfig() {
|
|
|
+ // // TODO Auto-generated method stub
|
|
|
+ // String resource = "/config.json";
|
|
|
+ // String path = null;
|
|
|
+ // JsonParser config = new JsonParser();
|
|
|
+ //
|
|
|
+ // try {
|
|
|
+ // LogUtil.info("System.get " + System.getProperty("user.dir") + resource);
|
|
|
+ // LogUtil.info("LogUtil.get " + LogUtil.GetPath() + resource);
|
|
|
+ // path = LogUtil.GetPath() + resource;
|
|
|
+ //
|
|
|
+ // JsonObject object = (JsonObject) config.parse(new FileReader(path));
|
|
|
+ //
|
|
|
+ // JsonArray db = object.get("DB").getAsJsonArray();
|
|
|
+ // for (int i = 0; i < db.size(); i++) {
|
|
|
+ // JsonObject subObject = db.get(i).getAsJsonObject();
|
|
|
+ // if (subObject.get("building") != null) {
|
|
|
+ // String building = subObject.get("building").getAsString();
|
|
|
+ // // if(Constant.BuildingDB.containsKey(building)){
|
|
|
+ // // continue;
|
|
|
+ // // }
|
|
|
+ // Constant.BuildingDB.put(building,
|
|
|
+ // subObject.get("database").getAsString());
|
|
|
+ //
|
|
|
+ // if (subObject.get("buildingadds") != null) {
|
|
|
+ // JsonArray buildingAdds = subObject.get("buildingadds").getAsJsonArray();
|
|
|
+ // for (int j = 0; j < buildingAdds.size(); j++) {
|
|
|
+ // JsonObject addObject = buildingAdds.get(j).getAsJsonObject();
|
|
|
+ // String builing_new = addObject.get("building").getAsString();
|
|
|
+ // if (!Constant.BuildingAdds.containsKey(building)) {
|
|
|
+ // Constant.BuildingAdds.put(building, new ArrayList<String>());
|
|
|
+ // }
|
|
|
+ // if (!exist(builing_new)) {
|
|
|
+ // Constant.BuildingAdds.get(building).add(builing_new);
|
|
|
+ // Constant.BuildingConv.put(builing_new, building);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // } else if (subObject.get("insertthread") != null) {
|
|
|
+ // Constant.InsertThread = subObject.get("insertthread").getAsInt();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // JsonArray port = object.get("Port").getAsJsonArray();
|
|
|
+ // for (int i = 0; i < port.size(); i++) {
|
|
|
+ // JsonObject subObject = port.get(i).getAsJsonObject();
|
|
|
+ // Constant.TypePort.put(subObject.get("type").getAsString(),
|
|
|
+ // subObject.get("port").getAsString());
|
|
|
+ // Constant.PortCompress.put(Integer.valueOf(subObject.get("port").getAsString()),
|
|
|
+ // subObject.get("Compress").getAsString());
|
|
|
+ // Constant.PortHistory.put(Integer.valueOf(subObject.get("port").getAsString()),
|
|
|
+ // subObject.get("History").getAsString());
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // } catch (Exception e) {
|
|
|
+ // // TODO Auto-generated catch block
|
|
|
+ // e.printStackTrace();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // private boolean exist(String builing_new) {
|
|
|
+ // // TODO Auto-generated method stub
|
|
|
+ // if (Constant.BuildingConv.containsKey(builing_new)) {
|
|
|
+ // return true;
|
|
|
+ // }
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
}
|