use of org.apache.ignite.internal.table.distributed.TableManager in project ignite-3 by apache.
the class TableManagerTest method testInternalApiTableManagerOnStop.
/**
* Tests a work of the public API for Table manager {@see org.apache.ignite.internal.table.IgniteTablesInternal} when the manager is
* stopping.
*/
@Test
public void testInternalApiTableManagerOnStop() {
createTableManager(tblManagerFut);
TableManager tableManager = tblManagerFut.join();
tableManager.beforeNodeStop();
tableManager.stop();
UUID fakeTblId = UUID.randomUUID();
assertThrows(IgniteException.class, () -> tableManager.table(fakeTblId));
assertThrows(IgniteException.class, () -> tableManager.tableAsync(fakeTblId));
assertThrows(NodeStoppingException.class, () -> tableManager.setBaseline(Collections.singleton("fakeNode0")));
}
use of org.apache.ignite.internal.table.distributed.TableManager in project ignite-3 by apache.
the class TableManagerTest method testApiTableManagerOnStop.
/**
* Tests a work of the public API for Table manager {@see org.apache.ignite.table.manager.IgniteTables} when the manager is stopping.
*/
@Test
public void testApiTableManagerOnStop() {
createTableManager(tblManagerFut);
TableManager tableManager = tblManagerFut.join();
tableManager.beforeNodeStop();
tableManager.stop();
String tblFullName = "PUBLIC." + DYNAMIC_TABLE_FOR_DROP_NAME;
Consumer<TableChange> createTableChange = (TableChange change) -> SchemaConfigurationConverter.convert(SchemaBuilders.tableBuilder("PUBLIC", DYNAMIC_TABLE_FOR_DROP_NAME).columns(SchemaBuilders.column("key", ColumnType.INT64).build(), SchemaBuilders.column("val", ColumnType.INT64).asNullable(true).build()).withPrimaryKey("key").build(), change).changeReplicas(REPLICAS).changePartitions(PARTITIONS);
final Consumer<TableChange> addColumnChange = (TableChange change) -> change.changeColumns(cols -> {
int colIdx = change.columns().namedListKeys().stream().mapToInt(Integer::parseInt).max().getAsInt() + 1;
cols.create(String.valueOf(colIdx), colChg -> SchemaConfigurationConverter.convert(SchemaBuilders.column("name", ColumnType.string()).build(), colChg));
});
TableManager igniteTables = tableManager;
assertThrows(IgniteException.class, () -> igniteTables.createTable(tblFullName, createTableChange));
assertThrows(IgniteException.class, () -> igniteTables.createTableAsync(tblFullName, createTableChange));
assertThrows(IgniteException.class, () -> igniteTables.alterTable(tblFullName, addColumnChange));
assertThrows(IgniteException.class, () -> igniteTables.alterTableAsync(tblFullName, addColumnChange));
assertThrows(IgniteException.class, () -> igniteTables.dropTable(tblFullName));
assertThrows(IgniteException.class, () -> igniteTables.dropTableAsync(tblFullName));
assertThrows(IgniteException.class, () -> igniteTables.tables());
assertThrows(IgniteException.class, () -> igniteTables.tablesAsync());
assertThrows(IgniteException.class, () -> igniteTables.table(tblFullName));
assertThrows(IgniteException.class, () -> igniteTables.tableAsync(tblFullName));
}
use of org.apache.ignite.internal.table.distributed.TableManager in project ignite-3 by apache.
the class TableManagerTest method testDropTable.
/**
* Tests drop a table through public API.
*
* @throws Exception If failed.
*/
@Test
public void testDropTable() throws Exception {
TableDefinition scmTbl = SchemaBuilders.tableBuilder("PUBLIC", DYNAMIC_TABLE_FOR_DROP_NAME).columns(SchemaBuilders.column("key", ColumnType.INT64).build(), SchemaBuilders.column("val", ColumnType.INT64).asNullable(true).build()).withPrimaryKey("key").build();
mockManagersAndCreateTable(scmTbl, tblManagerFut);
TableManager tableManager = tblManagerFut.join();
tableManager.dropTable(scmTbl.canonicalName());
assertNull(tableManager.table(scmTbl.canonicalName()));
assertEquals(0, tableManager.tables().size());
}
use of org.apache.ignite.internal.table.distributed.TableManager in project ignite-3 by apache.
the class StopCalciteModuleTest method before.
/**
* Before.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
@BeforeEach
public void before(TestInfo testInfo) {
when(clusterSrvc.messagingService()).thenReturn(msgSrvc);
when(clusterSrvc.topologyService()).thenReturn(topologySrvc);
when(clusterSrvc.localConfiguration()).thenReturn(localCfg);
ClusterNode node = new ClusterNode("mock-node-id", NODE_NAME, null);
when(topologySrvc.localMember()).thenReturn(node);
when(topologySrvc.allMembers()).thenReturn(Collections.singleton(node));
SchemaDescriptor schemaDesc = new SchemaDescriptor(1, new Column[] { new Column(0, "ID", NativeTypes.INT32, false) }, new Column[] { new Column(1, "VAL", NativeTypes.INT32, false) });
schemaReg = new SchemaRegistryImpl(1, (v) -> schemaDesc, () -> INITIAL_SCHEMA_VERSION);
when(tbl.name()).thenReturn("PUBLIC.TEST");
// Mock create table (notify on register listener).
doAnswer(invocation -> {
EventListener<TableEventParameters> clo = (EventListener<TableEventParameters>) invocation.getArguments()[1];
clo.notify(new TableEventParameters(0, UUID.randomUUID(), "TEST", new TableImpl(tbl, schemaReg)), null);
return null;
}).when(tableManager).listen(eq(TableEvent.CREATE), any());
RowAssembler asm = new RowAssembler(schemaReg.schema(), 0, 0, 0, 0);
asm.appendInt(0);
asm.appendInt(0);
BinaryRow binaryRow = asm.build();
// Mock table scan
doAnswer(invocation -> {
int part = (int) invocation.getArguments()[0];
return (Flow.Publisher<BinaryRow>) s -> {
s.onSubscribe(new Flow.Subscription() {
@Override
public void request(long n) {
}
@Override
public void cancel() {
}
});
if (part == 0) {
for (int i = 0; i < ROWS; ++i) {
s.onNext(binaryRow);
}
}
s.onComplete();
};
}).when(tbl).scan(anyInt(), any());
LOG.info(">>>> Starting test {}", testInfo.getTestMethod().orElseThrow().getName());
}
use of org.apache.ignite.internal.table.distributed.TableManager in project ignite-3 by apache.
the class MockedStructuresTest method createTableManager.
/**
* Creates Table manager.
*
* @return Table manager.
*/
@NotNull
private TableManager createTableManager() {
TableManager tableManager = new TableManager(revisionUpdater, tblsCfg, dataStorageCfg, rm, bm, ts, workDir, tm);
tableManager.start();
return tableManager;
}
Aggregations