use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class AbstractBasicIntegrationTest method createTable.
protected static void createTable(TableDefinitionBuilder tblBld) {
TableDefinition schTbl1 = tblBld.build();
CLUSTER_NODES.get(0).tables().createTable(schTbl1.canonicalName(), tblCh -> SchemaConfigurationConverter.convert(schTbl1, tblCh).changeReplicas(1).changePartitions(10));
}
use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class TableManagerTest method testGetTableDuringCreation.
/**
* Instantiates a table and prepares Table manager.
*/
@Test
public void testGetTableDuringCreation() {
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();
Phaser phaser = new Phaser(2);
CompletableFuture<Table> createFut = CompletableFuture.supplyAsync(() -> {
try {
return mockManagersAndCreateTableWithDelay(scmTbl, tblManagerFut, phaser);
} catch (NodeStoppingException e) {
fail(e.getMessage());
}
return null;
});
CompletableFuture<Table> getFut = CompletableFuture.supplyAsync(() -> {
phaser.awaitAdvance(0);
return tblManagerFut.join().table(scmTbl.canonicalName());
});
CompletableFuture<Collection<Table>> getAllTablesFut = CompletableFuture.supplyAsync(() -> {
phaser.awaitAdvance(0);
return tblManagerFut.join().tables();
});
assertFalse(createFut.isDone());
assertFalse(getFut.isDone());
assertFalse(getAllTablesFut.isDone());
phaser.arrive();
assertSame(createFut.join(), getFut.join());
assertEquals(1, getAllTablesFut.join().size());
}
use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class TableManagerTest method testCreateTable.
/**
* Tests create a table through public API.
*
* @throws Exception If failed.
*/
@Test
public void testCreateTable() throws Exception {
TableDefinition scmTbl = SchemaBuilders.tableBuilder("PUBLIC", DYNAMIC_TABLE_NAME).columns(SchemaBuilders.column("key", ColumnType.INT64).build(), SchemaBuilders.column("val", ColumnType.INT64).asNullable(true).build()).withPrimaryKey("key").build();
Table table = mockManagersAndCreateTable(scmTbl, tblManagerFut);
assertNotNull(table);
assertSame(table, tblManagerFut.join().table(scmTbl.canonicalName()));
}
use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class TableManagerTest method tableManagerStopTest.
/**
* Cheks that the all RAFT nodes will be stopped when Table manager is stopping.
*
* @throws Exception If failed.
*/
@Test
public void tableManagerStopTest() 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);
verify(rm, times(PARTITIONS)).prepareRaftGroup(anyString(), any(), any());
TableManager tableManager = tblManagerFut.join();
tableManager.stop();
verify(rm, times(PARTITIONS)).stopRaftGroup(anyString());
}
use of org.apache.ignite.schema.definition.TableDefinition in project ignite-3 by apache.
the class TableManagerTest method testDoubledCreateTable.
/**
* Tries to create a table that already exists.
*
* @throws Exception If failed.
*/
@Test
public void testDoubledCreateTable() throws Exception {
TableDefinition scmTbl = SchemaBuilders.tableBuilder("PUBLIC", DYNAMIC_TABLE_NAME).columns(SchemaBuilders.column("key", ColumnType.INT64).build(), SchemaBuilders.column("val", ColumnType.INT64).asNullable(true).build()).withPrimaryKey("key").build();
Table table = mockManagersAndCreateTable(scmTbl, tblManagerFut);
assertNotNull(table);
assertThrows(RuntimeException.class, () -> tblManagerFut.join().createTable(scmTbl.canonicalName(), tblCh -> SchemaConfigurationConverter.convert(scmTbl, tblCh).changeReplicas(REPLICAS).changePartitions(PARTITIONS)));
assertSame(table, tblManagerFut.join().table(scmTbl.canonicalName()));
}
Aggregations