lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1550548 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
Date Thu, 12 Dec 2013 21:57:39 GMT
Author: markrmiller
Date: Thu Dec 12 21:57:39 2013
New Revision: 1550548

URL: http://svn.apache.org/r1550548
Log:
SOLR-5547: Creating a collection alias using SolrJ's CollectionAdminRequest sets the alias
name and the collections to alias to the same value.

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java
    lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1550548&r1=1550547&r2=1550548&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Thu Dec 12 21:57:39 2013
@@ -198,6 +198,10 @@ Bug Fixes
 * SOLR-5532: SolrJ Content-Type validation is too strict for some
   webcontainers / proxies. (Jakob Furrer, hossman, Shawn Heisey, Uwe Schindler,
   Mark Miller)
+
+* SOLR-5547: Creating a collection alias using SolrJ's CollectionAdminRequest
+  sets the alias name and the collections to alias to the same value.
+  (Aaron Schram, Mark Miller)
   
 Optimizations
 ----------------------

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java?rev=1550548&r1=1550547&r2=1550548&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java Thu
Dec 12 21:57:39 2013
@@ -27,8 +27,10 @@ import org.apache.solr.client.solrj.Solr
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
 import org.apache.solr.client.solrj.impl.CloudSolrServer;
 import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
 import org.apache.solr.client.solrj.request.QueryRequest;
 import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.client.solrj.response.CollectionAdminResponse;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrInputDocument;
@@ -241,23 +243,38 @@ public class AliasIntegrationTest extend
     assertTrue(sawException);
   }
 
-  private void createAlias(String alias, String collections) throws SolrServerException,
IOException {
-    ModifiableSolrParams params = new ModifiableSolrParams();
-    params.set("collections", collections);
-    params.set("name", alias);
-    params.set("action", CollectionAction.CREATEALIAS.toString());
-    QueryRequest request = new QueryRequest(params);
-    request.setPath("/admin/collections");
-    NamedList<Object> result = createNewSolrServer("", getBaseUrl((HttpSolrServer)
clients.get(0))).request(request);
+  private void createAlias(String alias, String collections)
+      throws SolrServerException, IOException {
+    if (random().nextBoolean()) {
+      ModifiableSolrParams params = new ModifiableSolrParams();
+      params.set("collections", collections);
+      params.set("name", alias);
+      params.set("action", CollectionAction.CREATEALIAS.toString());
+      QueryRequest request = new QueryRequest(params);
+      request.setPath("/admin/collections");
+      NamedList<Object> result = createNewSolrServer("",
+          getBaseUrl((HttpSolrServer) clients.get(0))).request(request);
+    } else {
+      CollectionAdminResponse resp = CollectionAdminRequest.CreateAlias
+          .createAlias(alias, collections, createNewSolrServer("",
+              getBaseUrl((HttpSolrServer) clients.get(0))));
+    }
   }
   
-  private void deleteAlias(String alias) throws SolrServerException, IOException {
-    ModifiableSolrParams params = new ModifiableSolrParams();
-    params.set("name", alias);
-    params.set("action", CollectionAction.DELETEALIAS.toString());
-    QueryRequest request = new QueryRequest(params);
-    request.setPath("/admin/collections");
-    NamedList<Object> result = createNewSolrServer("", getBaseUrl((HttpSolrServer)
clients.get(0))).request(request);
+  private void deleteAlias(String alias) throws SolrServerException,
+      IOException {
+    if (random().nextBoolean()) {
+      ModifiableSolrParams params = new ModifiableSolrParams();
+      params.set("name", alias);
+      params.set("action", CollectionAction.DELETEALIAS.toString());
+      QueryRequest request = new QueryRequest(params);
+      request.setPath("/admin/collections");
+      NamedList<Object> result = createNewSolrServer("",
+          getBaseUrl((HttpSolrServer) clients.get(0))).request(request);
+    } else {
+      CollectionAdminResponse resp = CollectionAdminRequest.deleteAlias(alias,
+          createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0))));
+    }
   }
   
   protected void indexDoc(List<CloudJettyRunner> skipServers, Object... fields) throws
IOException,

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java?rev=1550548&r1=1550547&r2=1550548&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
(original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
Thu Dec 12 21:57:39 2013
@@ -197,7 +197,7 @@ public class CollectionAdminRequest exte
     @Override
     public SolrParams getParams() {
       ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
-      params.set( "collections", collection );
+      params.set( "collections", aliasedCollections );
       return params;
     }
 



Mime
View raw message