use of com.yahoo.container.StatisticsConfig in project vespa by vespa-engine.
the class ValueTestCase method testParameterFromConfig.
public void testParameterFromConfig() {
Logger logger = Logger.getLogger(Value.class.getName());
boolean initUseParentHandlers = logger.getUseParentHandlers();
logger.setUseParentHandlers(false);
CheckHistogram h = new CheckHistogram("(0) < 0.0 (0) < 1.0 (0) < 2.0 (1)", "REGULAR");
logger.addHandler(h);
List<Operations.Arguments.Builder> histogram = Arrays.asList(new Operations.Arguments.Builder[] { new Operations.Arguments.Builder().key("limits").value("0, 1, 2") });
List<Operations.Builder> ops = Arrays.asList(new Operations.Builder[] { new Operations.Builder().name(Operations.Name.Enum.MEAN), new Operations.Builder().name(Operations.Name.Enum.MIN), new Operations.Builder().name(Operations.Name.Enum.MAX), new Operations.Builder().name(Operations.Name.Enum.RAW), new Operations.Builder().name(Operations.Name.Enum.INSERTIONS), new Operations.Builder().name(Operations.Name.Enum.REGULAR).arguments(histogram), new Operations.Builder().name(Operations.Name.Enum.SUM) });
StatisticsConfig c = new StatisticsConfig(new StatisticsConfig.Builder().values(new StatisticsConfig.Values.Builder().name(NALLE).operations(ops)));
MockStatistics m = new MockStatistics();
m.config = c;
Value v = Value.buildValue(NALLE, m, null);
final double x = 79.0d;
v.put(x);
assertEquals(x, v.getMean());
v.run();
assertEquals(true, h.gotRecord);
logger.removeHandler(h);
logger.setUseParentHandlers(initUseParentHandlers);
}
use of com.yahoo.container.StatisticsConfig in project vespa by vespa-engine.
the class Value method buildParameters.
private static Parameters buildParameters(String name, Statistics manager, Parameters defaults) {
Parameters p = null;
StatisticsConfig config = manager.getConfig();
if (config != null) {
for (int i = 0; i < config.values().size(); i++) {
String configName = config.values(i).name();
if (configName.equals(name)) {
p = parametersFromConfig(config.values(i).operations());
break;
}
}
}
if (p == null) {
if (defaults == null) {
p = defaultParameters();
} else {
p = defaults;
}
} else {
p.merge(defaults);
}
return p;
}
use of com.yahoo.container.StatisticsConfig in project vespa by vespa-engine.
the class CounterGroupTestCase method testConfigStuff.
public void testConfigStuff() {
Logger logger = Logger.getLogger(CounterGroup.class.getName());
boolean initUseParentHandlers = logger.getUseParentHandlers();
logger.setUseParentHandlers(false);
MockStatistics m = new MockStatistics();
final String joppe = "joppe";
StatisticsConfig config = new StatisticsConfig(new StatisticsConfig.Builder().counterresets(Arrays.asList(new StatisticsConfig.Counterresets.Builder[] { new StatisticsConfig.Counterresets.Builder().name(joppe) })));
m.config = config;
CounterGroup c = new CounterGroup("nalle", m);
CounterGroup c2 = new CounterGroup(joppe, m);
final String bamse = "bamse";
c.increment(bamse);
c2.increment(bamse);
assertEquals(1L, c.getCounter(bamse).get());
assertEquals(1L, c2.getCounter(bamse).get());
c2.increment(bamse);
assertEquals(1L, c.getCounter(bamse).get());
assertEquals(2L, c2.getCounter(bamse).get());
c.run();
c2.run();
assertEquals(1L, c.getCounter(bamse).get());
assertEquals(0L, c2.getCounter(bamse).get());
logger.setUseParentHandlers(initUseParentHandlers);
}
use of com.yahoo.container.StatisticsConfig in project vespa by vespa-engine.
the class ConfigserverClusterTest method testStatisticsConfig.
@Test
public void testStatisticsConfig() {
StatisticsConfig config = root.getConfig(StatisticsConfig.class, "configserver/standalone");
assertThat((int) config.collectionintervalsec(), is(60));
assertThat((int) config.loggingintervalsec(), is(60));
}
use of com.yahoo.container.StatisticsConfig in project vespa by vespa-engine.
the class ValueTestCase method testCumulativeHistogram.
public void testCumulativeHistogram() {
Logger logger = Logger.getLogger(Value.class.getName());
boolean initUseParentHandlers = logger.getUseParentHandlers();
logger.setUseParentHandlers(false);
CheckHistogram h = new CheckHistogram("(0) < 0.0 (2) < 1.0 (2) < 2.0 (0)", "REGULAR");
logger.addHandler(h);
List<Operations.Arguments.Builder> histogram = Arrays.asList(new Operations.Arguments.Builder[] { new Operations.Arguments.Builder().key("limits").value("0, 1, 2") });
List<Operations.Builder> ops = Arrays.asList(new Operations.Builder[] { new Operations.Builder().name(Operations.Name.Enum.CUMULATIVE).arguments(histogram) });
StatisticsConfig c = new StatisticsConfig(new StatisticsConfig.Builder().values(new StatisticsConfig.Values.Builder().name(NALLE).operations(ops)));
MockStatistics m = new MockStatistics();
m.config = c;
Value v = Value.buildValue(NALLE, m, null);
assertEquals(HistogramType.REGULAR.toString(), v.histogramId.toString());
v.put(.5d);
v.put(.5d);
v.put(1.5d);
v.put(1.5d);
v.run();
assertEquals(true, h.gotRecord);
assertEquals(true, h.gotWarning);
logger.removeHandler(h);
logger.setUseParentHandlers(initUseParentHandlers);
}
Aggregations