@Override public DatasetSpecification reconfigure(String instanceName, DatasetProperties newProperties, DatasetSpecification currentSpec) throws IncompatibleUpdateException { return super.reconfigure(instanceName, noConflictDetection(newProperties), currentSpec); }
@Override public DatasetSpecification reconfigure(String instanceName, DatasetProperties newProperties, DatasetSpecification currentSpec) throws IncompatibleUpdateException { // TODO (CDAP-6268): validate schema compatibility return super.reconfigure(instanceName, configureSchema(newProperties), currentSpec); }
@Override public DatasetSpecification reconfigure(String instanceName, DatasetProperties newProperties, DatasetSpecification currentSpec) throws IncompatibleUpdateException { TimeseriesTableDefinition.validateNewIntervalSize(newProperties, currentSpec); return super.reconfigure(instanceName, newProperties, currentSpec); }
@Override public DatasetSpecification reconfigure(String instanceName, DatasetProperties newProperties, DatasetSpecification currentSpec) throws IncompatibleUpdateException { validateNewIntervalSize(newProperties, currentSpec); return super.reconfigure(instanceName, newProperties, currentSpec); }
@Override public DatasetSpecification reconfigure(String instanceName, DatasetProperties newProperties, DatasetSpecification currentSpec) throws IncompatibleUpdateException { return super.reconfigure(instanceName, noConflictDetection(newProperties), currentSpec); }
@Override public DatasetSpecification reconfigure(String instanceName, DatasetProperties newProperties, DatasetSpecification currentSpec) throws IncompatibleUpdateException { // TODO (CDAP-6268): validate schema compatibility return super.reconfigure(instanceName, configureSchema(newProperties), currentSpec); }
@Override public DatasetSpecification reconfigure(String instanceName, DatasetProperties newProperties, DatasetSpecification currentSpec) throws IncompatibleUpdateException { List<DatasetSpecification> specs = new ArrayList<>(); for (Map.Entry<String, ? extends DatasetDefinition> impl : this.delegates.entrySet()) { specs.add(reconfigure(impl.getValue(), impl.getKey(), newProperties, currentSpec.getSpecification(impl.getKey()))); } return DatasetSpecification.builder(instanceName, getName()) .properties(newProperties.getProperties()) .datasets(specs) .build(); }
@Override public DatasetSpecification reconfigure(String instanceName, DatasetProperties newProperties, DatasetSpecification currentSpec) throws IncompatibleUpdateException { // validate that the columns to index property is not null and the same as before String columnNamesToIndex = newProperties.getProperties().get(IndexedTable.INDEX_COLUMNS_CONF_KEY); if (columnNamesToIndex == null) { throw new IllegalArgumentException("columnsToIndex must be specified"); } String oldColumnsToIndex = currentSpec.getProperty(IndexedTable.INDEX_COLUMNS_CONF_KEY); if (!columnNamesToIndex.equals(oldColumnsToIndex)) { Set<byte[]> newColumns = parseColumns(columnNamesToIndex); Set<byte[]> oldColumns = parseColumns(oldColumnsToIndex); if (!newColumns.equals(oldColumns)) { throw new IncompatibleUpdateException(String.format("Attempt to change columns to index from '%s' to '%s'", oldColumnsToIndex, columnNamesToIndex)); } } return super.reconfigure(instanceName, newProperties, currentSpec); }
@Override public DatasetSpecification reconfigure(String instanceName, DatasetProperties newProperties, DatasetSpecification currentSpec) throws IncompatibleUpdateException { String currentValue = currentSpec.getProperty("immutable"); String newValue = newProperties.getProperties().get("immutable"); if (!Objects.equals(currentValue, newValue)) { throw new IncompatibleUpdateException(String.format("Cannot change property 'immutable' from %s to %s", currentValue, newValue)); } return super.reconfigure(instanceName, newProperties, currentSpec); }
@Test public void testCompositeDatasetReconfigure() throws IncompatibleUpdateException { CompositeDatasetDefinition composite = new CompositeDatasetDefinition( "composite", "pedantic", new PedanticDatasetDefinition("pedantic")) { @Override public Dataset getDataset(DatasetContext datasetContext, DatasetSpecification spec, Map arguments, ClassLoader classLoader) throws IOException { return null; } }; DatasetSpecification spec = composite.configure("nn", DatasetProperties.EMPTY); DatasetSpecification respec = composite.reconfigure("nn", DatasetProperties.EMPTY, spec); Assert.assertEquals(spec, respec); try { composite.reconfigure("nn", DatasetProperties.builder().add("immutable", "x").build(), spec); Assert.fail("reconfigure should have thrown exception"); } catch (IncompatibleUpdateException e) { // expected } }