mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
Allow Plural for Types in TagFilters (#2085)
* Allow Plural for Types in TagFilters * Moved the plural trick into flow. Add advisor output * Previous logging of TagFilter is sufficient * Add in Advisor
This commit is contained in:
parent
68b148575f
commit
8a3e849ff1
@ -31,20 +31,21 @@ public class NBAdvisorOutput {
|
||||
}
|
||||
|
||||
public static void test(String message) {
|
||||
output(Level.WARN, message);
|
||||
if (NBAdvisorLevel.get() == NBAdvisorLevel.enforce) {
|
||||
throw new NBAdvisorException(message, 2);
|
||||
output(Level.ERROR, message);
|
||||
throw new NBAdvisorException(message, 2);
|
||||
}
|
||||
output(Level.WARN, message);
|
||||
}
|
||||
|
||||
public static void output(Level level,String message) {
|
||||
if (level == Level.INFO) {
|
||||
logger.info(message);
|
||||
} else if (level == Level.WARN) {
|
||||
logger.warn(message);
|
||||
} else if (level == Level.ERROR) {
|
||||
logger.error(message);
|
||||
}
|
||||
if (level == Level.INFO) {
|
||||
NBAdvisorOutput.logger.info(message);
|
||||
} else if (level == Level.WARN) {
|
||||
NBAdvisorOutput.logger.warn(message);
|
||||
} else if (level == Level.ERROR) {
|
||||
NBAdvisorOutput.logger.error(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,9 @@ package io.nosqlbench.nb.api.tagging;
|
||||
import io.nosqlbench.nb.api.engine.util.Tagged;
|
||||
import io.nosqlbench.nb.api.labels.NBLabeledElement;
|
||||
import io.nosqlbench.nb.api.components.core.NBComponent;
|
||||
import io.nosqlbench.nb.api.advisor.NBAdvisorOutput;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
@ -198,8 +201,18 @@ public class TagFilter {
|
||||
boolean matchedKey = true;
|
||||
String filterval = filter.get(filterkey);
|
||||
String itemval = tags.get(filterkey);
|
||||
|
||||
|
||||
if ( itemval == null ) {
|
||||
// tag category not found, if ends in an 's' then try singular
|
||||
if (filterkey.endsWith("s")) {
|
||||
String filterkey2 = filterkey.substring(0, filterkey.length() - 1);
|
||||
itemval = tags.get(filterkey2);
|
||||
String message = "'" + filterkey + "' tags do not exist: try '" + filterkey2 + "'";
|
||||
NBAdvisorOutput.test(message);
|
||||
log.add("(☐, ) " + message);
|
||||
filterkey = filterkey2;
|
||||
}
|
||||
}
|
||||
|
||||
String detail = "filter(" + filterkey +
|
||||
((filterval != null) ? ":" + filterval : "") + ") " +
|
||||
"tag(" + ((tags.containsKey(filterkey) ? filterkey : "") +
|
||||
|
@ -77,6 +77,21 @@ public class TagFilterTest {
|
||||
assertThat(tf.matches(itemtags2).matched()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchingTagKeysValueDoesMatch() {
|
||||
Map<String, String> itemtags = new HashMap<>() {{
|
||||
put("one", "two");
|
||||
}};
|
||||
TagFilter tf = new TagFilter("ones");
|
||||
TagFilter.Result result = tf.matches(itemtags);
|
||||
assertThat(result.matched()).isTrue();
|
||||
|
||||
Map<String, String> itemtags2 = new HashMap<>() {{
|
||||
put("one", null);
|
||||
}};
|
||||
assertThat(tf.matches(itemtags2).matched()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchingKeyMismatchingValueDoesNotMatch() {
|
||||
Map<String, String> itemtags = new HashMap<>() {{
|
||||
|
@ -416,7 +416,7 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
|
||||
"progress", options.getProgressSpec(),
|
||||
"prompush_cache", "prompush_cache.txt",
|
||||
"heartbeat", String.valueOf(options.wantsHeartbeatIntervalMs()),
|
||||
"advisor", String.valueOf(options.getAdvisor())
|
||||
"advisor", String.valueOf(options.getAdvisor())
|
||||
);
|
||||
|
||||
try (
|
||||
|
Loading…
Reference in New Issue
Block a user