mirror of https://github.com/apache/lucene.git
SOLR-6673: Log collection, shard, replica, core name for update and search requests
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1669236 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b741482d58
commit
ed325dc91c
|
@ -36,6 +36,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||||
import org.apache.solr.client.solrj.impl.HttpClientUtil;
|
import org.apache.solr.client.solrj.impl.HttpClientUtil;
|
||||||
|
import org.apache.solr.cloud.CloudDescriptor;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
import org.apache.solr.common.SolrException.ErrorCode;
|
import org.apache.solr.common.SolrException.ErrorCode;
|
||||||
import org.apache.solr.common.cloud.Aliases;
|
import org.apache.solr.common.cloud.Aliases;
|
||||||
|
@ -307,14 +308,15 @@ public class SolrDispatchFilter extends BaseSolrFilter {
|
||||||
|
|
||||||
if (core != null) {
|
if (core != null) {
|
||||||
path = path.substring( idx );
|
path = path.substring( idx );
|
||||||
MDCUtils.setCore(core.getName());
|
addMDCValues(cores, core);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (core == null) {
|
if (core == null) {
|
||||||
if (!cores.isZooKeeperAware() ) {
|
if (!cores.isZooKeeperAware() ) {
|
||||||
core = cores.getCore("");
|
core = cores.getCore("");
|
||||||
if (core != null)
|
if (core != null) {
|
||||||
MDCUtils.setCore(core.getName());
|
addMDCValues(cores, core);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -326,7 +328,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {
|
||||||
if (core != null) {
|
if (core != null) {
|
||||||
// we found a core, update the path
|
// we found a core, update the path
|
||||||
path = path.substring( idx );
|
path = path.substring( idx );
|
||||||
MDCUtils.setCore(core.getName());
|
addMDCValues(cores, core);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we couldn't find it locally, look on other nodes
|
// if we couldn't find it locally, look on other nodes
|
||||||
|
@ -361,7 +363,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {
|
||||||
// try the default core
|
// try the default core
|
||||||
if (core == null) {
|
if (core == null) {
|
||||||
core = cores.getCore("");
|
core = cores.getCore("");
|
||||||
MDCUtils.setCore(core.getName());
|
addMDCValues(cores, core);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,6 +493,16 @@ public class SolrDispatchFilter extends BaseSolrFilter {
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addMDCValues(CoreContainer cores, SolrCore core) {
|
||||||
|
MDCUtils.setCore(core.getName());
|
||||||
|
if (cores.isZooKeeperAware()) {
|
||||||
|
CloudDescriptor cloud = core.getCoreDescriptor().getCloudDescriptor();
|
||||||
|
MDCUtils.setCollection(cloud.getCollectionName());
|
||||||
|
MDCUtils.setShard(cloud.getShardId());
|
||||||
|
MDCUtils.setReplica(cloud.getCoreNodeName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Map<String , Integer> checkStateIsValid(CoreContainer cores, String stateVer) {
|
private Map<String , Integer> checkStateIsValid(CoreContainer cores, String stateVer) {
|
||||||
Map<String, Integer> result = null;
|
Map<String, Integer> result = null;
|
||||||
String[] pairs = null;
|
String[] pairs = null;
|
||||||
|
|
|
@ -11,10 +11,9 @@ import org.apache.log4j.spi.LoggingEvent;
|
||||||
import org.apache.log4j.spi.ThrowableInformation;
|
import org.apache.log4j.spi.ThrowableInformation;
|
||||||
import org.apache.solr.cloud.ZkController;
|
import org.apache.solr.cloud.ZkController;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
|
import org.apache.solr.common.StringUtils;
|
||||||
import org.apache.solr.common.cloud.Replica;
|
import org.apache.solr.common.cloud.Replica;
|
||||||
import org.apache.solr.common.cloud.ZkStateReader;
|
|
||||||
import org.apache.solr.core.SolrCore;
|
import org.apache.solr.core.SolrCore;
|
||||||
import org.apache.solr.logging.MDCUtils;
|
|
||||||
import org.apache.solr.request.SolrQueryRequest;
|
import org.apache.solr.request.SolrQueryRequest;
|
||||||
import org.apache.solr.request.SolrRequestInfo;
|
import org.apache.solr.request.SolrRequestInfo;
|
||||||
import org.slf4j.MDC;
|
import org.slf4j.MDC;
|
||||||
|
@ -371,14 +370,17 @@ public class SolrLogLayout extends Layout {
|
||||||
|
|
||||||
|
|
||||||
private void appendMDC(StringBuilder sb) {
|
private void appendMDC(StringBuilder sb) {
|
||||||
sb.append(" [" + getMDCValueOrEmpty(COLLECTION_PROP) + "] ");
|
if (!StringUtils.isEmpty(MDC.get(COLLECTION_PROP))) {
|
||||||
sb.append("[" + getMDCValueOrEmpty(SHARD_ID_PROP) + "] ");
|
sb.append(" C:").append(MDC.get(COLLECTION_PROP));
|
||||||
sb.append("[" + getMDCValueOrEmpty(REPLICA_PROP) + "] ");
|
}
|
||||||
sb.append("[" + getMDCValueOrEmpty(CORE_NAME_PROP)+"] ");
|
if (!StringUtils.isEmpty(MDC.get(SHARD_ID_PROP))) {
|
||||||
}
|
sb.append(" S:").append(MDC.get(SHARD_ID_PROP));
|
||||||
|
}
|
||||||
private String getMDCValueOrEmpty(String key) {
|
if (!StringUtils.isEmpty(MDC.get(REPLICA_PROP))) {
|
||||||
String val = MDC.get(key);
|
sb.append(" R:").append(MDC.get(REPLICA_PROP));
|
||||||
return val==null? "": val;
|
}
|
||||||
|
if (!StringUtils.isEmpty(MDC.get(CORE_NAME_PROP))) {
|
||||||
|
sb.append(" c:").append(MDC.get(CORE_NAME_PROP));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue