|
@@ -0,0 +1,833 @@
|
|
|
+package com.saga.thread.common;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import org.zillion.util.log.LogUtil;
|
|
|
+import com.saga.entity.EntityHbase;
|
|
|
+import com.saga.entity.EntityMysql;
|
|
|
+import com.saga.entity.Server;
|
|
|
+import com.saga.entity.Transfer;
|
|
|
+import com.saga.util.Constant;
|
|
|
+import com.saga.util.ExcelUtil;
|
|
|
+
|
|
|
+
|
|
|
+ * 加载配置信息
|
|
|
+ *
|
|
|
+ * @author 李井强
|
|
|
+ */
|
|
|
+public class LoadConfigThread extends Thread {
|
|
|
+ public LoadConfigThread() {
|
|
|
+ try {
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ LogUtil.error("LoadConfigThread.Exception: " + e.toString());
|
|
|
+ System.exit(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void run() {
|
|
|
+ LogUtil.info("LoadConfigThread" + this.getName() + " Starting ...");
|
|
|
+ while (true) {
|
|
|
+ try {
|
|
|
+
|
|
|
+
|
|
|
+ loadExcelConfig();
|
|
|
+
|
|
|
+ this.loadPointList2();
|
|
|
+
|
|
|
+
|
|
|
+ Thread.sleep(Constant.Millisecond.MINUTE_5);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ LogUtil.error("LoadConfigThread.run.Exception: " + e.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 加载DB点位列表
|
|
|
+ */
|
|
|
+ private void loadPointList2() {
|
|
|
+
|
|
|
+ LogUtil.info("Clear Project Point List" + " Begin...");
|
|
|
+ synchronized (Constant.ps_PhysicalList) {
|
|
|
+ Constant.ps_PhysicalList = null;
|
|
|
+ Constant.ps_PhysicalList = new HashMap<String, List<String>>();
|
|
|
+
|
|
|
+ }
|
|
|
+ synchronized (Constant.ps_ProjectList) {
|
|
|
+ Constant.ps_ProjectList = null;
|
|
|
+ Constant.ps_ProjectList = new HashMap<String, List<String>>();
|
|
|
+
|
|
|
+ }
|
|
|
+ synchronized (Constant.ps_MeterList) {
|
|
|
+ Constant.ps_MeterList = null;
|
|
|
+ Constant.ps_MeterList = new HashMap<String, List<String>>();
|
|
|
+
|
|
|
+ }
|
|
|
+ LogUtil.info("Clear Project Point List" + " End...");
|
|
|
+ try {
|
|
|
+ Constant.LoadDB2Cache_dy_pointlist(Constant.Database, "dy_pointlist");
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ e.printStackTrace();
|
|
|
+ LogUtil.error("LoadConfigThread.loadPointList2: " + e.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 加载config配置文件
|
|
|
+ */
|
|
|
+ public static void loadExcelConfig() {
|
|
|
+
|
|
|
+ String resource = "/config.xls";
|
|
|
+ String path = null;
|
|
|
+ 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);
|
|
|
+ excuteNetworkTransfer(file);
|
|
|
+ excuteNetworkUp(file);
|
|
|
+ excuteNetworkDown(file);
|
|
|
+ excuteRulesGlobal(file);
|
|
|
+ excuteRulesBuildingConvert(file);
|
|
|
+ excuteRulesFuncConvert(file);
|
|
|
+ excuteRulesWhiteList(file);
|
|
|
+ excuteRulesTransferList(file);
|
|
|
+ excuteRulesBlackList(file);
|
|
|
+ excuteUploadMysql(file);
|
|
|
+ excuteUploadHbase(file);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 加载黑名单
|
|
|
+ */
|
|
|
+ private static void excuteRulesBlackList(File file) {
|
|
|
+
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Rules-BlackList".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+
|
|
|
+ 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) {
|
|
|
+
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Rules-WhiteList".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+
|
|
|
+ if (rowData.get(1) == null || rowData.get(1).length() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ pty = Constant.toLower(pty);
|
|
|
+
|
|
|
+ String building = rowData.get(pty.get("building"));
|
|
|
+ String meter = rowData.get(pty.get("meter"));
|
|
|
+ String funcid = rowData.get(pty.get("funcid"));
|
|
|
+
|
|
|
+ Constant.whilte_Points.put(building + "-" + meter + "-" + funcid, null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 加载转发列表
|
|
|
+ */
|
|
|
+ private static void excuteRulesTransferList(File file) {
|
|
|
+
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ 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-TransferList".equalsIgnoreCase(rowData.get(0))) {
|
|
|
+ begin = i;
|
|
|
+
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Rules-TransferList".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+
|
|
|
+ if (rowData.get(1) == null || rowData.get(1).length() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ pty = Constant.toLower(pty);
|
|
|
+
|
|
|
+ String building = rowData.get(pty.get("building"));
|
|
|
+ String meter = rowData.get(pty.get("meter"));
|
|
|
+ String funcid = rowData.get(pty.get("funcid"));
|
|
|
+
|
|
|
+ Constant.transfer_List.put(building + "-" + meter + "-" + funcid, null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 加载表号转换规则
|
|
|
+ */
|
|
|
+ private static void excuteRulesFuncConvert(File file) {
|
|
|
+
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Rules-FuncConvert".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+
|
|
|
+ if (rowData.get(1) == null || rowData.get(1).length() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ pty = Constant.toLower(pty);
|
|
|
+ String funcidOld = rowData.get(pty.get("oldfuncid"));
|
|
|
+ String funcidNew = rowData.get(pty.get("newfuncid"));
|
|
|
+
|
|
|
+ Constant.FunctionConv.put(funcidOld, funcidNew);
|
|
|
+ Constant.FunctionConvReverse.put(funcidNew, funcidOld);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 加载建筑转换规则
|
|
|
+ */
|
|
|
+ private static void excuteRulesBuildingConvert(File file) {
|
|
|
+
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0)
|
|
|
+ && !("Rules-BuildingConvert".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 加载全局配置
|
|
|
+ */
|
|
|
+ private static void excuteRulesGlobal(File file) {
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Rules-Global".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+
|
|
|
+ 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")));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (rowData.get(pty.get("savetype")) != null) {
|
|
|
+ for (String savetype : rowData.get(pty.get("savetype")).split(",")) {
|
|
|
+ Constant.saveTypeList.add(savetype);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (rowData.get(pty.get("delay")) != null) {
|
|
|
+ String delay = rowData.get(pty.get("delay"));
|
|
|
+ delay = delay.replace("Second", "").replace("second", "").replace("s", "").replace("S", "");
|
|
|
+ Constant.delay = Constant.Millisecond.SECOND_1 * Long.parseLong(delay);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 加载网络配置(对下)
|
|
|
+ */
|
|
|
+ private static void excuteNetworkDown(File file) {
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Network-Down".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+
|
|
|
+ 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 excuteNetworkTransfer(File file) {
|
|
|
+
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+ 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-Transfer".equalsIgnoreCase(rowData.get(0))) {
|
|
|
+ begin = i;
|
|
|
+
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Network-Transfer".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+
|
|
|
+ if (rowData.get(1) == null || rowData.get(1).length() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ pty = Constant.toLower(pty);
|
|
|
+ Constant.transfer.PROTOCOL = rowData.get(pty.get("protocol"));
|
|
|
+ Constant.transfer.IP = rowData.get(pty.get("ip"));
|
|
|
+ Constant.transfer.Port = Integer.valueOf(rowData.get(pty.get("port")));
|
|
|
+ Constant.transfer.ServerIP = rowData.get(pty.get("serverip"));
|
|
|
+ Constant.transfer.ServerPort = Integer.valueOf(rowData.get(pty.get("serverport")));
|
|
|
+ Constant.transfer.Mode = rowData.get(pty.get("mode"));
|
|
|
+ Constant.transfer.Max_size = Integer.valueOf(rowData.get(pty.get("max_size")));
|
|
|
+ Constant.transfer.SleepCount = Integer.valueOf(rowData.get(pty.get("sleepcount")));
|
|
|
+ Constant.transfer.Separate = rowData.get(pty.get("separate"));
|
|
|
+ Constant.transfer.Separate_begin = rowData.get(pty.get("separate_begin"));
|
|
|
+ Constant.transfer.Separate_end = rowData.get(pty.get("separate_end"));
|
|
|
+ Constant.transfer.compress = Boolean.getBoolean(rowData.get(pty.get("compress")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 加载网络配置(对上)
|
|
|
+ */
|
|
|
+ private static void excuteNetworkUp(File file) {
|
|
|
+
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Network-Up".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 加载HBase配置
|
|
|
+ */
|
|
|
+ private static void excuteDbHbase(File file) {
|
|
|
+
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Db-Hbase".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 加载mysql配置
|
|
|
+ */
|
|
|
+ private static void excuteDbMysql(File file) {
|
|
|
+
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Db-Mysql".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 加载mysql配置
|
|
|
+ */
|
|
|
+ private static void excuteUploadMysql(File file) {
|
|
|
+
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ 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 ("Upload-Mysql".equalsIgnoreCase(rowData.get(0))) {
|
|
|
+ begin = i;
|
|
|
+
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Upload-Mysql".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+
|
|
|
+ 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"));
|
|
|
+ entityMysql.UploadDatabase = rowData.get(pty.get("uploaddatabase"));
|
|
|
+ entityMysql.UploadTable = rowData.get(pty.get("uploadtable"));
|
|
|
+ Constant.DbConnection.put("Upload-Mysql", entityMysql);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 加载HBase配置
|
|
|
+ */
|
|
|
+ private static void excuteUploadHbase(File file) {
|
|
|
+
|
|
|
+
|
|
|
+ int begin = 65535;
|
|
|
+ int end = 65535;
|
|
|
+ Map<String, Integer> pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ 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 ("Upload-Hbase".equalsIgnoreCase(rowData.get(0))) {
|
|
|
+ begin = i;
|
|
|
+
|
|
|
+ for (int j = 1; j < rowData.size(); j++) {
|
|
|
+ pty.put(rowData.get(j), j);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ((rowData.get(0).length() > 0) && !("Upload-Hbase".equalsIgnoreCase(rowData.get(0)))) {
|
|
|
+ begin = 65535;
|
|
|
+ end = 65535;
|
|
|
+ pty = new HashMap<String, Integer>();
|
|
|
+
|
|
|
+
|
|
|
+ } else if (i > begin && i < end) {
|
|
|
+
|
|
|
+ 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"));
|
|
|
+ entityHbase.UploadDatabase = rowData.get(pty.get("UploadDatabase"));
|
|
|
+ entityHbase.UploadTable = rowData.get(pty.get("UploadTable"));
|
|
|
+
|
|
|
+ Constant.DbConnection.put("Upload-Hbase", entityHbase);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|