Repository: hive Updated Branches: refs/heads/master 0ad4f717a -> 09448652d
HIVE-11244: Beeline prompt info improvement for cluster mode(Nemon Lou, reviewed by Ferdinand Xu) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/09448652 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/09448652 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/09448652 Branch: refs/heads/master Commit: 09448652d254b211eb81efbf163936df591e18b6 Parents: 0ad4f71 Author: Ferdinand Xu <cheng.a...@intel.com> Authored: Mon Jul 20 21:26:53 2015 -0400 Committer: Ferdinand Xu <cheng.a...@intel.com> Committed: Mon Jul 20 21:26:53 2015 -0400 ---------------------------------------------------------------------- beeline/src/java/org/apache/hive/beeline/BeeLine.java | 5 +++-- beeline/src/java/org/apache/hive/beeline/BeeLineOpts.java | 9 +++++++++ .../java/org/apache/hive/beeline/DatabaseConnection.java | 9 +++++++++ beeline/src/main/resources/BeeLine.properties | 2 ++ jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java | 4 ++++ 5 files changed, 27 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/09448652/beeline/src/java/org/apache/hive/beeline/BeeLine.java ---------------------------------------------------------------------- diff --git a/beeline/src/java/org/apache/hive/beeline/BeeLine.java b/beeline/src/java/org/apache/hive/beeline/BeeLine.java index c760c94..1519619 100644 --- a/beeline/src/java/org/apache/hive/beeline/BeeLine.java +++ b/beeline/src/java/org/apache/hive/beeline/BeeLine.java @@ -1233,8 +1233,9 @@ public class BeeLine implements Closeable { return "beeline> "; } else { String printClosed = getDatabaseConnection().isClosed() ? " (closed)" : ""; - return getPrompt(getDatabaseConnections().getIndex() - + ": " + getDatabaseConnection().getUrl()) + printClosed + "> "; + String url = getOpts().getShowConnectedUrl() ? getDatabaseConnection().getConnectedUrl() + : getDatabaseConnection().getUrl(); + return getPrompt(getDatabaseConnections().getIndex() + ": " + url) + printClosed + "> "; } } http://git-wip-us.apache.org/repos/asf/hive/blob/09448652/beeline/src/java/org/apache/hive/beeline/BeeLineOpts.java ---------------------------------------------------------------------- diff --git a/beeline/src/java/org/apache/hive/beeline/BeeLineOpts.java b/beeline/src/java/org/apache/hive/beeline/BeeLineOpts.java index d8b8b78..a31c49c 100644 --- a/beeline/src/java/org/apache/hive/beeline/BeeLineOpts.java +++ b/beeline/src/java/org/apache/hive/beeline/BeeLineOpts.java @@ -80,6 +80,7 @@ class BeeLineOpts implements Completer { private String outputFormat = "table"; private boolean trimScripts = true; private boolean allowMultiLineCommand = true; + private boolean showConnectedUrl = false; //This can be set for old behavior of nulls printed as empty strings private boolean nullEmptyString = false; @@ -434,6 +435,14 @@ class BeeLineOpts implements Completer { return autosave; } + public boolean getShowConnectedUrl() { + return showConnectedUrl; + } + + public void setShowConnectedUrl(boolean showConnectedUrl) { + this.showConnectedUrl = showConnectedUrl; + } + public void setOutputFormat(String outputFormat) { if(outputFormat.equalsIgnoreCase("csv") || outputFormat.equalsIgnoreCase("tsv")) { beeLine.info("Format " + outputFormat + " is deprecated, please use " + outputFormat + "2"); http://git-wip-us.apache.org/repos/asf/hive/blob/09448652/beeline/src/java/org/apache/hive/beeline/DatabaseConnection.java ---------------------------------------------------------------------- diff --git a/beeline/src/java/org/apache/hive/beeline/DatabaseConnection.java b/beeline/src/java/org/apache/hive/beeline/DatabaseConnection.java index 02b2eec..e349a49 100644 --- a/beeline/src/java/org/apache/hive/beeline/DatabaseConnection.java +++ b/beeline/src/java/org/apache/hive/beeline/DatabaseConnection.java @@ -38,6 +38,8 @@ import java.util.Properties; import java.util.Set; import java.util.TreeSet; +import org.apache.hive.jdbc.HiveConnection; + import jline.console.completer.ArgumentCompleter; import jline.console.completer.Completer; @@ -264,6 +266,13 @@ class DatabaseConnection { return url; } + public String getConnectedUrl() { + if (connection instanceof HiveConnection) { + return ((HiveConnection) connection).getConnectedUrl(); + } + return getUrl(); + } + Completer getSQLCompleter() { return sqlCompleter; } http://git-wip-us.apache.org/repos/asf/hive/blob/09448652/beeline/src/main/resources/BeeLine.properties ---------------------------------------------------------------------- diff --git a/beeline/src/main/resources/BeeLine.properties b/beeline/src/main/resources/BeeLine.properties index 756c334..a118c09 100644 --- a/beeline/src/main/resources/BeeLine.properties +++ b/beeline/src/main/resources/BeeLine.properties @@ -178,6 +178,8 @@ cmd-usage: Usage: java org.apache.hive.cli.beeline.BeeLine \n \ \ --nullemptystring=[true/false] set to true to get historic behavior of printing null as empty string\n \ \ --addlocaldriverjar=DRIVERJARNAME Add driver jar file in the beeline client side\n \ \ --addlocaldrivername=DRIVERNAME Add drvier name needs to be supported in the beeline client side\n \ +\ --showConnectedUrl=[true/false] Prompt HiveServer2's URI to which this beeline connected.\n \ +\ Only works for HiveServer2 cluster mode.\n \ \ --help display this message http://git-wip-us.apache.org/repos/asf/hive/blob/09448652/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java ---------------------------------------------------------------------- diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java index 959822e..bb2b695 100644 --- a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java +++ b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java @@ -240,6 +240,10 @@ public class HiveConnection implements java.sql.Connection { } } + public String getConnectedUrl() { + return jdbcUriString; + } + private String getServerHttpUrl(boolean useSsl) { // Create the http/https url // JDBC driver will set up an https url if ssl is enabled, otherwise http