mirror of https://github.com/apache/lucene.git
SOLR-6533: logging added and formatting fixed
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1658916 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
78e1153dcb
commit
648eebbe92
|
@ -2148,6 +2148,7 @@ public final class ZkController {
|
|||
try {
|
||||
try {
|
||||
zkClient.setData(resourceLocation, content, znodeVersion, true);
|
||||
log.info("Persisted config data to node {} ", resourceLocation);
|
||||
touchConfDir(zkLoader);
|
||||
} catch (NoNodeException e) {
|
||||
if (createIfNotExists) {
|
||||
|
|
|
@ -91,7 +91,8 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
String httpMethod = (String) req.getContext().get("httpMethod");
|
||||
Command command = new Command(req, rsp, httpMethod);
|
||||
if ("POST".equals(httpMethod)) {
|
||||
if(configEditing_disabled) throw new SolrException(SolrException.ErrorCode.FORBIDDEN," solrconfig editing is not enabled");
|
||||
if (configEditing_disabled)
|
||||
throw new SolrException(SolrException.ErrorCode.FORBIDDEN, " solrconfig editing is not enabled");
|
||||
command.handlePOST();
|
||||
} else {
|
||||
command.handleGET();
|
||||
|
@ -204,7 +205,6 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
}
|
||||
|
||||
|
||||
|
||||
private void handleParams(ArrayList<CommandOperation> ops, RequestParams params) {
|
||||
for (CommandOperation op : ops) {
|
||||
switch (op.name) {
|
||||
|
@ -327,6 +327,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
}
|
||||
List errs = CommandOperation.captureErrors(ops);
|
||||
if (!errs.isEmpty()) {
|
||||
log.info("Failed to run commands errors are {}", StrUtils.join(errs, ','));
|
||||
resp.add(CommandOperation.ERR_MSGS, errs);
|
||||
return;
|
||||
}
|
||||
|
@ -336,12 +337,15 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
ZkController.persistConfigResourceToZooKeeper((ZkSolrResourceLoader) loader, overlay.getZnodeVersion(),
|
||||
ConfigOverlay.RESOURCE_NAME, overlay.toByteArray(), true);
|
||||
|
||||
log.info("Executed config commands successfully and persited to ZK {}", ops);
|
||||
} else {
|
||||
SolrResourceLoader.persistConfLocally(loader, ConfigOverlay.RESOURCE_NAME, overlay.toByteArray());
|
||||
req.getCore().getCoreDescriptor().getCoreContainer().reload(req.getCore().getName());
|
||||
log.info("Executed config commands successfully and persited to File System {}", ops);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ConfigOverlay deleteNamedComponent(CommandOperation op, ConfigOverlay overlay, String typ) {
|
||||
String name = op.getStr(CommandOperation.ROOT_OBJ);
|
||||
if (op.hasError()) return overlay;
|
||||
|
@ -417,7 +421,6 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
}
|
||||
|
||||
|
||||
|
||||
private ConfigOverlay applyUnset(CommandOperation op, ConfigOverlay overlay) {
|
||||
List<String> name = op.getStrs(CommandOperation.ROOT_OBJ);
|
||||
if (op.hasError()) return overlay;
|
||||
|
@ -485,8 +488,10 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
|
||||
private static Set<String> subPaths = new HashSet<>(Arrays.asList("/overlay", "/params",
|
||||
"/query", "/jmx", "/requestDispatcher"));
|
||||
|
||||
static {
|
||||
for (SolrConfig.SolrPluginInfo solrPluginInfo : SolrConfig.plugins) subPaths.add("/"+solrPluginInfo.tag.replaceAll("/",""));
|
||||
for (SolrConfig.SolrPluginInfo solrPluginInfo : SolrConfig.plugins)
|
||||
subPaths.add("/" + solrPluginInfo.tag.replaceAll("/", ""));
|
||||
|
||||
}
|
||||
|
||||
|
@ -510,7 +515,6 @@ public class SolrConfigHandler extends RequestHandlerBase {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public static final String SET_PROPERTY = "set-property";
|
||||
public static final String UNSET_PROPERTY = "unset-property";
|
||||
public static final String SET_USER_PROPERTY = "set-user-property";
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.solr.util;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -26,11 +27,14 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.noggit.JSONParser;
|
||||
import org.noggit.ObjectBuilder;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
|
||||
|
||||
public class CommandOperation {
|
||||
|
@ -92,10 +96,12 @@ public class CommandOperation {
|
|||
return val;
|
||||
|
||||
}
|
||||
|
||||
static final String REQD = "''{0}'' is a required field";
|
||||
|
||||
|
||||
/**Get collection of values for a key. If only one val is present a
|
||||
/**
|
||||
* Get collection of values for a key. If only one val is present a
|
||||
* single value collection is returned
|
||||
*/
|
||||
public List<String> getStrs(String key, List<String> def) {
|
||||
|
@ -122,7 +128,8 @@ public class CommandOperation {
|
|||
|
||||
}
|
||||
|
||||
/**Get a required field. If missing it adds to the errors
|
||||
/**
|
||||
* Get a required field. If missing it adds to the errors
|
||||
*/
|
||||
public String getStr(String key) {
|
||||
if (ROOT_OBJ.equals(key)) {
|
||||
|
@ -151,7 +158,8 @@ public class CommandOperation {
|
|||
errors.add(s);
|
||||
}
|
||||
|
||||
/**Get all the values from the metadata for the command
|
||||
/**
|
||||
* Get all the values from the metadata for the command
|
||||
* without the specified keys
|
||||
*/
|
||||
public Map getValuesExcluding(String... keys) {
|
||||
|
@ -169,8 +177,10 @@ public class CommandOperation {
|
|||
public List<String> getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
public static final String ERR_MSGS = "errorMessages";
|
||||
public static final String ROOT_OBJ = "";
|
||||
|
||||
public static List<Map> captureErrors(List<CommandOperation> ops) {
|
||||
List<Map> errors = new ArrayList<>();
|
||||
for (CommandOperation op : ops) {
|
||||
|
@ -182,7 +192,8 @@ public class CommandOperation {
|
|||
}
|
||||
|
||||
|
||||
/**Parse the command operations into command objects
|
||||
/**
|
||||
* Parse the command operations into command objects
|
||||
*/
|
||||
public static List<CommandOperation> parse(Reader rdr) throws IOException {
|
||||
JSONParser parser = new JSONParser(rdr);
|
||||
|
@ -210,6 +221,7 @@ public class CommandOperation {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public CommandOperation getCopy() {
|
||||
return new CommandOperation(name, commandData);
|
||||
}
|
||||
|
@ -225,4 +237,14 @@ public class CommandOperation {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
try {
|
||||
return new String(ZkStateReader.toJSON(singletonMap(name, commandData)), IOUtils.UTF_8);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
//should not happen
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue