You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2016/10/03 19:02:45 UTC

[1/2] lucene-solr:branch_6x: SOLR-9520: Kerberos delegation support in SolrJ

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 5b1066206 -> d44d07966


SOLR-9520: Kerberos delegation support in SolrJ


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/50abf957
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/50abf957
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/50abf957

Branch: refs/heads/branch_6x
Commit: 50abf9571c2d641f2216a5f9a00662b1474edea3
Parents: 8e31e50
Author: Noble Paul <no...@apache.org>
Authored: Tue Oct 4 00:32:26 2016 +0530
Committer: Noble Paul <no...@apache.org>
Committed: Tue Oct 4 00:32:26 2016 +0530

----------------------------------------------------------------------
 .../TestSolrCloudWithDelegationTokens.java      | 30 +++++-----
 .../solr/client/solrj/impl/CloudSolrClient.java | 42 +++++++-------
 .../client/solrj/impl/LBHttpSolrClient.java     | 59 ++++++++++++--------
 3 files changed, 70 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/50abf957/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithDelegationTokens.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithDelegationTokens.java b/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithDelegationTokens.java
index 3ff982d..364f004 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithDelegationTokens.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithDelegationTokens.java
@@ -178,20 +178,20 @@ public class TestSolrCloudWithDelegationTokens extends SolrTestCaseJ4 {
 
   private int getStatusCode(String token, final String user, final String op, HttpSolrClient client)
   throws Exception {
-    SolrClient delegationTokenServer = random().nextBoolean() ?
-        new HttpSolrClient.Builder(client.getBaseURL().toString())
-            .withKerberosDelegationToken(token)
+    SolrClient delegationTokenClient;
+    if (random().nextBoolean()) delegationTokenClient = new HttpSolrClient.Builder(client.getBaseURL().toString())
+        .withKerberosDelegationToken(token)
+        .withResponseParser(client.getParser())
+        .build();
+    else delegationTokenClient = new CloudSolrClient.Builder()
+        .withZkHost((miniCluster.getZkServer().getZkAddress()))
+        .withLBHttpSolrClientBuilder(new LBHttpSolrClient.Builder()
             .withResponseParser(client.getParser())
-            .build() :
-        new CloudSolrClient.Builder()
-            .withZkHost((miniCluster.getZkServer().getZkAddress()))
-            .withBuilder(new LBHttpSolrClient.Builder()
-                .withResponseParser(client.getParser())
-                .withHttpSolrClientBuilder(
-                    new HttpSolrClient.Builder()
-                        .withKerberosDelegationToken(token)
-                ))
-            .build();
+            .withHttpSolrClientBuilder(
+                new HttpSolrClient.Builder()
+                    .withKerberosDelegationToken(token)
+            ))
+        .build();
     try {
       ModifiableSolrParams p = new ModifiableSolrParams();
       if (user != null) p.set(USER_PARAM, user);
@@ -204,13 +204,13 @@ public class TestSolrCloudWithDelegationTokens extends SolrTestCaseJ4 {
         req.setQueryParams(queryParams);
       }
       try {
-        delegationTokenServer.request(req, null);
+        delegationTokenClient.request(req, null);
         return HttpStatus.SC_OK;
       } catch (HttpSolrClient.RemoteSolrException re) {
         return re.code();
       }
     } finally {
-      delegationTokenServer.close();
+      delegationTokenClient.close();
     }
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/50abf957/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
index 4b0afe1..88da5f3 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
@@ -341,7 +341,7 @@ public class CloudSolrClient extends SolrClient {
    *          the {@link HttpClient} instance to be used for all requests. The provided httpClient should use a
    *          multi-threaded connection manager.  If null, a default HttpClient will be used.
    * @param lbSolrClient
-   *          LBHttpSolrServer instance for requests.  If null, a default HttpClient will be used.
+   *          LBHttpSolrClient instance for requests.  If null, a default LBHttpSolrClient will be used.
    * @param updatesToLeaders
    *          If true, sends updates to shard leaders.
    *
@@ -350,7 +350,7 @@ public class CloudSolrClient extends SolrClient {
    */
   @Deprecated
   public CloudSolrClient(Collection<String> zkHosts, String chroot, HttpClient httpClient, LBHttpSolrClient lbSolrClient, boolean updatesToLeaders) {
-    this(zkHosts, chroot, httpClient, lbSolrClient, updatesToLeaders, false,null);
+    this(zkHosts, chroot, httpClient, lbSolrClient, null, updatesToLeaders, false);
   }
 
   /**
@@ -371,7 +371,9 @@ public class CloudSolrClient extends SolrClient {
    *          the {@link HttpClient} instance to be used for all requests. The provided httpClient should use a
    *          multi-threaded connection manager.  If null, a default HttpClient will be used.
    * @param lbSolrClient
-   *          LBHttpSolrServer instance for requests.  If null, a default HttpClient will be used.
+   *          LBHttpSolrClient instance for requests.  If null, a default LBHttpSolrClient will be used.
+   * @param lbHttpSolrClientBuilder
+   *          LBHttpSolrClient builder to construct the LBHttpSolrClient. If null, a default builder will be used.
    * @param updatesToLeaders
    *          If true, sends updates to shard leaders.
    * @param directUpdatesToLeadersOnly
@@ -381,24 +383,19 @@ public class CloudSolrClient extends SolrClient {
                           String chroot,
                           HttpClient httpClient,
                           LBHttpSolrClient lbSolrClient,
+                          LBHttpSolrClient.Builder lbHttpSolrClientBuilder,
                           boolean updatesToLeaders,
-                          boolean directUpdatesToLeadersOnly,
-                          LBHttpSolrClient.Builder builder) {
+                          boolean directUpdatesToLeadersOnly) {
+    this.clientIsInternal = httpClient == null;
+    this.shutdownLBHttpSolrServer = lbSolrClient == null;
+    if(lbHttpSolrClientBuilder != null) lbSolrClient = lbHttpSolrClientBuilder.build();
+    if(lbSolrClient != null) httpClient = lbSolrClient.getHttpClient();
+    this.myClient = httpClient == null ? HttpClientUtil.createClient(null) : httpClient;
+    if (lbSolrClient == null) lbSolrClient = createLBHttpSolrClient(myClient);
+    this.lbClient = lbSolrClient;
     this.zkHost = buildZkHostString(zkHosts, chroot);
     this.updatesToLeaders = updatesToLeaders;
     this.directUpdatesToLeadersOnly = directUpdatesToLeadersOnly;
-
-    if(builder !=null){
-      this.clientIsInternal = false;
-      this.lbClient = builder.build();
-      this.shutdownLBHttpSolrServer = true;
-    } else {
-      this.clientIsInternal = httpClient == null;
-      this.myClient = httpClient == null ? HttpClientUtil.createClient(null) : httpClient;
-
-      this.shutdownLBHttpSolrServer = lbSolrClient == null;
-      this.lbClient = lbSolrClient == null ? createLBHttpSolrClient(myClient) : lbSolrClient;
-    }
   }
   
   /**
@@ -486,7 +483,7 @@ public class CloudSolrClient extends SolrClient {
   public ResponseParser getParser() {
     return lbClient.getParser();
   }
-  
+
   /**
    * Note: This setter method is <b>not thread-safe</b>.
    * 
@@ -1582,8 +1579,8 @@ public class CloudSolrClient extends SolrClient {
     /**
      * Provides a {@link HttpClient} for the builder to use when creating clients.
      */
-    public Builder withBuilder(LBHttpSolrClient.Builder builder) {
-      this.lbClientBuilder = builder;
+    public Builder withLBHttpSolrClientBuilder(LBHttpSolrClient.Builder lbHttpSolrClientBuilder) {
+      this.lbClientBuilder = lbHttpSolrClientBuilder;
       return this;
     }
 
@@ -1596,7 +1593,6 @@ public class CloudSolrClient extends SolrClient {
     }
 
 
-    
     /**
      * Provide a series of ZooKeeper client endpoints for the builder to use when creating clients.
      * 
@@ -1666,8 +1662,8 @@ public class CloudSolrClient extends SolrClient {
      * Create a {@link CloudSolrClient} based on the provided configuration.
      */
     public CloudSolrClient build() {
-      return new CloudSolrClient(zkHosts, zkChroot, httpClient, loadBalancedSolrClient,
-          shardLeadersOnly, directUpdatesToLeadersOnly, lbClientBuilder);
+      return new CloudSolrClient(zkHosts, zkChroot, httpClient, loadBalancedSolrClient, lbClientBuilder,
+          shardLeadersOnly, directUpdatesToLeadersOnly);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/50abf957/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java
index 237db56..fab6759 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java
@@ -227,7 +227,7 @@ public class LBHttpSolrClient extends SolrClient {
    */
   @Deprecated
   public LBHttpSolrClient(String... solrServerUrls) throws MalformedURLException {
-    this((HttpClient) null, solrServerUrls);
+    this(null, solrServerUrls);
   }
   
   /**
@@ -239,13 +239,22 @@ public class LBHttpSolrClient extends SolrClient {
     this(httpClient, new BinaryResponseParser(), solrServerUrl);
   }
 
-  public LBHttpSolrClient(HttpSolrClient.Builder httpSolrClientBuilder, String... solrServerUrl) {
-    clientIsInternal = false;
+  /**
+   * The provided httpClient should use a multi-threaded connection manager
+   * @deprecated use {@link Builder} instead.  This will soon be a protected
+   * method and will only be available for use in implementing subclasses.
+   */
+  public LBHttpSolrClient(HttpSolrClient.Builder httpSolrClientBuilder,
+                          HttpClient httpClient, String... solrServerUrl) {
+    clientIsInternal = httpClient == null;
     this.httpSolrClientBuilder = httpSolrClientBuilder;
-    this.httpClient = null;
-    for (String s : solrServerUrl) {
-      ServerWrapper wrapper = new ServerWrapper(makeSolrClient(s));
-      aliveServers.put(wrapper.getKey(), wrapper);
+    httpClient = constructClient(null);
+    this.httpClient = httpClient;
+    if (solrServerUrl != null) {
+      for (String s : solrServerUrl) {
+        ServerWrapper wrapper = new ServerWrapper(makeSolrClient(s));
+        aliveServers.put(wrapper.getKey(), wrapper);
+      }
     }
     updateAliveList();
   }
@@ -258,19 +267,7 @@ public class LBHttpSolrClient extends SolrClient {
   @Deprecated
   public LBHttpSolrClient(HttpClient httpClient, ResponseParser parser, String... solrServerUrl) {
     clientIsInternal = (httpClient == null);
-    if (httpClient == null) {
-      ModifiableSolrParams params = new ModifiableSolrParams();
-      if (solrServerUrl.length > 1) {
-        // we prefer retrying another server
-        params.set(HttpClientUtil.PROP_USE_RETRY, false);
-      } else {
-        params.set(HttpClientUtil.PROP_USE_RETRY, true);
-      }
-      this.httpClient = HttpClientUtil.createClient(params);
-    } else {
-      this.httpClient = httpClient;
-    }
-    
+    this.httpClient = httpClient == null ? constructClient(solrServerUrl) : httpClient;
     this.parser = parser;
     
     for (String s : solrServerUrl) {
@@ -279,7 +276,18 @@ public class LBHttpSolrClient extends SolrClient {
     }
     updateAliveList();
   }
-  
+
+  private HttpClient constructClient(String[] solrServerUrl) {
+    ModifiableSolrParams params = new ModifiableSolrParams();
+    if (solrServerUrl != null && solrServerUrl.length > 1) {
+      // we prefer retrying another server
+      params.set(HttpClientUtil.PROP_USE_RETRY, false);
+    } else {
+      params.set(HttpClientUtil.PROP_USE_RETRY, true);
+    }
+    return HttpClientUtil.createClient(params);
+  }
+
   public Set<String> getQueryParams() {
     return queryParams;
   }
@@ -307,6 +315,7 @@ public class LBHttpSolrClient extends SolrClient {
       synchronized (this) {
         client = httpSolrClientBuilder
             .withBaseSolrUrl(server)
+            .withHttpClient(httpClient)
             .build();
       }
     } else {
@@ -784,7 +793,11 @@ public class LBHttpSolrClient extends SolrClient {
       this.baseSolrUrls = new ArrayList<>();
       this.responseParser = new BinaryResponseParser();
     }
-    
+
+    public HttpSolrClient.Builder getHttpSolrClientBuilder() {
+      return httpSolrClientBuilder;
+    }
+
     /**
      * Provide a Solr endpoint to be used when configuring {@link LBHttpSolrClient} instances.
      * 
@@ -839,7 +852,7 @@ public class LBHttpSolrClient extends SolrClient {
       final String[] baseUrlArray = new String[baseSolrUrls.size()];
       String[] solrServerUrls = baseSolrUrls.toArray(baseUrlArray);
       return httpSolrClientBuilder != null ?
-          new LBHttpSolrClient(httpSolrClientBuilder, solrServerUrls) :
+          new LBHttpSolrClient(httpSolrClientBuilder, httpClient, solrServerUrls) :
           new LBHttpSolrClient(httpClient, responseParser, solrServerUrls);
     }
   }


[2/2] lucene-solr:branch_6x: Merge remote-tracking branch 'origin/branch_6x' into branch_6x

Posted by no...@apache.org.
Merge remote-tracking branch 'origin/branch_6x' into branch_6x


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

Branch: refs/heads/branch_6x
Commit: d44d07966a64e4a055dfb5c84d12cfb5fd0c5320
Parents: 50abf95 5b10662
Author: Noble Paul <no...@apache.org>
Authored: Tue Oct 4 00:32:36 2016 +0530
Committer: Noble Paul <no...@apache.org>
Committed: Tue Oct 4 00:32:36 2016 +0530

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  2 +
 solr/webapp/web/css/angular/dashboard.css       |  8 +-
 .../web/js/angular/controllers/core-overview.js | 83 --------------------
 solr/webapp/web/partials/core_overview.html     | 17 ----
 4 files changed, 3 insertions(+), 107 deletions(-)
----------------------------------------------------------------------