mirror of https://github.com/apache/lucene.git
SOLR-6615: Refactor code to use String constants
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1670813 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b9a883625b
commit
9baabd177c
|
@ -17,6 +17,12 @@
|
|||
|
||||
package org.apache.solr.client.solrj.embedded;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
|
@ -42,11 +48,7 @@ import org.apache.solr.response.ResultContext;
|
|||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.servlet.SolrRequestParsers;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
import static org.apache.solr.common.params.CommonParams.PATH;
|
||||
|
||||
/**
|
||||
* SolrClient that connects directly to a CoreContainer.
|
||||
|
@ -170,7 +172,7 @@ public class EmbeddedSolrServer extends SolrClient {
|
|||
}
|
||||
|
||||
req = _parser.buildRequestFrom(core, params, request.getContentStreams());
|
||||
req.getContext().put("path", path);
|
||||
req.getContext().put(PATH, path);
|
||||
SolrQueryResponse rsp = new SolrQueryResponse();
|
||||
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));
|
||||
|
||||
|
|
|
@ -17,6 +17,22 @@ package org.apache.solr.cloud;
|
|||
* the License.
|
||||
*/
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.solr.client.solrj.SolrResponse;
|
||||
import org.apache.solr.cloud.overseer.ClusterStateMutator;
|
||||
|
@ -47,25 +63,10 @@ import org.apache.zookeeper.KeeperException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.apache.solr.cloud.OverseerCollectionProcessor.ONLY_ACTIVE_NODES;
|
||||
import static org.apache.solr.cloud.OverseerCollectionProcessor.SHARD_UNIQUE;
|
||||
import static org.apache.solr.common.params.CollectionParams.CollectionAction.BALANCESHARDUNIQUE;
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
* Cluster leader. Responsible for processing state updates, node assignments, creating/deleting
|
||||
|
@ -397,7 +398,7 @@ public class Overseer implements Closeable {
|
|||
}
|
||||
|
||||
private void handleProp(ZkNodeProps message) {
|
||||
String name = message.getStr("name");
|
||||
String name = message.getStr(NAME);
|
||||
String val = message.getStr("val");
|
||||
Map m = reader.getClusterProps();
|
||||
if(val ==null) m.remove(name);
|
||||
|
|
|
@ -17,8 +17,27 @@ package org.apache.solr.cloud;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.solr.client.solrj.SolrResponse;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
|
@ -44,7 +63,6 @@ import org.apache.solr.common.cloud.PlainIdRouter;
|
|||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.common.cloud.RoutingRule;
|
||||
import org.apache.solr.common.cloud.Slice;
|
||||
import org.apache.solr.common.cloud.Slice.State;
|
||||
import org.apache.solr.common.cloud.SolrZkClient;
|
||||
import org.apache.solr.common.cloud.ZkConfigManager;
|
||||
import org.apache.solr.common.cloud.ZkCoreNodeProps;
|
||||
|
@ -76,26 +94,6 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.apache.solr.cloud.Assign.getNodesForNewShard;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.BASE_URL_PROP;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.COLLECTION_PROP;
|
||||
|
@ -118,6 +116,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.CommonParams.NAME;
|
||||
|
||||
|
||||
public class OverseerCollectionProcessor implements Runnable, Closeable {
|
||||
|
@ -326,7 +325,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
for (QueueEvent head : heads) {
|
||||
final ZkNodeProps message = ZkNodeProps.load(head.getBytes());
|
||||
String collectionName = message.containsKey(COLLECTION_PROP) ?
|
||||
message.getStr(COLLECTION_PROP) : message.getStr("name");
|
||||
message.getStr(COLLECTION_PROP) : message.getStr(NAME);
|
||||
String asyncId = message.getStr(ASYNC);
|
||||
if (hasLeftOverItems) {
|
||||
if (head.getId().equals(oldestItemInWorkQueue))
|
||||
|
@ -381,7 +380,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
|
||||
private boolean checkExclusivity(ZkNodeProps message, String id) throws KeeperException, InterruptedException {
|
||||
String collectionName = message.containsKey(COLLECTION_PROP) ?
|
||||
message.getStr(COLLECTION_PROP) : message.getStr("name");
|
||||
message.getStr(COLLECTION_PROP) : message.getStr(NAME);
|
||||
|
||||
if(collectionName == null)
|
||||
return true;
|
||||
|
@ -639,7 +638,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
String collName = message.getStr("collection");
|
||||
if (collName == null) collName = message.getStr("name");
|
||||
if (collName == null) collName = message.getStr(NAME);
|
||||
|
||||
if (collName == null) {
|
||||
SolrException.log(log, "Operation " + operation + " failed", e);
|
||||
|
@ -1127,7 +1126,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
|
||||
private void deleteCollection(ZkNodeProps message, NamedList results)
|
||||
throws KeeperException, InterruptedException {
|
||||
final String collection = message.getStr("name");
|
||||
final String collection = message.getStr(NAME);
|
||||
try {
|
||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
params.set(CoreAdminParams.ACTION, CoreAdminAction.UNLOAD.toString());
|
||||
|
@ -1137,7 +1136,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
null);
|
||||
|
||||
ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION,
|
||||
DELETE.toLower(), "name", collection);
|
||||
DELETE.toLower(), NAME, collection);
|
||||
Overseer.getInQueue(zkStateReader.getZkClient()).offer(
|
||||
ZkStateReader.toJSON(m));
|
||||
|
||||
|
@ -1179,7 +1178,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
}
|
||||
|
||||
private void createAlias(Aliases aliases, ZkNodeProps message) {
|
||||
String aliasName = message.getStr("name");
|
||||
String aliasName = message.getStr(NAME);
|
||||
String collections = message.getStr("collections");
|
||||
|
||||
Map previousMDCContext = MDC.getCopyOfContextMap();
|
||||
|
@ -1258,7 +1257,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
}
|
||||
|
||||
private void deleteAlias(Aliases aliases, ZkNodeProps message) {
|
||||
String aliasName = message.getStr("name");
|
||||
String aliasName = message.getStr(NAME);
|
||||
Map previousMDCContext = MDC.getCopyOfContextMap();
|
||||
MDCUtils.setCollection(aliasName);
|
||||
|
||||
|
@ -1321,7 +1320,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
if (created) break;
|
||||
}
|
||||
if (!created)
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, "Could not fully create shard: " + message.getStr("name"));
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, "Could not fully create shard: " + message.getStr(NAME));
|
||||
|
||||
|
||||
String configName = message.getStr(COLL_CONF);
|
||||
|
@ -1996,7 +1995,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
log.info("Deleting temporary collection: " + tempSourceCollectionName);
|
||||
Map<String, Object> props = ZkNodeProps.makeMap(
|
||||
Overseer.QUEUE_OPERATION, DELETE.toLower(),
|
||||
"name", tempSourceCollectionName);
|
||||
NAME, tempSourceCollectionName);
|
||||
|
||||
try {
|
||||
deleteCollection(new ZkNodeProps(props), results);
|
||||
|
@ -2080,7 +2079,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
String configName = zkStateReader.readConfigName(sourceCollection.getName());
|
||||
Map<String, Object> props = ZkNodeProps.makeMap(
|
||||
Overseer.QUEUE_OPERATION, CREATE.toLower(),
|
||||
"name", tempSourceCollectionName,
|
||||
NAME, tempSourceCollectionName,
|
||||
ZkStateReader.REPLICATION_FACTOR, 1,
|
||||
NUM_SLICES, 1,
|
||||
COLL_CONF, configName,
|
||||
|
@ -2209,7 +2208,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
log.info("Deleting temporary collection: " + tempSourceCollectionName);
|
||||
props = ZkNodeProps.makeMap(
|
||||
Overseer.QUEUE_OPERATION, DELETE.toLower(),
|
||||
"name", tempSourceCollectionName);
|
||||
NAME, tempSourceCollectionName);
|
||||
deleteCollection(new ZkNodeProps(props), results);
|
||||
} catch (Exception e) {
|
||||
log.error("Unable to delete temporary collection: " + tempSourceCollectionName
|
||||
|
@ -2290,7 +2289,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
}
|
||||
|
||||
private void createCollection(ClusterState clusterState, ZkNodeProps message, NamedList results) throws KeeperException, InterruptedException {
|
||||
String collectionName = message.getStr("name");
|
||||
String collectionName = message.getStr(NAME);
|
||||
if (clusterState.hasCollection(collectionName)) {
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST, "collection already exists: " + collectionName);
|
||||
}
|
||||
|
@ -2376,11 +2375,11 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
boolean created = false;
|
||||
while (System.nanoTime() < waitUntil) {
|
||||
Thread.sleep(100);
|
||||
created = zkStateReader.getClusterState().getCollections().contains(message.getStr("name"));
|
||||
created = zkStateReader.getClusterState().getCollections().contains(message.getStr(NAME));
|
||||
if(created) break;
|
||||
}
|
||||
if (!created)
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, "Could not fully create collection: " + message.getStr("name"));
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, "Could not fully create collection: " + message.getStr(NAME));
|
||||
|
||||
// For tracking async calls.
|
||||
HashMap<String, String> requestMap = new HashMap<String, String>();
|
||||
|
@ -2664,7 +2663,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
|
||||
private void collectionCmd(ClusterState clusterState, ZkNodeProps message, ModifiableSolrParams params, NamedList results, String stateMatcher) {
|
||||
log.info("Executing Collection Cmd : " + params);
|
||||
String collectionName = message.getStr("name");
|
||||
String collectionName = message.getStr(NAME);
|
||||
ShardHandler shardHandler = shardHandlerFactory.getShardHandler();
|
||||
|
||||
DocCollection coll = clusterState.getCollection(collectionName);
|
||||
|
@ -2856,7 +2855,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
boolean success = false;
|
||||
String asyncId = message.getStr(ASYNC);
|
||||
String collectionName = message.containsKey(COLLECTION_PROP) ?
|
||||
message.getStr(COLLECTION_PROP) : message.getStr("name");
|
||||
message.getStr(COLLECTION_PROP) : message.getStr(NAME);
|
||||
Map previousMDCContext = MDC.getCopyOfContextMap();
|
||||
MDCUtils.setCollection(collectionName);
|
||||
try {
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.apache.solr.common.cloud.ZkStateReader;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
public class ClusterStateMutator {
|
||||
private static Logger log = LoggerFactory.getLogger(ClusterStateMutator.class);
|
||||
|
@ -49,7 +49,7 @@ public class ClusterStateMutator {
|
|||
}
|
||||
|
||||
public ZkWriteCommand createCollection(ClusterState clusterState, ZkNodeProps message) {
|
||||
String cName = message.getStr("name");
|
||||
String cName = message.getStr(NAME);
|
||||
log.info("building a new cName: " + cName);
|
||||
if (clusterState.hasCollection(cName)) {
|
||||
log.warn("Collection {} already exists. exit", cName);
|
||||
|
@ -68,7 +68,7 @@ public class ClusterStateMutator {
|
|||
}
|
||||
|
||||
Map<String, Object> routerSpec = DocRouter.getRouterSpec(message);
|
||||
String routerName = routerSpec.get("name") == null ? DocRouter.DEFAULT_NAME : (String) routerSpec.get("name");
|
||||
String routerName = routerSpec.get(NAME) == null ? DocRouter.DEFAULT_NAME : (String) routerSpec.get(NAME);
|
||||
DocRouter router = DocRouter.getDocRouter(routerName);
|
||||
|
||||
List<DocRouter.Range> ranges = router.partitionRange(shards.size(), router.fullRange());
|
||||
|
@ -110,8 +110,8 @@ public class ClusterStateMutator {
|
|||
}
|
||||
|
||||
public ZkWriteCommand deleteCollection(ClusterState clusterState, ZkNodeProps message) {
|
||||
final String collection = message.getStr("name");
|
||||
if (!CollectionMutator.checkKeyExistence(message, "name")) return ZkStateWriter.NO_OP;
|
||||
final String collection = message.getStr(NAME);
|
||||
if (!CollectionMutator.checkKeyExistence(message, NAME)) return ZkStateWriter.NO_OP;
|
||||
DocCollection coll = clusterState.getCollectionOrNull(collection);
|
||||
if (coll == null) return ZkStateWriter.NO_OP;
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ import org.apache.solr.common.cloud.ZkStateReader;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
public class CollectionMutator {
|
||||
private static Logger log = LoggerFactory.getLogger(CollectionMutator.class);
|
||||
|
||||
|
@ -92,7 +94,7 @@ public class CollectionMutator {
|
|||
slices = new LinkedHashMap<>(1);
|
||||
slices.put(slice.getName(), slice);
|
||||
Map<String, Object> props = new HashMap<>(1);
|
||||
props.put(DocCollection.DOC_ROUTER, ZkNodeProps.makeMap("name", ImplicitDocRouter.NAME));
|
||||
props.put(DocCollection.DOC_ROUTER, ZkNodeProps.makeMap(NAME, ImplicitDocRouter.NAME));
|
||||
newCollection = new DocCollection(collectionName, slices, props, new ImplicitDocRouter());
|
||||
} else {
|
||||
slices = new LinkedHashMap<>(collection.getSlicesMap()); // make a shallow copy
|
||||
|
|
|
@ -17,9 +17,6 @@ package org.apache.solr.cloud.overseer;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import static org.apache.solr.cloud.OverseerCollectionProcessor.*;
|
||||
import static org.apache.solr.cloud.overseer.CollectionMutator.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
|
@ -42,6 +39,11 @@ import org.apache.solr.common.cloud.ZkStateReader;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.cloud.OverseerCollectionProcessor.COLL_PROP_PREFIX;
|
||||
import static org.apache.solr.cloud.overseer.CollectionMutator.checkCollectionKeyExistence;
|
||||
import static org.apache.solr.cloud.overseer.CollectionMutator.checkKeyExistence;
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
public class ReplicaMutator {
|
||||
private static Logger log = LoggerFactory.getLogger(ReplicaMutator.class);
|
||||
|
||||
|
@ -214,7 +216,7 @@ public class ReplicaMutator {
|
|||
boolean collectionExists = prevState.hasCollection(cName);
|
||||
if (!collectionExists && numShards != null) {
|
||||
ClusterStateMutator.getShardNames(numShards, shardNames);
|
||||
Map<String, Object> createMsg = ZkNodeProps.makeMap("name", cName);
|
||||
Map<String, Object> createMsg = ZkNodeProps.makeMap(NAME, cName);
|
||||
createMsg.putAll(message.getProperties());
|
||||
writeCommand = new ClusterStateMutator(zkStateReader).createCollection(prevState, new ZkNodeProps(createMsg));
|
||||
DocCollection collection = writeCommand.collection;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.apache.solr.cloud.Assign;
|
||||
import org.apache.solr.cloud.Overseer;
|
||||
import org.apache.solr.common.cloud.ClusterState;
|
||||
|
@ -40,6 +39,7 @@ import org.slf4j.LoggerFactory;
|
|||
import static org.apache.solr.cloud.OverseerCollectionProcessor.COLL_PROP_PREFIX;
|
||||
import static org.apache.solr.cloud.overseer.CollectionMutator.checkCollectionKeyExistence;
|
||||
import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
public class SliceMutator {
|
||||
private static Logger log = LoggerFactory.getLogger(SliceMutator.class);
|
||||
|
@ -123,7 +123,7 @@ public class SliceMutator {
|
|||
// if there are no slices left in the collection, remove it?
|
||||
if (newSlices.size() == 0) {
|
||||
return new ClusterStateMutator(zkStateReader).deleteCollection(clusterState,
|
||||
new ZkNodeProps(ZkNodeProps.makeMap("name", collection)));
|
||||
new ZkNodeProps(ZkNodeProps.makeMap(NAME, collection)));
|
||||
} else {
|
||||
return new ZkWriteCommand(collection, coll.copyWithSlices(newSlices));
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.handler.PingRequestHandler;
|
||||
import org.apache.solr.handler.RealTimeGetHandler;
|
||||
|
@ -43,6 +44,9 @@ import org.apache.solr.request.SolrRequestHandler;
|
|||
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
|
||||
import static org.apache.solr.common.params.CommonParams.JSON;
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
import static org.apache.solr.common.params.CommonParams.WT;
|
||||
import static org.apache.solr.core.PluginInfo.DEFAULTS;
|
||||
import static org.apache.solr.core.PluginInfo.INVARIANTS;
|
||||
|
||||
|
@ -66,9 +70,9 @@ public class ImplicitPlugins {
|
|||
|
||||
implicits.add(getReqHandlerInfo("/get", RealTimeGetHandler.class,
|
||||
makeMap(
|
||||
"omitHeader", "true",
|
||||
"wt", "json",
|
||||
"indent", "true")));
|
||||
"omitHeader", "true",
|
||||
WT, JSON,
|
||||
"indent", "true")));
|
||||
//register adminHandlers
|
||||
implicits.add(getReqHandlerInfo("/admin/luke", LukeRequestHandler.class, null));
|
||||
implicits.add(getReqHandlerInfo("/admin/system", SystemInfoHandler.class, null));
|
||||
|
@ -87,8 +91,7 @@ public class ImplicitPlugins {
|
|||
|
||||
public static PluginInfo getReqHandlerInfo(String name, Class clz, Map defaults){
|
||||
if(defaults == null) defaults= Collections.emptyMap();
|
||||
Map m = makeMap("name", name, "class", clz.getName());
|
||||
Map m = makeMap(NAME, name, "class", clz.getName());
|
||||
return new PluginInfo(SolrRequestHandler.TYPE, m, new NamedList<>(singletonMap(DEFAULTS, new NamedList(defaults))),null);
|
||||
}
|
||||
public static final String IMPLICIT = "implicit";
|
||||
}
|
||||
|
|
|
@ -17,15 +17,21 @@ package org.apache.solr.core;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
import static org.apache.solr.common.params.CommonParams.PATH;
|
||||
import static org.apache.solr.core.PluginInfo.APPENDS;
|
||||
import static org.apache.solr.core.PluginInfo.DEFAULTS;
|
||||
import static org.apache.solr.core.PluginInfo.INVARIANTS;
|
||||
|
||||
/**
|
||||
* An Object which represents a {@code <initParams>} tag
|
||||
*/
|
||||
|
@ -36,18 +42,18 @@ public class InitParams {
|
|||
public final NamedList defaults, invariants, appends;
|
||||
|
||||
public InitParams(PluginInfo p) {
|
||||
this.name = p.attributes.get("name");
|
||||
this.name = p.attributes.get(NAME);
|
||||
Set<String> paths = null;
|
||||
String pathStr = p.attributes.get("path");
|
||||
String pathStr = p.attributes.get(PATH);
|
||||
if (pathStr != null) {
|
||||
paths = Collections.unmodifiableSet(new HashSet<>(StrUtils.splitSmart(pathStr, ',')));
|
||||
}
|
||||
this.paths = paths;
|
||||
NamedList nl = (NamedList) p.initArgs.get(PluginInfo.DEFAULTS);
|
||||
NamedList nl = (NamedList) p.initArgs.get(DEFAULTS);
|
||||
defaults = nl == null ? null : nl.getImmutableCopy();
|
||||
nl = (NamedList) p.initArgs.get(PluginInfo.INVARIANTS);
|
||||
nl = (NamedList) p.initArgs.get(INVARIANTS);
|
||||
invariants = nl == null ? null : nl.getImmutableCopy();
|
||||
nl = (NamedList) p.initArgs.get(PluginInfo.APPENDS);
|
||||
nl = (NamedList) p.initArgs.get(APPENDS);
|
||||
appends = nl == null ? null : nl.getImmutableCopy();
|
||||
}
|
||||
|
||||
|
@ -83,13 +89,13 @@ public class InitParams {
|
|||
public void apply(PluginInfo info) {
|
||||
if (!info.isFromSolrConfig()) {
|
||||
//if this is a component implicitly defined in code it should be overridden by initPrams
|
||||
merge(defaults, (NamedList) info.initArgs.get(PluginInfo.DEFAULTS), info.initArgs, PluginInfo.DEFAULTS, false);
|
||||
merge(defaults, (NamedList) info.initArgs.get(DEFAULTS), info.initArgs, DEFAULTS, false);
|
||||
} else {
|
||||
//if the args is initialized from solrconfig.xml inside the requesthHandler it should be taking precedence over initParams
|
||||
merge((NamedList) info.initArgs.get(PluginInfo.DEFAULTS), defaults, info.initArgs, PluginInfo.DEFAULTS, false);
|
||||
merge((NamedList) info.initArgs.get(DEFAULTS), defaults, info.initArgs, DEFAULTS, false);
|
||||
}
|
||||
merge((NamedList) info.initArgs.get(PluginInfo.INVARIANTS), invariants, info.initArgs, PluginInfo.INVARIANTS, false);
|
||||
merge((NamedList) info.initArgs.get(PluginInfo.APPENDS), appends, info.initArgs, PluginInfo.APPENDS, true);
|
||||
merge((NamedList) info.initArgs.get(INVARIANTS), invariants, info.initArgs, INVARIANTS, false);
|
||||
merge((NamedList) info.initArgs.get(APPENDS), appends, info.initArgs, APPENDS, true);
|
||||
}
|
||||
|
||||
private static void merge(NamedList first, NamedList second, NamedList sink, String name, boolean appends) {
|
||||
|
|
|
@ -16,14 +16,21 @@
|
|||
*/
|
||||
package org.apache.solr.core;
|
||||
|
||||
import org.apache.lucene.store.AlreadyClosedException;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.core.SolrConfig.JmxConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.management.*;
|
||||
import javax.management.Attribute;
|
||||
import javax.management.AttributeList;
|
||||
import javax.management.AttributeNotFoundException;
|
||||
import javax.management.DynamicMBean;
|
||||
import javax.management.InvalidAttributeValueException;
|
||||
import javax.management.MBeanAttributeInfo;
|
||||
import javax.management.MBeanException;
|
||||
import javax.management.MBeanInfo;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanServerFactory;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.Query;
|
||||
import javax.management.QueryExp;
|
||||
import javax.management.ReflectionException;
|
||||
import javax.management.openmbean.OpenMBeanAttributeInfoSupport;
|
||||
import javax.management.openmbean.OpenType;
|
||||
import javax.management.openmbean.SimpleType;
|
||||
|
@ -32,9 +39,23 @@ import javax.management.remote.JMXConnectorServerFactory;
|
|||
import javax.management.remote.JMXServiceURL;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.lucene.store.AlreadyClosedException;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.core.SolrConfig.JmxConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Responsible for finding (or creating) a MBeanServer from given configuration
|
||||
|
@ -239,7 +260,7 @@ public class JmxMonitoredMap<K, V> extends
|
|||
staticStats = new HashSet<>();
|
||||
|
||||
// For which getters are already available in SolrInfoMBean
|
||||
staticStats.add("name");
|
||||
staticStats.add(NAME);
|
||||
staticStats.add("version");
|
||||
staticStats.add("description");
|
||||
staticStats.add("category");
|
||||
|
|
|
@ -43,6 +43,8 @@ import org.apache.solr.util.plugin.SolrCoreAware;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
* This manages the lifecycle of a set of plugin of the same type .
|
||||
*/
|
||||
|
@ -372,7 +374,7 @@ public class PluginBag<T> implements AutoCloseable {
|
|||
|
||||
@Override
|
||||
public void init(PluginInfo info) {
|
||||
name = info.attributes.get("name");
|
||||
name = info.attributes.get(NAME);
|
||||
Object v = info.attributes.get("version");
|
||||
if (name == null || v == null) {
|
||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "runtimeLib must have name and version");
|
||||
|
|
|
@ -18,6 +18,28 @@
|
|||
package org.apache.solr.core;
|
||||
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.apache.lucene.index.IndexDeletionPolicy;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
|
@ -55,28 +77,8 @@ import org.w3c.dom.NodeList;
|
|||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
import static org.apache.solr.common.params.CommonParams.PATH;
|
||||
import static org.apache.solr.core.ConfigOverlay.ZNODEVER;
|
||||
import static org.apache.solr.core.SolrConfig.PluginOpts.LAZY;
|
||||
import static org.apache.solr.core.SolrConfig.PluginOpts.MULTI_OK;
|
||||
|
@ -242,7 +244,7 @@ public class SolrConfig extends Config implements MapSerializable {
|
|||
CacheConfig conf = CacheConfig.getConfig(this, "query/fieldValueCache");
|
||||
if (conf == null) {
|
||||
Map<String, String> args = new HashMap<>();
|
||||
args.put("name", "fieldValueCache");
|
||||
args.put(NAME, "fieldValueCache");
|
||||
args.put("size", "10000");
|
||||
args.put("initialSize", "10");
|
||||
args.put("showItems", "-1");
|
||||
|
@ -741,7 +743,7 @@ public class SolrConfig extends Config implements MapSerializable {
|
|||
Node node = nodes.item(i);
|
||||
|
||||
String baseDir = DOMUtil.getAttr(node, "dir");
|
||||
String path = DOMUtil.getAttr(node, "path");
|
||||
String path = DOMUtil.getAttr(node, PATH);
|
||||
if (null != baseDir) {
|
||||
// :TODO: add support for a simpler 'glob' mutually exclusive of regex
|
||||
String regex = DOMUtil.getAttr(node, "regex");
|
||||
|
|
|
@ -66,7 +66,6 @@ import org.apache.lucene.search.BooleanQuery;
|
|||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.IOContext;
|
||||
import org.apache.lucene.store.IndexInput;
|
||||
import org.apache.lucene.store.Lock;
|
||||
import org.apache.lucene.store.LockObtainFailedException;
|
||||
import org.apache.solr.client.solrj.impl.BinaryResponseParser;
|
||||
import org.apache.solr.cloud.CloudDescriptor;
|
||||
|
@ -146,6 +145,8 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.PATH;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -2012,7 +2013,7 @@ public final class SolrCore implements SolrInfoMBean, Closeable {
|
|||
// for back compat, we set these now just in case other code
|
||||
// are expecting them during handleRequest
|
||||
toLog.add("webapp", req.getContext().get("webapp"));
|
||||
toLog.add("path", req.getContext().get("path"));
|
||||
toLog.add(PATH, req.getContext().get(PATH));
|
||||
|
||||
final SolrParams params = req.getParams();
|
||||
final String lpList = params.get(CommonParams.LOG_PARAMS_LIST);
|
||||
|
|
|
@ -17,6 +17,20 @@ package org.apache.solr.core;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.solr.common.SolrException;
|
||||
|
@ -31,19 +45,7 @@ import org.w3c.dom.Node;
|
|||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -176,7 +178,7 @@ public class SolrXmlConfig {
|
|||
Properties properties = new Properties();
|
||||
for (int i = 0; i < props.getLength(); i++) {
|
||||
Node prop = props.item(i);
|
||||
properties.setProperty(DOMUtil.getAttr(prop, "name"),
|
||||
properties.setProperty(DOMUtil.getAttr(prop, NAME),
|
||||
PropertiesUtil.substituteProperty(DOMUtil.getAttr(prop, "value"), null));
|
||||
}
|
||||
return properties;
|
||||
|
|
|
@ -59,6 +59,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
|
||||
import static org.apache.solr.common.params.CommonParams.JSON;
|
||||
|
||||
public class BlobHandler extends RequestHandlerBase implements PluginInfoInitialized {
|
||||
protected static final Logger log = LoggerFactory.getLogger(BlobHandler.class);
|
||||
|
@ -72,7 +73,7 @@ public class BlobHandler extends RequestHandlerBase implements PluginInfoInitial
|
|||
public void handleRequestBody(final SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
|
||||
String httpMethod = (String) req.getContext().get("httpMethod");
|
||||
String path = (String) req.getContext().get("path");
|
||||
SolrConfigHandler.setWt(req, "json");
|
||||
SolrConfigHandler.setWt(req, JSON);
|
||||
|
||||
List<String> pieces = StrUtils.splitSmart(path, '/');
|
||||
String blobName = null;
|
||||
|
|
|
@ -17,6 +17,16 @@
|
|||
|
||||
package org.apache.solr.handler;
|
||||
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
@ -39,13 +49,7 @@ import org.apache.solr.util.EmptyEntityResolver;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
* An analysis handler that provides a breakdown of the analysis process of provided documents. This handler expects a
|
||||
|
@ -311,7 +315,7 @@ public class DocumentAnalysisRequestHandler extends AnalysisRequestHandlerBase {
|
|||
|
||||
for (int i = 0; i < reader.getAttributeCount(); i++) {
|
||||
String attrName = reader.getAttributeLocalName(i);
|
||||
if ("name".equals(attrName)) {
|
||||
if (NAME.equals(attrName)) {
|
||||
fieldName = reader.getAttributeValue(i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,12 +26,12 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.apache.solr.common.util.ContentStream;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.core.InitParams;
|
||||
import org.apache.solr.core.PluginInfo;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.request.SolrRequestHandler;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.util.plugin.PluginInfoInitialized;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
public class DumpRequestHandler extends RequestHandlerBase
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ public class DumpRequestHandler extends RequestHandlerBase
|
|||
// Cycle through each stream
|
||||
for( ContentStream content : req.getContentStreams() ) {
|
||||
NamedList<Object> stream = new SimpleOrderedMap<>();
|
||||
stream.add( "name", content.getName() );
|
||||
stream.add(NAME, content.getName());
|
||||
stream.add( "sourceInfo", content.getSourceInfo() );
|
||||
stream.add( "size", content.getSize() );
|
||||
stream.add( "contentType", content.getContentType() );
|
||||
|
|
|
@ -16,26 +16,6 @@
|
|||
*/
|
||||
package org.apache.solr.handler;
|
||||
|
||||
import static org.apache.solr.handler.ReplicationHandler.ALIAS;
|
||||
import static org.apache.solr.handler.ReplicationHandler.CHECKSUM;
|
||||
import static org.apache.solr.handler.ReplicationHandler.CMD_DETAILS;
|
||||
import static org.apache.solr.handler.ReplicationHandler.CMD_GET_FILE;
|
||||
import static org.apache.solr.handler.ReplicationHandler.CMD_GET_FILE_LIST;
|
||||
import static org.apache.solr.handler.ReplicationHandler.CMD_INDEX_VERSION;
|
||||
import static org.apache.solr.handler.ReplicationHandler.COMMAND;
|
||||
import static org.apache.solr.handler.ReplicationHandler.COMPRESSION;
|
||||
import static org.apache.solr.handler.ReplicationHandler.CONF_FILES;
|
||||
import static org.apache.solr.handler.ReplicationHandler.CONF_FILE_SHORT;
|
||||
import static org.apache.solr.handler.ReplicationHandler.EXTERNAL;
|
||||
import static org.apache.solr.handler.ReplicationHandler.FILE;
|
||||
import static org.apache.solr.handler.ReplicationHandler.FILE_STREAM;
|
||||
import static org.apache.solr.handler.ReplicationHandler.GENERATION;
|
||||
import static org.apache.solr.handler.ReplicationHandler.INTERNAL;
|
||||
import static org.apache.solr.handler.ReplicationHandler.MASTER_URL;
|
||||
import static org.apache.solr.handler.ReplicationHandler.NAME;
|
||||
import static org.apache.solr.handler.ReplicationHandler.OFFSET;
|
||||
import static org.apache.solr.handler.ReplicationHandler.SIZE;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -109,6 +89,27 @@ import org.apache.solr.util.RefCounted;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.JAVABIN;
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
import static org.apache.solr.handler.ReplicationHandler.ALIAS;
|
||||
import static org.apache.solr.handler.ReplicationHandler.CHECKSUM;
|
||||
import static org.apache.solr.handler.ReplicationHandler.CMD_DETAILS;
|
||||
import static org.apache.solr.handler.ReplicationHandler.CMD_GET_FILE;
|
||||
import static org.apache.solr.handler.ReplicationHandler.CMD_GET_FILE_LIST;
|
||||
import static org.apache.solr.handler.ReplicationHandler.CMD_INDEX_VERSION;
|
||||
import static org.apache.solr.handler.ReplicationHandler.COMMAND;
|
||||
import static org.apache.solr.handler.ReplicationHandler.COMPRESSION;
|
||||
import static org.apache.solr.handler.ReplicationHandler.CONF_FILES;
|
||||
import static org.apache.solr.handler.ReplicationHandler.CONF_FILE_SHORT;
|
||||
import static org.apache.solr.handler.ReplicationHandler.EXTERNAL;
|
||||
import static org.apache.solr.handler.ReplicationHandler.FILE;
|
||||
import static org.apache.solr.handler.ReplicationHandler.FILE_STREAM;
|
||||
import static org.apache.solr.handler.ReplicationHandler.GENERATION;
|
||||
import static org.apache.solr.handler.ReplicationHandler.INTERNAL;
|
||||
import static org.apache.solr.handler.ReplicationHandler.MASTER_URL;
|
||||
import static org.apache.solr.handler.ReplicationHandler.OFFSET;
|
||||
import static org.apache.solr.handler.ReplicationHandler.SIZE;
|
||||
|
||||
/**
|
||||
* <p> Provides functionality of downloading changed index files as well as config files and a timer for scheduling fetches from the
|
||||
* master. </p>
|
||||
|
@ -196,7 +197,7 @@ public class IndexFetcher {
|
|||
NamedList getLatestVersion() throws IOException {
|
||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
params.set(COMMAND, CMD_INDEX_VERSION);
|
||||
params.set(CommonParams.WT, "javabin");
|
||||
params.set(CommonParams.WT, JAVABIN);
|
||||
params.set(CommonParams.QT, "/replication");
|
||||
QueryRequest req = new QueryRequest(params);
|
||||
|
||||
|
@ -218,7 +219,7 @@ public class IndexFetcher {
|
|||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
params.set(COMMAND, CMD_GET_FILE_LIST);
|
||||
params.set(GENERATION, String.valueOf(gen));
|
||||
params.set(CommonParams.WT, "javabin");
|
||||
params.set(CommonParams.WT, JAVABIN);
|
||||
params.set(CommonParams.QT, "/replication");
|
||||
QueryRequest req = new QueryRequest(params);
|
||||
|
||||
|
|
|
@ -21,13 +21,15 @@ import org.apache.solr.common.SolrException;
|
|||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.PATH;
|
||||
|
||||
/**
|
||||
* Does nothing other than showing a 404 message
|
||||
*/
|
||||
public class NotFoundRequestHandler extends RequestHandlerBase{
|
||||
@Override
|
||||
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
|
||||
throw new SolrException(SolrException.ErrorCode.NOT_FOUND,""+req.getContext().get("path") +" is not found");
|
||||
throw new SolrException(SolrException.ErrorCode.NOT_FOUND, "" + req.getContext().get(PATH) + " is not found");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -88,6 +88,8 @@ import org.apache.solr.util.plugin.SolrCoreAware;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
* <p> A Handler which provides a REST API for replication and serves replication requests from Slaves. </p>
|
||||
* <p>When running on the master, it provides the following commands <ol> <li>Get the current replicable index version
|
||||
|
@ -295,12 +297,12 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
|
|||
}
|
||||
|
||||
private void deleteSnapshot(ModifiableSolrParams params) {
|
||||
String name = params.get("name");
|
||||
String name = params.get(NAME);
|
||||
if(name == null) {
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST, "Missing mandatory param: name");
|
||||
}
|
||||
|
||||
SnapShooter snapShooter = new SnapShooter(core, params.get("location"), params.get("name"));
|
||||
SnapShooter snapShooter = new SnapShooter(core, params.get("location"), params.get(NAME));
|
||||
snapShooter.validateDeleteSnapshot();
|
||||
snapShooter.deleteSnapAsync(this);
|
||||
}
|
||||
|
@ -398,7 +400,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
|
|||
}
|
||||
|
||||
// small race here before the commit point is saved
|
||||
SnapShooter snapShooter = new SnapShooter(core, params.get("location"), params.get("name"));
|
||||
SnapShooter snapShooter = new SnapShooter(core, params.get("location"), params.get(NAME));
|
||||
snapShooter.validateCreateSnapshot();
|
||||
snapShooter.createSnapAsync(indexCommit, numberToKeep, this);
|
||||
|
||||
|
@ -1445,8 +1447,6 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
|
|||
|
||||
public static final String FILE = "file";
|
||||
|
||||
public static final String NAME = "name";
|
||||
|
||||
public static final String SIZE = "size";
|
||||
|
||||
public static final String MAX_WRITE_PER_SECOND = "maxWriteMBPerSec";
|
||||
|
|
|
@ -39,12 +39,14 @@ import org.apache.solr.schema.ZkIndexSchemaReader;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.JSON;
|
||||
|
||||
public class SchemaHandler extends RequestHandlerBase {
|
||||
private static final Logger log = LoggerFactory.getLogger(SchemaHandler.class);
|
||||
|
||||
@Override
|
||||
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
|
||||
SolrConfigHandler.setWt(req, "json");
|
||||
SolrConfigHandler.setWt(req, JSON);
|
||||
String httpMethod = (String) req.getContext().get("httpMethod");
|
||||
if ("POST".equals(httpMethod)) {
|
||||
if (req.getContentStreams() == null) {
|
||||
|
|
|
@ -44,14 +44,12 @@ import org.apache.solr.client.solrj.SolrClient;
|
|||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrResponse;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.cloud.ZkCLI;
|
||||
import org.apache.solr.cloud.ZkController;
|
||||
import org.apache.solr.cloud.ZkSolrResourceLoader;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.cloud.ClusterState;
|
||||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.common.cloud.Slice;
|
||||
import org.apache.solr.common.cloud.SolrZkClient;
|
||||
import org.apache.solr.common.cloud.ZkNodeProps;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
|
@ -62,22 +60,18 @@ import org.apache.solr.common.util.ContentStream;
|
|||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.core.ConfigOverlay;
|
||||
import org.apache.solr.core.PluginInfo;
|
||||
import org.apache.solr.core.ImplicitPlugins;
|
||||
import org.apache.solr.core.PluginInfo;
|
||||
import org.apache.solr.core.RequestParams;
|
||||
import org.apache.solr.core.SolrConfig;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.core.SolrResourceLoader;
|
||||
import org.apache.solr.handler.admin.CollectionsHandler;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.request.SolrRequestHandler;
|
||||
import org.apache.solr.response.BinaryResponseWriter;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.schema.SchemaManager;
|
||||
import org.apache.solr.util.CommandOperation;
|
||||
import org.apache.solr.util.DefaultSolrThreadFactory;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
import org.apache.zookeeper.data.Stat;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -112,7 +106,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
@Override
|
||||
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
|
||||
|
||||
setWt(req, "json");
|
||||
setWt(req, CommonParams.JSON);
|
||||
String httpMethod = (String) req.getContext().get("httpMethod");
|
||||
Command command = new Command(req, rsp, httpMethod);
|
||||
if ("POST".equals(httpMethod)) {
|
||||
|
|
|
@ -17,15 +17,12 @@
|
|||
|
||||
package org.apache.solr.handler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.SolrException.ErrorCode;
|
||||
import org.apache.solr.common.cloud.ZkNodeProps;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.MapSolrParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
|
@ -33,7 +30,6 @@ import org.apache.solr.common.params.SolrParams;
|
|||
import org.apache.solr.common.params.UpdateParams;
|
||||
import org.apache.solr.common.util.ContentStream;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.core.PluginInfo;
|
||||
import org.apache.solr.handler.loader.CSVLoader;
|
||||
import org.apache.solr.handler.loader.ContentStreamLoader;
|
||||
import org.apache.solr.handler.loader.JavabinLoader;
|
||||
|
@ -45,8 +41,7 @@ import org.apache.solr.update.processor.UpdateRequestProcessor;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
|
||||
import static org.apache.solr.common.params.CommonParams.PATH;
|
||||
|
||||
/**
|
||||
* UpdateHandler that uses content-type to pick the right Loader
|
||||
|
@ -77,7 +72,7 @@ public class UpdateRequestHandler extends ContentStreamHandlerBase {
|
|||
public void load(SolrQueryRequest req, SolrQueryResponse rsp,
|
||||
ContentStream stream, UpdateRequestProcessor processor) throws Exception {
|
||||
|
||||
ContentStreamLoader loader = pathVsLoaders.get(req.getContext().get("path"));
|
||||
ContentStreamLoader loader = pathVsLoaders.get(req.getContext().get(PATH));
|
||||
if(loader == null) {
|
||||
String type = req.getParams().get(UpdateParams.ASSUME_CONTENT_TYPE);
|
||||
if (type == null) {
|
||||
|
|
|
@ -17,6 +17,17 @@ package org.apache.solr.handler.admin;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.solr.client.solrj.SolrResponse;
|
||||
|
@ -59,17 +70,6 @@ import org.apache.zookeeper.KeeperException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
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;
|
||||
|
@ -118,6 +118,7 @@ import static org.apache.solr.common.params.CollectionParams.CollectionAction.RE
|
|||
import static org.apache.solr.common.params.CollectionParams.CollectionAction.RELOAD;
|
||||
import static org.apache.solr.common.params.CollectionParams.CollectionAction.REMOVEROLE;
|
||||
import static org.apache.solr.common.params.CollectionParams.CollectionAction.SPLITSHARD;
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
public class CollectionsHandler extends RequestHandlerBase {
|
||||
protected static Logger log = LoggerFactory.getLogger(CollectionsHandler.class);
|
||||
|
@ -607,8 +608,8 @@ public class CollectionsHandler extends RequestHandlerBase {
|
|||
}
|
||||
|
||||
private void handleProp(SolrQueryRequest req, SolrQueryResponse rsp) throws KeeperException, InterruptedException {
|
||||
req.getParams().required().check("name");
|
||||
String name = req.getParams().get("name");
|
||||
req.getParams().required().check(NAME);
|
||||
String name = req.getParams().get(NAME);
|
||||
if(!OverseerCollectionProcessor.KNOWN_CLUSTER_PROPS.contains(name)){
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST, "Not a known cluster property "+ name);
|
||||
}
|
||||
|
@ -616,7 +617,7 @@ public class CollectionsHandler extends RequestHandlerBase {
|
|||
Map<String,Object> props = ZkNodeProps.makeMap(
|
||||
Overseer.QUEUE_OPERATION, CLUSTERPROP.toLower() );
|
||||
copyIfNotNull(req.getParams(),props,
|
||||
"name",
|
||||
NAME,
|
||||
"val");
|
||||
|
||||
Overseer.getInQueue(coreContainer.getZkController().getZkClient()).offer(ZkStateReader.toJSON(props)) ;
|
||||
|
@ -754,10 +755,10 @@ public class CollectionsHandler extends RequestHandlerBase {
|
|||
|
||||
private void handleReloadAction(SolrQueryRequest req, SolrQueryResponse rsp) throws KeeperException, InterruptedException {
|
||||
log.info("Reloading Collection : " + req.getParamString());
|
||||
String name = req.getParams().required().get("name");
|
||||
String name = req.getParams().required().get(NAME);
|
||||
|
||||
ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION,
|
||||
RELOAD.toLower(), "name", name);
|
||||
RELOAD.toLower(), NAME, name);
|
||||
|
||||
handleResponse(RELOAD.toLower(), m, rsp);
|
||||
}
|
||||
|
@ -787,11 +788,11 @@ public class CollectionsHandler extends RequestHandlerBase {
|
|||
private void handleCreateAliasAction(SolrQueryRequest req,
|
||||
SolrQueryResponse rsp) throws Exception {
|
||||
log.info("Create alias action : " + req.getParamString());
|
||||
String name = req.getParams().required().get("name");
|
||||
String name = req.getParams().required().get(NAME);
|
||||
String collections = req.getParams().required().get("collections");
|
||||
|
||||
ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION,
|
||||
CREATEALIAS.toLower(), "name", name, "collections",
|
||||
CREATEALIAS.toLower(), NAME, name, "collections",
|
||||
collections);
|
||||
|
||||
handleResponse(CREATEALIAS.toLower(), m, rsp);
|
||||
|
@ -800,21 +801,21 @@ public class CollectionsHandler extends RequestHandlerBase {
|
|||
private void handleDeleteAliasAction(SolrQueryRequest req,
|
||||
SolrQueryResponse rsp) throws Exception {
|
||||
log.info("Delete alias action : " + req.getParamString());
|
||||
String name = req.getParams().required().get("name");
|
||||
String name = req.getParams().required().get(NAME);
|
||||
|
||||
ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION,
|
||||
DELETEALIAS.toLower(), "name", name);
|
||||
DELETEALIAS.toLower(), NAME, name);
|
||||
|
||||
handleResponse(DELETEALIAS.toLower(), m, rsp);
|
||||
}
|
||||
|
||||
private void handleDeleteAction(SolrQueryRequest req, SolrQueryResponse rsp) throws KeeperException, InterruptedException {
|
||||
log.info("Deleting Collection : " + req.getParamString());
|
||||
|
||||
String name = req.getParams().required().get("name");
|
||||
|
||||
String name = req.getParams().required().get(NAME);
|
||||
|
||||
ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION,
|
||||
DELETE.toLower(), "name", name);
|
||||
DELETE.toLower(), NAME, name);
|
||||
|
||||
handleResponse(DELETE.toLower(), m, rsp);
|
||||
}
|
||||
|
@ -827,7 +828,7 @@ public class CollectionsHandler extends RequestHandlerBase {
|
|||
private void handleCreateAction(SolrQueryRequest req,
|
||||
SolrQueryResponse rsp) throws InterruptedException, KeeperException {
|
||||
log.info("Creating Collection : " + req.getParamString());
|
||||
String name = req.getParams().required().get("name");
|
||||
String name = req.getParams().required().get(NAME);
|
||||
if (name == null) {
|
||||
log.error("Collection name is required to create a new collection");
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST,
|
||||
|
@ -839,7 +840,7 @@ public class CollectionsHandler extends RequestHandlerBase {
|
|||
CREATE.toLower(),
|
||||
"fromApi","true");
|
||||
copyIfNotNull(req.getParams(),props,
|
||||
"name",
|
||||
NAME,
|
||||
REPLICATION_FACTOR,
|
||||
COLL_CONF,
|
||||
NUM_SLICES,
|
||||
|
@ -901,7 +902,7 @@ public class CollectionsHandler extends RequestHandlerBase {
|
|||
log.info("Create shard: " + req.getParamString());
|
||||
req.getParams().required().check(COLLECTION_PROP, SHARD_ID_PROP);
|
||||
ClusterState clusterState = coreContainer.getZkController().getClusterState();
|
||||
if(!ImplicitDocRouter.NAME.equals( ((Map) clusterState.getCollection(req.getParams().get(COLLECTION_PROP)).get(DOC_ROUTER)).get("name") ) )
|
||||
if (!ImplicitDocRouter.NAME.equals(((Map) clusterState.getCollection(req.getParams().get(COLLECTION_PROP)).get(DOC_ROUTER)).get(NAME)))
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST, "shards can be added only to 'implicit' collections" );
|
||||
|
||||
Map<String, Object> map = makeMap(QUEUE_OPERATION, CREATESHARD.toLower());
|
||||
|
|
|
@ -17,6 +17,23 @@
|
|||
|
||||
package org.apache.solr.handler.admin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -68,24 +85,9 @@ import org.apache.zookeeper.KeeperException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import static org.apache.solr.common.cloud.DocCollection.DOC_ROUTER;
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
import static org.apache.solr.common.params.CommonParams.PATH;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -312,7 +314,7 @@ public class CoreAdminHandler extends RequestHandlerBase {
|
|||
SolrParams params = adminReq.getParams();
|
||||
List<DocRouter.Range> ranges = null;
|
||||
|
||||
String[] pathsArr = params.getParams("path");
|
||||
String[] pathsArr = params.getParams(PATH);
|
||||
String rangesStr = params.get(CoreAdminParams.RANGES); // ranges=a-b,c-d,e-f
|
||||
if (rangesStr != null) {
|
||||
String[] rangesArr = rangesStr.split(",");
|
||||
|
@ -1105,7 +1107,7 @@ public class CoreAdminHandler extends RequestHandlerBase {
|
|||
// It would be a real mistake to load the cores just to get the status
|
||||
CoreDescriptor desc = cores.getUnloadedCoreDescriptor(cname);
|
||||
if (desc != null) {
|
||||
info.add("name", desc.getName());
|
||||
info.add(NAME, desc.getName());
|
||||
info.add("instanceDir", desc.getInstanceDir());
|
||||
// None of the following are guaranteed to be present in a not-yet-loaded core.
|
||||
String tmp = desc.getDataDir();
|
||||
|
@ -1119,7 +1121,7 @@ public class CoreAdminHandler extends RequestHandlerBase {
|
|||
} else {
|
||||
try (SolrCore core = cores.getCore(cname)) {
|
||||
if (core != null) {
|
||||
info.add("name", core.getName());
|
||||
info.add(NAME, core.getName());
|
||||
info.add("instanceDir", normalizePath(core.getResourceLoader().getInstanceDir()));
|
||||
info.add("dataDir", normalizePath(core.getDataDir()));
|
||||
info.add("config", core.getConfigResource());
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.solr.response.SolrQueryResponse;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.PATH;
|
||||
|
||||
public class InfoHandler extends RequestHandlerBase {
|
||||
protected static Logger log = LoggerFactory.getLogger(InfoHandler.class);
|
||||
|
@ -75,7 +76,7 @@ public class InfoHandler extends RequestHandlerBase {
|
|||
"Core container instance missing");
|
||||
}
|
||||
|
||||
String path = (String) req.getContext().get("path");
|
||||
String path = (String) req.getContext().get(PATH);
|
||||
int i = path.lastIndexOf('/');
|
||||
String name = path.substring(i + 1, path.length());
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ import org.apache.solr.handler.RequestHandlerBase;
|
|||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
* @since solr 1.2
|
||||
*/
|
||||
|
@ -60,7 +62,7 @@ public class PluginInfoHandler extends RequestHandlerBase
|
|||
SimpleOrderedMap<Object> info = new SimpleOrderedMap<>();
|
||||
category.add( entry.getKey(), info );
|
||||
|
||||
info.add( "name", (m.getName() !=null ? m.getName() : na) );
|
||||
info.add( NAME, (m.getName() !=null ? m.getName() : na) );
|
||||
info.add( "version", (m.getVersion() !=null ? m.getVersion() : na) );
|
||||
info.add( "description", (m.getDescription()!=null ? m.getDescription() : na) );
|
||||
info.add( "source", (m.getSource() !=null ? m.getSource() : na) );
|
||||
|
|
|
@ -18,12 +18,15 @@
|
|||
package org.apache.solr.handler.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.handler.RequestHandlerBase;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since solr 1.2
|
||||
|
@ -34,7 +37,7 @@ public class PropertiesRequestHandler extends RequestHandlerBase
|
|||
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException
|
||||
{
|
||||
Object props = null;
|
||||
String name = req.getParams().get( "name" );
|
||||
String name = req.getParams().get(NAME);
|
||||
if( name != null ) {
|
||||
NamedList<String> p = new SimpleOrderedMap<>();
|
||||
p.add( name, System.getProperty(name) );
|
||||
|
|
|
@ -20,6 +20,8 @@ import org.apache.solr.search.SolrIndexSearcher;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -67,7 +69,7 @@ public class SegmentsInfoRequestHandler extends RequestHandlerBase {
|
|||
if (mergeCandidates.contains(segmentCommitInfo.info.name)) {
|
||||
segmentInfo.add("mergeCandidate", true);
|
||||
}
|
||||
segmentInfos.add((String) segmentInfo.get("name"), segmentInfo);
|
||||
segmentInfos.add((String) segmentInfo.get(NAME), segmentInfo);
|
||||
}
|
||||
|
||||
return segmentInfos;
|
||||
|
@ -77,7 +79,7 @@ public class SegmentsInfoRequestHandler extends RequestHandlerBase {
|
|||
SegmentCommitInfo segmentCommitInfo) throws IOException {
|
||||
SimpleOrderedMap<Object> segmentInfoMap = new SimpleOrderedMap<>();
|
||||
|
||||
segmentInfoMap.add("name", segmentCommitInfo.info.name);
|
||||
segmentInfoMap.add(NAME, segmentCommitInfo.info.name);
|
||||
segmentInfoMap.add("delCount", segmentCommitInfo.getDelCount());
|
||||
segmentInfoMap.add("sizeInBytes", segmentCommitInfo.sizeInBytes());
|
||||
segmentInfoMap.add("size", segmentCommitInfo.info.maxDoc());
|
||||
|
|
|
@ -46,6 +46,8 @@ import org.apache.solr.schema.IndexSchema;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
|
||||
/**
|
||||
* This handler returns system info
|
||||
|
@ -158,7 +160,7 @@ public class SystemInfoHandler extends RequestHandlerBase
|
|||
SimpleOrderedMap<Object> info = new SimpleOrderedMap<>();
|
||||
|
||||
OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
|
||||
info.add( "name", os.getName() );
|
||||
info.add(NAME, os.getName());
|
||||
info.add( "version", os.getVersion() );
|
||||
info.add( "arch", os.getArch() );
|
||||
info.add( "systemLoadAverage", os.getSystemLoadAverage());
|
||||
|
@ -262,12 +264,12 @@ public class SystemInfoHandler extends RequestHandlerBase
|
|||
|
||||
// Summary Info
|
||||
jvm.add( "version", jreVersion + " " + vmVersion);
|
||||
jvm.add( "name", jreVendor + " " + vmName );
|
||||
jvm.add(NAME, jreVendor + " " + vmName);
|
||||
|
||||
// details
|
||||
SimpleOrderedMap<Object> java = new SimpleOrderedMap<>();
|
||||
java.add( "vendor", javaVendor );
|
||||
java.add( "name", javaName );
|
||||
java.add(NAME, javaName);
|
||||
java.add( "version", javaVersion );
|
||||
jvm.add( "spec", java );
|
||||
SimpleOrderedMap<Object> jre = new SimpleOrderedMap<>();
|
||||
|
@ -276,7 +278,7 @@ public class SystemInfoHandler extends RequestHandlerBase
|
|||
jvm.add( "jre", jre );
|
||||
SimpleOrderedMap<Object> vm = new SimpleOrderedMap<>();
|
||||
vm.add( "vendor", vmVendor );
|
||||
vm.add( "name", vmName );
|
||||
vm.add(NAME, vmName);
|
||||
vm.add( "version", vmVersion );
|
||||
jvm.add( "vm", vm );
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ import org.apache.solr.handler.RequestHandlerBase;
|
|||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since solr 1.2
|
||||
|
@ -85,7 +87,7 @@ public class ThreadDumpHandler extends RequestHandlerBase
|
|||
long tid = ti.getThreadId();
|
||||
|
||||
info.add( "id", tid );
|
||||
info.add( "name", ti.getThreadName() );
|
||||
info.add(NAME, ti.getThreadName());
|
||||
info.add( "state", ti.getThreadState().toString() );
|
||||
|
||||
if (ti.getLockName() != null) {
|
||||
|
@ -105,7 +107,7 @@ public class ThreadDumpHandler extends RequestHandlerBase
|
|||
|
||||
if (ti.getLockOwnerName() != null) {
|
||||
SimpleOrderedMap<Object> owner = new SimpleOrderedMap<>();
|
||||
owner.add( "name", ti.getLockOwnerName() );
|
||||
owner.add(NAME, ti.getLockOwnerName());
|
||||
owner.add( "id", ti.getLockOwnerId() );
|
||||
}
|
||||
|
||||
|
|
|
@ -17,17 +17,6 @@
|
|||
|
||||
package org.apache.solr.handler.component;
|
||||
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.search.DocList;
|
||||
import org.apache.solr.search.QueryParsing;
|
||||
import org.apache.solr.util.SolrPluginUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
@ -41,7 +30,19 @@ import java.util.Set;
|
|||
import java.util.TreeMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.search.DocList;
|
||||
import org.apache.solr.search.QueryParsing;
|
||||
import org.apache.solr.util.SolrPluginUtils;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.FQ;
|
||||
import static org.apache.solr.common.params.CommonParams.JSON;
|
||||
|
||||
/**
|
||||
* Adds debugging information to a request.
|
||||
|
@ -107,7 +108,7 @@ public class DebugComponent extends SearchComponent
|
|||
}
|
||||
|
||||
if (rb.req.getJSON() != null) {
|
||||
info.add("json", rb.req.getJSON());
|
||||
info.add(JSON, rb.req.getJSON());
|
||||
}
|
||||
|
||||
if (rb.isDebugQuery() && rb.getQparser() != null) {
|
||||
|
|
|
@ -17,12 +17,17 @@
|
|||
|
||||
package org.apache.solr.handler.component;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.index.ExitableDirectoryReader;
|
||||
import org.apache.lucene.util.Version;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.SolrException.ErrorCode;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.common.params.ShardParams;
|
||||
|
@ -43,11 +48,7 @@ import org.apache.solr.util.plugin.SolrCoreAware;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import static org.apache.solr.common.params.CommonParams.PATH;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -307,7 +308,7 @@ public class SearchHandler extends RequestHandlerBase implements SolrCoreAware ,
|
|||
// as the default but operators need to update their luceneMatchVersion to enable
|
||||
// this behavior since it did not work this way prior to 5.1
|
||||
if (req.getCore().getSolrConfig().luceneMatchVersion.onOrAfter(Version.LUCENE_5_1_0)) {
|
||||
String reqPath = (String)req.getContext().get("path");
|
||||
String reqPath = (String) req.getContext().get(PATH);
|
||||
if (!"/select".equals(reqPath)) {
|
||||
params.set(CommonParams.QT, reqPath);
|
||||
} // else if path is /select, then the qt gets passed thru if set
|
||||
|
|
|
@ -30,30 +30,33 @@ import java.util.Map;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.params.UpdateParams;
|
||||
import org.apache.solr.common.util.JsonRecordReader;
|
||||
import org.apache.solr.schema.SchemaField;
|
||||
import org.apache.solr.util.RecordingJSONParser;
|
||||
import org.noggit.JSONParser;
|
||||
import org.noggit.ObjectBuilder;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.SolrInputField;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.params.UpdateParams;
|
||||
import org.apache.solr.common.util.ContentStream;
|
||||
import org.apache.solr.common.util.JsonRecordReader;
|
||||
import org.apache.solr.handler.RequestHandlerUtils;
|
||||
import org.apache.solr.handler.UpdateRequestHandler;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.schema.SchemaField;
|
||||
import org.apache.solr.update.AddUpdateCommand;
|
||||
import org.apache.solr.update.CommitUpdateCommand;
|
||||
import org.apache.solr.update.DeleteUpdateCommand;
|
||||
import org.apache.solr.update.RollbackUpdateCommand;
|
||||
import org.apache.solr.update.processor.UpdateRequestProcessor;
|
||||
import org.apache.solr.util.RecordingJSONParser;
|
||||
import org.noggit.JSONParser;
|
||||
import org.noggit.ObjectBuilder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.JSON;
|
||||
import static org.apache.solr.common.params.CommonParams.PATH;
|
||||
|
||||
|
||||
/**
|
||||
* @since solr 4.0
|
||||
|
@ -64,7 +67,7 @@ public class JsonLoader extends ContentStreamLoader {
|
|||
|
||||
@Override
|
||||
public String getDefaultWT() {
|
||||
return "json";
|
||||
return JSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -115,7 +118,7 @@ public class JsonLoader extends ContentStreamLoader {
|
|||
|
||||
@SuppressWarnings("fallthrough")
|
||||
void processUpdate(Reader reader) throws IOException {
|
||||
String path = (String) req.getContext().get("path");
|
||||
String path = (String) req.getContext().get(PATH);
|
||||
if (UpdateRequestHandler.DOC_PATH.equals(path) || "false".equals(req.getParams().get("json.command"))) {
|
||||
String split = req.getParams().get("split");
|
||||
String[] f = req.getParams().getParams("f");
|
||||
|
|
|
@ -16,8 +16,27 @@ package org.apache.solr.handler.loader;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import javax.xml.stream.FactoryConfigurationError;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.sax.SAXSource;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.solr.client.solrj.request.UpdateRequest;
|
||||
import org.apache.solr.common.SolrException;
|
||||
|
@ -47,26 +66,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.XMLReader;
|
||||
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import javax.xml.stream.FactoryConfigurationError;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.sax.SAXSource;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
|
||||
public class XMLLoader extends ContentStreamLoader {
|
||||
|
@ -467,7 +467,7 @@ public class XMLLoader extends ContentStreamLoader {
|
|||
for (int i = 0; i < parser.getAttributeCount(); i++) {
|
||||
attrName = parser.getAttributeLocalName(i);
|
||||
attrVal = parser.getAttributeValue(i);
|
||||
if ("name".equals(attrName)) {
|
||||
if (NAME.equals(attrName)) {
|
||||
name = attrVal;
|
||||
} else if ("boost".equals(attrName)) {
|
||||
boost = Float.parseFloat(attrVal);
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.solr.logging;
|
|||
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
* Wrapper class for Logger implementaions
|
||||
*/
|
||||
|
@ -44,7 +46,7 @@ public abstract class LoggerInfo implements Comparable<LoggerInfo> {
|
|||
|
||||
public SimpleOrderedMap<?> getInfo() {
|
||||
SimpleOrderedMap<Object> info = new SimpleOrderedMap<>();
|
||||
info.add("name", getName());
|
||||
info.add(NAME, getName());
|
||||
info.add("level", getLevel());
|
||||
info.add("set", isSet());
|
||||
return info;
|
||||
|
|
|
@ -18,6 +18,11 @@ package org.apache.solr.request.json;
|
|||
*/
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
|
@ -25,7 +30,6 @@ import org.apache.solr.common.params.MultiMapSolrParams;
|
|||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.ContentStream;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.handler.component.SearchHandler;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.request.SolrRequestHandler;
|
||||
|
@ -33,10 +37,7 @@ import org.apache.solr.request.macro.MacroExpander;
|
|||
import org.noggit.JSONParser;
|
||||
import org.noggit.ObjectBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import static org.apache.solr.common.params.CommonParams.JSON;
|
||||
|
||||
public class RequestUtil {
|
||||
/**
|
||||
|
@ -65,7 +66,7 @@ public class RequestUtil {
|
|||
req.setParams(params);
|
||||
}
|
||||
|
||||
String[] jsonFromParams = map.remove("json"); // params from the query string should come after (and hence override) JSON content streams
|
||||
String[] jsonFromParams = map.remove(JSON); // params from the query string should come after (and hence override) JSON content streams
|
||||
|
||||
for (ContentStream cs : req.getContentStreams()) {
|
||||
String contentType = cs.getContentType();
|
||||
|
@ -75,7 +76,7 @@ public class RequestUtil {
|
|||
|
||||
try {
|
||||
String jsonString = IOUtils.toString( cs.getReader() );
|
||||
MultiMapSolrParams.addParam("json", jsonString, map);
|
||||
MultiMapSolrParams.addParam(JSON, jsonString, map);
|
||||
} catch (IOException e) {
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Exception reading content stream for request:"+req, e);
|
||||
}
|
||||
|
@ -84,12 +85,12 @@ public class RequestUtil {
|
|||
// append existing "json" params
|
||||
if (jsonFromParams != null) {
|
||||
for (String json : jsonFromParams) {
|
||||
MultiMapSolrParams.addParam("json", json, map);
|
||||
MultiMapSolrParams.addParam(JSON, json, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String[] jsonS = params.getParams("json");
|
||||
String[] jsonS = params.getParams(JSON);
|
||||
|
||||
boolean hasAdditions = defaults != null || invariants != null || appends != null || jsonS != null;
|
||||
|
||||
|
@ -168,12 +169,12 @@ public class RequestUtil {
|
|||
|
||||
Map<String, Object> json = null;
|
||||
// Handle JSON body first, so query params will always overlay on that
|
||||
jsonS = newMap.get("json");
|
||||
jsonS = newMap.get(JSON);
|
||||
if (jsonS != null) {
|
||||
if (json == null) {
|
||||
json = new LinkedHashMap<>();
|
||||
}
|
||||
mergeJSON(json, "json", jsonS, new ObjectUtil.ConflictHandler());
|
||||
mergeJSON(json, JSON, jsonS, new ObjectUtil.ConflictHandler());
|
||||
}
|
||||
for (String key : newMap.keySet()) {
|
||||
// json.nl, json.wrf are existing query parameters
|
||||
|
|
|
@ -36,6 +36,8 @@ import org.apache.solr.search.ReturnFields;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
* @lucene.internal
|
||||
*/
|
||||
|
@ -327,7 +329,7 @@ public class SchemaXmlWriter extends TextResponseWriter {
|
|||
writer.write('<');
|
||||
writer.write(tag);
|
||||
if (name!=null) {
|
||||
writeAttr("name", name);
|
||||
writeAttr(NAME, name);
|
||||
if (closeTag) {
|
||||
writer.write("/>");
|
||||
} else {
|
||||
|
|
|
@ -33,6 +33,8 @@ import org.apache.solr.request.SolrQueryRequest;
|
|||
import org.apache.solr.search.ReturnFields;
|
||||
import org.apache.solr.search.SolrReturnFields;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
|
||||
/**
|
||||
* @lucene.internal
|
||||
|
@ -144,7 +146,7 @@ public class XMLWriter extends TextResponseWriter {
|
|||
writer.write('<');
|
||||
writer.write(tag);
|
||||
if (name!=null) {
|
||||
writeAttr("name", name);
|
||||
writeAttr(NAME, name);
|
||||
if (closeTag) {
|
||||
writer.write("/>");
|
||||
} else {
|
||||
|
@ -167,7 +169,7 @@ public class XMLWriter extends TextResponseWriter {
|
|||
if (doIndent) indent();
|
||||
|
||||
writer.write("<result");
|
||||
writeAttr("name",name);
|
||||
writeAttr(NAME, name);
|
||||
writeAttr("numFound",Long.toString(numFound));
|
||||
writeAttr("start",Long.toString(start));
|
||||
if(maxScore!=null) {
|
||||
|
|
|
@ -16,6 +16,11 @@ package org.apache.solr.rest;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
|
@ -36,11 +41,7 @@ import org.restlet.resource.ResourceException;
|
|||
import org.restlet.resource.ServerResource;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.JSON;
|
||||
|
||||
/**
|
||||
* Base class of all Solr Restlet server resource classes.
|
||||
|
@ -103,7 +104,7 @@ public abstract class BaseSolrResource extends ServerResource {
|
|||
schema = solrRequest.getSchema();
|
||||
String responseWriterName = solrRequest.getParams().get(CommonParams.WT);
|
||||
if (null == responseWriterName) {
|
||||
responseWriterName = "json"; // Default to json writer
|
||||
responseWriterName = JSON; // Default to json writer
|
||||
}
|
||||
String indent = solrRequest.getParams().get("indent");
|
||||
if (null == indent || ! ("off".equals(indent) || "false".equals(indent))) {
|
||||
|
|
|
@ -17,27 +17,37 @@
|
|||
|
||||
package org.apache.solr.schema;
|
||||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.core.KeywordAnalyzer;
|
||||
import org.apache.lucene.analysis.core.KeywordTokenizerFactory;
|
||||
import org.apache.lucene.analysis.util.*;
|
||||
import org.apache.lucene.util.Version;
|
||||
import org.apache.solr.analysis.TokenizerChain;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.util.DOMUtil;
|
||||
import org.apache.solr.core.Config;
|
||||
import org.apache.solr.core.SolrResourceLoader;
|
||||
import org.apache.solr.util.plugin.AbstractPluginLoader;
|
||||
import org.w3c.dom.*;
|
||||
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.core.KeywordAnalyzer;
|
||||
import org.apache.lucene.analysis.core.KeywordTokenizerFactory;
|
||||
import org.apache.lucene.analysis.util.AbstractAnalysisFactory;
|
||||
import org.apache.lucene.analysis.util.CharFilterFactory;
|
||||
import org.apache.lucene.analysis.util.MultiTermAwareComponent;
|
||||
import org.apache.lucene.analysis.util.TokenFilterFactory;
|
||||
import org.apache.lucene.analysis.util.TokenizerFactory;
|
||||
import org.apache.lucene.util.Version;
|
||||
import org.apache.solr.analysis.TokenizerChain;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.core.Config;
|
||||
import org.apache.solr.core.SolrResourceLoader;
|
||||
import org.apache.solr.util.DOMUtil;
|
||||
import org.apache.solr.util.plugin.AbstractPluginLoader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
public final class FieldTypePluginLoader
|
||||
extends AbstractPluginLoader<FieldType> {
|
||||
|
@ -136,7 +146,7 @@ public final class FieldTypePluginLoader
|
|||
@Override
|
||||
protected void init(FieldType plugin, Node node) throws Exception {
|
||||
|
||||
Map<String,String> params = DOMUtil.toMapExcept( node.getAttributes(), "name");
|
||||
Map<String, String> params = DOMUtil.toMapExcept(node.getAttributes(), NAME);
|
||||
plugin.setArgs(schema, params);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,8 @@ import org.apache.solr.search.Sorting;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.JSON;
|
||||
|
||||
/**
|
||||
* Pre-analyzed field type provides a way to index a serialized token stream,
|
||||
* optionally with an independent stored value of a field.
|
||||
|
@ -70,7 +72,7 @@ public class PreAnalyzedField extends FieldType {
|
|||
parser = new JsonPreAnalyzedParser();
|
||||
} else {
|
||||
// short name
|
||||
if ("json".equalsIgnoreCase(implName)) {
|
||||
if (JSON.equalsIgnoreCase(implName)) {
|
||||
parser = new JsonPreAnalyzedParser();
|
||||
} else if ("simple".equalsIgnoreCase(implName)) {
|
||||
parser = new SimplePreAnalyzedParser();
|
||||
|
|
|
@ -17,22 +17,22 @@
|
|||
|
||||
package org.apache.solr.search;
|
||||
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.core.MapSerializable;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.util.DOMUtil;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.core.MapSerializable;
|
||||
import org.apache.solr.core.SolrConfig;
|
||||
import org.apache.solr.core.SolrResourceLoader;
|
||||
import org.apache.solr.util.DOMUtil;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
* Contains the knowledge of how cache config is
|
||||
|
@ -106,9 +106,9 @@ public class CacheConfig implements MapSerializable{
|
|||
}
|
||||
config.args = mapCopy;
|
||||
}
|
||||
String nameAttr = config.args.get("name"); // OPTIONAL
|
||||
String nameAttr = config.args.get(NAME); // OPTIONAL
|
||||
if (nameAttr==null) {
|
||||
config.args.put("name",config.nodeName);
|
||||
config.args.put(NAME, config.nodeName);
|
||||
}
|
||||
|
||||
SolrResourceLoader loader = solrConfig.getResourceLoader();
|
||||
|
|
|
@ -16,12 +16,6 @@ package org.apache.solr.search;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.util.ConcurrentLFUCache;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
@ -30,6 +24,14 @@ import java.util.Set;
|
|||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.util.ConcurrentLFUCache;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
* SolrCache based on ConcurrentLFUCache implementation.
|
||||
* <p>
|
||||
|
@ -64,7 +66,7 @@ public class LFUCache<K, V> implements SolrCache<K, V> {
|
|||
public Object init(Map args, Object persistence, CacheRegenerator regenerator) {
|
||||
state = State.CREATED;
|
||||
this.regenerator = regenerator;
|
||||
name = (String) args.get("name");
|
||||
name = (String) args.get(NAME);
|
||||
String str = (String) args.get("size");
|
||||
int limit = str == null ? 1024 : Integer.parseInt(str);
|
||||
int minLimit;
|
||||
|
|
|
@ -17,17 +17,17 @@
|
|||
|
||||
package org.apache.solr.search;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.core.SolrInfoMBean.Category;
|
||||
import org.apache.solr.search.SolrCache.State;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
* Common base class of reusable functionality for SolrCaches
|
||||
*/
|
||||
|
@ -113,9 +113,9 @@ public abstract class SolrCacheBase {
|
|||
|
||||
public void init(Map<String, String> args, CacheRegenerator regenerator) {
|
||||
this.regenerator = regenerator;
|
||||
state=State.CREATED;
|
||||
name = (String) args.get("name");
|
||||
autowarm = new AutoWarmCountRef((String)args.get("autowarmCount"));
|
||||
state = State.CREATED;
|
||||
name = args.get(NAME);
|
||||
autowarm = new AutoWarmCountRef(args.get("autowarmCount"));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.apache.solr.servlet;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -35,11 +36,8 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
|
@ -52,7 +50,6 @@ import org.apache.solr.common.params.SolrParams;
|
|||
import org.apache.solr.common.util.ContentStream;
|
||||
import org.apache.solr.common.util.ContentStreamBase;
|
||||
import org.apache.solr.common.util.FastInputStream;
|
||||
import org.apache.solr.core.CoreContainer;
|
||||
import org.apache.solr.core.RequestHandlers;
|
||||
import org.apache.solr.core.SolrConfig;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
|
@ -62,6 +59,8 @@ import org.apache.solr.util.RTimer;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.PATH;
|
||||
|
||||
|
||||
public class SolrRequestParsers
|
||||
{
|
||||
|
@ -163,7 +162,7 @@ public class SolrRequestParsers
|
|||
|
||||
// Handlers and login will want to know the path. If it contains a ':'
|
||||
// the handler could use it for RESTful URLs
|
||||
sreq.getContext().put( "path", RequestHandlers.normalize(path) );
|
||||
sreq.getContext().put(PATH, RequestHandlers.normalize(path));
|
||||
sreq.getContext().put("httpMethod", req.getMethod());
|
||||
|
||||
if(addHttpRequestToContext) {
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
|
||||
package org.apache.solr.servlet;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
|
@ -32,12 +35,8 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.solr.cloud.ZkController;
|
||||
|
@ -60,6 +59,7 @@ import org.noggit.ObjectBuilder;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.PATH;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -354,7 +354,7 @@ public final class ZookeeperInfoServlet extends BaseSolrServlet {
|
|||
return;
|
||||
}
|
||||
|
||||
String path = params.get("path");
|
||||
String path = params.get(PATH);
|
||||
String addr = params.get("addr");
|
||||
|
||||
if (addr != null && addr.length() == 0) {
|
||||
|
@ -785,7 +785,7 @@ public final class ZookeeperInfoServlet extends BaseSolrServlet {
|
|||
json.writeNameSeparator();
|
||||
json.startObject();
|
||||
|
||||
writeKeyValue(json, "path", path, true);
|
||||
writeKeyValue(json, PATH, path, true);
|
||||
|
||||
json.writeValueSeparator();
|
||||
json.writeString("prop");
|
||||
|
|
|
@ -37,6 +37,8 @@ import org.apache.solr.search.SolrIndexSearcher;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
* Responsible for loading the lookup and dictionary Implementations specified by
|
||||
* the SolrConfig.
|
||||
|
@ -49,9 +51,6 @@ public class SolrSuggester implements Accountable {
|
|||
/** Name used when an unnamed suggester config is passed */
|
||||
public static final String DEFAULT_DICT_NAME = "default";
|
||||
|
||||
/** Label to identify the name of the suggester */
|
||||
public static final String NAME = "name";
|
||||
|
||||
/** Location of the source data - either a path to a file, or null for the
|
||||
* current IndexReader.
|
||||
* */
|
||||
|
|
|
@ -17,7 +17,12 @@ package org.apache.solr.util;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
|
@ -26,6 +31,8 @@ import org.w3c.dom.NamedNodeMap;
|
|||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -137,7 +144,7 @@ public class DOMUtil {
|
|||
|
||||
final String type = nd.getNodeName();
|
||||
|
||||
final String name = getAttr(nd, "name");
|
||||
final String name = getAttr(nd, NAME);
|
||||
|
||||
Object val=null;
|
||||
|
||||
|
|
|
@ -17,6 +17,25 @@ package org.apache.solr.util;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.net.ConnectException;
|
||||
import java.net.SocketException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.GnuParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
|
@ -53,30 +72,14 @@ import org.apache.solr.common.cloud.Replica;
|
|||
import org.apache.solr.common.cloud.Slice;
|
||||
import org.apache.solr.common.cloud.ZkCoreNodeProps;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.noggit.CharArr;
|
||||
import org.noggit.JSONParser;
|
||||
import org.noggit.JSONWriter;
|
||||
import org.noggit.ObjectBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.net.ConnectException;
|
||||
import java.net.SocketException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
* Command-line utility for working with Solr.
|
||||
|
@ -498,7 +501,7 @@ public class SolrCLI {
|
|||
@SuppressWarnings({"unchecked"})
|
||||
public static Map<String,Object> getJson(HttpClient httpClient, String getUrl) throws Exception {
|
||||
// ensure we're requesting JSON back from Solr
|
||||
HttpGet httpGet = new HttpGet(new URIBuilder(getUrl).setParameter("wt", "json").build());
|
||||
HttpGet httpGet = new HttpGet(new URIBuilder(getUrl).setParameter(CommonParams.WT, CommonParams.JSON).build());
|
||||
// make the request and get back a parsed JSON object
|
||||
Map<String,Object> json = httpClient.execute(httpGet, new SolrResponseHandler());
|
||||
// check the response JSON from Solr to see if it is an error
|
||||
|
@ -793,7 +796,7 @@ public class SolrCLI {
|
|||
|
||||
public Map<String,Object> asMap() {
|
||||
Map<String,Object> map = new LinkedHashMap<String,Object>();
|
||||
map.put("name", name);
|
||||
map.put(NAME, name);
|
||||
map.put("url", url);
|
||||
map.put("numDocs", numDocs);
|
||||
map.put("status", status);
|
||||
|
@ -1043,7 +1046,7 @@ public class SolrCLI {
|
|||
.hasArg()
|
||||
.isRequired(true)
|
||||
.withDescription("Name of collection to create.")
|
||||
.create("name"),
|
||||
.create(NAME),
|
||||
OptionBuilder
|
||||
.withArgName("#")
|
||||
.hasArg()
|
||||
|
@ -1177,7 +1180,7 @@ public class SolrCLI {
|
|||
"there is at least 1 live node in the cluster.");
|
||||
String firstLiveNode = liveNodes.iterator().next();
|
||||
|
||||
String collectionName = cli.getOptionValue("name");
|
||||
String collectionName = cli.getOptionValue(NAME);
|
||||
|
||||
// build a URL to create the collection
|
||||
int numShards = optionAsInt(cli, "shards", 1);
|
||||
|
@ -1322,7 +1325,7 @@ public class SolrCLI {
|
|||
.hasArg()
|
||||
.isRequired(true)
|
||||
.withDescription("Name of the core to create.")
|
||||
.create("name"),
|
||||
.create(NAME),
|
||||
OptionBuilder
|
||||
.withArgName("CONFIG")
|
||||
.hasArg()
|
||||
|
@ -1362,7 +1365,7 @@ public class SolrCLI {
|
|||
}
|
||||
}
|
||||
|
||||
String coreName = cli.getOptionValue("name");
|
||||
String coreName = cli.getOptionValue(NAME);
|
||||
|
||||
String systemInfoUrl = solrUrl+"admin/info/system";
|
||||
CloseableHttpClient httpClient = getHttpClient();
|
||||
|
@ -1453,7 +1456,7 @@ public class SolrCLI {
|
|||
Map<String,Object> existsCheckResult = getJson(coreStatusUrl);
|
||||
Map<String,Object> status = (Map<String, Object>)existsCheckResult.get("status");
|
||||
Map<String,Object> coreStatus = (Map<String, Object>)status.get(coreName);
|
||||
exists = coreStatus != null && coreStatus.containsKey("name");
|
||||
exists = coreStatus != null && coreStatus.containsKey(NAME);
|
||||
} catch (Exception exc) {
|
||||
// just ignore it since we're only interested in a positive result here
|
||||
}
|
||||
|
@ -1529,7 +1532,7 @@ public class SolrCLI {
|
|||
.hasArg()
|
||||
.isRequired(true)
|
||||
.withDescription("Name of the core / collection to delete.")
|
||||
.create("name"),
|
||||
.create(NAME),
|
||||
OptionBuilder
|
||||
.withArgName("true|false")
|
||||
.hasArg()
|
||||
|
@ -1610,7 +1613,7 @@ public class SolrCLI {
|
|||
ZkStateReader zkStateReader = cloudSolrClient.getZkStateReader();
|
||||
String baseUrl = zkStateReader.getBaseUrlForNodeName(firstLiveNode);
|
||||
|
||||
String collectionName = cli.getOptionValue("name");
|
||||
String collectionName = cli.getOptionValue(NAME);
|
||||
|
||||
if (!zkStateReader.getClusterState().hasCollection(collectionName)) {
|
||||
System.err.println("\nERROR: Collection "+collectionName+" not found!");
|
||||
|
@ -1686,7 +1689,7 @@ public class SolrCLI {
|
|||
protected int deleteCore(CommandLine cli, CloseableHttpClient httpClient, String solrUrl) throws Exception {
|
||||
|
||||
int status = 0;
|
||||
String coreName = cli.getOptionValue("name");
|
||||
String coreName = cli.getOptionValue(NAME);
|
||||
String deleteCoreUrl =
|
||||
String.format(Locale.ROOT,
|
||||
"%sadmin/cores?action=UNLOAD&core=%s&deleteIndex=true&deleteDataDir=true&deleteInstanceDir=true",
|
||||
|
|
|
@ -19,17 +19,18 @@ package org.apache.solr.util.plugin;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.SolrException.ErrorCode;
|
||||
import org.apache.solr.util.DOMUtil;
|
||||
import org.apache.solr.core.SolrConfig;
|
||||
import org.apache.solr.core.SolrResourceLoader;
|
||||
import org.apache.solr.util.DOMUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
* An abstract super class that manages standard solr-style plugin configuration.
|
||||
*
|
||||
|
@ -144,7 +145,7 @@ public abstract class AbstractPluginLoader<T>
|
|||
|
||||
String name = null;
|
||||
try {
|
||||
name = DOMUtil.getAttr(node,"name", requireName?type:null);
|
||||
name = DOMUtil.getAttr(node, NAME, requireName ? type : null);
|
||||
String className = DOMUtil.getAttr(node,"class", type);
|
||||
String defaultStr = DOMUtil.getAttr(node,"default", null );
|
||||
|
||||
|
@ -222,7 +223,7 @@ public abstract class AbstractPluginLoader<T>
|
|||
T plugin = null;
|
||||
|
||||
try {
|
||||
String name = DOMUtil.getAttr(node, "name", requireName ? type : null);
|
||||
String name = DOMUtil.getAttr(node, NAME, requireName ? type : null);
|
||||
String className = DOMUtil.getAttr(node, "class", type);
|
||||
plugin = create(loader, name, className, node);
|
||||
log.debug("created " + name + ": " + plugin.getClass().getName());
|
||||
|
@ -265,13 +266,11 @@ public abstract class AbstractPluginLoader<T>
|
|||
* Internal class to hold onto initialization info so that it can be initialized
|
||||
* after it is registered.
|
||||
*/
|
||||
private class PluginInitInfo
|
||||
{
|
||||
private class PluginInitInfo {
|
||||
final T plugin;
|
||||
final Node node;
|
||||
|
||||
PluginInitInfo( T plugin, Node node )
|
||||
{
|
||||
|
||||
PluginInitInfo(T plugin, Node node) {
|
||||
this.plugin = plugin;
|
||||
this.node = node;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ import java.util.Map;
|
|||
import org.apache.solr.util.DOMUtil;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -38,7 +40,7 @@ public class MapPluginLoader<T extends MapInitializedPlugin> extends AbstractPlu
|
|||
|
||||
@Override
|
||||
protected void init(T plugin, Node node) throws Exception {
|
||||
Map<String,String> params = DOMUtil.toMapExcept( node.getAttributes(), "name","class" );
|
||||
Map<String, String> params = DOMUtil.toMapExcept(node.getAttributes(), NAME, "class");
|
||||
plugin.init( params );
|
||||
}
|
||||
|
||||
|
|
|
@ -228,5 +228,9 @@ public interface CommonParams {
|
|||
public static final String JAVABIN = "javabin";
|
||||
|
||||
public static final String JSON = "json";
|
||||
|
||||
public static final String PATH = "path";
|
||||
|
||||
public static final String NAME = "name";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue