Search in sources :

Example 1 with StatisticsConfig

use of com.yahoo.container.StatisticsConfig in project vespa by vespa-engine.

the class AdminTestCase method testContainerMetricsSnapshotInterval.

@Test
public void testContainerMetricsSnapshotInterval() throws Exception {
    VespaModel vespaModel = getVespaModel(TESTDIR + "metricconfig");
    ContainerCluster docprocCluster = vespaModel.getContainerClusters().get("cluster.music.indexing");
    HealthMonitorConfig.Builder builder = new HealthMonitorConfig.Builder();
    docprocCluster.getConfig(builder);
    HealthMonitorConfig docprocConfig = new HealthMonitorConfig(builder);
    assertEquals(60, (int) docprocConfig.snapshot_interval());
    ContainerCluster qrCluster = vespaModel.getContainerClusters().get("container");
    builder = new HealthMonitorConfig.Builder();
    qrCluster.getConfig(builder);
    HealthMonitorConfig qrClusterConfig = new HealthMonitorConfig(builder);
    assertEquals(60, (int) qrClusterConfig.snapshot_interval());
    StatisticsComponent stat = null;
    for (Component component : qrCluster.getAllComponents()) {
        if (component.getClassId().getName().contains("com.yahoo.statistics.StatisticsImpl")) {
            stat = (StatisticsComponent) component;
            break;
        }
    }
    assertNotNull(stat);
    StatisticsConfig.Builder sb = new StatisticsConfig.Builder();
    stat.getConfig(sb);
    StatisticsConfig sc = new StatisticsConfig(sb);
    assertEquals(60, (int) sc.collectionintervalsec());
    assertEquals(60, (int) sc.loggingintervalsec());
}
Also used : StatisticsComponent(com.yahoo.vespa.model.container.component.StatisticsComponent) StatisticsConfig(com.yahoo.container.StatisticsConfig) VespaModel(com.yahoo.vespa.model.VespaModel) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) HealthMonitorConfig(com.yahoo.container.jdisc.config.HealthMonitorConfig) StatisticsComponent(com.yahoo.vespa.model.container.component.StatisticsComponent) Component(com.yahoo.vespa.model.container.component.Component) Test(org.junit.Test)

Example 2 with StatisticsConfig

use of com.yahoo.container.StatisticsConfig in project vespa by vespa-engine.

the class AdminTestCase method testStatisticsConfig.

@Test
public void testStatisticsConfig() {
    StatisticsComponent stat = new StatisticsComponent();
    StatisticsConfig.Builder sb = new StatisticsConfig.Builder();
    stat.getConfig(sb);
    StatisticsConfig sc = new StatisticsConfig(sb);
    assertEquals(sc.collectionintervalsec(), 300, 0.1);
    assertEquals(sc.loggingintervalsec(), 300, 0.1);
    assertEquals(sc.values(0).operations(0).name(), StatisticsConfig.Values.Operations.Name.REGULAR);
    assertEquals(sc.values(0).operations(0).arguments(0).key(), "limits");
    assertEquals(sc.values(0).operations(0).arguments(0).value(), "25,50,100,500");
}
Also used : StatisticsComponent(com.yahoo.vespa.model.container.component.StatisticsComponent) StatisticsConfig(com.yahoo.container.StatisticsConfig) Test(org.junit.Test)

Example 3 with StatisticsConfig

use of com.yahoo.container.StatisticsConfig in project vespa by vespa-engine.

the class CounterTestCase method testConfigStuff.

public void testConfigStuff() {
    Logger logger = Logger.getLogger(Counter.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;
    Counter c = new Counter("nalle", m, true);
    Counter c2 = new Counter(joppe, m, true);
    c.increment();
    c2.increment();
    assertEquals(1L, c.get());
    assertEquals(1L, c2.get());
    c.run();
    c2.run();
    assertEquals(1L, c.get());
    assertEquals(0L, c2.get());
    logger.setUseParentHandlers(initUseParentHandlers);
}
Also used : StatisticsConfig(com.yahoo.container.StatisticsConfig) Logger(java.util.logging.Logger)

Example 4 with StatisticsConfig

use of com.yahoo.container.StatisticsConfig in project vespa by vespa-engine.

the class StatisticsImplTestCase method testRegister.

@Test
public final void testRegister() {
    final StatisticsConfig config = new StatisticsConfig(new StatisticsConfig.Builder().collectionintervalsec(31e9).loggingintervalsec(31e9));
    final StatisticsImpl s = new StatisticsImpl(config);
    final Logger logger = Logger.getLogger(TestHandle.class.getName());
    final boolean initUseParentHandlers = logger.getUseParentHandlers();
    logger.setUseParentHandlers(false);
    final String firstHandle = "a";
    final Handle a = new TestHandle(firstHandle, s, null);
    final Handle a2 = new TestHandle(firstHandle, s, null);
    final String secondHandle = "b";
    final Handle b = new TestHandle(secondHandle, s, null);
    s.register(a);
    s.register(a2);
    assertFalse("Old handle should be cancelled.", a.isCancelled() == false);
    assertFalse("New handle should not be cancelled.", a2.isCancelled());
    assertEquals("Internal handles map semantics have been changed?", 1, s.handles.size());
    s.register(b);
    s.remove(secondHandle);
    assertFalse("Removed handle should be cancelled.", b.isCancelled() == false);
    a2.cancel();
    s.purge();
    assertEquals("Cancelled tasks should be removed.", 0, s.handles.size());
    s.deconstruct();
    assertSame(config, s.getConfig());
    logger.setUseParentHandlers(initUseParentHandlers);
}
Also used : StatisticsConfig(com.yahoo.container.StatisticsConfig) Logger(java.util.logging.Logger) Test(org.junit.Test)

Example 5 with StatisticsConfig

use of com.yahoo.container.StatisticsConfig in project vespa by vespa-engine.

the class ValueTestCase method testReverseHistogram.

public void testReverseHistogram() {
    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.REVERSE_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