Search in sources :

Example 1 with DataStorageView

use of org.apache.ignite.configuration.schemas.store.DataStorageView in project ignite-3 by apache.

the class TableValidatorImpl method validateDataRegion.

/**
 * Checks that data region configuration is valid. Check involves data region existence and region type preservation if it's updated.
 *
 * @param oldTable Previous configuration, maybe {@code null}.
 * @param newTable New configuration.
 * @param ctx      Validation context.
 */
private static void validateDataRegion(@Nullable TableView oldTable, TableView newTable, ValidationContext<?> ctx) {
    DataStorageView oldDbCfg = ctx.getOldRoot(DataStorageConfiguration.KEY);
    DataStorageView newDbCfg = ctx.getNewRoot(DataStorageConfiguration.KEY);
    if (oldTable != null && Objects.equals(oldTable.dataRegion(), newTable.dataRegion())) {
        return;
    }
    DataRegionView newRegion = dataRegion(newDbCfg, newTable.dataRegion());
    if (newRegion == null) {
        ctx.addIssue(new ValidationIssue(String.format("Data region '%s' configured for table '%s' isn't found", newTable.dataRegion(), newTable.name())));
        return;
    }
    if (oldDbCfg == null || oldTable == null) {
        return;
    }
    DataRegionView oldRegion = dataRegion(oldDbCfg, oldTable.dataRegion());
    if (!oldRegion.type().equalsIgnoreCase(newRegion.type())) {
        ctx.addIssue(new ValidationIssue(String.format("Unable to move table '%s' from region '%s' to region '%s' because it has different type (old=%s, new=%s)", newTable.name(), oldTable.dataRegion(), newTable.dataRegion(), oldRegion.type(), newRegion.type())));
    }
}
Also used : DataRegionView(org.apache.ignite.configuration.schemas.store.DataRegionView) DataStorageView(org.apache.ignite.configuration.schemas.store.DataStorageView) ValidationIssue(org.apache.ignite.configuration.validation.ValidationIssue)

Aggregations

DataRegionView (org.apache.ignite.configuration.schemas.store.DataRegionView)1 DataStorageView (org.apache.ignite.configuration.schemas.store.DataStorageView)1 ValidationIssue (org.apache.ignite.configuration.validation.ValidationIssue)1