|
@@ -152,124 +152,133 @@ public class CheckThread extends Thread {
|
|
|
|
|
|
private void virtual_project_status_up_Check() {
|
|
|
// TODO Auto-generated method stub
|
|
|
- for (Entry<String, List<String>> ps : Constant.ps_ProjectList.entrySet()) {
|
|
|
- String project = ps.getKey();
|
|
|
- List<String> l = ps.getValue();
|
|
|
- String status = this.gatherStatus(l);
|
|
|
- try {
|
|
|
- if ("conn".equalsIgnoreCase(status)) {
|
|
|
- HBaseUtil.Insert_ps_virtual_project_status(Constant.agent, Constant.BuildingDB.get(project),
|
|
|
- project, status, Constant.format(new Date()), "");
|
|
|
- }
|
|
|
-
|
|
|
- if (
|
|
|
- // 首次
|
|
|
- !this.projectStatus.containsKey(project) || null == this.projectStatus.get(project) ||
|
|
|
- // 已有记录
|
|
|
- !status.equalsIgnoreCase(this.projectStatus.get(project))) {
|
|
|
-
|
|
|
- HBaseUtil.Insert_ps_virtual_project_log(Constant.agent, Constant.BuildingDB.get(project), project,
|
|
|
- Constant.format(new Date()), status);
|
|
|
- if ("disconn".equalsIgnoreCase(status)) {
|
|
|
+ synchronized (Constant.ps_ProjectList) {
|
|
|
+ for (Entry<String, List<String>> ps : Constant.ps_ProjectList.entrySet()) {
|
|
|
+ String project = ps.getKey();
|
|
|
+ List<String> l = ps.getValue();
|
|
|
+ String status = this.gatherStatus(l);
|
|
|
+ try {
|
|
|
+ if ("conn".equalsIgnoreCase(status)) {
|
|
|
HBaseUtil.Insert_ps_virtual_project_status(Constant.agent, Constant.BuildingDB.get(project),
|
|
|
project, status, Constant.format(new Date()), "");
|
|
|
}
|
|
|
+
|
|
|
+ if (
|
|
|
+ // 首次
|
|
|
+ !this.projectStatus.containsKey(project) || null == this.projectStatus.get(project) ||
|
|
|
+ // 已有记录
|
|
|
+ !status.equalsIgnoreCase(this.projectStatus.get(project))) {
|
|
|
+
|
|
|
+ HBaseUtil.Insert_ps_virtual_project_log(Constant.agent, Constant.BuildingDB.get(project),
|
|
|
+ project, Constant.format(new Date()), status);
|
|
|
+ if ("disconn".equalsIgnoreCase(status)) {
|
|
|
+ HBaseUtil.Insert_ps_virtual_project_status(Constant.agent, Constant.BuildingDB.get(project),
|
|
|
+ project, status, Constant.format(new Date()), "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
+ this.projectStatus.put(project, status);
|
|
|
}
|
|
|
- this.projectStatus.put(project, status);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void virtual_meter_status_up_Check() {
|
|
|
// TODO Auto-generated method stub
|
|
|
- for (Entry<String, List<String>> ms : Constant.ps_MeterList.entrySet()) {
|
|
|
- String pm = ms.getKey();
|
|
|
- List<String> l = ms.getValue();
|
|
|
- String status = this.gatherStatus(l);
|
|
|
- String[] ml = pm.split("-");
|
|
|
- String project = ml[0];
|
|
|
- String meter = ml[1];
|
|
|
- try {
|
|
|
- if ("conn".equalsIgnoreCase(status)) {
|
|
|
- HBaseUtil.Insert_ps_virtual_meter_status(Constant.agent, Constant.BuildingDB.get(project), project,
|
|
|
- meter, "up", status, Constant.format(new Date()), "");
|
|
|
- }
|
|
|
-
|
|
|
- if (
|
|
|
- // 首次
|
|
|
- !this.meterStatus.containsKey(pm) || null == this.meterStatus.get(pm) ||
|
|
|
- // 已有记录
|
|
|
- !status.equalsIgnoreCase(this.meterStatus.get(pm))) {
|
|
|
-
|
|
|
- HBaseUtil.Insert_ps_virtual_meter_log(Constant.agent, Constant.BuildingDB.get(project), project,
|
|
|
- meter, "up", Constant.format(new Date()), status);
|
|
|
- if ("disconn".equalsIgnoreCase(status)) {
|
|
|
+ synchronized (Constant.ps_MeterList) {
|
|
|
+ for (Entry<String, List<String>> ms : Constant.ps_MeterList.entrySet()) {
|
|
|
+ String pm = ms.getKey();
|
|
|
+ List<String> l = ms.getValue();
|
|
|
+ String status = this.gatherStatus(l);
|
|
|
+ String[] ml = pm.split("-");
|
|
|
+ String project = ml[0];
|
|
|
+ String meter = ml[1];
|
|
|
+ try {
|
|
|
+ if ("conn".equalsIgnoreCase(status)) {
|
|
|
HBaseUtil.Insert_ps_virtual_meter_status(Constant.agent, Constant.BuildingDB.get(project),
|
|
|
project, meter, "up", status, Constant.format(new Date()), "");
|
|
|
}
|
|
|
+
|
|
|
+ if (
|
|
|
+ // 首次
|
|
|
+ !this.meterStatus.containsKey(pm) || null == this.meterStatus.get(pm) ||
|
|
|
+ // 已有记录
|
|
|
+ !status.equalsIgnoreCase(this.meterStatus.get(pm))) {
|
|
|
+
|
|
|
+ HBaseUtil.Insert_ps_virtual_meter_log(Constant.agent, Constant.BuildingDB.get(project), project,
|
|
|
+ meter, "up", Constant.format(new Date()), status);
|
|
|
+ if ("disconn".equalsIgnoreCase(status)) {
|
|
|
+ HBaseUtil.Insert_ps_virtual_meter_status(Constant.agent, Constant.BuildingDB.get(project),
|
|
|
+ project, meter, "up", status, Constant.format(new Date()), "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
+ this.meterStatus.put(pm, status);
|
|
|
}
|
|
|
- this.meterStatus.put(pm, status);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void physical_status_address_Check() {
|
|
|
// TODO Auto-generated method stub
|
|
|
- for (Entry<String, List<String>> ps : Constant.ps_PhysicalList.entrySet()) {
|
|
|
- String physical = ps.getKey();
|
|
|
- String[] pl = physical.split(";");
|
|
|
- String project = pl[0];
|
|
|
- String address_1 = pl.length < 2 ? "" : pl[1];
|
|
|
- if ("".equalsIgnoreCase(address_1)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- String address_2 = pl.length < 3 ? "" : pl[2];
|
|
|
- String address_3 = pl.length < 4 ? "" : pl[3];
|
|
|
- String address_4 = pl.length < 5 ? "" : pl[4];
|
|
|
- String status = "disconn";
|
|
|
- if (!physical.endsWith(";;;")) {
|
|
|
- List<String> l = ps.getValue();
|
|
|
- status = this.gatherStatus(l);
|
|
|
- } else {
|
|
|
- if (Constant.ps_PhysicalStatus.get(physical) != null) {
|
|
|
- if (this.realCheck - Constant.ps_PhysicalStatus.get(physical) < Constant.Millisecond.MINUTE_1) {
|
|
|
- status = "conn";
|
|
|
- }
|
|
|
- } else {
|
|
|
- status = "disconn";
|
|
|
+ synchronized (Constant.ps_PhysicalList) {
|
|
|
+ for (Entry<String, List<String>> ps : Constant.ps_PhysicalList.entrySet()) {
|
|
|
+ String physical = ps.getKey();
|
|
|
+ String[] pl = physical.split(";");
|
|
|
+ String project = pl[0];
|
|
|
+ String address_1 = pl.length < 2 ? "" : pl[1];
|
|
|
+ if ("".equalsIgnoreCase(address_1)) {
|
|
|
+ continue;
|
|
|
}
|
|
|
- }
|
|
|
- try {
|
|
|
- if ("conn".equalsIgnoreCase(status)) {
|
|
|
- HBaseUtil.Insert_ps_physical_status(Constant.agent, Constant.BuildingDB.get(project), project,
|
|
|
- address_1, address_2, address_3, address_4, status, Constant.format(new Date()), "");
|
|
|
+ String address_2 = pl.length < 3 ? "" : pl[2];
|
|
|
+ String address_3 = pl.length < 4 ? "" : pl[3];
|
|
|
+ String address_4 = pl.length < 5 ? "" : pl[4];
|
|
|
+ String status = "disconn";
|
|
|
+ if (!physical.endsWith(";;;")) {
|
|
|
+ List<String> l = ps.getValue();
|
|
|
+ status = this.gatherStatus(l);
|
|
|
+ } else {
|
|
|
+ if (Constant.ps_PhysicalStatus.get(physical) != null) {
|
|
|
+ if (this.realCheck - Constant.ps_PhysicalStatus.get(physical) < Constant.Millisecond.MINUTE_1) {
|
|
|
+ status = "conn";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ status = "disconn";
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- if (
|
|
|
- // 首次
|
|
|
- !this.physicalStatus.containsKey(physical) || null == this.physicalStatus.get(physical) ||
|
|
|
- // 已有记录
|
|
|
- !status.equalsIgnoreCase(this.physicalStatus.get(physical))) {
|
|
|
-
|
|
|
- HBaseUtil.Insert_ps_physical_log(Constant.agent, Constant.BuildingDB.get(project), project,
|
|
|
- address_1, address_2, address_3, address_4, Constant.format(new Date()), status);
|
|
|
- if ("disconn".equalsIgnoreCase(status)) {
|
|
|
+ try {
|
|
|
+ if ("conn".equalsIgnoreCase(status)) {
|
|
|
HBaseUtil.Insert_ps_physical_status(Constant.agent, Constant.BuildingDB.get(project), project,
|
|
|
address_1, address_2, address_3, address_4, status, Constant.format(new Date()), "");
|
|
|
}
|
|
|
+
|
|
|
+ if (
|
|
|
+ // 首次
|
|
|
+ !this.physicalStatus.containsKey(physical) || null == this.physicalStatus.get(physical) ||
|
|
|
+ // 已有记录
|
|
|
+ !status.equalsIgnoreCase(this.physicalStatus.get(physical))) {
|
|
|
+
|
|
|
+ HBaseUtil.Insert_ps_physical_log(Constant.agent, Constant.BuildingDB.get(project), project,
|
|
|
+ address_1, address_2, address_3, address_4, Constant.format(new Date()), status);
|
|
|
+ if ("disconn".equalsIgnoreCase(status)) {
|
|
|
+ HBaseUtil.Insert_ps_physical_status(Constant.agent, Constant.BuildingDB.get(project),
|
|
|
+ project, address_1, address_2, address_3, address_4, status,
|
|
|
+ Constant.format(new Date()), "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
+ this.physicalStatus.put(physical, status);
|
|
|
}
|
|
|
- this.physicalStatus.put(physical, status);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private String gatherStatus(List<String> l) {
|