flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fhue...@apache.org
Subject [1/5] flink git commit: [refactor] Change if-else conditions to switch-case statements.
Date Thu, 07 Jan 2016 17:58:58 GMT
Repository: flink
Updated Branches:
  refs/heads/master c674a6558 -> 08c81378b


[refactor] Change if-else conditions to switch-case statements.

This closes #1485


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/54b89b95
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/54b89b95
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/54b89b95

Branch: refs/heads/master
Commit: 54b89b95c82f2d660f320e97f961b69e50e0f06e
Parents: c674a65
Author: Henry Saputra <hsaputra@apache.org>
Authored: Tue Jan 5 13:45:14 2016 -0800
Committer: Fabian Hueske <fhueske@apache.org>
Committed: Thu Jan 7 16:55:10 2016 +0100

----------------------------------------------------------------------
 .../org/apache/flink/client/CliFrontend.java    | 95 ++++++++++----------
 1 file changed, 46 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/54b89b95/flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java
----------------------------------------------------------------------
diff --git a/flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java b/flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java
index 30007cd..b201cf4 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java
@@ -965,57 +965,54 @@ public class CliFrontend {
 		final String[] params = Arrays.copyOfRange(args, 1, args.length);
 
 		// do action
-		if (action.equals(ACTION_RUN)) {
-			// run() needs to run in a secured environment for the optimizer.
-			if (SecurityUtils.isSecurityEnabled()) {
-				String message = "Secure Hadoop environment setup detected. Running in secure context.";
-				LOG.info(message);
-				if (!webFrontend) {
-					System.out.println(message);
-				}
+		switch (action) {
+			case ACTION_RUN:
+				// run() needs to run in a secured environment for the optimizer.
+				if (SecurityUtils.isSecurityEnabled()) {
+					String message = "Secure Hadoop environment setup detected. Running in secure context.";
+					LOG.info(message);
+					if (!webFrontend) {
+						System.out.println(message);
+					}
 
-				try {
-					return SecurityUtils.runSecured(new SecurityUtils.FlinkSecuredRunner<Integer>()
{
-						@Override
-						public Integer run() throws Exception {
-							return CliFrontend.this.run(params);
-						}
-					});
-				} catch (Exception e) {
-					handleError(e);
+					try {
+						return SecurityUtils.runSecured(new SecurityUtils.FlinkSecuredRunner<Integer>()
{
+							@Override
+							public Integer run() throws Exception {
+								return CliFrontend.this.run(params);
+							}
+						});
+					} catch (Exception e) {
+						return handleError(e);
+					}
 				}
-			}
-			return run(params);
-		}
-		else if (action.equals(ACTION_LIST)) {
-			return list(params);
-		}
-		else if (action.equals(ACTION_INFO)) {
-			return info(params);
-		}
-		else if (action.equals(ACTION_CANCEL)) {
-			return cancel(params);
-		}
-		else if (action.equals("-h") || action.equals("--help")) {
-			CliFrontendParser.printHelp();
-			return 0;
-		}
-		else if (action.equals("-v") || action.equals("--version")) {
-			String version = EnvironmentInformation.getVersion();
-			String commitID = EnvironmentInformation.getRevisionInformation().commitId;
-			System.out.print("Version: " + version);
-			System.out.println(!commitID.equals(EnvironmentInformation.UNKNOWN) ? ", Commit ID: "
+ commitID : "");
-			return 0;
-		}
-		else {
-			System.out.printf("\"%s\" is not a valid action.\n", action);
-			System.out.println();
-			System.out.println("Valid actions are \"run\", \"list\", \"info\", or \"cancel\".");
-			System.out.println();
-			System.out.println("Specify the version option (-v or --version) to print Flink version.");
-			System.out.println();
-			System.out.println("Specify the help option (-h or --help) to get help on the command.");
-			return 1;
+				return run(params);
+			case ACTION_LIST:
+				return list(params);
+			case ACTION_INFO:
+				return info(params);
+			case ACTION_CANCEL:
+				return cancel(params);
+			case "-h":
+			case "--help":
+				CliFrontendParser.printHelp();
+				return 0;
+			case "-v":
+			case "--version":
+				String version = EnvironmentInformation.getVersion();
+				String commitID = EnvironmentInformation.getRevisionInformation().commitId;
+				System.out.print("Version: " + version);
+				System.out.println(!commitID.equals(EnvironmentInformation.UNKNOWN) ? ", Commit ID: "
+ commitID : "");
+				return 0;
+			default:
+				System.out.printf("\"%s\" is not a valid action.\n", action);
+				System.out.println();
+				System.out.println("Valid actions are \"run\", \"list\", \"info\", or \"cancel\".");
+				System.out.println();
+				System.out.println("Specify the version option (-v or --version) to print Flink version.");
+				System.out.println();
+				System.out.println("Specify the help option (-h or --help) to get help on the command.");
+				return 1;
 		}
 	}
 


Mime
View raw message