use of org.apache.ignite.internal.app.IgniteImpl in project ignite-3 by apache.
the class ItDataSchemaSyncTest method test.
/**
* The test executes various operation over the lagging node.
* The operations can be executed only the node overtakes a distributed cluster state.
*/
@Test
public void test() throws Exception {
Ignite ignite0 = clusterNodes.get(0);
final IgniteImpl ignite1 = (IgniteImpl) clusterNodes.get(1);
createTable(ignite0, SCHEMA, SHORT_TABLE_NAME);
TableImpl table = (TableImpl) ignite0.tables().table(TABLE_NAME);
assertEquals(1, table.schemaView().schema().version());
for (int i = 0; i < 10; i++) {
table.recordView().insert(null, Tuple.create().set("key", (long) i).set("valInt", i).set("valStr", "str_" + i));
}
WatchListenerInhibitor listenerInhibitor = WatchListenerInhibitor.metastorageEventsInhibitor(ignite1);
listenerInhibitor.startInhibit();
ColumnDefinition columnDefinition = SchemaBuilders.column("valStr2", ColumnType.string()).withDefaultValueExpression("default").build();
ignite0.tables().alterTable(TABLE_NAME, tblChanger -> tblChanger.changeColumns(cols -> cols.create(columnDefinition.name(), colChg -> convert(columnDefinition, colChg))));
for (Ignite node : clusterNodes) {
if (node == ignite1) {
continue;
}
TableImpl tableOnNode = (TableImpl) node.tables().table(TABLE_NAME);
IgniteTestUtils.waitForCondition(() -> tableOnNode.schemaView().lastSchemaVersion() == 2, 10_000);
}
TableImpl table1 = (TableImpl) ignite1.tables().table(TABLE_NAME);
for (int i = 10; i < 20; i++) {
table.recordView().insert(null, Tuple.create().set("key", (long) i).set("valInt", i).set("valStr", "str_" + i).set("valStr2", "str2_" + i));
}
final CompletableFuture insertFut = IgniteTestUtils.runAsync(() -> table1.recordView().insert(null, Tuple.create().set("key", 0L).set("valInt", 0).set("valStr", "str_" + 0).set("valStr2", "str2_" + 0)));
final CompletableFuture getFut = IgniteTestUtils.runAsync(() -> {
table1.recordView().get(null, Tuple.create().set("key", 10L));
});
final CompletableFuture checkDefaultFut = IgniteTestUtils.runAsync(() -> {
assertEquals("default", table1.recordView().get(null, Tuple.create().set("key", 0L)).value("valStr2"));
});
assertEquals(1, table1.schemaView().lastSchemaVersion());
assertFalse(getFut.isDone());
assertFalse(insertFut.isDone());
assertFalse(checkDefaultFut.isDone());
listenerInhibitor.stopInhibit();
getFut.get(10, TimeUnit.SECONDS);
insertFut.get(10, TimeUnit.SECONDS);
checkDefaultFut.get(10, TimeUnit.SECONDS);
for (Ignite node : clusterNodes) {
Table tableOnNode = node.tables().table(TABLE_NAME);
for (int i = 0; i < 20; i++) {
Tuple row = tableOnNode.recordView().get(null, Tuple.create().set("key", (long) i));
assertNotNull(row);
assertEquals(i, row.intValue("valInt"));
assertEquals("str_" + i, row.value("valStr"));
assertEquals(i < 10 ? "default" : ("str2_" + i), row.value("valStr2"));
}
}
}
use of org.apache.ignite.internal.app.IgniteImpl in project ignite-3 by apache.
the class PlatformTestNodeRunner method main.
/**
* Entry point.
*
* @param args Args.
*/
public static void main(String[] args) throws Exception {
System.out.println("Starting test node runner...");
for (int i = 0; i < args.length; i++) {
System.out.println("Arg " + i + ": " + args[i]);
}
if (args.length > 0 && "dry-run".equals(args[0])) {
System.out.println("Dry run succeeded.");
return;
}
IgniteUtils.deleteIfExists(BASE_PATH);
Files.createDirectories(BASE_PATH);
List<Ignite> startedNodes = new ArrayList<>();
nodesBootstrapCfg.forEach((nodeName, configStr) -> startedNodes.add(IgnitionManager.start(nodeName, configStr, BASE_PATH.resolve(nodeName))));
var keyCol = "key";
var valCol = "val";
TableDefinition schTbl = SchemaBuilders.tableBuilder(SCHEMA_NAME, TABLE_NAME).columns(SchemaBuilders.column(keyCol, ColumnType.INT64).build(), SchemaBuilders.column(valCol, ColumnType.string()).asNullable(true).build()).withPrimaryKey(keyCol).build();
startedNodes.get(0).tables().createTable(schTbl.canonicalName(), tblCh -> SchemaConfigurationConverter.convert(schTbl, tblCh).changeReplicas(1).changePartitions(10));
String ports = startedNodes.stream().map(n -> String.valueOf(getPort((IgniteImpl) n))).collect(Collectors.joining(","));
System.out.println("THIN_CLIENT_PORTS=" + ports);
Thread.sleep(RUN_TIME_MINUTES * 60_000);
System.out.println("Exiting after " + RUN_TIME_MINUTES + " minutes.");
}
use of org.apache.ignite.internal.app.IgniteImpl in project ignite-3 by apache.
the class ItIgniteNodeRestartTest method twoCustomPropertiesTest.
/**
* Checks that the only one non-default property overwrites after another configuration is passed on the node restart.
*/
@Test
public void twoCustomPropertiesTest(TestInfo testInfo) {
String nodeName = testNodeName(testInfo, 3344);
String startCfg = "network: {\n" + " port:3344,\n" + " nodeFinder: {netClusterNodes:[ \"localhost:3344\" ]}\n" + "}";
IgniteImpl ignite = (IgniteImpl) IgnitionManager.start(nodeName, startCfg, workDir);
assertEquals(3344, ignite.nodeConfiguration().getConfiguration(NetworkConfiguration.KEY).port().value());
assertArrayEquals(new String[] { "localhost:3344" }, ignite.nodeConfiguration().getConfiguration(NetworkConfiguration.KEY).nodeFinder().netClusterNodes().value());
IgnitionManager.stop(ignite.name());
ignite = (IgniteImpl) IgnitionManager.start(nodeName, "network.nodeFinder.netClusterNodes=[ \"localhost:3344\", \"localhost:3343\" ]", workDir);
assertEquals(3344, ignite.nodeConfiguration().getConfiguration(NetworkConfiguration.KEY).port().value());
assertArrayEquals(new String[] { "localhost:3344", "localhost:3343" }, ignite.nodeConfiguration().getConfiguration(NetworkConfiguration.KEY).nodeFinder().netClusterNodes().value());
IgnitionManager.stop(ignite.name());
}
use of org.apache.ignite.internal.app.IgniteImpl in project ignite-3 by apache.
the class ItIgniteNodeRestartTest method emptyNodeTest.
/**
* Restarts empty node.
*/
@Test
public void emptyNodeTest(TestInfo testInfo) {
String nodeName = testNodeName(testInfo, DEFAULT_NODE_PORT);
IgniteImpl ignite = (IgniteImpl) IgnitionManager.start(nodeName, null, workDir);
int nodePort = ignite.nodeConfiguration().getConfiguration(NetworkConfiguration.KEY).port().value();
assertEquals(DEFAULT_NODE_PORT, nodePort);
IgnitionManager.stop(ignite.name());
ignite = (IgniteImpl) IgnitionManager.start(nodeName, null, workDir);
nodePort = ignite.nodeConfiguration().getConfiguration(NetworkConfiguration.KEY).port().value();
assertEquals(DEFAULT_NODE_PORT, nodePort);
IgnitionManager.stop(ignite.name());
}
use of org.apache.ignite.internal.app.IgniteImpl in project ignite-3 by apache.
the class ItIgniteNodeRestartTest method changeConfigurationOnStartTest.
/**
* Restarts a node with changing configuration.
*/
@Test
public void changeConfigurationOnStartTest(TestInfo testInfo) {
String nodeName = testNodeName(testInfo, DEFAULT_NODE_PORT);
IgniteImpl ignite = (IgniteImpl) IgnitionManager.start(nodeName, null, workDir);
int nodePort = ignite.nodeConfiguration().getConfiguration(NetworkConfiguration.KEY).port().value();
assertEquals(DEFAULT_NODE_PORT, nodePort);
IgnitionManager.stop(ignite.name());
int newPort = 3322;
String updateCfg = "network.port=" + newPort;
ignite = (IgniteImpl) IgnitionManager.start(nodeName, updateCfg, workDir);
nodePort = ignite.nodeConfiguration().getConfiguration(NetworkConfiguration.KEY).port().value();
assertEquals(newPort, nodePort);
IgnitionManager.stop(ignite.name());
}
Aggregations