SOLR-7485: Replace shards.info occurrences with ShardParams.SHARDS_INFO

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1688025 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ramkumar Aiyengar 2015-06-28 17:18:04 +00:00
parent 9281fd9378
commit b9854071cf
4 changed files with 61 additions and 7 deletions

View File

@ -141,7 +141,7 @@ public class TestTolerantSearch extends SolrJettyTestBase {
query.set(ShardParams.SHARDS_TOLERANT, "true");
QueryResponse response = collection1.query(query);
assertTrue(response.getResponseHeader().getBooleanArg("partialResults"));
NamedList<Object> shardsInfo = ((NamedList<Object>)response.getResponse().get("shards.info"));
NamedList<Object> shardsInfo = ((NamedList<Object>)response.getResponse().get(ShardParams.SHARDS_INFO));
boolean foundError = false;
for (int i = 0; i < shardsInfo.size(); i++) {
if (shardsInfo.getName(i).contains("collection2")) {
@ -189,7 +189,7 @@ public class TestTolerantSearch extends SolrJettyTestBase {
query.set(ShardParams.SHARDS_TOLERANT, "true");
QueryResponse response = collection1.query(query);
assertTrue(response.getResponseHeader().getBooleanArg("partialResults"));
NamedList<Object> shardsInfo = ((NamedList<Object>)response.getResponse().get("shards.info"));
NamedList<Object> shardsInfo = ((NamedList<Object>)response.getResponse().get(ShardParams.SHARDS_INFO));
boolean foundError = false;
for (int i = 0; i < shardsInfo.size(); i++) {
if (shardsInfo.getName(i).contains("collection2")) {

View File

@ -19,6 +19,10 @@ package org.apache.solr.common.params;
/**
* Parameters used for distributed search.
*
* When adding a new parameter here, please also add the corresponding
* one-line test case in the ShardParamsTest class.
*
*/
public interface ShardParams {
/** the shards to use (distributed configuration) */

View File

@ -423,7 +423,7 @@ public class CloudSolrClientTest extends AbstractFullDistribZkTestBase {
ModifiableSolrParams qParams = new ModifiableSolrParams();
qParams.add("preferLocalShards", Boolean.toString(preferLocalShards));
qParams.add("shards.info", "true");
qParams.add(ShardParams.SHARDS_INFO, "true");
qRequest.add(qParams);
// CloudSolrClient sends the request to some node.
@ -432,8 +432,8 @@ public class CloudSolrClientTest extends AbstractFullDistribZkTestBase {
// local shards only
QueryResponse qResponse = cloudClient.query (qRequest);
Object shardsInfo = qResponse.getResponse().get("shards.info");
assertNotNull("Unable to obtain shards.info", shardsInfo);
Object shardsInfo = qResponse.getResponse().get(ShardParams.SHARDS_INFO);
assertNotNull("Unable to obtain "+ShardParams.SHARDS_INFO, shardsInfo);
// Iterate over shards-info and check what cores responded
SimpleOrderedMap<?> shardsInfoMap = (SimpleOrderedMap<?>)shardsInfo;
@ -441,9 +441,9 @@ public class CloudSolrClientTest extends AbstractFullDistribZkTestBase {
List<String> shardAddresses = new ArrayList<String>();
while (itr.hasNext()) {
Map.Entry<String, ?> e = itr.next();
assertTrue("Did not find map-type value in shards.info", e.getValue() instanceof Map);
assertTrue("Did not find map-type value in "+ShardParams.SHARDS_INFO, e.getValue() instanceof Map);
String shardAddress = (String)((Map)e.getValue()).get("shardAddress");
assertNotNull("shards.info did not return 'shardAddress' parameter", shardAddress);
assertNotNull(ShardParams.SHARDS_INFO+" did not return 'shardAddress' parameter", shardAddress);
shardAddresses.add(shardAddress);
}
log.info("Shards giving the response: " + Arrays.toString(shardAddresses.toArray()));

View File

@ -0,0 +1,50 @@
package org.apache.solr.common.params;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.lucene.util.LuceneTestCase;
/**
* This class tests backwards compatibility of {@link ShardParams} parameter constants.
* If someone accidentally changes those constants then this test will flag that up.
*/
public class ShardParamsTest extends LuceneTestCase
{
public void testShards() { assertEquals(ShardParams.SHARDS, "shards"); }
public void testShardsRows() { assertEquals(ShardParams.SHARDS_ROWS, "shards.rows"); }
public void testShardsStart() { assertEquals(ShardParams.SHARDS_START, "shards.start"); }
public void testIds() { assertEquals(ShardParams.IDS, "ids"); }
public void testIsShard() { assertEquals(ShardParams.IS_SHARD, "isShard"); }
public void testShardUrl() { assertEquals(ShardParams.SHARD_URL, "shard.url"); }
public void testShardsQt() { assertEquals(ShardParams.SHARDS_QT, "shards.qt"); }
public void testShardsInfo() { assertEquals(ShardParams.SHARDS_INFO, "shards.info"); }
public void testShardsTolerant() { assertEquals(ShardParams.SHARDS_TOLERANT, "shards.tolerant"); }
public void testShardsPurpose() { assertEquals(ShardParams.SHARDS_PURPOSE, "shards.purpose"); }
public void testRoute() { assertEquals(ShardParams._ROUTE_, "_route_"); }
public void testDistribSinglePass() { assertEquals(ShardParams.DISTRIB_SINGLE_PASS, "distrib.singlePass"); }
}