lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject svn commit: r1669428 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/solrj/ solr/solrj/src/java/org/apache/solr/client/solrj/request/ solr/solrj/src/java/org/apache/solr/common/params/ solr/solrj/src/test/org/apache/solr/client/solrj/
Date Thu, 26 Mar 2015 20:24:35 GMT
Author: shaie
Date: Thu Mar 26 20:24:35 2015
New Revision: 1669428

URL: http://svn.apache.org/r1669428
Log:
SOLR-7298: Fix Collections API SolrJ calls to not add name parameter when not needed

Added:
    lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/CollectionAdminRequestRequiredParamsTest.java
      - copied unchanged from r1669426, lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/CollectionAdminRequestRequiredParamsTest.java
Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
    lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java

Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1669428&r1=1669427&r2=1669428&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Thu Mar 26 20:24:35 2015
@@ -266,6 +266,9 @@ Bug Fixes
 * SOLR-7293: Fix bug that Solr server does not listen on IPv6 interfaces by default.
   (Uwe Schindler, Sebastian Pesman)
 
+* SOLR-7298: Fix Collections API calls (SolrJ) to not add name parameter when not needed.
+  (Shai Erera, Anshum Gupta)
+
 Optimizations
 ----------------------
 

Modified: lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java?rev=1669428&r1=1669427&r2=1669428&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
(original)
+++ lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
Thu Mar 26 20:24:35 2015
@@ -47,27 +47,25 @@ public class CollectionAdminRequest exte
 
   private static String PROPERTY_PREFIX = "property.";
 
-  protected void setAction( CollectionAction action ) {
+  protected void setAction(CollectionAction action) {
     this.action = action;
   }
 
-  public CollectionAdminRequest()
-  {
-    super( METHOD.GET, "/admin/collections" );
+  public CollectionAdminRequest() {
+    super(METHOD.GET, "/admin/collections");
   }
 
-  public CollectionAdminRequest( String path )
-  {
-    super( METHOD.GET, path );
+  public CollectionAdminRequest(String path) {
+    super(METHOD.GET, path);
   }
 
   @Override
   public SolrParams getParams() {
-    if( action == null ) {
+    if (action == null) {
       throw new RuntimeException( "no action specified!" );
     }
     ModifiableSolrParams params = new ModifiableSolrParams();
-    params.set( CoreAdminParams.ACTION, action.toString() );
+    params.set(CoreAdminParams.ACTION, action.toString());
     return params;
   }
 
@@ -98,8 +96,7 @@ public class CollectionAdminRequest exte
   protected static class CollectionSpecificAdminRequest extends CollectionAdminRequest {
     protected String collection = null;
 
-    public final void setCollectionName( String collectionName )
-    {
+    public final void setCollectionName(String collectionName) {
       this.collection = collectionName;
     }
     
@@ -113,16 +110,30 @@ public class CollectionAdminRequest exte
 
   }
   
-  protected static class CollectionShardAdminRequest extends CollectionSpecificAdminRequest
{
+  protected static class CollectionShardAdminRequest extends CollectionAdminRequest {
     protected String shardName = null;
+    protected String collection = null;
 
-    public void setShardName(String shard) { this.shardName = shard; }
-    public String getShardName() { return this.shardName; }
+    public void setCollectionName(String collectionName) {
+      this.collection = collectionName;
+    }
+    
+    public String getCollectionName() {
+      return collection;
+    }
+    
+    public void setShardName(String shard) {
+      this.shardName = shard;
+    }
+    
+    public String getShardName() {
+      return this.shardName;
+    }
 
     public ModifiableSolrParams getCommonParams() {
       ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
-      params.set( "collection", collection );
-      params.set( "shard", shardName);
+      params.set(CoreAdminParams.COLLECTION, collection);
+      params.set(CoreAdminParams.SHARD, shardName);
       return params;
     }
 
@@ -180,7 +191,6 @@ public class CollectionAdminRequest exte
     protected Integer stateFormat;
     protected String asyncId;
 
-
     public Create() {
       action = CollectionAction.CREATE;
     }
@@ -297,8 +307,10 @@ public class CollectionAdminRequest exte
     @Override
     public SolrParams getParams() {
       ModifiableSolrParams params = getCommonParams();
-      params.set( "createNodeSet", nodeSet);
-      if(properties != null) {
+      if (nodeSet != null) {
+        params.set("createNodeSet", nodeSet);
+      }
+      if (properties != null) {
         addProperties(params, properties);
       }
       return params;
@@ -376,13 +388,18 @@ public class CollectionAdminRequest exte
       action = CollectionAction.REQUESTSTATUS;
     }
 
-    public void setRequestId(String requestId) {this.requestId = requestId; }
-    public String getRequestId() { return this.requestId; }
+    public void setRequestId(String requestId) {
+      this.requestId = requestId;
+    }
+    
+    public String getRequestId() {
+      return this.requestId;
+    }
 
     @Override
     public SolrParams getParams() {
       ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
-      params.set("requestid", requestId);
+      params.set(CoreAdminParams.REQUESTID, requestId);
       return params;
     }
   }
@@ -404,8 +421,13 @@ public class CollectionAdminRequest exte
       return aliasName;
     }
     
-    public void setAliasedCollections(String alias) { this.aliasedCollections = alias; }
-    public String getAliasedCollections() { return this.aliasedCollections; }
+    public void setAliasedCollections(String alias) {
+      this.aliasedCollections = alias;
+    }
+    
+    public String getAliasedCollections() {
+      return this.aliasedCollections;
+    }
     
     @Deprecated
     public void setCollectionName(String aliasName) {
@@ -415,8 +437,8 @@ public class CollectionAdminRequest exte
     @Override
     public SolrParams getParams() {
       ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
-      params.set("name", aliasName);
-      params.set( "collections", aliasedCollections );
+      params.set(CoreAdminParams.NAME, aliasName);
+      params.set("collections", aliasedCollections);
       return params;
     }
   }
@@ -436,7 +458,7 @@ public class CollectionAdminRequest exte
     @Override
     public SolrParams getParams() {
       ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
-      params.set("name", aliasName);
+      params.set(CoreAdminParams.NAME, aliasName);
       return params;
     }
   }
@@ -498,13 +520,15 @@ public class CollectionAdminRequest exte
     public SolrParams getParams() {
       ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
       if (shardName == null || shardName.isEmpty()) {
-        params.remove("shard");
+        params.remove(CoreAdminParams.SHARD);
         if (routeKey == null) {
           throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Either shard or routeKey
must be provided");
         }
         params.add(ShardParams._ROUTE_, routeKey);
       }
-      params.set("async", asyncId);
+      if (asyncId != null) {
+        params.set("async", asyncId);
+      }
       if (node != null) {
         params.add("node", node);
       }
@@ -591,9 +615,10 @@ public class CollectionAdminRequest exte
       return this.propertyValue;
     }
     
+    @Override
     public SolrParams getParams() {
       ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
-      params.add("name", propertyName);
+      params.add(CoreAdminParams.NAME, propertyName);
       params.add("val", propertyValue);
       
       return params;
@@ -602,7 +627,8 @@ public class CollectionAdminRequest exte
   }
   
   // MIGRATE request
-  public static class Migrate extends CollectionSpecificAdminRequest {
+  public static class Migrate extends CollectionAdminRequest {
+    private String collection;
     private String targetCollection;
     private String splitKey;
     private Integer forwardTimeout;
@@ -613,6 +639,14 @@ public class CollectionAdminRequest exte
       action = CollectionAction.MIGRATE;
     }
     
+    public void setCollectionName(String collection) {
+      this.collection = collection;
+    }
+    
+    public String getCollectionName() {
+      return collection;
+    }
+    
     public void setTargetCollection(String targetCollection) {
       this.targetCollection = targetCollection;
     }
@@ -648,15 +682,15 @@ public class CollectionAdminRequest exte
     @Override
     public SolrParams getParams() {
       ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
-      params.set( "collection", collection );
+      params.set(CoreAdminParams.COLLECTION, collection);
       params.set("target.collection", targetCollection);
       params.set("split.key", splitKey);
-      if(forwardTimeout != null) {
+      if (forwardTimeout != null) {
         params.set("forward.timeout", forwardTimeout);
       }
       params.set("async", asyncId);
       
-      if(properties != null) {
+      if (properties != null) {
         addProperties(params, properties);
       }
       
@@ -694,12 +728,43 @@ public class CollectionAdminRequest exte
   }
 
   // CLUSTERSTATUS request
-  public static class ClusterStatus extends CollectionShardAdminRequest {
+  public static class ClusterStatus extends CollectionAdminRequest {
+    
+    protected String shardName = null;
+    protected String collection = null;
     
     public ClusterStatus () {
       action = CollectionAction.CLUSTERSTATUS;
     }
     
+    public void setCollectionName(String collectionName) {
+      this.collection = collectionName;
+    }
+    
+    public String getCollectionName() {
+      return collection;
+    }
+    
+    public void setShardName(String shard) {
+      this.shardName = shard;
+    }
+    
+    public String getShardName() {
+      return this.shardName;
+    }
+
+    @Override
+    public SolrParams getParams() {
+      ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
+      if (collection != null) {
+        params.set(CoreAdminParams.COLLECTION, collection);
+      }
+      if (shardName != null) {
+        params.set(CoreAdminParams.SHARD, shardName);
+      }
+      return params;
+    }
+    
   }
 
   // LIST request
@@ -755,12 +820,13 @@ public class CollectionAdminRequest exte
     @Override
     public SolrParams getParams() {
       ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
-      params.set("replica", replica);
+      params.set(CoreAdminParams.REPLICA, replica);
       params.set("property", propertyName);
       params.set("property.value", propertyValue);
       
-      if(shardUnique != null)
+      if (shardUnique != null) {
         params.set("shardUnique", shardUnique);
+      }
       
       return params;
     }
@@ -847,7 +913,7 @@ public class CollectionAdminRequest exte
     @Override
     public SolrParams getParams() {
       ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
-      params.set("collection", collection);
+      params.set(CoreAdminParams.COLLECTION, collection);
       params.set("property", propertyName);
       if(onlyActiveNodes != null)
         params.set("onlyactivenodes", onlyActiveNodes);

Modified: lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java?rev=1669428&r1=1669427&r2=1669428&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java
(original)
+++ lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java
Thu Mar 26 20:24:35 2015
@@ -74,6 +74,9 @@ public abstract class CoreAdminParams
   /** The collection name in solr cloud */
   public final static String COLLECTION = "collection";
 
+  /** The replica name in solr cloud */
+  public final static String REPLICA = "replica";
+  
   /** The shard id in solr cloud */
   public final static String SHARD = "shard";
   



Mime
View raw message