Search in sources :

Example 6 with MetricsTable

use of io.cdap.cdap.data2.dataset2.lib.table.MetricsTable in project cdap by caskdata.

the class SystemDatasetRuntimeModule method getInMemoryModules.

@Override
public Module getInMemoryModules() {
    return new AbstractModule() {

        @Override
        protected void configure() {
            MapBinder<String, DatasetModule> mapBinder = MapBinder.newMapBinder(binder(), String.class, DatasetModule.class, Constants.Dataset.Manager.DefaultDatasetModules.class);
            // NOTE: order is important due to dependencies between modules
            mapBinder.addBinding("orderedTable-memory").toInstance(new InMemoryTableModule());
            mapBinder.addBinding("metricsTable-memory").toInstance(new InMemoryMetricsTableModule());
            bindDefaultModules(mapBinder);
        }
    };
}
Also used : InMemoryTableModule(co.cask.cdap.data2.dataset2.module.lib.inmemory.InMemoryTableModule) InMemoryMetricsTableModule(co.cask.cdap.data2.dataset2.module.lib.inmemory.InMemoryMetricsTableModule) Constants(co.cask.cdap.common.conf.Constants) HBaseQueueDatasetModule(co.cask.cdap.data2.transaction.queue.hbase.HBaseQueueDatasetModule) LineageDatasetModule(co.cask.cdap.data2.metadata.lineage.LineageDatasetModule) ExternalDatasetModule(co.cask.cdap.data2.dataset2.lib.external.ExternalDatasetModule) UsageDatasetModule(co.cask.cdap.data2.registry.UsageDatasetModule) MetadataDatasetModule(co.cask.cdap.data2.metadata.dataset.MetadataDatasetModule) DatasetModule(co.cask.cdap.api.dataset.module.DatasetModule) AbstractModule(com.google.inject.AbstractModule)

Example 7 with MetricsTable

use of io.cdap.cdap.data2.dataset2.lib.table.MetricsTable in project cdap by caskdata.

the class EntityTableTest method testGetName.

@Test
public void testGetName() throws Exception {
    InMemoryTableService.create("testGetName");
    MetricsTable table = new InMemoryMetricsTable("testGetName");
    EntityTable entityTable = new EntityTable(table);
    // Create some entities.
    for (int i = 1; i <= 10; i++) {
        Assert.assertEquals((long) i, entityTable.getId("app", "app" + i));
    }
    // Reverse lookup
    for (int i = 1; i <= 10; i++) {
        Assert.assertEquals("app" + i, entityTable.getName(i, "app"));
    }
}
Also used : InMemoryMetricsTable(co.cask.cdap.data2.dataset2.lib.table.inmemory.InMemoryMetricsTable) MetricsTable(co.cask.cdap.data2.dataset2.lib.table.MetricsTable) InMemoryMetricsTable(co.cask.cdap.data2.dataset2.lib.table.inmemory.InMemoryMetricsTable) Test(org.junit.Test)

Example 8 with MetricsTable

use of io.cdap.cdap.data2.dataset2.lib.table.MetricsTable in project cdap by caskdata.

the class FactTableTest method testPreSplits.

@Test
public void testPreSplits() throws Exception {
    InMemoryTableService.create("presplitEntityTable");
    InMemoryTableService.create("presplitDataTable");
    int resolution = 10;
    int rollTimebaseInterval = 2;
    InMemoryMetricsTable metricsTable = new InMemoryMetricsTable("presplitDataTable");
    FactTable table = new FactTable(metricsTable, new EntityTable(new InMemoryMetricsTable("presplitEntityTable")), resolution, rollTimebaseInterval);
    byte[][] splits = FactTable.getSplits(3);
    long ts = System.currentTimeMillis() / 1000;
    DimensionValue dimVal1 = new DimensionValue("dim1", "value1");
    DimensionValue dimVal2 = new DimensionValue("dim2", "value2");
    DimensionValue dimVal3 = new DimensionValue("dim3", "value3");
    // first agg view: dim1
    table.add(ImmutableList.of(new Fact(ts, ImmutableList.of(dimVal1), new Measurement("metric1", MeasureType.COUNTER, 1))));
    // second agg view: dim1 & dim2
    table.add(ImmutableList.of(new Fact(ts, ImmutableList.of(dimVal1, dimVal2), new Measurement("metric1", MeasureType.COUNTER, 1))));
    // third agg view: dim3
    table.add(ImmutableList.of(new Fact(ts, ImmutableList.of(dimVal3), new Measurement("metric1", MeasureType.COUNTER, 1))));
    // Verify all written records are spread across splits
    Scanner scanner = metricsTable.scan(null, null, null);
    Row row;
    Set<Integer> splitsWithRows = Sets.newHashSet();
    while ((row = scanner.next()) != null) {
        boolean added = false;
        for (int i = 0; i < splits.length; i++) {
            if (Bytes.compareTo(row.getRow(), splits[i]) < 0) {
                splitsWithRows.add(i);
                added = true;
                break;
            }
        }
        if (!added) {
            // falls into last split
            splitsWithRows.add(splits.length);
        }
    }
    Assert.assertEquals(3, splitsWithRows.size());
}
Also used : Measurement(co.cask.cdap.api.dataset.lib.cube.Measurement) Scanner(co.cask.cdap.api.dataset.table.Scanner) DimensionValue(co.cask.cdap.api.dataset.lib.cube.DimensionValue) InMemoryMetricsTable(co.cask.cdap.data2.dataset2.lib.table.inmemory.InMemoryMetricsTable) Row(co.cask.cdap.api.dataset.table.Row) Test(org.junit.Test)

Example 9 with MetricsTable

use of io.cdap.cdap.data2.dataset2.lib.table.MetricsTable in project cdap by caskdata.

the class CubeDatasetDefinition method getDataset.

@Override
public CubeDataset getDataset(DatasetContext datasetContext, DatasetSpecification spec, Map<String, String> arguments, ClassLoader classLoader) throws IOException {
    MetricsTable entityTable = metricsTableDef.getDataset(datasetContext, spec.getSpecification("entity"), arguments, classLoader);
    int[] resolutions = getResolutions(spec.getProperties());
    Map<Integer, Table> resolutionTables = Maps.newHashMap();
    for (int resolution : resolutions) {
        resolutionTables.put(resolution, tableDef.getDataset(datasetContext, spec.getSpecification(String.valueOf(resolution)), arguments, classLoader));
    }
    Map<String, Aggregation> aggregations = getAggregations(spec.getProperties());
    return new CubeDataset(spec.getName(), entityTable, resolutionTables, aggregations);
}
Also used : MetricsTable(co.cask.cdap.data2.dataset2.lib.table.MetricsTable) FactTable(co.cask.cdap.data2.dataset2.lib.timeseries.FactTable) Table(co.cask.cdap.api.dataset.table.Table) MetricsTable(co.cask.cdap.data2.dataset2.lib.table.MetricsTable)

Example 10 with MetricsTable

use of io.cdap.cdap.data2.dataset2.lib.table.MetricsTable in project cdap by caskdata.

the class DefaultMetricDatasetFactory method createConsumerMeta.

@Override
public MetricsConsumerMetaTable createConsumerMeta() {
    String tableName = cConf.get(Constants.Metrics.KAFKA_META_TABLE);
    MetricsTable table = getOrCreateMetricsTable(tableName, DatasetProperties.EMPTY);
    return new MetricsConsumerMetaTable(table);
}
Also used : MetricsConsumerMetaTable(co.cask.cdap.metrics.process.MetricsConsumerMetaTable) CombinedHBaseMetricsTable(co.cask.cdap.data2.dataset2.lib.table.hbase.CombinedHBaseMetricsTable) MetricsTable(co.cask.cdap.data2.dataset2.lib.table.MetricsTable)

Aggregations

MetricsTable (io.cdap.cdap.data2.dataset2.lib.table.MetricsTable)30 Test (org.junit.Test)23 MetricsTable (co.cask.cdap.data2.dataset2.lib.table.MetricsTable)19 InMemoryMetricsTable (io.cdap.cdap.data2.dataset2.lib.table.inmemory.InMemoryMetricsTable)12 AbstractModule (com.google.inject.AbstractModule)9 DatasetId (co.cask.cdap.proto.id.DatasetId)6 TypeLiteral (com.google.inject.TypeLiteral)6 DatasetAdmin (io.cdap.cdap.api.dataset.DatasetAdmin)6 DimensionValue (io.cdap.cdap.api.dataset.lib.cube.DimensionValue)6 DatasetModule (io.cdap.cdap.api.dataset.module.DatasetModule)6 Table (io.cdap.cdap.api.dataset.table.Table)6 Constants (io.cdap.cdap.common.conf.Constants)6 ExternalDatasetModule (io.cdap.cdap.data2.dataset2.lib.external.ExternalDatasetModule)6 InMemoryMetricsTable (co.cask.cdap.data2.dataset2.lib.table.inmemory.InMemoryMetricsTable)5 ArrayList (java.util.ArrayList)5 MetricsTableTest (co.cask.cdap.data2.dataset2.lib.table.MetricsTableTest)4 CombinedHBaseMetricsTable (co.cask.cdap.data2.dataset2.lib.table.hbase.CombinedHBaseMetricsTable)4 Measurement (io.cdap.cdap.api.dataset.lib.cube.Measurement)4 DatasetId (io.cdap.cdap.proto.id.DatasetId)4 DatasetManagementException (co.cask.cdap.api.dataset.DatasetManagementException)3