diff --git a/build.gradle b/build.gradle index ee9a9edb..95ff6673 100644 --- a/build.gradle +++ b/build.gradle @@ -55,7 +55,7 @@ dependencies { exclude group: "org.fisco-bcos.java-sdk" exclude group: "org.slf4j" } - compile ('com.fasterxml.jackson.core:jackson-databind:2.14.2'){ + compile ('com.fasterxml.jackson.core:jackson-databind:2.14.3'){ force true } testCompile('com.github.stefanbirkner:system-rules:1.19.0') diff --git a/src/integration-test/java/console/ConsoleClientTest.java b/src/integration-test/java/console/ConsoleClientTest.java index 37f8dfe0..18298a3b 100644 --- a/src/integration-test/java/console/ConsoleClientTest.java +++ b/src/integration-test/java/console/ConsoleClientTest.java @@ -90,7 +90,7 @@ public void clientNotParamsTest() throws IOException { consoleClientFace.getGroupInfoList(emptyParams); assertTrue(log.getLog().startsWith("[")); log.clearLog(); - consoleClientFace.getNodeName(); + consoleClientFace.getNodeName(consoleInitializer); } @Test diff --git a/src/main/java/console/client/ConsoleClientFace.java b/src/main/java/console/client/ConsoleClientFace.java index b3bd673c..836a84fa 100644 --- a/src/main/java/console/client/ConsoleClientFace.java +++ b/src/main/java/console/client/ConsoleClientFace.java @@ -1,6 +1,7 @@ package console.client; import com.fasterxml.jackson.core.JsonProcessingException; +import console.ConsoleInitializer; import java.io.IOException; import org.fisco.bcos.sdk.v3.client.Client; @@ -63,9 +64,9 @@ public interface ConsoleClientFace { void getGroupNodeInfo(String[] params) throws JsonProcessingException; - void setNodeName(String[] params) throws IOException; + void setNodeName(ConsoleInitializer consoleInitializer, String[] params) throws IOException; - void clearNodeName(); + void clearNodeName(ConsoleInitializer consoleInitializer); - void getNodeName(); + void getNodeName(ConsoleInitializer consoleInitializer); } diff --git a/src/main/java/console/client/ConsoleClientImpl.java b/src/main/java/console/client/ConsoleClientImpl.java index a4ad8425..a6316f91 100644 --- a/src/main/java/console/client/ConsoleClientImpl.java +++ b/src/main/java/console/client/ConsoleClientImpl.java @@ -1,6 +1,7 @@ package console.client; import com.fasterxml.jackson.core.JsonProcessingException; +import console.ConsoleInitializer; import console.client.model.TotalTransactionCountResult; import console.common.Common; import console.common.ConsoleUtils; @@ -473,7 +474,7 @@ public void getGroupNodeInfo(String[] params) throws JsonProcessingException { } @Override - public void setNodeName(String[] params) { + public void setNodeName(ConsoleInitializer consoleInitializer, String[] params) { String newNodeName = params[1]; List nodeInfos = client.getGroupInfo().getResult().getNodeList(); @@ -491,23 +492,24 @@ public void setNodeName(String[] params) { + ", node not contains in node list, check command 'getGroupInfo'."); return; } - this.nodeName = newNodeName; - getNodeName(); + consoleInitializer.getClient().setNodeToSendRequest(newNodeName); + getNodeName(consoleInitializer); } @Override - public void clearNodeName() { + public void clearNodeName(ConsoleInitializer consoleInitializer) { System.out.println("Clear nodeName to empty."); - this.nodeName = ""; + consoleInitializer.getClient().setNodeToSendRequest(""); } @Override - public void getNodeName() { - if (this.nodeName.isEmpty()) { + public void getNodeName(ConsoleInitializer consoleInitializer) { + String nodeToSendRequest = consoleInitializer.getClient().getNodeToSendRequest(); + if (nodeToSendRequest.isEmpty()) { System.out.println( "Current default node name is empty, RPC will send request to node randomly."); return; } - System.out.println("Current default node name: " + this.nodeName); + System.out.println("Current default node name: " + nodeToSendRequest); } } diff --git a/src/main/java/console/command/category/BasicCommand.java b/src/main/java/console/command/category/BasicCommand.java index f2f9e7af..c74063a9 100644 --- a/src/main/java/console/command/category/BasicCommand.java +++ b/src/main/java/console/command/category/BasicCommand.java @@ -71,7 +71,9 @@ public Map getAllCommandInfo(boolean isWasm) { "Set default node name to send request.", HelpInfo::setNodeNameHelp, (consoleInitializer, params, pwd) -> - consoleInitializer.getConsoleClientFace().setNodeName(params), + consoleInitializer + .getConsoleClientFace() + .setNodeName(consoleInitializer, params), 1, 1); @@ -81,7 +83,9 @@ public Map getAllCommandInfo(boolean isWasm) { "Get default node name in this client.", HelpInfo::getNodeNameHelp, (consoleInitializer, params, pwd) -> - consoleInitializer.getConsoleClientFace().getNodeName(), + consoleInitializer + .getConsoleClientFace() + .getNodeName(consoleInitializer), 0, 0); @@ -91,7 +95,9 @@ public Map getAllCommandInfo(boolean isWasm) { "Clear default node name to empty.", HelpInfo::clearNodeNameHelp, (consoleInitializer, params, pwd) -> - consoleInitializer.getConsoleClientFace().clearNodeName(), + consoleInitializer + .getConsoleClientFace() + .clearNodeName(consoleInitializer), 0, 0);