Search in sources :

Example 11 with MetricsTable

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

the class HBaseMetricsTableTest method getTable.

@Override
protected MetricsTable getTable(String name) throws Exception {
    DatasetId metricsDatasetInstanceId = NamespaceId.SYSTEM.dataset(name);
    DatasetProperties props = TableProperties.builder().setReadlessIncrementSupport(true).build();
    return DatasetsUtil.getOrCreateDataset(dsFramework, metricsDatasetInstanceId, MetricsTable.class.getName(), props, null);
}
Also used : MetricsTable(co.cask.cdap.data2.dataset2.lib.table.MetricsTable) DatasetProperties(co.cask.cdap.api.dataset.DatasetProperties) DatasetId(co.cask.cdap.proto.id.DatasetId)

Example 12 with MetricsTable

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

the class DataMigration method createRegisteredDatasetFramework.

/**
   * Sets up a {@link DatasetFramework} instance for standalone usage.  NOTE: should NOT be used by applications!!!
   */
public static DatasetFramework createRegisteredDatasetFramework(Injector injector) throws DatasetManagementException, IOException {
    DatasetDefinitionRegistryFactory registryFactory = injector.getInstance(DatasetDefinitionRegistryFactory.class);
    DatasetFramework datasetFramework = new InMemoryDatasetFramework(registryFactory);
    // TODO: this doesn't sound right. find out why its needed.
    datasetFramework.addModule(NamespaceId.SYSTEM.datasetModule("table"), new HBaseTableModule());
    datasetFramework.addModule(NamespaceId.SYSTEM.datasetModule("metricsTable"), new HBaseMetricsTableModule());
    datasetFramework.addModule(NamespaceId.SYSTEM.datasetModule("core"), new CoreDatasetsModule());
    datasetFramework.addModule(NamespaceId.SYSTEM.datasetModule("fileSet"), new FileSetModule());
    return datasetFramework;
}
Also used : DatasetFramework(co.cask.cdap.data2.dataset2.DatasetFramework) InMemoryDatasetFramework(co.cask.cdap.data2.dataset2.InMemoryDatasetFramework) DatasetDefinitionRegistryFactory(co.cask.cdap.data2.dataset2.DatasetDefinitionRegistryFactory) CoreDatasetsModule(co.cask.cdap.data2.dataset2.lib.table.CoreDatasetsModule) HBaseMetricsTableModule(co.cask.cdap.data2.dataset2.module.lib.hbase.HBaseMetricsTableModule) HBaseTableModule(co.cask.cdap.data2.dataset2.module.lib.hbase.HBaseTableModule) FileSetModule(co.cask.cdap.data2.dataset2.lib.file.FileSetModule) InMemoryDatasetFramework(co.cask.cdap.data2.dataset2.InMemoryDatasetFramework)

Example 13 with MetricsTable

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

the class DefaultMetricDatasetFactory method getOrCreateMetricsTable.

private MetricsTable getOrCreateMetricsTable(String tableName, DatasetProperties props) {
    // metrics tables are in the system namespace
    DatasetId metricsDatasetInstanceId = NamespaceId.SYSTEM.dataset(tableName);
    MetricsTable table = null;
    try {
        table = DatasetsUtil.getOrCreateDataset(dsFramework, metricsDatasetInstanceId, MetricsTable.class.getName(), props, null);
    } catch (Exception e) {
        Throwables.propagate(e);
    }
    return table;
}
Also used : MetricsTable(co.cask.cdap.data2.dataset2.lib.table.MetricsTable) DatasetManagementException(co.cask.cdap.api.dataset.DatasetManagementException) DataMigrationException(co.cask.cdap.metrics.store.upgrade.DataMigrationException) IOException(java.io.IOException) DatasetId(co.cask.cdap.proto.id.DatasetId)

Example 14 with MetricsTable

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

the class MetricsDataMigrator method migrateMetricsTableFromVersion27.

private void migrateMetricsTableFromVersion27(Version version) throws DataMigrationException {
    EntityTable entityTable = new EntityTable(getOrCreateMetricsTable(entityTableName, DatasetProperties.EMPTY));
    MetricsTable metricsTable = getOrCreateMetricsTable(metricsTableName, DatasetProperties.EMPTY);
    System.out.println("Migrating Metrics Data from table : " + metricsTableName);
    migrateMetricsData(entityTable, metricsTable, null, version);
}
Also used : EntityTable(co.cask.cdap.data2.dataset2.lib.timeseries.EntityTable) MetricsTable(co.cask.cdap.data2.dataset2.lib.table.MetricsTable)

Example 15 with MetricsTable

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

the class DefaultMetricDatasetFactory method getOrCreateFactTable.

// todo: figure out roll time based on resolution from config? See DefaultMetricsTableFactory for example
@Override
public FactTable getOrCreateFactTable(int resolution) {
    String tableName = cConf.get(Constants.Metrics.METRICS_TABLE_PREFIX, Constants.Metrics.DEFAULT_METRIC_TABLE_PREFIX) + ".ts." + resolution;
    int ttl = cConf.getInt(Constants.Metrics.RETENTION_SECONDS + "." + resolution + ".seconds", -1);
    TableProperties.Builder props = TableProperties.builder();
    // don't add TTL for MAX_RESOLUTION table. CDAP-1626
    if (ttl > 0 && resolution != Integer.MAX_VALUE) {
        props.setTTL(ttl);
    }
    // for efficient counters
    props.setReadlessIncrementSupport(true);
    // configuring pre-splits
    props.add(HBaseTableAdmin.PROPERTY_SPLITS, GSON.toJson(FactTable.getSplits(DefaultMetricStore.AGGREGATIONS.size())));
    MetricsTable table = getOrCreateMetricsTable(tableName, props.build());
    return new FactTable(table, entityTable.get(), resolution, getRollTime(resolution));
}
Also used : FactTable(co.cask.cdap.data2.dataset2.lib.timeseries.FactTable) MetricsTable(co.cask.cdap.data2.dataset2.lib.table.MetricsTable) TableProperties(co.cask.cdap.api.dataset.table.TableProperties)

Aggregations

MetricsTable (co.cask.cdap.data2.dataset2.lib.table.MetricsTable)14 Test (org.junit.Test)6 InMemoryMetricsTable (co.cask.cdap.data2.dataset2.lib.table.inmemory.InMemoryMetricsTable)5 DatasetId (co.cask.cdap.proto.id.DatasetId)4 DatasetModule (co.cask.cdap.api.dataset.module.DatasetModule)3 Table (co.cask.cdap.api.dataset.table.Table)3 Constants (co.cask.cdap.common.conf.Constants)3 ExternalDatasetModule (co.cask.cdap.data2.dataset2.lib.external.ExternalDatasetModule)3 MetadataDatasetModule (co.cask.cdap.data2.metadata.dataset.MetadataDatasetModule)3 LineageDatasetModule (co.cask.cdap.data2.metadata.lineage.LineageDatasetModule)3 UsageDatasetModule (co.cask.cdap.data2.registry.UsageDatasetModule)3 HBaseQueueDatasetModule (co.cask.cdap.data2.transaction.queue.hbase.HBaseQueueDatasetModule)3 AbstractModule (com.google.inject.AbstractModule)3 DatasetManagementException (co.cask.cdap.api.dataset.DatasetManagementException)2 DimensionValue (co.cask.cdap.api.dataset.lib.cube.DimensionValue)2 EntityTable (co.cask.cdap.data2.dataset2.lib.timeseries.EntityTable)2 FactTable (co.cask.cdap.data2.dataset2.lib.timeseries.FactTable)2 HBaseMetricsTableModule (co.cask.cdap.data2.dataset2.module.lib.hbase.HBaseMetricsTableModule)2 IOException (java.io.IOException)2 DatasetProperties (co.cask.cdap.api.dataset.DatasetProperties)1