修改读取arango方式为分页读取
This commit is contained in:
@@ -41,9 +41,11 @@ public class BaseArangoData {
|
|||||||
map.put(i,new ConcurrentHashMap<>());
|
map.put(i,new ConcurrentHashMap<>());
|
||||||
}
|
}
|
||||||
CountDownLatch countDownLatch = new CountDownLatch(ApplicationConfig.THREAD_POOL_NUMBER);
|
CountDownLatch countDownLatch = new CountDownLatch(ApplicationConfig.THREAD_POOL_NUMBER);
|
||||||
long[] timeRange = getTimeRange(table);
|
// long[] timeRange = getTimeRange(table);
|
||||||
|
Long total = getCountTotal(table);
|
||||||
for (int i = 0; i < ApplicationConfig.THREAD_POOL_NUMBER; i++) {
|
for (int i = 0; i < ApplicationConfig.THREAD_POOL_NUMBER; i++) {
|
||||||
String sql = getQuerySql(timeRange, i, table);
|
// String sql = getQuerySql(timeRange, i, table);
|
||||||
|
String sql = getQuerySql(total, i, table);
|
||||||
ReadHistoryArangoData<T> readHistoryArangoData =
|
ReadHistoryArangoData<T> readHistoryArangoData =
|
||||||
new ReadHistoryArangoData<>(arangoDBConnect, sql, map,type,table,countDownLatch);
|
new ReadHistoryArangoData<>(arangoDBConnect, sql, map,type,table,countDownLatch);
|
||||||
threadPool.executor(readHistoryArangoData);
|
threadPool.executor(readHistoryArangoData);
|
||||||
@@ -56,6 +58,30 @@ public class BaseArangoData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Long getCountTotal(String table){
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
Long cnt = 0L;
|
||||||
|
String sql = "RETURN LENGTH("+table+")";
|
||||||
|
try {
|
||||||
|
ArangoCursor<Long> longs = arangoDBConnect.executorQuery(sql, Long.class);
|
||||||
|
while (longs.hasNext()){
|
||||||
|
cnt = longs.next();
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
LOG.error(sql +"执行异常");
|
||||||
|
}
|
||||||
|
long last = System.currentTimeMillis();
|
||||||
|
LOG.info(sql+" 结果:"+cnt+" 执行时间:"+(last-start));
|
||||||
|
return cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getQuerySql(Long cnt,int threadNumber, String table){
|
||||||
|
long sepNum = cnt / ApplicationConfig.THREAD_POOL_NUMBER + 1;
|
||||||
|
long offsetNum = threadNumber * sepNum;
|
||||||
|
return "FOR doc IN " + table + " limit "+offsetNum+","+sepNum+" RETURN doc";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private long[] getTimeRange(String table){
|
private long[] getTimeRange(String table){
|
||||||
long minTime = 0L;
|
long minTime = 0L;
|
||||||
long maxTime = 0L;
|
long maxTime = 0L;
|
||||||
|
|||||||
@@ -44,14 +44,14 @@ public class UpdateGraphData {
|
|||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
updateDocument(newVertexFqdnMap, historyVertexFqdnMap, "FQDN", Fqdn.class,BaseDocument.class,
|
// updateDocument(newVertexFqdnMap, historyVertexFqdnMap, "FQDN", Fqdn.class,BaseDocument.class,
|
||||||
ReadClickhouseData::getVertexFqdnSql,ReadClickhouseData::getVertexFqdnDocument);
|
// ReadClickhouseData::getVertexFqdnSql,ReadClickhouseData::getVertexFqdnDocument);
|
||||||
|
|
||||||
updateDocument(newVertexIpMap,historyVertexIpMap,"IP", Ip.class,BaseDocument.class,
|
// updateDocument(newVertexIpMap,historyVertexIpMap,"IP", Ip.class,BaseDocument.class,
|
||||||
ReadClickhouseData::getVertexIpSql,ReadClickhouseData::getVertexIpDocument);
|
// ReadClickhouseData::getVertexIpSql,ReadClickhouseData::getVertexIpDocument);
|
||||||
|
|
||||||
updateDocument(newVertexSubscriberMap,historyVertexSubscriberMap,"SUBSCRIBER", Subscriber.class,BaseDocument.class,
|
// updateDocument(newVertexSubscriberMap,historyVertexSubscriberMap,"SUBSCRIBER", Subscriber.class,BaseDocument.class,
|
||||||
ReadClickhouseData::getVertexSubscriberSql,ReadClickhouseData::getVertexSubscriberDocument);
|
// ReadClickhouseData::getVertexSubscriberSql,ReadClickhouseData::getVertexSubscriberDocument);
|
||||||
|
|
||||||
updateDocument(newRelationFqdnAddressIpMap,historyRelationFqdnAddressIpMap,"R_LOCATE_FQDN2IP", LocateFqdn2Ip.class,BaseEdgeDocument.class,
|
updateDocument(newRelationFqdnAddressIpMap,historyRelationFqdnAddressIpMap,"R_LOCATE_FQDN2IP", LocateFqdn2Ip.class,BaseEdgeDocument.class,
|
||||||
ReadClickhouseData::getRelationshipFqdnAddressIpSql,ReadClickhouseData::getRelationFqdnAddressIpDocument);
|
ReadClickhouseData::getRelationshipFqdnAddressIpSql,ReadClickhouseData::getRelationFqdnAddressIpDocument);
|
||||||
@@ -60,9 +60,9 @@ public class UpdateGraphData {
|
|||||||
// VisitIp2Fqdn.class,BaseEdgeDocument.class,
|
// VisitIp2Fqdn.class,BaseEdgeDocument.class,
|
||||||
// ReadClickhouseData::getRelationshipIpVisitFqdnSql,ReadClickhouseData::getRelationIpVisitFqdnDocument);
|
// ReadClickhouseData::getRelationshipIpVisitFqdnSql,ReadClickhouseData::getRelationIpVisitFqdnDocument);
|
||||||
|
|
||||||
updateDocument(newRelationSubsciberLocateIpMap,historyRelationSubsciberLocateIpMap,"R_LOCATE_SUBSCRIBER2IP",
|
// updateDocument(newRelationSubsciberLocateIpMap,historyRelationSubsciberLocateIpMap,"R_LOCATE_SUBSCRIBER2IP",
|
||||||
LocateSubscriber2Ip.class,BaseEdgeDocument.class,
|
// LocateSubscriber2Ip.class,BaseEdgeDocument.class,
|
||||||
ReadClickhouseData::getRelationshipSubsciberLocateIpSql,ReadClickhouseData::getRelationshipSubsciberLocateIpDocument);
|
// ReadClickhouseData::getRelationshipSubsciberLocateIpSql,ReadClickhouseData::getRelationshipSubsciberLocateIpDocument);
|
||||||
|
|
||||||
|
|
||||||
long last = System.currentTimeMillis();
|
long last = System.currentTimeMillis();
|
||||||
|
|||||||
Reference in New Issue
Block a user