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/20 09:17:46 UTC
lucene-solr:apiv2: SOLR-8029: more cleanup of specs
Repository: lucene-solr
Updated Branches:
refs/heads/apiv2 db0483215 -> e0a09f537
SOLR-8029: more cleanup of specs
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/e0a09f53
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e0a09f53
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e0a09f53
Branch: refs/heads/apiv2
Commit: e0a09f5370ae770f7aeca474970969f70e30b9c8
Parents: db04832
Author: Noble Paul <no...@apache.org>
Authored: Tue Sep 20 14:47:31 2016 +0530
Committer: Noble Paul <no...@apache.org>
Committed: Tue Sep 20 14:47:31 2016 +0530
----------------------------------------------------------------------
solr/core/src/java/org/apache/solr/api/ApiBag.java | 2 +-
solr/core/src/java/org/apache/solr/cloud/Assign.java | 10 ++++++++--
.../java/org/apache/solr/cloud/CreateShardCmd.java | 2 +-
.../org/apache/solr/handler/admin/ApiCommand.java | 1 +
.../solr/handler/admin/CollectionHandlerApi.java | 15 ++++++++++++---
.../solr/handler/admin/CollectionsHandler.java | 3 ++-
.../org/apache/solr/util/JsonSchemaValidator.java | 4 +---
.../src/resources/apispec/collections.Commands.json | 9 ++++++---
.../collections.collection.shards.Commands.json | 13 ++++++++-----
...collections.collection.shards.shard.Commands.json | 6 ++++--
solr/core/src/resources/apispec/core.SchemaRead.json | 2 --
.../apispec/core.config.Params.Commands.json | 2 +-
solr/core/src/resources/apispec/cores.Commands.json | 4 ++--
.../test/org/apache/solr/util/JsonValidatorTest.java | 2 +-
14 files changed, 48 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0a09f53/solr/core/src/java/org/apache/solr/api/ApiBag.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/api/ApiBag.java b/solr/core/src/java/org/apache/solr/api/ApiBag.java
index 44449a0..0660f43 100644
--- a/solr/core/src/java/org/apache/solr/api/ApiBag.java
+++ b/solr/core/src/java/org/apache/solr/api/ApiBag.java
@@ -166,7 +166,7 @@ public class ApiBag {
try {
validators.put((String) cmd.getKey(), new JsonSchemaValidator((Map) cmd.getValue()));
} catch (Exception e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error in spi spec" , e);
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error in api spec" , e);
}
}
return validators;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0a09f53/solr/core/src/java/org/apache/solr/cloud/Assign.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/Assign.java b/solr/core/src/java/org/apache/solr/cloud/Assign.java
index e6e08f9..ba03ccd 100644
--- a/solr/core/src/java/org/apache/solr/cloud/Assign.java
+++ b/solr/core/src/java/org/apache/solr/cloud/Assign.java
@@ -146,10 +146,16 @@ public class Assign {
// could be created on live nodes given maxShardsPerNode, Replication factor (if from createShard) etc.
public static List<ReplicaCount> getNodesForNewReplicas(ClusterState clusterState, String collectionName,
String shard, int numberOfNodes,
- String createNodeSetStr, CoreContainer cc) {
+ Object createNodeSet, CoreContainer cc) {
DocCollection coll = clusterState.getCollection(collectionName);
Integer maxShardsPerNode = coll.getInt(MAX_SHARDS_PER_NODE, 1);
- List<String> createNodeList = createNodeSetStr == null ? null: StrUtils.splitSmart(createNodeSetStr, ",", true);
+ List<String> createNodeList = null;
+
+ if (createNodeSet instanceof List) {
+ createNodeList = (List) createNodeSet;
+ } else {
+ createNodeList = createNodeSet == null ? null : StrUtils.splitSmart((String) createNodeSet, ",", true);
+ }
HashMap<String, ReplicaCount> nodeNameVsShardCount = getNodeNameVsShardCount(collectionName, clusterState, createNodeList);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0a09f53/solr/core/src/java/org/apache/solr/cloud/CreateShardCmd.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/CreateShardCmd.java b/solr/core/src/java/org/apache/solr/cloud/CreateShardCmd.java
index 3d5aa41..52df32b 100644
--- a/solr/core/src/java/org/apache/solr/cloud/CreateShardCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/CreateShardCmd.java
@@ -68,7 +68,7 @@ public class CreateShardCmd implements Cmd {
ShardHandler shardHandler = ocmh.shardHandlerFactory.getShardHandler();
DocCollection collection = clusterState.getCollection(collectionName);
int repFactor = message.getInt(REPLICATION_FACTOR, collection.getInt(REPLICATION_FACTOR, 1));
- String createNodeSetStr = message.getStr(OverseerCollectionMessageHandler.CREATE_NODE_SET);
+ Object createNodeSetStr = message.get(OverseerCollectionMessageHandler.CREATE_NODE_SET);
List<Assign.ReplicaCount> sortedNodeList = getNodesForNewReplicas(clusterState, collectionName, sliceName, repFactor,
createNodeSetStr, ocmh.overseer.getZkController().getCoreContainer());
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0a09f53/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 5a85c14..effd284 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
@@ -37,6 +37,7 @@ public interface ApiCommand {
}
+
default String getParamSubstitute(String name) {
return name;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0a09f53/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 9d3bcd0..ae5938b 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
@@ -36,6 +36,7 @@ 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.cloud.OverseerCollectionMessageHandler.CREATE_NODE_SET;
import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.handler.admin.CollectionsHandler.CollectionOperation.*;
@@ -70,7 +71,8 @@ public class CollectionHandlerApi extends BaseHandlerApiSupport {
CREATE_OP.action.toLower(),
ImmutableMap.of(
COLL_CONF, "config",
- "createNodeSet.shuffle","shuffleNodes"
+ "createNodeSet.shuffle", "shuffleNodes",
+ "createNodeSet", "nodeSet"
),
ImmutableMap.of("properties.", "property.")),
@@ -117,8 +119,13 @@ public class CollectionHandlerApi extends BaseHandlerApiSupport {
POST,
CREATESHARD_OP,
"create",
- null,
- ImmutableMap.of("coreProperties.", "property.")),
+ ImmutableMap.of(CREATE_NODE_SET, "nodeSet"),
+ ImmutableMap.of("coreProperties.", "property.")) {
+ @Override
+ public String getParamSubstitute(String param) {
+ return super.getParamSubstitute(param);
+ }
+ },
SPLIT_SHARD(EndPoint.PER_COLLECTION_SHARDS_COMMANDS,
POST,
@@ -188,6 +195,8 @@ public class CollectionHandlerApi extends BaseHandlerApiSupport {
rsp.add("nodes", ((CollectionHandlerApi) apiHandler).handler.coreContainer.getZkController().getClusterState().getLiveNodes());
}
},
+ FORCELEADER(EndPoint.PER_COLLECTION_PER_SHARD_COMMANDS,POST, FORCELEADER_OP,"force-leader",null),
+ SYNCSHARD(EndPoint.PER_COLLECTION_PER_SHARD_COMMANDS,POST, SYNCSHARD_OP, "sync-shard",null),
BALANCESHARDUNIQUE(EndPoint.PER_COLLECTION, POST, BALANCESHARDUNIQUE_OP, "balanceshardunique",null)
;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0a09f53/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
index 9cee179..dac56fb 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
@@ -389,7 +389,8 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission
COLL_CONF,
NUM_SLICES,
MAX_SHARDS_PER_NODE,
- CREATE_NODE_SET, CREATE_NODE_SET_SHUFFLE,
+ CREATE_NODE_SET,
+ CREATE_NODE_SET_SHUFFLE,
SHARDS_PROP,
STATE_FORMAT,
AUTO_ADD_REPLICAS,
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0a09f53/solr/core/src/java/org/apache/solr/util/JsonSchemaValidator.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/JsonSchemaValidator.java b/solr/core/src/java/org/apache/solr/util/JsonSchemaValidator.java
index 62d3247..65875d5 100644
--- a/solr/core/src/java/org/apache/solr/util/JsonSchemaValidator.java
+++ b/solr/core/src/java/org/apache/solr/util/JsonSchemaValidator.java
@@ -151,9 +151,7 @@ public class JsonSchemaValidator {
Object val = attrSchema.get(key);
if (val == null) {
Object additional = attrSchema.get(additionalProperties.key);
- if (!Boolean.TRUE.equals(additional)) {
- errors.add("'properties' tag is missing, additionalProperties=true is expected" + Utils.toJSONString(attrSchema));
- }
+ if (Boolean.TRUE.equals(additional)) schemaNode.additionalProperties = Boolean.TRUE;
}
}
},
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0a09f53/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 cd2ed59..ba16076 100644
--- a/solr/core/src/resources/apispec/collections.Commands.json
+++ b/solr/core/src/resources/apispec/collections.Commands.json
@@ -49,9 +49,12 @@
"type": "number",
"description": "The number of replicas to be created for each shard."
},
- "createNodeSet": {
- "type": "string",
- "description": " comma-separated list of node_names, such as localhost:8983_solr, localhost:8984_solr, localhost:8985_solr. "
+ "nodeSet": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "list of node_names"
},
"shuffleNodes": {
"type": "boolean",
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0a09f53/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 22c9ad7..67f2383 100644
--- a/solr/core/src/resources/apispec/collections.collection.shards.Commands.json
+++ b/solr/core/src/resources/apispec/collections.collection.shards.Commands.json
@@ -1,5 +1,5 @@
{
- "documentation": "https://cwiki.apache.org",
+ "documentation": "https://cwiki.apache.org/confluence/display/solr/Collections+API",
"methods": [
"POST"
],
@@ -39,9 +39,12 @@
"create": {
"type":"object",
"properties": {
- "createNodeSet": {
- "description": "Allows defining the nodes to spread the new collection across",
- "type": "string"
+ "nodeSet": {
+ "description": "list of node names",
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
},
"shard": {
"description": "The name of the shard to be created",
@@ -63,7 +66,7 @@
"properties": {
"shard": {
"type": "string",
- "description": "The name of the shard where "
+ "description": "The name of the shard in which this replica should be created"
},
"_route_": {
"type": "string",
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0a09f53/solr/core/src/resources/apispec/collections.collection.shards.shard.Commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/collections.collection.shards.shard.Commands.json b/solr/core/src/resources/apispec/collections.collection.shards.shard.Commands.json
index b29298c..18de4b8 100644
--- a/solr/core/src/resources/apispec/collections.collection.shards.shard.Commands.json
+++ b/solr/core/src/resources/apispec/collections.collection.shards.shard.Commands.json
@@ -14,8 +14,10 @@
"force-leader": {
"description": "In the unlikely event of a shard losing its leader, this command can be invoked to force the election of a new leader",
"documentation": "https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-ForceLeader",
- "type": "object",
- "additionalProperties": true
+ "type": "object"
+ },
+ "synch-shard": {
+ "type": "object"
}
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0a09f53/solr/core/src/resources/apispec/core.SchemaRead.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/core.SchemaRead.json b/solr/core/src/resources/apispec/core.SchemaRead.json
index b81a818..237a9f2 100644
--- a/solr/core/src/resources/apispec/core.SchemaRead.json
+++ b/solr/core/src/resources/apispec/core.SchemaRead.json
@@ -12,12 +12,10 @@
"/schema/similarity",
"/schema/solrqueryparser",
"/schema/zkversion",
- "/schema/zkversion",
"/schema/solrqueryparser/defaultoperator",
"/schema/name",
"/schema/version",
"/schema/uniquekey",
- "/schema/similarity",
"/schema/similarity"
]
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0a09f53/solr/core/src/resources/apispec/core.config.Params.Commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/core.config.Params.Commands.json b/solr/core/src/resources/apispec/core.config.Params.Commands.json
index 0c1196e..fd968b1 100644
--- a/solr/core/src/resources/apispec/core.config.Params.Commands.json
+++ b/solr/core/src/resources/apispec/core.config.Params.Commands.json
@@ -23,7 +23,7 @@
},
"update": {
"type":"object",
- "description": "update one or more configsets",
+ "description": "update one or more param sets",
"additionalProperties": true
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0a09f53/solr/core/src/resources/apispec/cores.Commands.json
----------------------------------------------------------------------
diff --git a/solr/core/src/resources/apispec/cores.Commands.json b/solr/core/src/resources/apispec/cores.Commands.json
index 6a2d469..1bda490 100644
--- a/solr/core/src/resources/apispec/cores.Commands.json
+++ b/solr/core/src/resources/apispec/cores.Commands.json
@@ -22,11 +22,11 @@
},
"schema": {
"type": "string",
- "description": "The core name"
+ "description": "Name of the schema file to use for the core. Please note that if you are using a 'managed schema' (the default behavior) then any value for this property which does not match the effective managedSchemaResourceName will be read once, backed up, and converted for managed schema use"
},
"dataDir": {
"type": "string",
- "description": "The core name"
+ "description": "Name of the data directory relative to instanceDir"
},
"config": {
"type": "string",
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e0a09f53/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java b/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java
index 84d89f6..38210b7 100644
--- a/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java
+++ b/solr/core/src/test/org/apache/solr/util/JsonValidatorTest.java
@@ -115,7 +115,7 @@ public class JsonValidatorTest extends SolrTestCaseJ4 {
" name: {type: string}}}");
fail("should have failed");
} catch (Exception e) {
- assertTrue(e.getMessage().contains("'properties' tag is missing"));
+ assertTrue(e.getMessage().contains("Unknown key : propertes"));
}
validator = new JsonSchemaValidator("{" +