sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kathl...@apache.org
Subject git commit: SQOOP-972: Sqoop2: Load server URL from environment in shell
Date Mon, 15 Apr 2013 15:36:38 GMT
Updated Branches:
  refs/heads/sqoop2 75ae6e3ea -> a82878bc7


SQOOP-972: Sqoop2: Load server URL from environment in shell

(Jarek Jarcec Cecho via Kate Ting)


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

Branch: refs/heads/sqoop2
Commit: a82878bc759266b3368e80ea1b43abebdbbefd41
Parents: 75ae6e3
Author: Kate Ting <kathleen@apache.org>
Authored: Mon Apr 15 11:35:45 2013 -0400
Committer: Kate Ting <kathleen@apache.org>
Committed: Mon Apr 15 11:35:45 2013 -0400

----------------------------------------------------------------------
 .../org/apache/sqoop/client/core/Constants.java    |    5 +++++
 .../sqoop/client/shell/ShellEnvironment.java       |   11 ++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/a82878bc/client/src/main/java/org/apache/sqoop/client/core/Constants.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/core/Constants.java b/client/src/main/java/org/apache/sqoop/client/core/Constants.java
index c6c6d8e..a48857e 100644
--- a/client/src/main/java/org/apache/sqoop/client/core/Constants.java
+++ b/client/src/main/java/org/apache/sqoop/client/core/Constants.java
@@ -27,6 +27,11 @@ public class Constants {
   public static final String BOLD_STR_SEQUENCE = "@|bold";
   public static final String END_STR_SEQUENCE = "|@";
 
+  // Environmental variables
+  public static final String ENV_HOST = "SQOOP2_HOST";
+  public static final String ENV_PORT = "SQOOP2_PORT";
+  public static final String ENV_WEBAPP = "SQOOP2_WEBAPP";
+
   // Options
 
   public static final String OPT_XID = "xid";

http://git-wip-us.apache.org/repos/asf/sqoop/blob/a82878bc/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java b/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java
index 25ae364..f6d1267 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java
@@ -35,9 +35,9 @@ public final class ShellEnvironment {
     // using static API.
   }
 
-  private static String serverHost = "localhost";
-  private static String serverPort = "12000";
-  private static String serverWebapp = "sqoop";
+  private static String serverHost = getEnv(Constants.ENV_HOST, "localhost");
+  private static String serverPort = getEnv(Constants.ENV_PORT, "12000");
+  private static String serverWebapp = getEnv(Constants.ENV_WEBAPP, "sqoop");
 
   private static boolean verbose = false;
   private static boolean interactive = false;
@@ -46,6 +46,11 @@ public final class ShellEnvironment {
   static SqoopClient client = new SqoopClient(getServerUrl());
   static IO io;
 
+  public static String getEnv(String variable, String defaultValue) {
+    String value = System.getenv(variable);
+    return value != null ? value : defaultValue;
+  }
+
   public static SqoopClient getClient() {
     return client;
   }


Mime
View raw message