You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2021/12/09 14:35:56 UTC
[incubator-doris] branch master updated: [refactor] modify the control flow code to improve code readability (#7302)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new ac739fe [refactor] modify the control flow code to improve code readability (#7302)
ac739fe is described below
commit ac739fec10b45794b32158661250b6e38b6a92e9
Author: jakevin <30...@users.noreply.github.com>
AuthorDate: Thu Dec 9 22:35:46 2021 +0800
[refactor] modify the control flow code to improve code readability (#7302)
Now the code of command handler isn't clear.
We can modify `if` and `else` to improve code readability.
---
.../src/main/java/org/apache/doris/PaloFe.java | 78 ++++++++++++----------
1 file changed, 41 insertions(+), 37 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/PaloFe.java b/fe/fe-core/src/main/java/org/apache/doris/PaloFe.java
index 6877820..e5e04ba 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/PaloFe.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/PaloFe.java
@@ -133,7 +133,7 @@ public class PaloFe {
FeServer feServer = new FeServer(Config.rpc_port);
feServer.start();
-
+
if (!Config.enable_http_server_v2) {
HttpServer httpServer = new HttpServer(
Config.http_port,
@@ -232,63 +232,67 @@ public class PaloFe {
// version
if (cmd.hasOption('v') || cmd.hasOption("version")) {
return new CommandLineOptions(true, "", null);
- } else if (cmd.hasOption('b') || cmd.hasOption("bdb")) {
+ }
+ // helper
+ if (cmd.hasOption('h') || cmd.hasOption("helper")) {
+ String helperNode = cmd.getOptionValue("helper");
+ if (Strings.isNullOrEmpty(helperNode)) {
+ System.err.println("Missing helper node");
+ System.exit(-1);
+ }
+ return new CommandLineOptions(false, helperNode, null);
+ }
+
+ if (cmd.hasOption('b') || cmd.hasOption("bdb")) {
if (cmd.hasOption('l') || cmd.hasOption("listdb")) {
// list bdb je databases
BDBToolOptions bdbOpts = new BDBToolOptions(true, "", false, "", "", 0);
return new CommandLineOptions(false, "", bdbOpts);
- } else if (cmd.hasOption('d') || cmd.hasOption("db")) {
+ }
+ if (cmd.hasOption('d') || cmd.hasOption("db")) {
// specify a database
String dbName = cmd.getOptionValue("db");
if (Strings.isNullOrEmpty(dbName)) {
System.err.println("BDBJE database name is missing");
System.exit(-1);
}
-
if (cmd.hasOption('s') || cmd.hasOption("stat")) {
BDBToolOptions bdbOpts = new BDBToolOptions(false, dbName, true, "", "", 0);
return new CommandLineOptions(false, "", bdbOpts);
- } else {
- String fromKey = "";
- String endKey = "";
- int metaVersion = 0;
- if (cmd.hasOption('f') || cmd.hasOption("from")) {
- fromKey = cmd.getOptionValue("from");
- if (Strings.isNullOrEmpty(fromKey)) {
- System.err.println("from key is missing");
- System.exit(-1);
- }
+ }
+ String fromKey = "";
+ String endKey = "";
+ int metaVersion = 0;
+ if (cmd.hasOption('f') || cmd.hasOption("from")) {
+ fromKey = cmd.getOptionValue("from");
+ if (Strings.isNullOrEmpty(fromKey)) {
+ System.err.println("from key is missing");
+ System.exit(-1);
}
- if (cmd.hasOption('t') || cmd.hasOption("to")) {
- endKey = cmd.getOptionValue("to");
- if (Strings.isNullOrEmpty(endKey)) {
- System.err.println("end key is missing");
- System.exit(-1);
- }
+ }
+ if (cmd.hasOption('t') || cmd.hasOption("to")) {
+ endKey = cmd.getOptionValue("to");
+ if (Strings.isNullOrEmpty(endKey)) {
+ System.err.println("end key is missing");
+ System.exit(-1);
}
- if (cmd.hasOption('m') || cmd.hasOption("metaversion")) {
- try {
- metaVersion = Integer.valueOf(cmd.getOptionValue("metaversion"));
- } catch (NumberFormatException e) {
- System.err.println("Invalid meta version format");
- System.exit(-1);
- }
+ }
+ if (cmd.hasOption('m') || cmd.hasOption("metaversion")) {
+ try {
+ metaVersion = Integer.parseInt(cmd.getOptionValue("metaversion"));
+ } catch (NumberFormatException e) {
+ System.err.println("Invalid meta version format");
+ System.exit(-1);
}
-
- BDBToolOptions bdbOpts = new BDBToolOptions(false, dbName, false, fromKey, endKey, metaVersion);
- return new CommandLineOptions(false, "", bdbOpts);
}
+
+ BDBToolOptions bdbOpts = new BDBToolOptions(false, dbName, false, fromKey, endKey, metaVersion);
+ return new CommandLineOptions(false, "", bdbOpts);
+
} else {
System.err.println("Invalid options when running bdb je tools");
System.exit(-1);
}
- } else if (cmd.hasOption('h') || cmd.hasOption("helper")) {
- String helperNode = cmd.getOptionValue("helper");
- if (Strings.isNullOrEmpty(helperNode)) {
- System.err.println("Missing helper node");
- System.exit(-1);
- }
- return new CommandLineOptions(false, helperNode, null);
}
// helper node is null, means no helper node is specified
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org