hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject git commit: HBASE-11890 HBase REST Client is hard coded to http protocol
Date Mon, 06 Oct 2014 19:23:47 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 07f0c030c -> ed17aacbb


HBASE-11890 HBase REST Client is hard coded to http protocol


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

Branch: refs/heads/branch-1
Commit: ed17aacbbaecce887d07124c7ff0c3c3fd197b88
Parents: 07f0c03
Author: stack <stack@apache.org>
Authored: Mon Oct 6 12:23:38 2014 -0700
Committer: stack <stack@apache.org>
Committed: Mon Oct 6 12:23:38 2014 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hbase/rest/client/Client.java | 33 +++++++++++++++-----
 1 file changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/ed17aacb/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java
index 2a47f38..ebedf57 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java
@@ -57,6 +57,7 @@ public class Client {
 
   private HttpClient httpClient;
   private Cluster cluster;
+  private boolean sslEnabled;
 
   private Map<String, String> extraHeaders;
 
@@ -67,13 +68,10 @@ public class Client {
     this(null);
   }
 
-  /**
-   * Constructor
-   * @param cluster the cluster definition
-   */
-  public Client(Cluster cluster) {
+  private void initialize(Cluster cluster, boolean sslEnabled) {
     this.cluster = cluster;
-    MultiThreadedHttpConnectionManager manager = 
+    this.sslEnabled = sslEnabled;
+    MultiThreadedHttpConnectionManager manager =
       new MultiThreadedHttpConnectionManager();
     HttpConnectionManagerParams managerParams = manager.getParams();
     managerParams.setConnectionTimeout(2000); // 2 s
@@ -83,6 +81,23 @@ public class Client {
     this.httpClient = new HttpClient(manager);
     HttpClientParams clientParams = httpClient.getParams();
     clientParams.setVersion(HttpVersion.HTTP_1_1);
+
+  }
+  /**
+   * Constructor
+   * @param cluster the cluster definition
+   */
+  public Client(Cluster cluster) {
+    initialize(cluster, false);
+  }
+
+  /**
+   * Constructor
+   * @param cluster the cluster definition
+   * @param sslEnabled enable SSL or not
+   */
+  public Client(Cluster cluster, boolean sslEnabled) {
+    initialize(cluster, sslEnabled);
   }
 
   /**
@@ -156,7 +171,11 @@ public class Client {
       cluster.lastHost = cluster.nodes.get(i);
       try {
         StringBuilder sb = new StringBuilder();
-        sb.append("http://");
+        if (sslEnabled) {
+          sb.append("https://");
+        } else {
+          sb.append("http://");
+        }
         sb.append(cluster.lastHost);
         sb.append(path);
         URI uri = new URI(sb.toString(), true);


Mime
View raw message