/** * Reconfigure a dataset instance. Delegates to {@link Reconfigurable#reconfigure} if the dataset definition * implements that interface, and delegates to {@link #configure} otherwise. * @param def the dataset definition that will perform the (re)configure * @param name name of the dataset instance to reconfigure * @param newProps the updated dataset properties * @param currentSpec the current dataset specification * @return a new dataset specification representing the updated properties * @throws IncompatibleUpdateException if the updated properties are incompatible with the existing properties */ public static DatasetSpecification reconfigure(DatasetDefinition def, String name, DatasetProperties newProps, DatasetSpecification currentSpec) throws IncompatibleUpdateException { return def instanceof Reconfigurable ? ((Reconfigurable) def).reconfigure(name, newProps, currentSpec) : def.configure(name, newProps); } }
private void testFileSetReconfigure(boolean expectSuccess, DatasetDefinition def, Boolean wasExternal, String path, Boolean newExternal, String newPath, DatasetProperties extraProps) throws IncompatibleUpdateException { Assert.assertTrue(def instanceof Reconfigurable); DatasetProperties props = buildFileSetProps(extraProps, wasExternal, path); DatasetProperties newProps = buildFileSetProps(extraProps, newExternal, newPath); DatasetSpecification spec = def.configure("fs", props); if (expectSuccess) { ((Reconfigurable) def).reconfigure("fs", newProps, spec); } else { try { ((Reconfigurable) def).reconfigure("fs", newProps, spec); Assert.fail("reconfigure should have thrown exception"); } catch (IncompatibleUpdateException e) { // expected } } }
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 } }
.add(IndexedTable.INDEX_COLUMNS_CONF_KEY, "c,b,a") .build(); spec = ((Reconfigurable) indexedTableDef).reconfigure("idxtb", compat, spec); .build(); try { ((Reconfigurable) indexedTableDef).reconfigure("idxtb", incompat, spec); Assert.fail("reconfigure should have thrown exception"); } catch (IncompatibleUpdateException e) { .build(); try { ((Reconfigurable) indexedTableDef).reconfigure("idxtb", incompat, spec); Assert.fail("reconfigure should have thrown exception"); } catch (IncompatibleUpdateException e) {
Partitioning.builder().addStringField("s").build()).build(); try { ((Reconfigurable) pfsDef).reconfigure("pfs", noIprops, spec); Assert.fail("reconfigure should have thrown exception"); } catch (IncompatibleUpdateException e) { Partitioning.builder().addLongField("i").addStringField("s").build()).build(); try { ((Reconfigurable) pfsDef).reconfigure("pfs", longIprops, spec); Assert.fail("reconfigure should have thrown exception"); } catch (IncompatibleUpdateException e) { Partitioning.builder().addStringField("s").addIntField("i").build()).build(); try { ((Reconfigurable) pfsDef).reconfigure("pfs", revProps, spec); Assert.fail("reconfigure should have thrown exception"); } catch (IncompatibleUpdateException e) { .build(); DatasetSpecification oldSpec = pfsDef.configure("pfs", oldProps); DatasetSpecification newSpec = ((Reconfigurable) pfsDef).reconfigure("pfs", oldProps, oldSpec); .build(); oldSpec = pfsDef.configure("pfs", props); newSpec = ((Reconfigurable) pfsDef).reconfigure("pfs", props, oldSpec); newSpec = ((Reconfigurable) pfsDef).reconfigure("pfs", props, oldSpec);