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/09/15 11:17:24 UTC

lucene-solr:apiv2: SOLR-8029: moved the set-replica to collections/collection level

Repository: lucene-solr
Updated Branches:
  refs/heads/apiv2 c47ea512b -> bbb44137e


SOLR-8029: moved the set-replica to collections/collection level


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

Branch: refs/heads/apiv2
Commit: bbb44137e1f457b02f47ce0798d4d213d964d8cb
Parents: c47ea51
Author: Noble Paul <no...@apache.org>
Authored: Thu Sep 15 16:47:13 2016 +0530
Committer: Noble Paul <no...@apache.org>
Committed: Thu Sep 15 16:47:13 2016 +0530

----------------------------------------------------------------------
 .../handler/admin/CollectionHandlerApi.java     | 18 ++--
 .../resources/apispec/collections.Commands.json | 86 ++++++++++++++------
 .../collections.collection.Commands.json        | 50 ++++++++++++
 ...ollection.shards.shard.replica.Commands.json | 42 ----------
 ....collection.shards.shard.replica.delete.json |  4 +
 .../solr/handler/admin/TestCollectionAPIs.java  | 13 ++-
 6 files changed, 129 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bbb44137/solr/core/src/java/org/apache/solr/handler/admin/CollectionHandlerApi.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionHandlerApi.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionHandlerApi.java
index b7881d1..9d3bcd0 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionHandlerApi.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionHandlerApi.java
@@ -35,6 +35,7 @@ import org.apache.solr.util.CommandOperation;
 import static org.apache.solr.client.solrj.SolrRequest.METHOD.DELETE;
 import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
 import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
+import static org.apache.solr.cloud.OverseerCollectionMessageHandler.COLL_CONF;
 import static org.apache.solr.common.params.CommonParams.NAME;
 import static org.apache.solr.handler.admin.CollectionsHandler.CollectionOperation.*;
 
@@ -68,7 +69,9 @@ public class CollectionHandlerApi extends BaseHandlerApiSupport {
         CREATE_OP,
         CREATE_OP.action.toLower(),
         ImmutableMap.of(
-            OverseerCollectionMessageHandler.COLL_CONF, "config"),
+            COLL_CONF, "config",
+            "createNodeSet.shuffle","shuffleNodes"
+        ),
         ImmutableMap.of("properties.", "property.")),
 
     DELETE_COLL(EndPoint.PER_COLLECTION_DELETE,
@@ -109,7 +112,7 @@ public class CollectionHandlerApi extends BaseHandlerApiSupport {
         POST,
         DELETEALIAS_OP,
         "delete-alias",
-        ImmutableMap.of(NAME, "")),
+        null),
     CREATE_SHARD(EndPoint.PER_COLLECTION_SHARDS_COMMANDS,
         POST,
         CREATESHARD_OP,
@@ -144,16 +147,16 @@ public class CollectionHandlerApi extends BaseHandlerApiSupport {
         SYNCSHARD_OP,
         "synch-shard",
         null),
-    ADDREPLICAPROP(EndPoint.PER_COLLECTION_PER_SHARD_PER_REPLICA_COMMANDS,
+    ADDREPLICAPROP(EndPoint.PER_COLLECTION,
         POST,
         ADDREPLICAPROP_OP,
-        "set-property",
+        "add-replica-property",
         ImmutableMap.of("property", "name", "property.value", "value")),
-    DELETEREPLICAPROP(EndPoint.PER_COLLECTION_PER_SHARD_PER_REPLICA_COMMANDS,
+    DELETEREPLICAPROP(EndPoint.PER_COLLECTION,
         POST,
         DELETEREPLICAPROP_OP,
-        "delete-property",
-        ImmutableMap.of("property", "")),
+        "delete-replica-property",
+        null),
     ADDROLE(EndPoint.CLUSTER_CMD,
         POST,
         ADDROLE_OP,
@@ -288,7 +291,6 @@ public class CollectionHandlerApi extends BaseHandlerApiSupport {
     PER_COLLECTION_SHARDS_COMMANDS("collections.collection.shards.Commands"),
     PER_COLLECTION_PER_SHARD_COMMANDS("collections.collection.shards.shard.Commands"),
     PER_COLLECTION_PER_SHARD_DELETE("collections.collection.shards.shard.delete"),
-    PER_COLLECTION_PER_SHARD_PER_REPLICA_COMMANDS("collections.collection.shards.shard.replica.Commands"),
     PER_COLLECTION_PER_SHARD_PER_REPLICA_DELETE("collections.collection.shards.shard.replica.delete");
     final String specName;
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bbb44137/solr/core/src/resources/apispec/collections.Commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/collections.Commands.json b/solr/core/src/resources/apispec/collections.Commands.json
index 46660d2..cd2ed59 100644
--- a/solr/core/src/resources/apispec/collections.Commands.json
+++ b/solr/core/src/resources/apispec/collections.Commands.json
@@ -11,9 +11,9 @@
   },
   "commands": {
     "create": {
-      "type":"object",
-      "documentation":"https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-api1",
-      "description":"",
+      "type": "object",
+      "documentation": "https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-api1",
+      "description": "",
       "properties": {
         "name": {
           "type": "string",
@@ -27,13 +27,13 @@
           "type": "object",
           "properties": {
             "name": {
-              "type":"string",
-              "description" :"Router implementation compositeId or implicit",
-              "default" :"compositeId"
+              "type": "string",
+              "description": "Router implementation compositeId or implicit",
+              "default": "compositeId"
             },
             "field": {
-              "type":"string",
-              "description" :"Field on which doc routing is done"
+              "type": "string",
+              "description": "Field on which doc routing is done"
             }
           }
         },
@@ -53,57 +53,89 @@
           "type": "string",
           "description": " comma-separated list of node_names, such as localhost:8983_solr, localhost:8984_solr, localhost:8985_solr. "
         },
+        "shuffleNodes": {
+          "type": "boolean",
+          "description": "Controls wether or not the shard-replicas created for this collection will be assigned to the nodes specified by the createNodeSet in a sequential manner, or if the list of nodes should be shuffled prior to creating individual replicas.  A 'false' value makes the results of a collection creation predictible and gives more exact control over the location of the individual shard-replicas, but 'true' can be a better choice for ensuring replicas are distributed evenly across nodes. Ignored if createNodeSet is not also specified."
+        },
+        "maxShardsPerNode": {
+          "type": "integer",
+          "description": "When creating collections, the shards and/or replicas are spread across all available (i.e., live) nodes, and two replicas of the same shard will never be on the same node. If a node is not live when the CREATE operation is called, it will not get any parts of the new collection, which could lead to too many replicas being created on a single live node. Defining maxShardsPerNode sets a limit on the number of replicas CREATE will spread to each node. If the entire collection can not be fit into the live nodes, no collection will be created at all."
+        },
         "autoAddReplicas": {
           "type": "boolean",
           "description": "When set to true, enables auto addition of replicas on shared file systems. See the section autoAddReplicas Settings for more details on settings and overrides."
         },
         "rule": {
-          "type":"array",
+          "type": "array",
           "items": {
             "type": "string"
           },
-          "description":"replica placement rules. See the section Rule-based Replica Placement for details."
+          "description": "replica placement rules. See the section Rule-based Replica Placement for details."
         },
         "snitch": {
-          "type":"array",
+          "type": "array",
           "items": {
             "type": "string"
           },
-          "description":""
+          "description": ""
         },
         "properties": {
           "type": "object",
           "additionalProperties": true
+        },
+        "async": {
+          "type": "string",
+          "description": "Request ID to track this action which will be processed asynchronously"
         }
       },
-      "required":["name"]
+      "required": [
+        "name"
+      ]
     },
-    "create-alias":{
-      "type":"object",
+    "create-alias": {
+      "type": "object",
       "properties": {
         "name": {
           "type": "string",
           "description": "The alias name to be created"
         },
-        "collections" :{
-          "type":"array",
+        "collections": {
+          "type": "array",
           "items": {
             "type": "string"
           },
-          "description":"The list of collections to be aliased"
+          "description": "The list of collections to be aliased"
+        },
+        "async": {
+          "type": "string",
+          "description": "Request ID to track this action which will be processed asynchronously"
         }
       },
-      "required" : ["name","collections"]
+      "required": [
+        "name",
+        "collections"
+      ],
+      "documentation": "https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-api4",
+      "description": " create or modify an alias for a collection"
     },
-    "delete-alias":{
-      "type":"array",
-      "items": {
-        "type": "string"
-      },
-      "description":""
+    "delete-alias": {
+      "documentation": "https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-api5",
+      "description": "Delete a Collection Alias",
+      "type": "object",
+      "properties": {
+        "name": {
+          "type": "string",
+          "description": "The name of the alias to delete"
+        },
+        "async": {
+          "type": "string",
+          "description": "Request ID to track this action which will be processed asynchronously"
+        }
+      }
     },
-    
     "backup-collection": {
+      "documentation": "https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-Backup",
+      "description": "Backup Solr indexes and configurations for a specifc collection",
       "type": "object",
       "properties": {
         "collection": {
@@ -130,6 +162,8 @@
       ]
     },
     "restore-collection": {
+      "description": "Restore Solr indexes and configurations for a specific collection",
+      "documentation": "https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-Restore",
       "type": "object",
       "properties": {
         "collection": {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bbb44137/solr/core/src/resources/apispec/collections.collection.Commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/collections.collection.Commands.json b/solr/core/src/resources/apispec/collections.collection.Commands.json
index 18ecd67..aa30351 100644
--- a/solr/core/src/resources/apispec/collections.collection.Commands.json
+++ b/solr/core/src/resources/apispec/collections.collection.Commands.json
@@ -42,6 +42,56 @@
           "description":"This is the timeout value when waiting for leaders to be reassigned"
         }
       }
+    },
+    "add-replica-property": {
+      "description": "Assign an arbitrary property to a particular replica and give it the value specified. If the property already exists, it will be overwritten with the new value",
+      "documentation": "https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-AddReplicaProp",
+      "type": "object",
+      "properties": {
+        "shard": {
+          "type": "string",
+          "description": "The shard name"
+        },
+        "replica": {
+          "type": "string",
+          "description": "The replica name"
+        },
+        "name": {
+          "type": "string",
+          "description": "The property name"
+        },
+        "value": {
+          "type": "string",
+          "description": "he value to assign to the property"
+        },
+        "shardUnique": {
+          "type": "boolean",
+          "description": "If true, then setting this property in one replica will remove the property from all other replicas in that shard"
+        }
+      },
+      "required": [
+        "name",
+        "value"
+      ]
+    },
+    "delete-replica-property": {
+      "description": "Deletes an arbitrary property from a particular replica",
+      "documentation": "https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-DeleteReplicaProp",
+      "type": "object",
+      "properties": {
+        "shard": {
+          "type": "string",
+          "description": "The shard name"
+        },
+        "replica": {
+          "type": "string",
+          "description": "The replica name"
+        },
+        "property": {
+          "type": "string",
+          "description": "The property name"
+        }
+      }
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bbb44137/solr/core/src/resources/apispec/collections.collection.shards.shard.replica.Commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/collections.collection.shards.shard.replica.Commands.json b/solr/core/src/resources/apispec/collections.collection.shards.shard.replica.Commands.json
deleted file mode 100644
index 7a77012..0000000
--- a/solr/core/src/resources/apispec/collections.collection.shards.shard.replica.Commands.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
-  "documentation": "https://cwiki.apache.org",
-  "methods": [
-    "POST"
-  ],
-  "url": {
-    "paths": [
-      "/collections/{collection}/shards/{shard}/{replica}",
-      "/c/{collection}/shards/{shard}/{replica}"
-    ]
-  },
-  "commands": {
-    "set-property": {
-      "description": "Assign an arbitrary property to a particular replica and give it the value specified. If the property already exists, it will be overwritten with the new value",
-      "type":"object",
-      "properties": {
-        "name": {
-          "type": "string",
-          "description": "The property name"
-        },
-        "value": {
-          "type": "string",
-          "description": "The property name"
-        },
-        "shardUnique": {
-          "type": "boolean",
-          "description": "If true, then setting this property in one replica will remove the property from all other replicas in that shard"
-        }
-      },
-      "required":["name","value"]
-
-    },
-    "delete-property": {
-      "description": "Deletes an arbitrary property from a particular replica",
-      "type": "array",
-      "items": {
-        "type": "string"
-      }
-
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bbb44137/solr/core/src/resources/apispec/collections.collection.shards.shard.replica.delete.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/collections.collection.shards.shard.replica.delete.json b/solr/core/src/resources/apispec/collections.collection.shards.shard.replica.delete.json
index 47aaa9d..304233d 100644
--- a/solr/core/src/resources/apispec/collections.collection.shards.shard.replica.delete.json
+++ b/solr/core/src/resources/apispec/collections.collection.shards.shard.replica.delete.json
@@ -28,6 +28,10 @@
         "type": "boolean",
         "default": false,
         "description": "By default Solr will delete the entire instanceDir of the replica that is deleted. Set this to false to prevent the instance directory from being deleted"
+      },
+      "async":{
+        "type":"string",
+        "description":"Request ID to track this action which will be processed asynchronously."
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/bbb44137/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java b/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java
index 5f09aaf..537c4dc 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/TestCollectionAPIs.java
@@ -74,7 +74,7 @@ public class TestCollectionAPIs extends SolrTestCaseJ4 {
         "{create-alias:{name: aliasName , collections:[c1,c2] }}", null, "{operation : createalias, name: aliasName, collections:[c1,c2] }");
 
     compareOutput(apiBag, "/collections", POST,
-        "{delete-alias:aliasName}", null, "{operation : deletealias, name: aliasName}");
+        "{delete-alias:{ name: aliasName}}", null, "{operation : deletealias, name: aliasName}");
 
     compareOutput(apiBag, "/collections/collName", POST,
         "{reload:{}}", null,
@@ -107,13 +107,13 @@ public class TestCollectionAPIs extends SolrTestCaseJ4 {
         "{collection: collName , split.key : id12345 , operation : splitshard, property.prop1:prop1Val, property.prop2: prop2Val}"
     );
 
-    compareOutput(apiBag, "/collections/collName/shards/shard1/replica1", POST,
-        "{set-property : {name:propA , value: VALA}}", null,
+    compareOutput(apiBag, "/collections/collName", POST,
+        "{add-replica-property : {name:propA , value: VALA, shard: shard1, replica:replica1}}", null,
         "{collection: collName, shard: shard1, replica : replica1 , property : propA , operation : addreplicaprop, property.value : 'VALA'}"
     );
 
-    compareOutput(apiBag, "/collections/collName/shards/shard1/replica1", POST,
-        "{delete-property : propA }", null,
+    compareOutput(apiBag, "/collections/collName", POST,
+        "{delete-replica-property : {property: propA , shard: shard1, replica:replica1} }", null,
         "{collection: collName, shard: shard1, replica : replica1 , property : propA , operation : deletereplicaprop}"
     );
 
@@ -136,9 +136,6 @@ public class TestCollectionAPIs extends SolrTestCaseJ4 {
         "{operation : balanceshardunique ,collection : coll1, property : preferredLeader}"
     );
 
-
-    System.out.println();
-
   }
 
   ZkNodeProps compareOutput(final ApiBag apiBag, final String path, final SolrRequest.METHOD method,