Search in sources :

Example 6 with StatisticsConfig

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);
}
Also used : Logger(java.util.logging.Logger) StatisticsConfig(com.yahoo.container.StatisticsConfig) Operations(com.yahoo.container.StatisticsConfig.Values.Operations)

Example 7 with StatisticsConfig

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;
}
Also used : StatisticsConfig(com.yahoo.container.StatisticsConfig)

Example 8 with StatisticsConfig

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);
}
Also used : StatisticsConfig(com.yahoo.container.StatisticsConfig) Logger(java.util.logging.Logger)

Example 9 with StatisticsConfig

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));
}
Also used : StatisticsConfig(com.yahoo.container.StatisticsConfig) Test(org.junit.Test)

Example 10 with StatisticsConfig

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);
}
Also used : Logger(java.util.logging.Logger) StatisticsConfig(com.yahoo.container.StatisticsConfig) Operations(com.yahoo.container.StatisticsConfig.Values.Operations)

Aggregations

StatisticsConfig (com.yahoo.container.StatisticsConfig)11 Logger (java.util.logging.Logger)6 Test (org.junit.Test)4 Operations (com.yahoo.container.StatisticsConfig.Values.Operations)3 StatisticsComponent (com.yahoo.vespa.model.container.component.StatisticsComponent)2 HealthMonitorConfig (com.yahoo.container.jdisc.config.HealthMonitorConfig)1 NullMetric (com.yahoo.docproc.jdisc.metric.NullMetric)1 StatisticsImpl (com.yahoo.statistics.StatisticsImpl)1 VespaModel (com.yahoo.vespa.model.VespaModel)1 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)1 Component (com.yahoo.vespa.model.container.component.Component)1