SOLR-7710: Replace async occurrences with CommonAdminParams.ASYNC

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1688039 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ramkumar Aiyengar 2015-06-28 18:53:45 +00:00
parent 385a1283fe
commit 8c964253b5
12 changed files with 89 additions and 26 deletions

View File

@ -257,6 +257,9 @@ Other Changes
* SOLR-7485: Replace shards.info occurrences with ShardParams.SHARDS_INFO
(Christine Poerschke via Ramkumar Aiyengar)
* SOLR-7710: Replace async occurrences with CommonAdminParams.ASYNC
(Christine Poerschke, Ramkumar Aiyengar)
================== 5.2.1 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

View File

@ -114,7 +114,7 @@ public class DistributedQueue {
/**
* Returns true if the queue contains a task with the specified async id.
*/
public boolean containsTaskWithRequestId(String requestId)
public boolean containsTaskWithRequestId(String requestIdKey, String requestId)
throws KeeperException, InterruptedException {
List<String> childNames = zookeeper.getChildren(dir, null, true);
@ -125,9 +125,9 @@ public class DistributedQueue {
byte[] data = zookeeper.getData(dir + "/" + childName, null, null, true);
if (data != null) {
ZkNodeProps message = ZkNodeProps.load(data);
if (message.containsKey(OverseerCollectionProcessor.ASYNC)) {
LOG.debug(">>>> {}", message.get(OverseerCollectionProcessor.ASYNC));
if(message.get(OverseerCollectionProcessor.ASYNC).equals(requestId)) return true;
if (message.containsKey(requestIdKey)) {
LOG.debug(">>>> {}", message.get(requestIdKey));
if(message.get(requestIdKey).equals(requestId)) return true;
}
}
} catch (KeeperException.NoNodeException e) {

View File

@ -121,6 +121,7 @@ import static org.apache.solr.common.params.CollectionParams.CollectionAction.DE
import static org.apache.solr.common.params.CollectionParams.CollectionAction.DELETEREPLICAPROP;
import static org.apache.solr.common.params.CollectionParams.CollectionAction.DELETESHARD;
import static org.apache.solr.common.params.CollectionParams.CollectionAction.REMOVEROLE;
import static org.apache.solr.common.params.CommonAdminParams.ASYNC;
import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.common.util.StrUtils.formatString;
@ -137,8 +138,6 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
public static final String SHARDS_PROP = "shards";
public static final String ASYNC = "async";
public static final String REQUESTID = "requestid";
public static final String COLL_CONF = "collection.configName";
@ -327,7 +326,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
final ZkNodeProps message = ZkNodeProps.load(head.getBytes());
String collectionName = message.containsKey(COLLECTION_PROP) ?
message.getStr(COLLECTION_PROP) : message.getStr(NAME);
String asyncId = message.getStr(ASYNC);
final String asyncId = message.getStr(ASYNC);
if (hasLeftOverItems) {
if (head.getId().equals(oldestItemInWorkQueue))
hasLeftOverItems = false;
@ -1494,7 +1493,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
// the only side effect of this is that the sub shard may end up having more replicas than we want
collectShardResponses(results, false, null, shardHandler);
String asyncId = message.getStr(ASYNC);
final String asyncId = message.getStr(ASYNC);
HashMap<String,String> requestMap = new HashMap<String,String>();
for (int i = 0; i < subRanges.size(); i++) {
@ -2260,8 +2259,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
int repFactor = message.getInt(REPLICATION_FACTOR, 1);
ShardHandler shardHandler = shardHandlerFactory.getShardHandler();
String async = null;
async = message.getStr("async");
final String async = message.getStr(ASYNC);
Integer numSlices = message.getInt(NUM_SLICES, null);
String router = message.getStr("router.name", DocRouter.DEFAULT_NAME);
@ -2490,7 +2488,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
String shard = message.getStr(SHARD_ID_PROP);
String coreName = message.getStr(CoreAdminParams.NAME);
String asyncId = message.getStr("async");
final String asyncId = message.getStr(ASYNC);
DocCollection coll = clusterState.getCollection(collection);
if (coll == null) {
@ -2845,7 +2843,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
final TimerContext timerContext = stats.time("collection_" + operation);
boolean success = false;
String asyncId = message.getStr(ASYNC);
final String asyncId = message.getStr(ASYNC);
String collectionName = message.containsKey(COLLECTION_PROP) ?
message.getStr(COLLECTION_PROP) : message.getStr(NAME);

View File

@ -70,7 +70,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.solr.cloud.Overseer.QUEUE_OPERATION;
import static org.apache.solr.cloud.OverseerCollectionProcessor.ASYNC;
import static org.apache.solr.cloud.OverseerCollectionProcessor.COLL_CONF;
import static org.apache.solr.cloud.OverseerCollectionProcessor.COLL_PROP_PREFIX;
import static org.apache.solr.cloud.OverseerCollectionProcessor.CREATE_NODE_SET;
@ -94,6 +93,7 @@ import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
import static org.apache.solr.common.cloud.ZkStateReader.REPLICA_PROP;
import static org.apache.solr.common.cloud.ZkStateReader.SHARD_ID_PROP;
import static org.apache.solr.common.params.CollectionParams.CollectionAction.*;
import static org.apache.solr.common.params.CommonAdminParams.ASYNC;
import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.common.params.CommonParams.VALUE_LONG;
import static org.apache.solr.common.params.CoreAdminParams.DATA_DIR;
@ -252,7 +252,7 @@ public class CollectionsHandler extends RequestHandlerBase {
private boolean overseerCollectionQueueContains(String asyncId) throws KeeperException, InterruptedException {
DistributedQueue collectionQueue = coreContainer.getZkController().getOverseerCollectionQueue();
return collectionQueue.containsTaskWithRequestId(asyncId);
return collectionQueue.containsTaskWithRequestId(ASYNC, asyncId);
}
private static Map<String, Object> copyPropertiesWithPrefix(SolrParams params, Map<String, Object> props, String prefix) {

View File

@ -54,6 +54,7 @@ import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CommonAdminParams;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction;
import org.apache.solr.common.params.ModifiableSolrParams;
@ -165,7 +166,7 @@ public class CoreAdminHandler extends RequestHandlerBase {
"Core container instance missing");
}
//boolean doPersist = false;
String taskId = req.getParams().get("async");
final String taskId = req.getParams().get(CommonAdminParams.ASYNC);
TaskObject taskObject = new TaskObject(taskId);
if(taskId != null) {

View File

@ -41,7 +41,6 @@ import org.apache.solr.response.SolrQueryResponse;
import org.apache.zookeeper.KeeperException;
import static org.apache.solr.cloud.Overseer.QUEUE_OPERATION;
import static org.apache.solr.cloud.OverseerCollectionProcessor.ASYNC;
import static org.apache.solr.common.cloud.ZkStateReader.COLLECTION_PROP;
import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
import static org.apache.solr.common.cloud.ZkStateReader.ELECTION_NODE_PROP;
@ -52,6 +51,7 @@ import static org.apache.solr.common.cloud.ZkStateReader.NODE_NAME_PROP;
import static org.apache.solr.common.cloud.ZkStateReader.REJOIN_AT_HEAD_PROP;
import static org.apache.solr.common.cloud.ZkStateReader.SHARD_ID_PROP;
import static org.apache.solr.common.params.CollectionParams.CollectionAction.REBALANCELEADERS;
import static org.apache.solr.common.params.CommonAdminParams.ASYNC;
class RebalanceLeaders {
final SolrQueryRequest req;

View File

@ -22,6 +22,7 @@ import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.CommonAdminParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.junit.Test;
@ -68,7 +69,7 @@ public class AsyncMigrateRouteKeyTest extends MigrateRouteKeyTest {
params.set("target.collection", targetCollection);
params.set("split.key", splitKey);
params.set("forward.timeout", 45);
params.set("async", asyncId);
params.set(CommonAdminParams.ASYNC, asyncId);
invoke(params);

View File

@ -22,6 +22,7 @@ import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.CommonAdminParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.junit.Test;
@ -46,7 +47,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
params.set("replicationFactor", 1);
params.set("maxShardsPerNode", 100);
params.set("collection.configName", "conf1");
params.set("async", "1000");
params.set(CommonAdminParams.ASYNC, "1000");
try {
sendRequest(params);
} catch (SolrServerException | IOException e) {
@ -90,7 +91,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
params.set(CollectionParams.ACTION, CollectionParams.CollectionAction.SPLITSHARD.toString());
params.set("collection", "collection2");
params.set("shard", "shard1");
params.set("async", "1001");
params.set(CommonAdminParams.ASYNC, "1001");
try {
sendRequest(params);
} catch (SolrServerException | IOException e) {
@ -116,7 +117,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
params.set("replicationFactor", 1);
params.set("maxShardsPerNode", 100);
params.set("collection.configName", "conf1");
params.set("async", "1002");
params.set(CommonAdminParams.ASYNC, "1002");
try {
sendRequest(params);
} catch (SolrServerException | IOException e) {
@ -145,7 +146,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
params.set("replicationFactor", 1);
params.set("maxShardsPerNode", 100);
params.set("collection.configName", "conf1");
params.set("async", "1002");
params.set(CommonAdminParams.ASYNC, "1002");
try {
r = sendRequest(params);
} catch (SolrServerException | IOException e) {

View File

@ -21,6 +21,7 @@ import java.io.File;
import org.apache.commons.io.FileUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.CommonAdminParams;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
@ -62,7 +63,7 @@ public class CoreAdminRequestStatusTest extends SolrTestCaseJ4{
CoreAdminParams.CoreAdminAction.CREATE.toString(),
CoreAdminParams.INSTANCE_DIR, instPropFile.getAbsolutePath(),
CoreAdminParams.NAME, "dummycore",
"async", "42"),
CommonAdminParams.ASYNC, "42"),
resp);
assertNull("Exception on create", resp.getException());

View File

@ -24,6 +24,7 @@ import org.apache.solr.common.SolrException;
import org.apache.solr.common.cloud.DocCollection;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionParams.CollectionAction;
import org.apache.solr.common.params.CommonAdminParams;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams;
@ -266,7 +267,7 @@ public abstract class CollectionAdminRequest <Q extends CollectionAdminRequest<Q
if (replicationFactor != null) {
params.set( "replicationFactor", replicationFactor);
}
params.set("async", asyncId);
params.set(CommonAdminParams.ASYNC, asyncId);
if (autoAddReplicas != null) {
params.set(ZkStateReader.AUTO_ADD_REPLICAS, autoAddReplicas);
}
@ -412,7 +413,7 @@ public abstract class CollectionAdminRequest <Q extends CollectionAdminRequest<Q
addProperties(params, properties);
}
params.set("async", asyncId);
params.set(CommonAdminParams.ASYNC, asyncId);
return params;
}
@ -609,7 +610,7 @@ public abstract class CollectionAdminRequest <Q extends CollectionAdminRequest<Q
params.add(ShardParams._ROUTE_, routeKey);
}
if (asyncId != null) {
params.set("async", asyncId);
params.set(CommonAdminParams.ASYNC, asyncId);
}
if (node != null) {
params.add("node", node);
@ -794,7 +795,7 @@ public abstract class CollectionAdminRequest <Q extends CollectionAdminRequest<Q
if (forwardTimeout != null) {
params.set("forward.timeout", forwardTimeout);
}
params.set("async", asyncId);
params.set(CommonAdminParams.ASYNC, asyncId);
if (properties != null) {
addProperties(params, properties);

View File

@ -0,0 +1,26 @@
/*
* 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.
*/
package org.apache.solr.common.params;
public interface CommonAdminParams
{
/** async or not? **/
public static final String ASYNC = "async";
}

View File

@ -0,0 +1,31 @@
/*
* 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.
*/
package org.apache.solr.common.params;
import org.apache.lucene.util.LuceneTestCase;
/**
* Unit test for {@link CommonAdminParams CommonAdminParams}
*
* This class tests backwards compatibility of CommonAdminParams parameter constants.
* If someone accidentally changes those constants then this test will flag that up.
*/
public class CommonAdminParamsTest extends LuceneTestCase
{
public void testAsync() { assertEquals(CommonAdminParams.ASYNC, "async"); }
}