Explorar o código

增加只收数据模式

sensordb2 hai 1 ano
pai
achega
fd5e8ef5bc

+ 4 - 1
conf/application-insert.yml

@@ -43,4 +43,7 @@ logging:
 server:
   port: 8088
   servlet:
-    context-path: /api/v1
+    context-path: /api/v1
+
+debug:
+  justReceivePacket: false

+ 15 - 9
insert-app/src/main/java/db/handler/PackageHandler.java

@@ -61,6 +61,9 @@ public class PackageHandler {
     @Value("${system.data-file.tsdb-writer-thread-num}")
     private int tsdbWriterThreadNum;
 
+    @Value("${debug.justReceivePacket}")
+    private Boolean isJustReceivePacket;
+
     private long bufferIndex = 0;
     private SpentTimeCalculator bufferFullTimeCalculator = SpentTimeCalculator.create().begin();
 
@@ -216,18 +219,21 @@ public class PackageHandler {
         log.debug("开始处理探针上传的数据包:{}", dataResponsePackage);
         statisticService.incrDataCount();
 
-        if (enableWal) {  // 生成 WAL 文件
-            WalItem walItem = new WalItem(dataResponsePackage.getProbeId(), dataResponsePackage.getPort(),
-                    dataResponsePackage.getDataStrategy(), dataResponsePackage.getClockSync(),
-                    dataResponsePackage.getTimestamp(), dataResponsePackage.getRawPacket());
+        if(isJustReceivePacket) {
 
-            try {
-                walFileService.appendWal(walItem);
-            } catch (IOException e) {
-                log.error("添加walItem到wal文件失败,walItem:{}", walItem, e);
+            if (enableWal) {  // 生成 WAL 文件
+                WalItem walItem = new WalItem(dataResponsePackage.getProbeId(), dataResponsePackage.getPort(),
+                        dataResponsePackage.getDataStrategy(), dataResponsePackage.getClockSync(),
+                        dataResponsePackage.getTimestamp(), dataResponsePackage.getRawPacket());
+
+                try {
+                    walFileService.appendWal(walItem);
+                } catch (IOException e) {
+                    log.error("添加walItem到wal文件失败,walItem:{}", walItem, e);
+                }
             }
+            addToPackageBuffer(dataResponsePackage);
         }
-        addToPackageBuffer(dataResponsePackage);
     }
 
     /**

+ 4 - 1
insert-app/src/main/resources/application.yml

@@ -60,4 +60,7 @@ netty:
 server:
   port: 8081
   servlet:
-    context-path: /api/v1
+    context-path: /api/v1
+
+debug:
+  justReceivePacket: false