Search in sources :

Example 1 with SourceMetric

use of ddf.catalog.metrics.source.SourceMetricsImpl.SourceMetric in project ddf by codice.

the class SourceMetricsImplTest method assertMetricCount.

private void assertMetricCount(String sourceId, String metricName, int expectedCount) {
    String key = sourceId + "." + metricName;
    SourceMetric sourceMetric = sourceMetrics.metrics.get(key);
    if (sourceMetric.isHistogram()) {
        Histogram histogram = (Histogram) sourceMetric.getMetric();
        assertThat(histogram.getCount(), is((long) expectedCount));
    } else {
        Meter meter = (Meter) sourceMetric.getMetric();
        assertThat(meter.getCount(), is((long) expectedCount));
    }
}
Also used : Histogram(com.codahale.metrics.Histogram) Meter(com.codahale.metrics.Meter) SourceMetric(ddf.catalog.metrics.source.SourceMetricsImpl.SourceMetric)

Example 2 with SourceMetric

use of ddf.catalog.metrics.source.SourceMetricsImpl.SourceMetric in project ddf by codice.

the class SourceMetricsImplTest method testUpdateNonExistingSourceMetric.

@Test
public void testUpdateNonExistingSourceMetric() throws Exception {
    String sourceId = "existing-source";
    String metricName = SourceMetrics.QUERIES_SCOPE;
    sourceMetrics = configureSourceMetrics(sourceId);
    String nonExistingSourceId = "non-existing-source-id";
    sourceMetrics.updateMetric(nonExistingSourceId, metricName, 1);
    String key = nonExistingSourceId + "." + metricName;
    SourceMetric sourceMetric = sourceMetrics.metrics.get(key);
    assertThat(sourceMetric, is(nullValue()));
}
Also used : SourceMetric(ddf.catalog.metrics.source.SourceMetricsImpl.SourceMetric) Test(org.junit.Test)

Example 3 with SourceMetric

use of ddf.catalog.metrics.source.SourceMetricsImpl.SourceMetric in project ddf by codice.

the class SourceMetricsImplTest method testDeleteSourceBlankSourceId.

@Test
public void testDeleteSourceBlankSourceId() throws Exception {
    String sourceId = "cp-1";
    String metricName = SourceMetrics.QUERIES_SCOPE;
    sourceMetrics = configureSourceMetrics(sourceId);
    addSource();
    // Simulate Source returning empty sourceId
    when(catalogProvider.getId()).thenReturn("");
    sourceMetrics.deletingSource(catalogProvider, null);
    String key = sourceId + "." + metricName;
    SourceMetric sourceMetric = sourceMetrics.metrics.get(key);
    assertThat(sourceMetric, not(nullValue()));
    sourceMetrics.deletingSource(null, null);
    key = sourceId + "." + metricName;
    sourceMetric = sourceMetrics.metrics.get(key);
    assertThat(sourceMetric, not(nullValue()));
}
Also used : SourceMetric(ddf.catalog.metrics.source.SourceMetricsImpl.SourceMetric) Test(org.junit.Test)

Example 4 with SourceMetric

use of ddf.catalog.metrics.source.SourceMetricsImpl.SourceMetric in project ddf by codice.

the class SourceMetricsImplTest method testAddDeleteSource.

@Test
public void testAddDeleteSource() throws Exception {
    String sourceId = "cp-1";
    String metricName = SourceMetrics.QUERIES_SCOPE;
    sourceMetrics = configureSourceMetrics(sourceId);
    addSource();
    String key = sourceId + "." + metricName;
    SourceMetric sourceMetric = sourceMetrics.metrics.get(key);
    assertThat(sourceMetric, not(nullValue()));
    sourceMetrics.deletingSource(catalogProvider, null);
    sourceMetric = sourceMetrics.metrics.get(key);
    assertThat(sourceMetric, is(nullValue()));
}
Also used : SourceMetric(ddf.catalog.metrics.source.SourceMetricsImpl.SourceMetric) Test(org.junit.Test)

Aggregations

SourceMetric (ddf.catalog.metrics.source.SourceMetricsImpl.SourceMetric)4 Test (org.junit.Test)3 Histogram (com.codahale.metrics.Histogram)1 Meter (com.codahale.metrics.Meter)1