From 52a616932364c8a81e7b9ac2b163c60fa07fa298 Mon Sep 17 00:00:00 2001 From: huangsimin Date: Mon, 1 Aug 2022 00:27:00 +0800 Subject: [PATCH] =?UTF-8?q?todo:=20=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 46 +++++++++++++------ .vscode/tasks.json | 30 +++++++++--- clear_old_data.sh | 3 ++ .../dataflow/controller/MasterProcessor.java | 6 +++ 4 files changed, 64 insertions(+), 21 deletions(-) create mode 100644 clear_old_data.sh diff --git a/.vscode/launch.json b/.vscode/launch.json index 42668ae..097b04c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,9 +10,18 @@ "request": "launch", "mainClass": "com.yuandian.dataflow.Server", "projectName": "dataflow", + "console": "integratedTerminal", "args": [ "0" ], + "preLaunchTask": "rename", + "presentation": { + "reveal": "always", + "plane": "new", + "hidden": false, + "group": "", + "order": 1 + } }, { "type": "java", @@ -20,9 +29,17 @@ "request": "launch", "mainClass": "com.yuandian.dataflow.Server", "projectName": "dataflow", + "console": "integratedTerminal", "args": [ "1" ], + "presentation": { + "reveal": "always", + "plane": "new", + "hidden": false, + "group": "", + "order": 2 + } }, { "type": "java", @@ -30,29 +47,28 @@ "request": "launch", "mainClass": "com.yuandian.dataflow.Server", "projectName": "dataflow", + "console": "integratedTerminal", "args": [ "2" ], + "presentation": { + "reveal": "always", + "plane": "new", + "hidden": false, + "group": "", + "order": 3 + } }, - - - // { - // "type": "java", - // "name": "Launch Server", - // "request": "launch", - // "mainClass": "com.yuandian.dataflow.Server", - // "projectName": "dataflow", - // "args": [ - // "2" - // ], - // "preLaunchTask": "restart", - // "postDebugTask": "stopall" - // } + ], + "compounds": [ { + "name": "Rafts-Server", - "configurations": ["Raft-0","Raft-1", "Raft-2"] + "configurations": ["Raft-0","Raft-1", "Raft-2"], + "preLaunchTask": "clear old data" } ] + } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 029d8f2..97231cc 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -18,17 +18,35 @@ }, }, { - "label": "stopall", + "label": "clear old data", "type": "shell", - "command": "sh stop.sh", + "command": "sh clear_old_data.sh", "presentation": { "echo": true, "reveal": "always", "focus": false, - "panel": "shared", - "close": true + "panel": "new", + "showReuseMessage": true, + "clear": false, + "close": false + }, + }, + { + "label": "rename", + "type": "shell", + "command": "ehco ${workbench.action.terminal.rename}", + "args": [ + "123" + ] - } - ] + }, + + + + ], + + + + } \ No newline at end of file diff --git a/clear_old_data.sh b/clear_old_data.sh new file mode 100644 index 0000000..ebdeccf --- /dev/null +++ b/clear_old_data.sh @@ -0,0 +1,3 @@ +#! /bin/bash +rm raftdata/ -rf + \ No newline at end of file diff --git a/src/main/java/com/yuandian/dataflow/controller/MasterProcessor.java b/src/main/java/com/yuandian/dataflow/controller/MasterProcessor.java index 28c4f2e..f865a58 100644 --- a/src/main/java/com/yuandian/dataflow/controller/MasterProcessor.java +++ b/src/main/java/com/yuandian/dataflow/controller/MasterProcessor.java @@ -29,6 +29,12 @@ public class MasterProcessor implements MasterExecute { @Override public void loop(MasterContext cxt) { + try { + Thread.sleep(3000); + } catch (InterruptedException e1) { + e1.printStackTrace(); + return; + } var alivePeers = List.copyOf(StateFactory.getRaftNode().listAlivePeers()); log.debug("master({}) execute {}", StateFactory.getServerId(),