Search in sources :

Example 11 with NodeStoppingException

use of org.apache.ignite.lang.NodeStoppingException in project ignite-3 by apache.

the class ItTablesApiTest method testCreateDropTable.

/**
 * Checks that if a table would be created/dropped in any cluster node, this action reflects on all others.
 * Table management operations should pass in linearize order: if an action completed in one node,
 * the result has to be visible to another one.
 *
 * @throws Exception If failed.
 */
@Test
public void testCreateDropTable() throws Exception {
    clusterNodes.forEach(ign -> assertNull(ign.tables().table(TABLE_NAME)));
    Ignite ignite1 = clusterNodes.get(1);
    WatchListenerInhibitor ignite1Inhibitor = metastorageEventsInhibitor(ignite1);
    ignite1Inhibitor.startInhibit();
    Table table = createTable(clusterNodes.get(0), SCHEMA, SHORT_TABLE_NAME);
    UUID tblId = ((TableImpl) table).tableId();
    CompletableFuture<Table> tableByNameFut = CompletableFuture.supplyAsync(() -> {
        return ignite1.tables().table(TABLE_NAME);
    });
    CompletableFuture<Table> tableByIdFut = CompletableFuture.supplyAsync(() -> {
        try {
            return ((IgniteTablesInternal) ignite1.tables()).table(tblId);
        } catch (NodeStoppingException e) {
            throw new AssertionError(e.getMessage());
        }
    });
    // Therefore the table still doesn't exists locally, but API prevents getting null and waits events.
    for (Ignite ignite : clusterNodes) {
        if (ignite != ignite1) {
            assertNotNull(ignite.tables().table(TABLE_NAME));
            assertNotNull(((IgniteTablesInternal) ignite.tables()).table(tblId));
        }
    }
    assertFalse(tableByNameFut.isDone());
    assertFalse(tableByIdFut.isDone());
    ignite1Inhibitor.stopInhibit();
    assertNotNull(tableByNameFut.get(10, TimeUnit.SECONDS));
    assertNotNull(tableByIdFut.get(10, TimeUnit.SECONDS));
    ignite1Inhibitor.startInhibit();
    clusterNodes.get(0).tables().dropTable(TABLE_NAME);
    // Therefore the table still exists locally, but API prevents getting it.
    for (Ignite ignite : clusterNodes) {
        assertNull(ignite.tables().table(TABLE_NAME));
        assertNull(((IgniteTablesInternal) ignite.tables()).table(tblId));
        assertThrows(TableNotFoundException.class, () -> dropTable(ignite, SCHEMA, SHORT_TABLE_NAME));
        dropTableIfExists(ignite, SCHEMA, SHORT_TABLE_NAME);
    }
    ignite1Inhibitor.stopInhibit();
}
Also used : Table(org.apache.ignite.table.Table) NodeStoppingException(org.apache.ignite.lang.NodeStoppingException) TableImpl(org.apache.ignite.internal.table.TableImpl) Ignite(org.apache.ignite.Ignite) WatchListenerInhibitor(org.apache.ignite.internal.test.WatchListenerInhibitor) UUID(java.util.UUID) IgniteTablesInternal(org.apache.ignite.internal.table.IgniteTablesInternal) Test(org.junit.jupiter.api.Test) IgniteAbstractTest(org.apache.ignite.internal.testframework.IgniteAbstractTest)

Example 12 with NodeStoppingException

use of org.apache.ignite.lang.NodeStoppingException in project ignite-3 by apache.

the class SqlSchemaManagerImpl method awaitLatestTableSchema.

@Nullable
private IgniteTable awaitLatestTableSchema(UUID tableId) {
    try {
        TableImpl table = tableManager.table(tableId);
        if (table == null) {
            return null;
        }
        table.schemaView().waitLatestSchema();
        return convert(table);
    } catch (NodeStoppingException e) {
        throw new IgniteInternalException(e);
    }
}
Also used : NodeStoppingException(org.apache.ignite.lang.NodeStoppingException) IgniteInternalException(org.apache.ignite.lang.IgniteInternalException) TableImpl(org.apache.ignite.internal.table.TableImpl) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with NodeStoppingException

use of org.apache.ignite.lang.NodeStoppingException in project ignite-3 by apache.

the class ConfigurationChanger method stop.

/**
 * Stop component.
 */
public void stop() {
    IgniteUtils.shutdownAndAwaitTermination(pool, 10, TimeUnit.SECONDS);
    StorageRoots roots = storageRoots;
    if (roots != null) {
        roots.changeFuture.completeExceptionally(new NodeStoppingException());
    }
}
Also used : NodeStoppingException(org.apache.ignite.lang.NodeStoppingException)

Aggregations

NodeStoppingException (org.apache.ignite.lang.NodeStoppingException)13 IgniteException (org.apache.ignite.lang.IgniteException)6 IgniteInternalException (org.apache.ignite.lang.IgniteInternalException)6 Table (org.apache.ignite.table.Table)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 NoSuchElementException (java.util.NoSuchElementException)4 UUID (java.util.UUID)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 Nullable (org.jetbrains.annotations.Nullable)4 IOException (java.io.IOException)3 Collection (java.util.Collection)3 Map (java.util.Map)3 Set (java.util.Set)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Consumer (java.util.function.Consumer)3 Collectors (java.util.stream.Collectors)3 DataStorageConfiguration (org.apache.ignite.configuration.schemas.store.DataStorageConfiguration)3 IgniteComponent (org.apache.ignite.internal.manager.IgniteComponent)3 Loza (org.apache.ignite.internal.raft.Loza)3