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/07 13:09:46 UTC

lucene-solr:apiv2: SOLR-8029: added , commands add-role, remove-role, clusterprop

Repository: lucene-solr
Updated Branches:
  refs/heads/apiv2 d83b6b802 -> ea739f735


SOLR-8029: added , commands add-role, remove-role, clusterprop


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

Branch: refs/heads/apiv2
Commit: ea739f7350b0971249267532e30e979116754d2e
Parents: d83b6b8
Author: Noble Paul <no...@apache.org>
Authored: Wed Sep 7 18:39:34 2016 +0530
Committer: Noble Paul <no...@apache.org>
Committed: Wed Sep 7 18:39:34 2016 +0530

----------------------------------------------------------------------
 .../apache/solr/handler/admin/ApiCommand.java   |  2 +-
 .../handler/admin/CollectionHandlerApi.java     | 19 ++++++-
 .../handler/admin/ConfigSetsHandlerApi.java     |  9 ++--
 .../solr/handler/admin/CoreAdminHandlerApi.java |  4 +-
 .../src/resources/apispec/cluster.Commands.json | 32 ++++++++++--
 .../resources/apispec/collections.Commands.json | 53 ++++++++++++++++++++
 .../collections.collection.Commands.reload.json |  1 +
 .../collections.collection.shards.Commands.json | 12 +++++
 .../resources/apispec/cores.core.Commands.json  | 27 +++++++++-
 .../solr/handler/admin/TestCollectionAPIs.java  |  3 +-
 10 files changed, 148 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ea739f73/solr/core/src/java/org/apache/solr/handler/admin/ApiCommand.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ApiCommand.java b/solr/core/src/java/org/apache/solr/handler/admin/ApiCommand.java
index 3b9d194..cd9d4b3 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/ApiCommand.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ApiCommand.java
@@ -22,7 +22,7 @@ import java.util.Collection;
 import org.apache.solr.client.solrj.SolrRequest;
 import org.apache.solr.util.CommandOperation;
 
-public interface ApiCommand<T> {
+public interface ApiCommand {
   String getName();
 
   SolrRequest.METHOD getHttpMethod();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ea739f73/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 f5649e2..249794c 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
@@ -67,7 +67,7 @@ public class CollectionHandlerApi extends BaseHandlerApiSupport {
   }
 
 
-  enum Cmd implements ApiCommand<CollectionHandlerApi> {
+  enum Cmd implements ApiCommand {
     GET_COLLECTIONS(EndPoint.COLLECTIONS, GET, LIST_OP),
     GET_CLUSTER(EndPoint.CLUSTER, GET, LIST_OP, "/cluster", null),
     GET_CLUSTER_OVERSEER(EndPoint.CLUSTER, GET, OVERSEERSTATUS_OP, "/cluster/overseer", null),
@@ -172,6 +172,23 @@ public class CollectionHandlerApi extends BaseHandlerApiSupport {
         POST,
         REMOVEROLE_OP,
         "remove-role",null),
+
+    CLUSTERPROP(EndPoint.CLUSTER_CMD,
+        POST,
+        CLUSTERPROP_OP,
+        "set-property",null),
+
+    BACKUP(EndPoint.COLLECTIONS_COMMANDS,
+        POST,
+        BACKUP_OP,
+        "backup-collection", null
+        ),
+    RESTORE(EndPoint.COLLECTIONS_COMMANDS,
+        POST,
+        RESTORE_OP,
+        "restore-collection",
+        null
+        )
     ;
     public final String commandName;
     public final EndPoint endPoint;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ea739f73/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandlerApi.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandlerApi.java b/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandlerApi.java
index 349f4d1..546040f 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandlerApi.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandlerApi.java
@@ -21,6 +21,7 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.handler.admin.ConfigSetsHandler.ConfigSetOperation;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.util.CommandOperation;
@@ -62,21 +63,21 @@ public class ConfigSetsHandlerApi extends BaseHandlerApiSupport {
     return Arrays.asList(EndPoint.values());
   }
 
-  enum Cmd implements ApiCommand<ConfigSetsHandler> {
+  enum Cmd implements ApiCommand {
     LIST(EndPoint.LIST_CONFIG, LIST_OP, GET),
     CREATE(EndPoint.CONFIG_COMMANDS, CREATE_OP, POST, "create"),
     DEL(EndPoint.CONFIG_DEL, DELETE_OP, DELETE)
     ;
     private final EndPoint endPoint;
-    private final ConfigSetsHandler.ConfigSetOperation op;
+    private final ConfigSetOperation op;
     private final SolrRequest.METHOD method;
     private final String cmdName;
 
-    Cmd(EndPoint endPoint, ConfigSetsHandler.ConfigSetOperation op, SolrRequest.METHOD method) {
+    Cmd(EndPoint endPoint, ConfigSetOperation op, SolrRequest.METHOD method) {
       this(endPoint, op, method, null);
     }
 
-    Cmd(EndPoint endPoint, ConfigSetsHandler.ConfigSetOperation op, SolrRequest.METHOD method, String cmdName) {
+    Cmd(EndPoint endPoint, ConfigSetOperation op, SolrRequest.METHOD method, String cmdName) {
       this.cmdName = cmdName;
       this.endPoint = endPoint;
       this.op = op;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ea739f73/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandlerApi.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandlerApi.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandlerApi.java
index 9173ad2..a8fb159 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandlerApi.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandlerApi.java
@@ -44,14 +44,14 @@ public class CoreAdminHandlerApi extends BaseHandlerApiSupport {
     this.handler = handler;
   }
 
-  enum Cmd implements ApiCommand<CoreAdminHandlerApi> {
+  enum Cmd implements ApiCommand {
     CREATE(CORES_COMMANDS, POST, CREATE_OP, null, ImmutableMap.of("config", "configSet")),
     UNLOAD(PER_CORE_COMMANDS, POST, UNLOAD_OP, null, null),
     RELOAD(PER_CORE_COMMANDS, POST, RELOAD_OP, null, null),
     STATUS(CORES_STATUS, GET, STATUS_OP),
     SWAP(PER_CORE_COMMANDS, POST, SWAP_OP, null, ImmutableMap.of("other", "with")),
     RENAME(PER_CORE_COMMANDS, POST, RENAME_OP, null, null),
-    MERGEINDEXES(PER_CORE_COMMANDS, POST, MERGEINDEXES_OP, null, null),
+    MERGEINDEXES(PER_CORE_COMMANDS, POST, MERGEINDEXES_OP, "merge-indexes", null),
     SPLIT(PER_CORE_COMMANDS, POST, SPLIT_OP, null, ImmutableMap.of("split.key", "splitKey")),
     PREPRECOVERY(PER_CORE_COMMANDS, POST, PREPRECOVERY_OP, null, null),
     REQUESTRECOVERY(PER_CORE_COMMANDS, POST, REQUESTRECOVERY_OP, null, null),

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ea739f73/solr/core/src/resources/apispec/cluster.Commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cluster.Commands.json b/solr/core/src/resources/apispec/cluster.Commands.json
index 7e72d40..41419e0 100644
--- a/solr/core/src/resources/apispec/cluster.Commands.json
+++ b/solr/core/src/resources/apispec/cluster.Commands.json
@@ -25,7 +25,11 @@
           "description": "The name of the node. It is possible to assign a role even before that node is started"
 
         }
-      }
+      },
+      "required": [
+        "role",
+        "node"
+      ]
     },
     "remove-role":{
       "type":"object",
@@ -41,8 +45,30 @@
           "type": "string",
           "description": "The name of the node. It is possible to assign a role even before that node is started"
         }
-      }
+      },
+      "required": [
+        "role",
+        "node"
+      ]
+    },
+    "set-property": {
+      "type": "object",
+      "documentation": "https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-api11",
+      "description": "Add, edit or delete a cluster-wide property.",
+      "properties": {
+        "name": {
+          "type": "string",
+          "description": "The name of the property"
+        },
+        "val": {
+          "type": "string",
+          "description": "The value of the property. If the value is empty or null, the property is unset."
+        }
+      },
+      "required": [
+        "name",
+        "val"
+      ]
     }
-
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ea739f73/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 17ff34a..46660d2 100644
--- a/solr/core/src/resources/apispec/collections.Commands.json
+++ b/solr/core/src/resources/apispec/collections.Commands.json
@@ -101,6 +101,59 @@
         "type": "string"
       },
       "description":""
+    },
+    
+    "backup-collection": {
+      "type": "object",
+      "properties": {
+        "collection": {
+          "type": "string",
+          "description": "Name of the collection"
+        },
+        "name": {
+          "type": "string",
+          "description": "Name of the backup"
+        },
+        "location": {
+          "type": "string",
+          "description": "The location on the shared drive for the backup command to write to. Alternately it can be set as a cluster property"
+        },
+        "async": {
+          "type": "string",
+          "description": "Request ID to track this action which will be processed asynchronously"
+        }
+      },
+      "required": [
+        "collection",
+        "name",
+        "location"
+      ]
+    },
+    "restore-collection": {
+      "type": "object",
+      "properties": {
+        "collection": {
+          "type": "string",
+          "description": "Name of the collection"
+        },
+        "name": {
+          "type": "string",
+          "description": "Name of the backup"
+        },
+        "location": {
+          "type": "string",
+          "description": "The location on the shared drive for the backup command to write to. Alternately it can be set as a cluster property"
+        },
+        "async": {
+          "type": "string",
+          "description": "Request ID to track this action which will be processed asynchronously"
+        }
+      },
+      "required": [
+        "collection",
+        "name",
+        "location"
+      ]
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ea739f73/solr/core/src/resources/apispec/collections.collection.Commands.reload.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/collections.collection.Commands.reload.json b/solr/core/src/resources/apispec/collections.collection.Commands.reload.json
index 2db0948..6547e1d 100644
--- a/solr/core/src/resources/apispec/collections.collection.Commands.reload.json
+++ b/solr/core/src/resources/apispec/collections.collection.Commands.reload.json
@@ -4,6 +4,7 @@
   "properties":{
     "async" : {
       "type" : "string"
+
     }
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ea739f73/solr/core/src/resources/apispec/collections.collection.shards.Commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/collections.collection.shards.Commands.json b/solr/core/src/resources/apispec/collections.collection.shards.Commands.json
index 0639ab0..22c9ad7 100644
--- a/solr/core/src/resources/apispec/collections.collection.shards.Commands.json
+++ b/solr/core/src/resources/apispec/collections.collection.shards.Commands.json
@@ -29,6 +29,10 @@
         "coreProperties":{
           "type":"object",
           "additionalProperties":true
+        },
+        "async": {
+          "type": "string",
+          "description": "Request ID to track this action which will be processed asynchronously"
         }
       }
     },
@@ -46,6 +50,10 @@
         "coreProperties": {
           "type": "object",
           "additionalProperties": true
+        },
+        "async": {
+          "type": "string",
+          "description": "Request ID to track this action which will be processed asynchronously"
         }
       }
     },
@@ -76,6 +84,10 @@
         "coreProperties": {
           "type": "object",
           "additionalProperties": true
+        },
+        "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/ea739f73/solr/core/src/resources/apispec/cores.core.Commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cores.core.Commands.json b/solr/core/src/resources/apispec/cores.core.Commands.json
index f1be59ad..65cac8b 100644
--- a/solr/core/src/resources/apispec/cores.core.Commands.json
+++ b/solr/core/src/resources/apispec/cores.core.Commands.json
@@ -57,7 +57,26 @@
 
     "merge-indexes": {
       "type":"object",
-      "additionalProperties":true
+      "properties": {
+        "indexDir": {
+          "type": "array",
+          "items": {
+            "type": "string"
+          },
+          "description": "Multi-valued, directories that would be merged"
+        },
+        "srcCore": {
+          "type": "array",
+          "items": {
+            "type": "string"
+          },
+          "description": "Multi-valued, source cores that would be merged."
+        }
+      },
+      "async": {
+        "type": "string",
+        "description": "Request ID to track this action which will be processed asynchronously"
+      }
     },
     "request-recovery": {
       "type":"object",
@@ -67,6 +86,10 @@
       "type": "object",
       "additionalProperties": true
     },
-    "split": "cores.core.Commands.split"
+    "split": "cores.core.Commands.split",
+    "preprecovery": {
+      "type": "object",
+      "additionalProperties": true
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ea739f73/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 de6f01f..8d0dd41 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
@@ -146,7 +146,8 @@ public class TestCollectionAPIs extends SolrTestCaseJ4 {
 
   }
 
-  public static Pair<SolrQueryRequest, SolrQueryResponse> makeCall(final ApiBag apiBag, String path, final SolrRequest.METHOD method,
+  public static Pair<SolrQueryRequest, SolrQueryResponse> makeCall(final ApiBag apiBag, String path,
+                                                                   final SolrRequest.METHOD method,
                                     final String payload, final CoreContainer cc) throws Exception {
     SolrParams queryParams = new MultiMapSolrParams(Collections.EMPTY_MAP);
     if (path.indexOf('?') > 0) {