This is an automated email from the ASF dual-hosted git repository.

jbernste pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new a397b2d  SOLR-15755: Parse collection, shard, core, replica info from 
newSearcher events in postlogs tool
a397b2d is described below

commit a397b2d811dfefee22b3ee5743d01df46a2c5362
Author: Joel Bernstein <[email protected]>
AuthorDate: Wed Jan 26 09:30:47 2022 -0500

    SOLR-15755: Parse collection, shard, core, replica info from newSearcher 
events in postlogs tool
---
 solr/bin/postlogs                                  |  4 +--
 .../java/org/apache/solr/util/SolrLogPostTool.java | 36 ++++------------------
 .../org/apache/solr/util/SolrLogPostToolTest.java  | 30 +++++++++---------
 3 files changed, 22 insertions(+), 48 deletions(-)

diff --git a/solr/bin/postlogs b/solr/bin/postlogs
index b08d8d5..98d8e90 100755
--- a/solr/bin/postlogs
+++ b/solr/bin/postlogs
@@ -32,7 +32,5 @@
 
############################################################################################
 
 
-SOLR_TIP=`dirname "$THIS_SCRIPT"`/..
-SOLR_TIP=`cd "$SOLR_TIP"; pwd`
-
+SOLR_TIP="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/..
 java -classpath 
"$SOLR_TIP/server/lib/ext/*:$SOLR_TIP/server/solr-webapp/webapp/WEB-INF/lib/*" 
org.apache.solr.util.SolrLogPostTool $1 $2
diff --git a/solr/core/src/java/org/apache/solr/util/SolrLogPostTool.java 
b/solr/core/src/java/org/apache/solr/util/SolrLogPostTool.java
index eae5d23..365c9fe 100644
--- a/solr/core/src/java/org/apache/solr/util/SolrLogPostTool.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrLogPostTool.java
@@ -189,8 +189,6 @@ public class SolrLogPostTool {
           } else if (line.contains(" ERROR ")) {
             this.cause = null;
             parseError(lineDoc, line, readTrace());
-          } else if (line.contains("start commit")) {
-            parseCommit(lineDoc, line);
           } else if(line.contains("QTime=")) {
             parseQueryRecord(lineDoc, line);
           }
@@ -286,18 +284,6 @@ public class SolrLogPostTool {
       lineRecord.setField("replica_s", parseReplica(line));
     }
 
-    private void parseCommit(SolrInputDocument lineRecord, String line) throws 
IOException {
-      lineRecord.setField("type_s", "commit");
-      lineRecord.setField("soft_commit_s", 
Boolean.toString(line.contains("softCommit=true")));
-
-      lineRecord.setField("open_searcher_s", 
Boolean.toString(line.contains("openSearcher=true")));
-
-      lineRecord.setField("collection_s", parseCollection(line));
-      lineRecord.setField("core_s", parseCore(line));
-      lineRecord.setField("shard_s", parseShard(line));
-      lineRecord.setField("replica_s", parseReplica(line));
-    }
-
     private void parseQueryRecord(SolrInputDocument lineRecord, String line) {
       lineRecord.setField("qtime_i", parseQTime(line));
       lineRecord.setField("status_s", parseStatus(line));
@@ -331,10 +317,12 @@ public class SolrLogPostTool {
       }
     }
 
-
     private void parseNewSearch(SolrInputDocument lineRecord, String line) {
-      lineRecord.setField("core_s", parseNewSearcherCore(line));
+      lineRecord.setField("core_s", parseCore(line));
       lineRecord.setField("type_s", "newSearcher");
+      lineRecord.setField("collection_s", parseCollection(line));
+      lineRecord.setField("shard_s", parseShard(line));
+      lineRecord.setField("replica_s", parseReplica(line));
     }
 
     private String parseCollection(String line) {
@@ -352,6 +340,8 @@ public class SolrLogPostTool {
         lineRecord.setField("type_s", "deleteByQuery");
       } else if(line.contains("delete=")) {
         lineRecord.setField("type_s", "delete");
+      } else if(line.contains("commit=true")) {
+        lineRecord.setField("type_s", "commit");
       } else {
         lineRecord.setField("type_s", "update");
       }
@@ -362,20 +352,6 @@ public class SolrLogPostTool {
       lineRecord.setField("replica_s", parseReplica(line));
     }
 
-    private String parseNewSearcherCore(String line) {
-      String xCore = parseCore(line);
-      if (xCore != null) {
-        return xCore;
-      }
-      // pre Solr 9
-      char[] ca = {']'};
-      String parts[] = line.split("\\[");
-      if(parts.length > 3) {
-        return readUntil(parts[2], ca);
-      } else {
-        return null;
-      }
-    }
 
     private String parseCore(String line) {
       char[] ca = {' ', ']', '}', ','};
diff --git a/solr/core/src/test/org/apache/solr/util/SolrLogPostToolTest.java 
b/solr/core/src/test/org/apache/solr/util/SolrLogPostToolTest.java
index 5be6469..19ff8bf 100644
--- a/solr/core/src/test/org/apache/solr/util/SolrLogPostToolTest.java
+++ b/solr/core/src/test/org/apache/solr/util/SolrLogPostToolTest.java
@@ -268,43 +268,43 @@ public class SolrLogPostToolTest extends SolrTestCaseJ4 {
 
   @Test
   public void testCommit() throws Exception{
-    String record = "2019-12-16T14:20:19.708 INFO  (qtp812143047-22671) 
[c:production_201912 s:shard128 r:core_node7 
x:production_201912_shard128_replica] o.a.s.u.DirectUpdateHandler2 start 
commit{_version_=1653086376121335808,optimize=false,openSearcher=true,waitSearcher=true,expungeDeletes=false,softCommit=false,prepareCommit=false}\n";
+    String record = "2021-10-08 16:42:10.636 INFO  (qtp1080476785-26) 
[c:collection1 s:shard1 r:core_node2 x:collection1_shard1_replica_n1] 
o.a.s.u.p.LogUpdateProcessorFactory [collection1_shard1_replica_n1]  
webapp=/solr path=/update 
params={waitSearcher=true&commit=true&softCommit=false&wt=javabin&version=2}{commit=}
 0 152";
     List<SolrInputDocument> docs = readDocs(record);
     assertEquals(docs.size(), 1);
     SolrInputDocument doc = docs.get(0);
-
     SolrInputField date = doc.getField("date_dt");
     SolrInputField type = doc.getField("type_s");
     SolrInputField shard = doc.getField("shard_s");
     SolrInputField replica = doc.getField("replica_s");
     SolrInputField core = doc.getField("core_s");
-    SolrInputField openSearcher = doc.getField("open_searcher_s");
-    SolrInputField softCommit = doc.getField("soft_commit_s");
     SolrInputField collection = doc.getField("collection_s");
-
-    assertEquals(date.getValue(), "2019-12-16T14:20:19.708Z");
+    assertEquals(date.getValue(), "2021-10-08T16:42:10.636Z");
     assertEquals(type.getValue(), "commit");
-    assertEquals(shard.getValue(), "shard128");
-    assertEquals(replica.getValue(), "core_node7");
-    assertEquals(core.getValue(), "production_201912_shard128_replica");
-    assertEquals(openSearcher.getValue(), "true");
-    assertEquals(softCommit.getValue(), "false");
-    assertEquals(collection.getValue(), "production_201912");
+    assertEquals(shard.getValue(), "shard1");
+    assertEquals(replica.getValue(), "core_node2");
+    assertEquals(core.getValue(), "collection1_shard1_replica_n1");
+    assertEquals(collection.getValue(), "collection1");
   }
 
+
   @Test
   public void testNewSearcher() throws Exception{
     String record = sometimesSolr9Format(
-        "2019-12-16 19:00:23.931 INFO  (searcherExecutor-66-thread-1) [ 
x:production_cv_month_201912_shard35_replica_n1] o.a.s.c.SolrCore 
[production_cv_month_201912_shard35_replica_n1] Registered new searcher 
Searcher@16ef5fac[production_cv_month_201912_shard35_replica_n1] ...");
+"2022-01-25 20:01:15.903 INFO  
(searcherExecutor-19-thread-1-processing-localhost:8983_solr 
test_shard1_replica_n1 test shard1 core_node2) [c:test s:shard1 r:core_node2 
x:test_shard1_replica_n1] o.a.s.c.SolrCore Registered new searcher autowarm 
time: 0 ms");
+
     List<SolrInputDocument> docs = readDocs(record);
     assertEquals(docs.size(), 1);
     SolrInputDocument doc = docs.get(0);
     SolrInputField date = doc.getField("date_dt");
     SolrInputField type = doc.getField("type_s");
     SolrInputField core = doc.getField("core_s");
-    assertEquals(date.getValue(), "2019-12-16T19:00:23.931Z");
+    SolrInputField replica = doc.getField("replica_s");
+    SolrInputField collection = doc.getField("collection_s");
+    assertEquals(date.getValue(), "2022-01-25T20:01:15.903Z");
     assertEquals(type.getValue(), "newSearcher");
-    assertEquals(core.getValue(), 
"production_cv_month_201912_shard35_replica_n1");
+    assertEquals(core.getValue(), "test_shard1_replica_n1");
+    assertEquals(replica.getValue(), "core_node2");
+    assertEquals(collection.getValue(), "test");
   }
 
   // Ensure SolrLogPostTool parses _all_ log lines into searchable records

Reply via email to