Ver código fonte

恢复heart触发pointlist请求。

Jay Lee 6 anos atrás
pai
commit
976fa58479

+ 2 - 2
collect/src/main/java/com/saga/main/Main.java

@@ -199,8 +199,8 @@ public class Main {
 
 				// // V2.0ľăÎťČŐÖž˝ášš
 				// {
-				// //dropTB2(db);
-				// //Thread.sleep(Constant.Millisecond.SECOND_1);
+				// // dropTB2(db);
+				// // Thread.sleep(Constant.Millisecond.SECOND_1);
 				// createTB2(db);
 				// }
 

+ 22 - 16
collect/src/main/java/com/saga/thread/down/CollectThread.java

@@ -21,7 +21,7 @@ import com.saga.util.HBaseUtil;
 
 public class CollectThread extends Thread {
 	private int port = 0;
-	private long getPointList = 0;
+	// private long getPointList = 0;
 	private String ip = null;
 	// private List<IServerManager> serverList = new
 	// ArrayList<IServerManager>();
@@ -352,13 +352,14 @@ public class CollectThread extends Thread {
 						// Date()));
 						Constant.ps_NodeStatus.put(rList[0] + "-" + rList[1], System.currentTimeMillis());
 						// this.insertCollectorCommunicationLog(rList);
-						if (this.needGetPointList()) {
-							int id = Constant.getID();
-							server.AppendToSend(p.address,
-									new Packet(rList[0] + ";" + rList[1] + ";" + "pointcount" + ";" + "" + ";" + id));
-							LogUtil.info(server.Name() + " AppendToSend:" + p.address + " " + rList[0] + ";" + rList[1]
-									+ ";" + "pointcount" + ";" + "" + ";" + id);
-						}
+				
+						// if (this.needGetPointList()) {
+						int id = Constant.getID();
+						server.AppendToSend(p.address,
+								new Packet(rList[0] + ";" + rList[1] + ";" + "pointcount" + ";" + "" + ";" + id));
+						LogUtil.info(server.Name() + " AppendToSend:" + p.address + " " + rList[0] + ";" + rList[1]
+								+ ";" + "pointcount" + ";" + "" + ";" + id);
+						// }
 
 					} else if ("pointcountack".equalsIgnoreCase(rList[2])) {
 						int count = Integer.valueOf(rList[5]);
@@ -471,14 +472,19 @@ public class CollectThread extends Thread {
 		}
 	}
 
-	private boolean needGetPointList() {
-		// TODO Auto-generated method stub
-		if (System.currentTimeMillis() - this.getPointList > Constant.Millisecond.MINUTE_3) {
-			this.getPointList = System.currentTimeMillis();
-			return true;
-		}
-		return false;
-	}
+	// private boolean needGetPointList() {
+	// // TODO Auto-generated method stub
+	// LogUtil.error(System.currentTimeMillis() + " " + this.getPointList + " "
+	// + (System.currentTimeMillis() - this.getPointList) /
+	// Constant.Millisecond.MINUTE_1);
+	// if (System.currentTimeMillis() - this.getPointList >
+	// Constant.Millisecond.MINUTE_3) {
+	// this.getPointList = System.currentTimeMillis();
+	// LogUtil.error("needGetPointList true ...");
+	// return true;
+	// }
+	// return false;
+	// }
 
 	// private void insertCollectorStatus(String[] rList) {
 	// // TODO Auto-generated method stub

+ 28 - 1
collect/src/main/java/com/saga/util/HBaseUtil.java

@@ -31,6 +31,33 @@ public class HBaseUtil {
 		// 10 collect_cycle String 采集频率 采集器上传频率
 		// 11 data_type String 点位类型 Acc:累积变量;Inst:瞬时变量;Boolv:通断变量;
 		// Enumv:状态变量;Step:阶跃变量
+		JSONObject Criteria = new JSONObject();
+		Criteria.put("building", project);
+
+		JSONObject wrapperObject = new JSONObject();
+		wrapperObject.put("QueryType", "select");
+		wrapperObject.put("Database", db);
+		wrapperObject.put("Datatable", tb);
+		wrapperObject.put("Criteria", Criteria);
+
+		JSONObject queryResult = agent.Query(wrapperObject);
+		JSONArray resultContent = (JSONArray) queryResult.get("Content");
+		for (int i = 0; i < resultContent.size(); i++) {
+			JSONObject dataItem = (JSONObject) resultContent.get(i);
+			String meter = (String) dataItem.get("meter");
+			long funcid = (long) dataItem.get("funcid");
+			String address_1 = (String) dataItem.get("address_1");
+			String address_2 = (String) dataItem.get("address_2");
+			String address_3 = (String) dataItem.get("address_3");
+			String address_4 = (String) dataItem.get("address_4");
+			String key = project + ";" + address_1 + ";" + address_2 + ";" + address_3 + ";" + address_4;
+			String value = project + "-" + meter + "." + funcid;
+			Constant.ps_PhysicalList.put(key, value);
+			Constant.ps_MeterListUp.put(meter, value);
+			Constant.ps_ProjectList.put(project, value);
+
+		}
+		LogUtil.info("Reload Project:" + project + "  CollectorStatus End...");
 	}
 
 	public static void LoadDB2Cache_ps_physical_status(ZillionAgent agent, String db, String tb, String project)
@@ -66,7 +93,7 @@ public class HBaseUtil {
 			Constant.ps_NodeStatus.put(key, Constant.parse(receivetime).getTime());
 
 		}
-		LogUtil.info("Reload Project:" + project + "  CollectorStatus End...");
+		LogUtil.info("Reload Project:" + project + "  ps_physical_status End...");
 
 	}