SOLR-14363: Separate /get requests into their own type designation (#1379)

This commit is contained in:
Jason Gerlowski 2020-04-01 08:41:48 -04:00 committed by GitHub
parent 46d011645c
commit 1f5705ff5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 3 deletions

View File

@ -28,6 +28,7 @@ import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField;
/**
@ -277,6 +278,9 @@ public class SolrLogPostTool {
doc.addField("qtime_i", parseQTime(line));
doc.addField("status_s", parseStatus(line));
String path = parsePath(line);
doc.addField("path_s", path);
if(line.contains("hits=")) {
doc.addField("hits_l", parseHits(line));
}
@ -291,12 +295,13 @@ public class SolrLogPostTool {
doc.addField("shard_s", parseShard(line));
doc.addField("replica_s", parseReplica(line));
String path = parsePath(line);
doc.addField("path_s", path);
if(path != null && path.contains("/admin")) {
doc.addField("type_s", "admin");
} else if(path != null && params.contains("/replication")) {
doc.addField("type_s", "replication");
} else if (path != null && path.contains("/get")) {
doc.addField("type_s", "get");
} else {
doc.addField("type_s", "query");
}
@ -487,7 +492,7 @@ public class SolrLogPostTool {
doc.addField("shards_s", "true");
}
if(parts[0].equals("ids")) {
if(parts[0].equals("ids") && ! isRTGRequest(doc)) {
doc.addField("ids_s", "true");
}
@ -524,5 +529,13 @@ public class SolrLogPostTool {
doc.addField("ids_s", "false");
}
}
private boolean isRTGRequest(SolrInputDocument doc) {
final SolrInputField path = doc.getField("path_s");
if (path == null) return false;
return "/get".equals(path.getValue());
}
}
}

View File

@ -69,7 +69,27 @@ public class SolrLogPostToolTest extends SolrTestCaseJ4 {
assertEquals(isShard.getValue(), "true");
assertEquals(ids.getValue(), "false");
assertEquals(shards.getValue(), "false");
}
@Test
public void testRTGRecord() throws Exception {
final String record = "2020-03-19 20:00:30.845 INFO (qtp1635378213-20354) [c:logs4 s:shard8 r:core_node63 x:logs4_shard8_replica_n60] o.a.s.c.S.Request [logs4_shard8_replica_n60] webapp=/solr path=/get params={qt=/get&_stateVer_=logs4:104&ids=id1&ids=id2&ids=id3&wt=javabin&version=2} status=0 QTime=61";
List<SolrInputDocument> docs = readDocs(record);
assertEquals(docs.size(), 1);
SolrInputDocument doc = docs.get(0);
assertEquals(doc.getField("type_s").getValue(), "get");
assertEquals(doc.getField("date_dt").getValue(), "2020-03-19T20:00:30.845");
assertEquals(doc.getField("collection_s").getValue(), "logs4");
assertEquals(doc.getField("path_s").getValue(), "/get");
assertEquals(doc.getField("status_s").getValue(), "0");
assertEquals(doc.getField("shard_s").getValue(), "shard8");
assertEquals(doc.getField("replica_s").getValue(), "core_node63");
assertEquals(doc.getField("core_s").getValue(), "logs4_shard8_replica_n60");
assertEquals(doc.getField("wt_s").getValue(), "javabin");
assertEquals(doc.getField("distrib_s").getValue(), "true");
assertEquals(doc.getField("ids_s").getValue(), "false");
}
@Test