增加IP vertex COMMON_LINK_INFO属性
This commit is contained in:
@@ -14,6 +14,7 @@ public class ApplicationConfig {
|
||||
public static final Integer ARANGODB_BATCH = ConfigUtils.getIntProperty( "arangoDB.batch");
|
||||
|
||||
public static final Integer UPDATE_ARANGO_BATCH = ConfigUtils.getIntProperty("update.arango.batch");
|
||||
public static final String ARANGODB_READ_LIMIT = ConfigUtils.getStringProperty("arangoDB.read.limit");
|
||||
|
||||
public static final Integer THREAD_POOL_NUMBER = ConfigUtils.getIntProperty( "thread.pool.number");
|
||||
public static final Integer THREAD_AWAIT_TERMINATION_TIME = ConfigUtils.getIntProperty( "thread.await.termination.time");
|
||||
|
||||
@@ -87,7 +87,7 @@ public class BaseArangoData {
|
||||
long diffTime = (maxTime - minTime) / ApplicationConfig.THREAD_POOL_NUMBER;
|
||||
long maxThreadTime = minTime + (threadNumber + 1)* diffTime;
|
||||
long minThreadTime = minTime + threadNumber * diffTime;
|
||||
return "FOR doc IN "+table+" filter doc.FIRST_FOUND_TIME >= "+minThreadTime+" and doc.FIRST_FOUND_TIME <= "+maxThreadTime+" RETURN doc";
|
||||
return "FOR doc IN "+table+" filter doc.FIRST_FOUND_TIME >= "+minThreadTime+" and doc.FIRST_FOUND_TIME <= "+maxThreadTime+" " + ApplicationConfig.ARANGODB_READ_LIMIT + " RETURN doc";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,6 +65,11 @@ public class ReadClickhouseData {
|
||||
long sessionCount = resultSet.getLong("SESSION_COUNT");
|
||||
long bytesSum = resultSet.getLong("BYTES_SUM");
|
||||
String ipType = resultSet.getString("ip_type");
|
||||
String[] commonLinkInfos = (String[]) resultSet.getArray("common_link_info").getArray();
|
||||
String commonLinkInfo = "";
|
||||
if (commonLinkInfos.length > 1){
|
||||
commonLinkInfo = commonLinkInfos[1];
|
||||
}
|
||||
newDoc.setKey(ip);
|
||||
newDoc.addAttribute("IP", ip);
|
||||
newDoc.addAttribute("FIRST_FOUND_TIME", firstFoundTime);
|
||||
@@ -84,7 +89,7 @@ public class ReadClickhouseData {
|
||||
break;
|
||||
default:
|
||||
}
|
||||
newDoc.addAttribute("COMMON_LINK_INFO", "");
|
||||
newDoc.addAttribute("COMMON_LINK_INFO", commonLinkInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -258,8 +263,8 @@ public class ReadClickhouseData {
|
||||
|
||||
public static String getVertexIpSql() {
|
||||
String where = " common_recv_time >= " + minTime + " AND common_recv_time < " + maxTime;
|
||||
String clientIpSql = "SELECT common_client_ip AS IP, MIN(common_recv_time) AS FIRST_FOUND_TIME,MAX(common_recv_time) AS LAST_FOUND_TIME,count(*) as SESSION_COUNT,sum(common_c2s_byte_num) as BYTES_SUM,'client' as ip_type FROM tsg_galaxy_v3.connection_record_log where " + where + " group by IP";
|
||||
String serverIpSql = "SELECT common_server_ip AS IP, MIN(common_recv_time) AS FIRST_FOUND_TIME,MAX(common_recv_time) AS LAST_FOUND_TIME,count(*) as SESSION_COUNT,sum(common_s2c_byte_num) as BYTES_SUM,'server' as ip_type FROM tsg_galaxy_v3.connection_record_log where " + where + " group by IP";
|
||||
String clientIpSql = "SELECT common_client_ip AS IP, MIN(common_recv_time) AS FIRST_FOUND_TIME,MAX(common_recv_time) AS LAST_FOUND_TIME,count(*) as SESSION_COUNT,sum(common_c2s_byte_num) as BYTES_SUM,groupUniqArray(2)(common_link_info) as common_link_info,'client' as ip_type FROM tsg_galaxy_v3.connection_record_log where " + where + " group by IP";
|
||||
String serverIpSql = "SELECT common_server_ip AS IP, MIN(common_recv_time) AS FIRST_FOUND_TIME,MAX(common_recv_time) AS LAST_FOUND_TIME,count(*) as SESSION_COUNT,sum(common_s2c_byte_num) as BYTES_SUM,groupUniqArray(2)(common_link_info) as common_link_info,'server' as ip_type FROM tsg_galaxy_v3.connection_record_log where " + where + " group by IP";
|
||||
return "SELECT * FROM((" + clientIpSql + ") UNION ALL (" + serverIpSql + "))";
|
||||
}
|
||||
|
||||
|
||||
@@ -124,5 +124,10 @@ public class Document<T extends BaseDocument> extends Thread{
|
||||
lastDoc.addAttribute(attribute,firstSumAttribute+lastSumAttribute);
|
||||
}
|
||||
|
||||
protected void replaceAttribute(T firstDoc,T lastDoc,String attribute){
|
||||
Object attributeObj = firstDoc.getAttribute(attribute);
|
||||
lastDoc.addAttribute(attribute,attributeObj);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,19 +23,13 @@ public class Ip extends Vertex {
|
||||
protected void updateFunction(BaseDocument newDocument, BaseDocument historyDocument) {
|
||||
super.updateFunction(newDocument, historyDocument);
|
||||
updateIpByType(newDocument, historyDocument);
|
||||
super.replaceAttribute(newDocument,historyDocument,"COMMON_LINK_INFO");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mergeFunction(BaseDocument lastDoc, BaseDocument newDocument) {
|
||||
super.mergeFunction(lastDoc, newDocument);
|
||||
mergeIpByType(lastDoc, newDocument);
|
||||
}
|
||||
|
||||
private void mergeIpByType(BaseDocument lastDoc, BaseDocument newDocument) {
|
||||
putSumAttribute(lastDoc,newDocument,"CLIENT_SESSION_COUNT");
|
||||
putSumAttribute(lastDoc,newDocument,"CLIENT_BYTES_SUM");
|
||||
putSumAttribute(lastDoc,newDocument,"SERVER_SESSION_COUNT");
|
||||
putSumAttribute(lastDoc,newDocument,"SERVER_BYTES_SUM");
|
||||
updateIpByType(lastDoc, newDocument);
|
||||
}
|
||||
|
||||
private void updateIpByType(BaseDocument newDocument, BaseDocument historyDocument) {
|
||||
|
||||
Reference in New Issue
Block a user