use of org.apache.ignite.lang.TableNotFoundException in project ignite-3 by apache.
the class TableManager method dropTableAsyncInternal.
/**
* Internal method that drops a table with the name specified. If appropriate table does not be found, a future will be
* completed with {@link TableNotFoundException}.
*
* @param name Table name.
* @return Future representing pending completion of the operation.
* @throws IgniteException If an unspecified platform exception has happened internally. Is thrown when:
* <ul>
* <li>the node is stopping.</li>
* </ul>
* @see TableNotFoundException
*/
@NotNull
private CompletableFuture<Void> dropTableAsyncInternal(String name) {
CompletableFuture<Void> dropTblFut = new CompletableFuture<>();
tableAsyncInternal(name).thenAccept(tbl -> {
// distributed table and the local config has lagged behind.
if (tbl == null) {
dropTblFut.completeExceptionally(new TableNotFoundException(name));
} else {
tablesCfg.tables().change(change -> {
if (change.get(name) == null) {
throw new TableNotFoundException(name);
}
change.delete(name);
}).whenComplete((res, t) -> {
if (t != null) {
Throwable ex = getRootCause(t);
if (ex instanceof TableNotFoundException) {
dropTblFut.completeExceptionally(ex);
} else {
LOG.error(IgniteStringFormatter.format("Table wasn't dropped [name={}]", name), ex);
dropTblFut.completeExceptionally(ex);
}
} else {
dropTblFut.complete(res);
}
});
}
});
return dropTblFut;
}
use of org.apache.ignite.lang.TableNotFoundException in project ignite-3 by apache.
the class TableManager method alterTableAsyncInternal.
/**
* Internal method that alters a cluster table. If an appropriate table does not exist, a future will be
* completed with {@link TableNotFoundException}.
*
* @param name Table name.
* @param tableChange Table changer.
* @return Future representing pending completion of the operation.
* @throws IgniteException If an unspecified platform exception has happened internally. Is thrown when:
* <ul>
* <li>the node is stopping.</li>
* </ul>
* @see TableNotFoundException
*/
@NotNull
private CompletableFuture<Void> alterTableAsyncInternal(String name, Consumer<TableChange> tableChange) {
CompletableFuture<Void> tblFut = new CompletableFuture<>();
tableAsync(name).thenAccept(tbl -> {
if (tbl == null) {
tblFut.completeExceptionally(new TableNotFoundException(name));
} else {
TableImpl tblImpl = (TableImpl) tbl;
tablesCfg.tables().change(ch -> {
if (ch.get(name) == null) {
throw new TableNotFoundException(name);
}
ch.update(name, tblCh -> {
tableChange.accept(tblCh);
((ExtendedTableChange) tblCh).changeSchemas(schemasCh -> schemasCh.createOrUpdate(String.valueOf(schemasCh.size() + 1), schemaCh -> {
ExtendedTableView currTableView = (ExtendedTableView) tablesCfg.tables().get(name).value();
SchemaDescriptor descriptor;
// here to ensure a valid configuration passed to prepareSchemaDescriptor() method.
try {
descriptor = SchemaUtils.prepareSchemaDescriptor(((ExtendedTableView) tblCh).schemas().size(), tblCh);
descriptor.columnMapping(SchemaUtils.columnMapper(tblImpl.schemaView().schema(currTableView.schemas().size()), currTableView, descriptor, tblCh));
} catch (IllegalArgumentException ex) {
// Convert unexpected exceptions here,
// because validation actually happens later,
// when bulk configuration update is applied.
ConfigurationValidationException e = new ConfigurationValidationException(ex.getMessage());
e.addSuppressed(ex);
throw e;
}
schemaCh.changeSchema(SchemaSerializerImpl.INSTANCE.serialize(descriptor));
}));
});
}).whenComplete((res, t) -> {
if (t != null) {
Throwable ex = getRootCause(t);
if (ex instanceof TableNotFoundException) {
tblFut.completeExceptionally(ex);
} else {
LOG.error(IgniteStringFormatter.format("Table wasn't altered [name={}]", name), ex);
tblFut.completeExceptionally(ex);
}
} else {
tblFut.complete(res);
}
});
}
});
return tblFut;
}
Aggregations