use of io.cdap.cdap.api.dataset.DatasetSpecification in project cdap by caskdata.
the class FakeDatasetDefinition method getDataset.
@Override
public FakeDataset 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 FakeDataset(spec.getName(), table);
}
use of io.cdap.cdap.api.dataset.DatasetSpecification in project cdap by caskdata.
the class InMemoryDatasetOpExecutor method create.
@Override
public DatasetCreationResponse create(DatasetId datasetInstanceId, DatasetTypeMeta typeMeta, DatasetProperties props) throws Exception {
DatasetType type = client.getDatasetType(typeMeta, null, new ConstantClassLoaderProvider());
if (type == null) {
throw new IllegalArgumentException("Dataset type cannot be instantiated for provided type meta: " + typeMeta);
}
DatasetSpecification spec = type.configure(datasetInstanceId.getEntityName(), props);
DatasetAdmin admin = type.getAdmin(DatasetContext.from(datasetInstanceId.getNamespace()), spec);
admin.create();
return new DatasetCreationResponse(spec, null);
}
use of io.cdap.cdap.api.dataset.DatasetSpecification in project cdap by caskdata.
the class InMemoryDatasetOpExecutor method update.
@Override
public DatasetCreationResponse update(DatasetId datasetInstanceId, DatasetTypeMeta typeMeta, DatasetProperties props, DatasetSpecification existing) throws Exception {
DatasetType type = client.getDatasetType(typeMeta, null, new ConstantClassLoaderProvider());
if (type == null) {
throw new IllegalArgumentException("Dataset type cannot be instantiated for provided type meta: " + typeMeta);
}
try {
DatasetSpecification spec = type.reconfigure(datasetInstanceId.getEntityName(), props, existing);
DatasetAdmin admin = type.getAdmin(DatasetContext.from(datasetInstanceId.getNamespace()), spec);
if (admin instanceof Updatable) {
((Updatable) admin).update(existing);
} else {
admin.create();
}
if (spec.getDescription() == null && existing.getDescription() != null) {
spec.setDescription(existing.getDescription());
}
return new DatasetCreationResponse(spec, null);
} catch (IncompatibleUpdateException e) {
throw new ConflictException(e.getMessage());
}
}
use of io.cdap.cdap.api.dataset.DatasetSpecification in project cdap by caskdata.
the class PrefixedTable method getDataset.
@Override
public PrefixedTable getDataset(DatasetContext datasetContext, DatasetSpecification spec, Map<String, String> arguments, ClassLoader classLoader) throws IOException {
DatasetSpecification kvTableSpec = spec.getSpecification("table");
KeyValueTable table = tableDef.getDataset(datasetContext, kvTableSpec, DatasetDefinition.NO_ARGUMENTS, classLoader);
return new PrefixedTable(spec.getName(), table, arguments);
}
use of io.cdap.cdap.api.dataset.DatasetSpecification in project cdap by caskdata.
the class DatasetDefinitionRegistryWithDefaultModules method testTimeSeriesReconfigure.
private void testTimeSeriesReconfigure(DatasetDefinition def) throws IncompatibleUpdateException {
DatasetProperties props = DatasetProperties.builder().add(TimeseriesDataset.ATTR_TIME_INTERVAL_TO_STORE_PER_ROW, String.valueOf(TimeUnit.HOURS.toMillis(1))).build();
DatasetProperties compatProps = TableProperties.builder().setTTL(TimeUnit.DAYS.toSeconds(1)).add(TimeseriesDataset.ATTR_TIME_INTERVAL_TO_STORE_PER_ROW, String.valueOf(TimeUnit.HOURS.toMillis(1))).build();
DatasetProperties incompatProps = TableProperties.builder().setTTL(TimeUnit.DAYS.toSeconds(1)).add(TimeseriesDataset.ATTR_TIME_INTERVAL_TO_STORE_PER_ROW, String.valueOf(TimeUnit.HOURS.toMillis(2))).build();
DatasetSpecification spec = def.configure("tt", props);
Assert.assertTrue(def instanceof Reconfigurable);
((Reconfigurable) def).reconfigure("tt", compatProps, spec);
try {
((Reconfigurable) def).reconfigure("tt", incompatProps, spec);
Assert.fail("reconfigure should have thrown exception");
} catch (IncompatibleUpdateException e) {
// expected
}
}
Aggregations