[Rename] Fix imports in the libs module. (#385)

Signed-off-by: Rabi Panda <adnapibar@gmail.com>
This commit is contained in:
Rabi Panda 2021-03-18 06:33:37 -07:00 committed by Nick Knize
parent 2df59c4a4b
commit 1bdfbb4ef1
2 changed files with 73 additions and 73 deletions

View File

@ -32,7 +32,7 @@ import java.util.Collection;
* *
* This differs from a morton encoded value which interleaves lat/lon (y/x). * This differs from a morton encoded value which interleaves lat/lon (y/x).
* *
* NOTE: this will replace {@code org.elasticsearch.common.geo.GeoHashUtils} * NOTE: this will replace {@code org.opensearch.common.geo.GeoHashUtils}
*/ */
public class Geohash { public class Geohash {
private static final char[] BASE_32 = {'0', '1', '2', '3', '4', '5', '6', private static final char[] BASE_32 = {'0', '1', '2', '3', '4', '5', '6',

View File

@ -53,20 +53,20 @@ import static org.hamcrest.Matchers.nullValue;
public class GrokTests extends OpenSearchTestCase { public class GrokTests extends OpenSearchTestCase {
public void testMatchWithoutCaptures() { public void testMatchWithoutCaptures() {
Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "value", logger::warn); Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "value", logger::warn);
assertThat(grok.captures("value"), equalTo(org.elasticsearch.common.collect.Map.of())); assertThat(grok.captures("value"), equalTo(org.opensearch.common.collect.Map.of()));
assertThat(grok.captures("prefix_value"), equalTo(org.elasticsearch.common.collect.Map.of())); assertThat(grok.captures("prefix_value"), equalTo(org.opensearch.common.collect.Map.of()));
assertThat(grok.captures("no_match"), nullValue()); assertThat(grok.captures("no_match"), nullValue());
} }
public void testCaputuresBytes() { public void testCaputuresBytes() {
Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{NUMBER:n:int}", logger::warn); Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{NUMBER:n:int}", logger::warn);
byte[] utf8 = "10".getBytes(StandardCharsets.UTF_8); byte[] utf8 = "10".getBytes(StandardCharsets.UTF_8);
assertThat(captureBytes(grok, utf8, 0, utf8.length), equalTo(org.elasticsearch.common.collect.Map.of("n", 10))); assertThat(captureBytes(grok, utf8, 0, utf8.length), equalTo(org.opensearch.common.collect.Map.of("n", 10)));
assertThat(captureBytes(grok, utf8, 0, 1), equalTo(org.elasticsearch.common.collect.Map.of("n", 1))); assertThat(captureBytes(grok, utf8, 0, 1), equalTo(org.opensearch.common.collect.Map.of("n", 1)));
utf8 = "10 11 12".getBytes(StandardCharsets.UTF_8); utf8 = "10 11 12".getBytes(StandardCharsets.UTF_8);
assertThat(captureBytes(grok, utf8, 0, 2), equalTo(org.elasticsearch.common.collect.Map.of("n", 10))); assertThat(captureBytes(grok, utf8, 0, 2), equalTo(org.opensearch.common.collect.Map.of("n", 10)));
assertThat(captureBytes(grok, utf8, 3, 2), equalTo(org.elasticsearch.common.collect.Map.of("n", 11))); assertThat(captureBytes(grok, utf8, 3, 2), equalTo(org.opensearch.common.collect.Map.of("n", 11)));
assertThat(captureBytes(grok, utf8, 6, 2), equalTo(org.elasticsearch.common.collect.Map.of("n", 12))); assertThat(captureBytes(grok, utf8, 6, 2), equalTo(org.opensearch.common.collect.Map.of("n", 12)));
} }
private Map<String, Object> captureBytes(Grok grok, byte[] utf8, int offset, int length) { private Map<String, Object> captureBytes(Grok grok, byte[] utf8, int offset, int length) {
@ -87,15 +87,15 @@ public class GrokTests extends OpenSearchTestCase {
Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{SYSLOGLINE}", logger::warn); Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{SYSLOGLINE}", logger::warn);
assertCaptureConfig( assertCaptureConfig(
grok, grok,
org.elasticsearch.common.collect.Map.ofEntries( org.opensearch.common.collect.Map.ofEntries(
org.elasticsearch.common.collect.Map.entry("facility", STRING), org.opensearch.common.collect.Map.entry("facility", STRING),
org.elasticsearch.common.collect.Map.entry("logsource", STRING), org.opensearch.common.collect.Map.entry("logsource", STRING),
org.elasticsearch.common.collect.Map.entry("message", STRING), org.opensearch.common.collect.Map.entry("message", STRING),
org.elasticsearch.common.collect.Map.entry("pid", STRING), org.opensearch.common.collect.Map.entry("pid", STRING),
org.elasticsearch.common.collect.Map.entry("priority", STRING), org.opensearch.common.collect.Map.entry("priority", STRING),
org.elasticsearch.common.collect.Map.entry("program", STRING), org.opensearch.common.collect.Map.entry("program", STRING),
org.elasticsearch.common.collect.Map.entry("timestamp", STRING), org.opensearch.common.collect.Map.entry("timestamp", STRING),
org.elasticsearch.common.collect.Map.entry("timestamp8601", STRING) org.opensearch.common.collect.Map.entry("timestamp8601", STRING)
) )
); );
Map<String, Object> matches = grok.captures(line); Map<String, Object> matches = grok.captures(line);
@ -122,16 +122,16 @@ public class GrokTests extends OpenSearchTestCase {
Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{SYSLOG5424LINE}", logger::warn); Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{SYSLOG5424LINE}", logger::warn);
assertCaptureConfig( assertCaptureConfig(
grok, grok,
org.elasticsearch.common.collect.Map.ofEntries( org.opensearch.common.collect.Map.ofEntries(
org.elasticsearch.common.collect.Map.entry("syslog5424_app", STRING), org.opensearch.common.collect.Map.entry("syslog5424_app", STRING),
org.elasticsearch.common.collect.Map.entry("syslog5424_host", STRING), org.opensearch.common.collect.Map.entry("syslog5424_host", STRING),
org.elasticsearch.common.collect.Map.entry("syslog5424_msg", STRING), org.opensearch.common.collect.Map.entry("syslog5424_msg", STRING),
org.elasticsearch.common.collect.Map.entry("syslog5424_msgid", STRING), org.opensearch.common.collect.Map.entry("syslog5424_msgid", STRING),
org.elasticsearch.common.collect.Map.entry("syslog5424_pri", STRING), org.opensearch.common.collect.Map.entry("syslog5424_pri", STRING),
org.elasticsearch.common.collect.Map.entry("syslog5424_proc", STRING), org.opensearch.common.collect.Map.entry("syslog5424_proc", STRING),
org.elasticsearch.common.collect.Map.entry("syslog5424_sd", STRING), org.opensearch.common.collect.Map.entry("syslog5424_sd", STRING),
org.elasticsearch.common.collect.Map.entry("syslog5424_ts", STRING), org.opensearch.common.collect.Map.entry("syslog5424_ts", STRING),
org.elasticsearch.common.collect.Map.entry("syslog5424_ver", STRING) org.opensearch.common.collect.Map.entry("syslog5424_ver", STRING)
) )
); );
Map<String, Object> matches = grok.captures(line); Map<String, Object> matches = grok.captures(line);
@ -149,14 +149,14 @@ public class GrokTests extends OpenSearchTestCase {
public void testDatePattern() { public void testDatePattern() {
String line = "fancy 12-12-12 12:12:12"; String line = "fancy 12-12-12 12:12:12";
Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "(?<timestamp>%{DATE_EU} %{TIME})", logger::warn); Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "(?<timestamp>%{DATE_EU} %{TIME})", logger::warn);
assertCaptureConfig(grok, org.elasticsearch.common.collect.Map.of("timestamp", STRING)); assertCaptureConfig(grok, org.opensearch.common.collect.Map.of("timestamp", STRING));
Map<String, Object> matches = grok.captures(line); Map<String, Object> matches = grok.captures(line);
assertEquals("12-12-12 12:12:12", matches.get("timestamp")); assertEquals("12-12-12 12:12:12", matches.get("timestamp"));
} }
public void testNilCoercedValues() { public void testNilCoercedValues() {
Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "test (N/A|%{BASE10NUM:duration:float}ms)", logger::warn); Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "test (N/A|%{BASE10NUM:duration:float}ms)", logger::warn);
assertCaptureConfig(grok, org.elasticsearch.common.collect.Map.of("duration", FLOAT)); assertCaptureConfig(grok, org.opensearch.common.collect.Map.of("duration", FLOAT));
Map<String, Object> matches = grok.captures("test 28.4ms"); Map<String, Object> matches = grok.captures("test 28.4ms");
assertEquals(28.4f, matches.get("duration")); assertEquals(28.4f, matches.get("duration"));
matches = grok.captures("test N/A"); matches = grok.captures("test N/A");
@ -165,7 +165,7 @@ public class GrokTests extends OpenSearchTestCase {
public void testNilWithNoCoercion() { public void testNilWithNoCoercion() {
Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "test (N/A|%{BASE10NUM:duration}ms)", logger::warn); Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "test (N/A|%{BASE10NUM:duration}ms)", logger::warn);
assertCaptureConfig(grok, org.elasticsearch.common.collect.Map.of("duration", STRING)); assertCaptureConfig(grok, org.opensearch.common.collect.Map.of("duration", STRING));
Map<String, Object> matches = grok.captures("test 28.4ms"); Map<String, Object> matches = grok.captures("test 28.4ms");
assertEquals("28.4", matches.get("duration")); assertEquals("28.4", matches.get("duration"));
matches = grok.captures("test N/A"); matches = grok.captures("test N/A");
@ -178,13 +178,13 @@ public class GrokTests extends OpenSearchTestCase {
"%{GREEDYDATA:syslog_message}", logger::warn); "%{GREEDYDATA:syslog_message}", logger::warn);
assertCaptureConfig( assertCaptureConfig(
grok, grok,
org.elasticsearch.common.collect.Map.ofEntries( org.opensearch.common.collect.Map.ofEntries(
org.elasticsearch.common.collect.Map.entry("syslog_hostname", STRING), org.opensearch.common.collect.Map.entry("syslog_hostname", STRING),
org.elasticsearch.common.collect.Map.entry("syslog_message", STRING), org.opensearch.common.collect.Map.entry("syslog_message", STRING),
org.elasticsearch.common.collect.Map.entry("syslog_pid", STRING), org.opensearch.common.collect.Map.entry("syslog_pid", STRING),
org.elasticsearch.common.collect.Map.entry("syslog_pri", STRING), org.opensearch.common.collect.Map.entry("syslog_pri", STRING),
org.elasticsearch.common.collect.Map.entry("syslog_program", STRING), org.opensearch.common.collect.Map.entry("syslog_program", STRING),
org.elasticsearch.common.collect.Map.entry("syslog_timestamp", STRING) org.opensearch.common.collect.Map.entry("syslog_timestamp", STRING)
) )
); );
Map<String, Object> matches = grok.captures("<22>Jan 4 07:50:46 mailmaster postfix/policy-spf[9454]: : " + Map<String, Object> matches = grok.captures("<22>Jan 4 07:50:46 mailmaster postfix/policy-spf[9454]: : " +
@ -197,21 +197,21 @@ public class GrokTests extends OpenSearchTestCase {
public void testNamedFieldsWithWholeTextMatch() { public void testNamedFieldsWithWholeTextMatch() {
Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{DATE_EU:stimestamp}", logger::warn); Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{DATE_EU:stimestamp}", logger::warn);
assertCaptureConfig(grok, org.elasticsearch.common.collect.Map.of("stimestamp", STRING)); assertCaptureConfig(grok, org.opensearch.common.collect.Map.of("stimestamp", STRING));
Map<String, Object> matches = grok.captures("11/01/01"); Map<String, Object> matches = grok.captures("11/01/01");
assertThat(matches.get("stimestamp"), equalTo("11/01/01")); assertThat(matches.get("stimestamp"), equalTo("11/01/01"));
} }
public void testWithOniguramaNamedCaptures() { public void testWithOniguramaNamedCaptures() {
Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "(?<foo>\\w+)", logger::warn); Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "(?<foo>\\w+)", logger::warn);
assertCaptureConfig(grok, org.elasticsearch.common.collect.Map.of("foo", STRING)); assertCaptureConfig(grok, org.opensearch.common.collect.Map.of("foo", STRING));
Map<String, Object> matches = grok.captures("hello world"); Map<String, Object> matches = grok.captures("hello world");
assertThat(matches.get("foo"), equalTo("hello")); assertThat(matches.get("foo"), equalTo("hello"));
} }
public void testISO8601() { public void testISO8601() {
Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "^%{TIMESTAMP_ISO8601}$", logger::warn); Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "^%{TIMESTAMP_ISO8601}$", logger::warn);
assertCaptureConfig(grok, org.elasticsearch.common.collect.Map.of()); assertCaptureConfig(grok, org.opensearch.common.collect.Map.of());
List<String> timeMessages = Arrays.asList( List<String> timeMessages = Arrays.asList(
"2001-01-01T00:00:00", "2001-01-01T00:00:00",
"1974-03-02T04:09:09", "1974-03-02T04:09:09",
@ -236,7 +236,7 @@ public class GrokTests extends OpenSearchTestCase {
public void testNotISO8601() { public void testNotISO8601() {
Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "^%{TIMESTAMP_ISO8601}$", logger::warn); Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "^%{TIMESTAMP_ISO8601}$", logger::warn);
assertCaptureConfig(grok, org.elasticsearch.common.collect.Map.of()); assertCaptureConfig(grok, org.opensearch.common.collect.Map.of());
List<String> timeMessages = Arrays.asList( List<String> timeMessages = Arrays.asList(
"2001-13-01T00:00:00", // invalid month "2001-13-01T00:00:00", // invalid month
"2001-00-01T00:00:00", // invalid month "2001-00-01T00:00:00", // invalid month
@ -276,7 +276,7 @@ public class GrokTests extends OpenSearchTestCase {
String text = "wowza !!!Tal!!! - Tal"; String text = "wowza !!!Tal!!! - Tal";
String pattern = "%{EXCITED_NAME} - %{NAME}"; String pattern = "%{EXCITED_NAME} - %{NAME}";
Grok g = new Grok(bank, pattern, false, logger::warn); Grok g = new Grok(bank, pattern, false, logger::warn);
assertCaptureConfig(g, org.elasticsearch.common.collect.Map.of("EXCITED_NAME_0", STRING, "NAME_21", STRING, "NAME_22", STRING)); assertCaptureConfig(g, org.opensearch.common.collect.Map.of("EXCITED_NAME_0", STRING, "NAME_21", STRING, "NAME_22", STRING));
assertEquals("(?<EXCITED_NAME_0>!!!(?<NAME_21>Tal)!!!) - (?<NAME_22>Tal)", g.toRegex(pattern)); assertEquals("(?<EXCITED_NAME_0>!!!(?<NAME_21>Tal)!!!) - (?<NAME_22>Tal)", g.toRegex(pattern));
assertEquals(true, g.match(text)); assertEquals(true, g.match(text));
@ -351,7 +351,7 @@ public class GrokTests extends OpenSearchTestCase {
public void testBooleanCaptures() { public void testBooleanCaptures() {
String pattern = "%{WORD:name}=%{WORD:status:boolean}"; String pattern = "%{WORD:name}=%{WORD:status:boolean}";
Grok g = new Grok(Grok.BUILTIN_PATTERNS, pattern, logger::warn); Grok g = new Grok(Grok.BUILTIN_PATTERNS, pattern, logger::warn);
assertCaptureConfig(g, org.elasticsearch.common.collect.Map.of("name", STRING, "status", BOOLEAN)); assertCaptureConfig(g, org.opensearch.common.collect.Map.of("name", STRING, "status", BOOLEAN));
String text = "active=true"; String text = "active=true";
Map<String, Object> expected = new HashMap<>(); Map<String, Object> expected = new HashMap<>();
@ -379,7 +379,7 @@ public class GrokTests extends OpenSearchTestCase {
String pattern = "%{NUMBER:bytes:float} %{NUMBER:id:long} %{NUMBER:rating:double}"; String pattern = "%{NUMBER:bytes:float} %{NUMBER:id:long} %{NUMBER:rating:double}";
Grok g = new Grok(bank, pattern, logger::warn); Grok g = new Grok(bank, pattern, logger::warn);
assertCaptureConfig(g, org.elasticsearch.common.collect.Map.of("bytes", FLOAT, "id", LONG, "rating", DOUBLE)); assertCaptureConfig(g, org.opensearch.common.collect.Map.of("bytes", FLOAT, "id", LONG, "rating", DOUBLE));
String text = "12009.34 20000000000 4820.092"; String text = "12009.34 20000000000 4820.092";
Map<String, Object> expected = new HashMap<>(); Map<String, Object> expected = new HashMap<>();
@ -427,7 +427,7 @@ public class GrokTests extends OpenSearchTestCase {
String pattern = "%{NUMBER:bytes:float} %{NUMBER:status} %{NUMBER}"; String pattern = "%{NUMBER:bytes:float} %{NUMBER:status} %{NUMBER}";
Grok g = new Grok(bank, pattern, logger::warn); Grok g = new Grok(bank, pattern, logger::warn);
assertCaptureConfig(g, org.elasticsearch.common.collect.Map.of("bytes", FLOAT, "status", STRING)); assertCaptureConfig(g, org.opensearch.common.collect.Map.of("bytes", FLOAT, "status", STRING));
String text = "12009.34 200 9032"; String text = "12009.34 200 9032";
Map<String, Object> expected = new HashMap<>(); Map<String, Object> expected = new HashMap<>();
@ -445,8 +445,8 @@ public class GrokTests extends OpenSearchTestCase {
String pattern = "%{NUMBER:f:not_a_valid_type}"; String pattern = "%{NUMBER:f:not_a_valid_type}";
Grok g = new Grok(bank, pattern, logger::warn); Grok g = new Grok(bank, pattern, logger::warn);
assertCaptureConfig(g, org.elasticsearch.common.collect.Map.of("f", STRING)); assertCaptureConfig(g, org.opensearch.common.collect.Map.of("f", STRING));
assertThat(g.captures("12009.34"), equalTo(org.elasticsearch.common.collect.Map.of("f", "12009.34"))); assertThat(g.captures("12009.34"), equalTo(org.opensearch.common.collect.Map.of("f", "12009.34")));
} }
public void testApacheLog() { public void testApacheLog() {
@ -456,19 +456,19 @@ public class GrokTests extends OpenSearchTestCase {
Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{COMBINEDAPACHELOG}", logger::warn); Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{COMBINEDAPACHELOG}", logger::warn);
assertCaptureConfig( assertCaptureConfig(
grok, grok,
org.elasticsearch.common.collect.Map.ofEntries( org.opensearch.common.collect.Map.ofEntries(
org.elasticsearch.common.collect.Map.entry("agent", STRING), org.opensearch.common.collect.Map.entry("agent", STRING),
org.elasticsearch.common.collect.Map.entry("auth", STRING), org.opensearch.common.collect.Map.entry("auth", STRING),
org.elasticsearch.common.collect.Map.entry("bytes", STRING), org.opensearch.common.collect.Map.entry("bytes", STRING),
org.elasticsearch.common.collect.Map.entry("clientip", STRING), org.opensearch.common.collect.Map.entry("clientip", STRING),
org.elasticsearch.common.collect.Map.entry("httpversion", STRING), org.opensearch.common.collect.Map.entry("httpversion", STRING),
org.elasticsearch.common.collect.Map.entry("ident", STRING), org.opensearch.common.collect.Map.entry("ident", STRING),
org.elasticsearch.common.collect.Map.entry("rawrequest", STRING), org.opensearch.common.collect.Map.entry("rawrequest", STRING),
org.elasticsearch.common.collect.Map.entry("referrer", STRING), org.opensearch.common.collect.Map.entry("referrer", STRING),
org.elasticsearch.common.collect.Map.entry("request", STRING), org.opensearch.common.collect.Map.entry("request", STRING),
org.elasticsearch.common.collect.Map.entry("response", STRING), org.opensearch.common.collect.Map.entry("response", STRING),
org.elasticsearch.common.collect.Map.entry("timestamp", STRING), org.opensearch.common.collect.Map.entry("timestamp", STRING),
org.elasticsearch.common.collect.Map.entry("verb", STRING) org.opensearch.common.collect.Map.entry("verb", STRING)
) )
); );
Map<String, Object> matches = grok.captures(logLine); Map<String, Object> matches = grok.captures(logLine);
@ -533,18 +533,18 @@ public class GrokTests extends OpenSearchTestCase {
Grok grok = new Grok(bank, pattern, logger::warn); Grok grok = new Grok(bank, pattern, logger::warn);
assertCaptureConfig( assertCaptureConfig(
grok, grok,
org.elasticsearch.common.collect.Map.ofEntries( org.opensearch.common.collect.Map.ofEntries(
org.elasticsearch.common.collect.Map.entry("agent", STRING), org.opensearch.common.collect.Map.entry("agent", STRING),
org.elasticsearch.common.collect.Map.entry("auth", STRING), org.opensearch.common.collect.Map.entry("auth", STRING),
org.elasticsearch.common.collect.Map.entry("bytes", INTEGER), org.opensearch.common.collect.Map.entry("bytes", INTEGER),
org.elasticsearch.common.collect.Map.entry("clientip", STRING), org.opensearch.common.collect.Map.entry("clientip", STRING),
org.elasticsearch.common.collect.Map.entry("httpversion", STRING), org.opensearch.common.collect.Map.entry("httpversion", STRING),
org.elasticsearch.common.collect.Map.entry("ident", STRING), org.opensearch.common.collect.Map.entry("ident", STRING),
org.elasticsearch.common.collect.Map.entry("referrer", STRING), org.opensearch.common.collect.Map.entry("referrer", STRING),
org.elasticsearch.common.collect.Map.entry("request", STRING), org.opensearch.common.collect.Map.entry("request", STRING),
org.elasticsearch.common.collect.Map.entry("response", INTEGER), org.opensearch.common.collect.Map.entry("response", INTEGER),
org.elasticsearch.common.collect.Map.entry("timestamp", STRING), org.opensearch.common.collect.Map.entry("timestamp", STRING),
org.elasticsearch.common.collect.Map.entry("verb", STRING) org.opensearch.common.collect.Map.entry("verb", STRING)
) )
); );
@ -578,7 +578,7 @@ public class GrokTests extends OpenSearchTestCase {
Map<String, String> bank = new HashMap<>(); Map<String, String> bank = new HashMap<>();
bank.put("SINGLEDIGIT", "[0-9]"); bank.put("SINGLEDIGIT", "[0-9]");
Grok grok = new Grok(bank, "%{SINGLEDIGIT:num}%{SINGLEDIGIT:num}", logger::warn); Grok grok = new Grok(bank, "%{SINGLEDIGIT:num}%{SINGLEDIGIT:num}", logger::warn);
assertCaptureConfig(grok, org.elasticsearch.common.collect.Map.of("num", STRING)); assertCaptureConfig(grok, org.opensearch.common.collect.Map.of("num", STRING));
Map<String, Object> expected = new HashMap<>(); Map<String, Object> expected = new HashMap<>();
expected.put("num", "1"); expected.put("num", "1");