Apache Lucene open-source search software
SOLR-350 -- removing name from log if it is null
Ryan McKinleyaa3db299e4a7
diff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.javaindex 0dbfaf3f952..251508a1528 100644--- a/src/java/org/apache/solr/core/SolrCore.java+++ b/src/java/org/apache/solr/core/SolrCore.java@@ -84,6 +84,8 @@ public final class SolrCore {public static Logger log = Logger.getLogger(SolrCore.class.getName());private String name;+ private String logid; // used to show what name is set+private final SolrConfig solrConfig;private final IndexSchema schema;private final String dataDir;@@ -139,6 +141,12 @@ public final class SolrCore {public void setName(String v) {this.name = v;+ this.logid = (v==null)?"":("["+v+"] ");+ }++ public String getLogId()+ {+ return this.logid;}/**@@ -151,7 +159,7 @@ public final class SolrCore {public List<SolrEventListener> parseListener(String path) {List<SolrEventListener> lst = new ArrayList<SolrEventListener>();- log.info( "["+name+"] Searching for listeners: " +path);+ log.info( logid+"Searching for listeners: " +path);NodeList nodes = (NodeList)solrConfig.evaluate(path, XPathConstants.NODESET);if (nodes!=null) {for (int i=0; i<nodes.getLength(); i++) {@@ -160,7 +168,7 @@ public final class SolrCore {SolrEventListener listener = createEventListener(className);listener.init(DOMUtil.childNodesToNamedList(node));lst.add(listener);- log.info( "["+name+"] Added SolrEventListener: " + listener);+ log.info( logid+"Added SolrEventListener: " + listener);}}return lst;@@ -194,7 +202,7 @@ public final class SolrCore {// if it didn't exist already...Directory dir = FSDirectory.getDirectory(dirFile, !indexExists);if (IndexReader.isLocked(dir)) {- log.warning("["+name+"] WARNING: Solr index directory '" + getIndexDir() + "' is locked. Unlocking...");+ log.warning(logid+"WARNING: Solr index directory '" + getIndexDir() + "' is locked. Unlocking...");IndexReader.unlock(dir);}}@@ -202,7 +210,7 @@ public final class SolrCore {// Create the index if it doesn't exist. Note that indexExists was tested *before*// lock removal, since that will result in the creation of the directory.if(!indexExists) {- log.warning("["+name+"] Solr index directory '" + dirFile + "' doesn't exist."+ log.warning(logid+"Solr index directory '" + dirFile + "' doesn't exist."+ " Creating new index...");SolrIndexWriter writer = new SolrIndexWriter("SolrCore.initIndex",getIndexDir(), true, schema, solrConfig.mainIndexConfig);@@ -267,7 +275,7 @@ public final class SolrCore {if( instance == null ) {try {// sets 'instance' to the latest solr core- instance = new SolrCore("default", null, new SolrConfig(), null);+ instance = new SolrCore( null, null, new SolrConfig(), null);} catch(Exception xany) {throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"error creating core", xany );@@ -278,7 +286,7 @@ public final class SolrCore {}public SolrCore(String dataDir, IndexSchema schema) throws ParserConfigurationException, IOException, SAXException {- this( "core", dataDir, new SolrConfig(), schema );+ this( null, dataDir, new SolrConfig(), schema );}/**@@ -293,13 +301,13 @@ public final class SolrCore {// this is for backward compatibility (and also the reason// the sync block is needed)instance = this; // set singleton- this.name = name;+ this.setName( name );SolrResourceLoader loader = config.getResourceLoader();if (dataDir ==null) {dataDir = config.get("dataDir",loader.getInstanceDir()+"data");}- log.info("["+name+"] Opening new SolrCore at " + loader.getInstanceDir() + ", dataDir="+dataDir);+ log.info(logid+"Opening new SolrCore at " + loader.getInstanceDir() + ", dataDir="+dataDir);if (schema==null) {schema = new IndexSchema(config, "schema.xml");@@ -398,7 +406,7 @@ public final class SolrCore {}public void close() {- log.info("["+name+"] CLOSING SolrCore!");+ log.info(logid+"CLOSING SolrCore!");try {closeSearcher();} catch (Exception e) {@@ -622,16 +630,16 @@ public final class SolrCore {onDeckSearchers++;if (onDeckSearchers < 1) {// should never happen... just a sanity check- log.severe("["+name+"] ERROR!!! onDeckSearchers is " + onDeckSearchers);+ log.severe(logid+"ERROR!!! onDeckSearchers is " + onDeckSearchers);onDeckSearchers=1; // reset} else if (onDeckSearchers > maxWarmingSearchers) {onDeckSearchers--;String msg="Error opening new searcher. exceeded limit of maxWarmingSearchers="+maxWarmingSearchers + ", try again later.";- log.warning("["+name+"] "+ msg);+ log.warning(logid+""+ msg);// HTTP 503==service unavailable, or 409==Conflictthrow new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE,msg,true);} else if (onDeckSearchers > 1) {- log.info("["+name+"] PERFORMANCE WARNING: Overlapping onDeckSearchers=" + onDeckSearchers);+ log.info(logid+"PERFORMANCE WARNING: Overlapping onDeckSearchers=" + onDeckSearchers);}}@@ -791,7 +799,7 @@ public final class SolrCore {}if (onDeckSearchers < 0) {// sanity check... should never happen- log.severe("["+name+"] ERROR!!! onDeckSearchers after decrement=" + onDeckSearchers);+ log.severe(logid+"ERROR!!! onDeckSearchers after decrement=" + onDeckSearchers);onDeckSearchers=0; // try and recover}// if we failed, we need to wake up at least one waiter to continue the process@@ -840,7 +848,7 @@ public final class SolrCore {SolrIndexSearcher newSearcher = newSearcherHolder.get();newSearcher.register(); // register subitems (caches)- log.info("["+name+"] Registered new searcher " + newSearcher);+ log.info(logid+"Registered new searcher " + newSearcher);} catch (Throwable e) {log(e);@@ -856,7 +864,7 @@ public final class SolrCore {public void closeSearcher() {- log.info("["+name+"] Closing main searcher on request.");+ log.info(logid+"Closing main searcher on request.");synchronized (searcherLock) {if (_searcher != null) {_searcher.decref(); // dec refcount for this._searcher@@ -869,7 +877,7 @@ public final class SolrCore {public void execute(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp) {if (handler==null) {- log.warning("["+name+"] Null Request Handler '" + req.getQueryType() +"' :" + req);+ log.warning(logid+"Null Request Handler '" + req.getQueryType() +"' :" + req);throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"Null Request Handler '" + req.getQueryType() + "'", true);}// setup response header and handle request@@ -878,7 +886,7 @@ public final class SolrCore {handler.handleRequest(req,rsp);setResponseHeaderValues(handler,responseHeader,req,rsp);- log.info("["+name+"] " + req.getContext().get("path") + " "+ log.info(logid+"" + req.getContext().get("path") + " "+ req.getParamString()+ " 0 "+(int)(rsp.getEndTime() - req.getStartTime()));}@@ -887,7 +895,7 @@ public final class SolrCore {public void execute(SolrQueryRequest req, SolrQueryResponse rsp) {SolrRequestHandler handler = getRequestHandler(req.getQueryType());if (handler==null) {- log.warning("["+name+"] Unknown Request Handler '" + req.getQueryType() +"' :" + req);+ log.warning(logid+"Unknown Request Handler '" + req.getQueryType() +"' :" + req);throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Unknown Request Handler '" + req.getQueryType() + "'", true);}execute(handler, req, rsp);diff --git a/src/java/org/apache/solr/update/DirectUpdateHandler.java b/src/java/org/apache/solr/update/DirectUpdateHandler.javaindex 5e0ac5db1fb..824272eeb8e 100644--- a/src/java/org/apache/solr/update/DirectUpdateHandler.java+++ b/src/java/org/apache/solr/update/DirectUpdateHandler.java@@ -135,7 +135,7 @@ public class DirectUpdateHandler extends UpdateHandler {Term term = new Term(idField.getName(), indexedId);num = ir.deleteDocuments(term);if (core.log.isLoggable(Level.FINEST)) {- core.log.finest( "["+core.getName()+"] deleted " + num + " docs matching id " + idFieldType.indexedToReadable(indexedId));+ core.log.finest( core.getLogId()+"deleted " + num + " docs matching id " + idFieldType.indexedToReadable(indexedId));}} finally {try { if (tdocs != null) tdocs.close(); } catch (Exception e) {}@@ -203,7 +203,7 @@ public class DirectUpdateHandler extends UpdateHandler {}if (core.log.isLoggable(Level.FINE)) {- core.log.fine("["+core.getName()+"] docs deleted:" + totDeleted);+ core.log.fine(core.getLogId()+"docs deleted:" + totDeleted);}}diff --git a/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/src/java/org/apache/solr/update/DirectUpdateHandler2.javaindex cd297a1fa84..c82d9b37671 100644--- a/src/java/org/apache/solr/update/DirectUpdateHandler2.java+++ b/src/java/org/apache/solr/update/DirectUpdateHandler2.java@@ -176,7 +176,7 @@ public class DirectUpdateHandler2 extends UpdateHandler {// must only be called when iwCommit lock heldprivate void deleteAll() throws IOException {- core.log.info("["+core.getName()+"] REMOVING ALL DOCUMENTS FROM INDEX");+ core.log.info(core.getLogId()+"REMOVING ALL DOCUMENTS FROM INDEX");closeWriter();closeSearcher();pset.clear(); // ignore docs marked for deletion since we are removing all@@ -377,7 +377,7 @@ public class DirectUpdateHandler2 extends UpdateHandler {if (!delAll) {if (core.log.isLoggable(Level.FINE)) {- core.log.fine("["+core.getName()+"] docs deleted by query:" + totDeleted);+ core.log.fine(core.getLogId()+"docs deleted by query:" + totDeleted);}numDocsDeleted.getAndAdd(totDeleted);}diff --git a/src/java/org/apache/solr/util/TestHarness.java b/src/java/org/apache/solr/util/TestHarness.javaindex 0f7bb1a62d4..cd6f81333f5 100644--- a/src/java/org/apache/solr/util/TestHarness.java+++ b/src/java/org/apache/solr/util/TestHarness.java@@ -124,7 +124,7 @@ public class TestHarness {SolrConfig solrConfig,IndexSchema indexSchema) {try {- core = new SolrCore( "test-"+System.currentTimeMillis(), dataDirectory, solrConfig, indexSchema);+ core = new SolrCore( null, dataDirectory, solrConfig, indexSchema);builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();updater = new XmlUpdateRequestHandler();diff --git a/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java b/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.javaindex 5da52405ef7..95653af7e64 100644--- a/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java+++ b/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java@@ -107,7 +107,7 @@ public class DirectSolrConnection// If the Data directory is specified, initialize SolrCore directlyIndexSchema schema = new IndexSchema(config, instanceDir+"/conf/schema.xml");- core = new SolrCore( "core", dataDir, config, schema );+ core = new SolrCore( null, dataDir, config, schema );parser = new SolrRequestParsers( true, Long.MAX_VALUE );}catch (Exception ee) {diff --git a/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java b/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.javaindex c46bae60f00..b977da1b001 100644--- a/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java+++ b/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java@@ -82,7 +82,7 @@ public class SolrDispatchFilter implements Filtersinglecore = null;}else {- singlecore = new SolrCore( "core", null, new SolrConfig(), null );+ singlecore = new SolrCore( null, null, new SolrConfig(), null );core = singlecore;}