5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-10 02:21:34 +08:00

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

(Jarek Jarcec Cecho via Kate Ting)
This commit is contained in:
Kate Ting 2013-04-15 11:35:45 -04:00
parent 75ae6e3ea0
commit a82878bc75
2 changed files with 13 additions and 3 deletions

View File

@ -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";

View File

@ -35,9 +35,9 @@ private 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 @@ private 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;
}