use of io.cdap.cdap.api.dataset.lib.KeyValueTable in project cdap by cdapio.
the class TestDatasetDefinition method getDataset.
@Override
public TestDataset getDataset(DatasetContext datasetContext, DatasetSpecification spec, Map<String, String> arguments, ClassLoader classLoader) throws IOException {
DatasetSpecification kvTableSpec = spec.getSpecification("kv");
KeyValueTable table = tableDef.getDataset(datasetContext, kvTableSpec, DatasetDefinition.NO_ARGUMENTS, classLoader);
return new TestDataset(spec, table, arguments);
}
use of io.cdap.cdap.api.dataset.lib.KeyValueTable in project cdap by cdapio.
the class TestDatasetModule method register.
@Override
public void register(DatasetDefinitionRegistry registry) {
DatasetDefinition<KeyValueTable, DatasetAdmin> kvTableDef = registry.get("keyValueTable");
DatasetDefinition definition = new TestDatasetDefinition("testDataset", kvTableDef);
registry.add(definition);
}
use of io.cdap.cdap.api.dataset.lib.KeyValueTable in project cdap by cdapio.
the class StandaloneDatasetDefinition method getDataset.
@Override
public StandaloneDataset getDataset(DatasetContext datasetContext, DatasetSpecification spec, Map<String, String> arguments, ClassLoader classLoader) throws IOException {
DatasetSpecification kvTableSpec = spec.getSpecification("objects");
KeyValueTable table = tableDef.getDataset(datasetContext, kvTableSpec, arguments, classLoader);
return new StandaloneDataset(spec.getName(), table);
}
use of io.cdap.cdap.api.dataset.lib.KeyValueTable in project cdap by cdapio.
the class TestFrameworkTestRun method testMapReduceTaskMetricsDisable.
@Category(SlowTests.class)
@Test
public void testMapReduceTaskMetricsDisable() throws Exception {
addDatasetInstance("keyValueTable", "table1");
addDatasetInstance("keyValueTable", "table2");
DataSetManager<KeyValueTable> tableManager = getDataset("table1");
KeyValueTable inputTable = tableManager.get();
inputTable.write("hello", "world");
tableManager.flush();
ApplicationManager appManager = deployApplication(DatasetWithMRApp.class);
Map<String, String> argsForMR = ImmutableMap.of(DatasetWithMRApp.INPUT_KEY, "table1", DatasetWithMRApp.OUTPUT_KEY, "table2", "task.*." + SystemArguments.METRICS_ENABLED, "false");
MapReduceManager mrManager = appManager.getMapReduceManager(DatasetWithMRApp.MAPREDUCE_PROGRAM).start(argsForMR);
mrManager.waitForRun(ProgramRunStatus.COMPLETED, 5, TimeUnit.MINUTES);
appManager.stopAll();
testTaskMetric(mrManager.getHistory().get(0).getPid(), false);
}
use of io.cdap.cdap.api.dataset.lib.KeyValueTable in project cdap by cdapio.
the class TestFrameworkTestRun method assertWorkerDatasetWrites.
private void assertWorkerDatasetWrites(byte[] startRow, byte[] endRow, int expectedCount, int expectedTotalCount) throws Exception {
DataSetManager<KeyValueTable> datasetManager = getDataset(testSpace.dataset(AppUsingGetServiceURL.WORKER_INSTANCES_DATASET));
KeyValueTable instancesTable = datasetManager.get();
try (CloseableIterator<KeyValue<byte[], byte[]>> instancesIterator = instancesTable.scan(startRow, endRow)) {
List<KeyValue<byte[], byte[]>> workerInstances = Lists.newArrayList(instancesIterator);
// Assert that the worker starts with expectedCount instances
Assert.assertEquals(expectedCount, workerInstances.size());
// Assert that each instance of the worker knows the total number of instances
for (KeyValue<byte[], byte[]> keyValue : workerInstances) {
Assert.assertEquals(expectedTotalCount, Bytes.toInt(keyValue.getValue()));
}
}
}
Aggregations