use of co.cask.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);
}
use of co.cask.cdap.data2.dataset2.lib.table.MetricsTable in project cdap by caskdata.
the class SystemDatasetRuntimeModule method getStandaloneModules.
@Override
public Module getStandaloneModules() {
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-leveldb").toInstance(new LevelDBTableModule());
mapBinder.addBinding("metricsTable-leveldb").toInstance(new LevelDBMetricsTableModule());
bindDefaultModules(mapBinder);
}
};
}
use of co.cask.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);
}
};
}
use of co.cask.cdap.data2.dataset2.lib.table.MetricsTable in project cdap by caskdata.
the class SystemDatasetRuntimeModule method getDistributedModules.
@Override
public Module getDistributedModules() {
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-hbase").toProvider(OrderedTableModuleProvider.class).in(Singleton.class);
mapBinder.addBinding("metricsTable-hbase").toInstance(new HBaseMetricsTableModule());
bindDefaultModules(mapBinder);
mapBinder.addBinding("queueDataset").toInstance(new HBaseQueueDatasetModule());
}
};
}
use of co.cask.cdap.data2.dataset2.lib.table.MetricsTable in project cdap by caskdata.
the class HBaseMetricsTableTest method testConcurrentIncrement.
@Override
@Test
public void testConcurrentIncrement() throws Exception {
String testConcurrentIncrement = "testConcurrentIncrement";
final MetricsTable table = getTable(testConcurrentIncrement);
final int rounds = 500;
Map<byte[], Long> inc1 = ImmutableMap.of(X, 1L, Y, 2L);
Map<byte[], Long> inc2 = ImmutableMap.of(Y, 1L, Z, 2L);
// HTable used by HBaseMetricsTable is not thread safe, so each thread must use a separate instance
// HBaseMetricsTable does not support mixed increment and incrementAndGet so the
// updates and assertions here are different from MetricsTableTest.testConcurrentIncrement()
Collection<? extends Thread> threads = ImmutableList.of(new IncThread(getTable(testConcurrentIncrement), A, inc1, rounds), new IncThread(getTable(testConcurrentIncrement), A, inc2, rounds), new IncAndGetThread(getTable(testConcurrentIncrement), A, R, 5, rounds), new IncAndGetThread(getTable(testConcurrentIncrement), A, R, 2, rounds));
for (Thread t : threads) {
t.start();
}
for (Thread t : threads) {
t.join();
if (t instanceof Closeable) {
((Closeable) t).close();
}
}
assertEquals(rounds, Bytes.toLong(table.get(A, X)));
assertEquals(3 * rounds, Bytes.toLong(table.get(A, Y)));
assertEquals(2 * rounds, Bytes.toLong(table.get(A, Z)));
assertEquals(7 * rounds, Bytes.toLong(table.get(A, R)));
}
Aggregations