kgusakov commented on a change in pull request #379:
URL: https://github.com/apache/ignite-3/pull/379#discussion_r724195595
##########
File path: modules/raft/src/main/java/org/apache/ignite/internal/raft/Loza.java
##########
@@ -147,4 +166,44 @@ public void stopRaftGroup(String groupId,
List<ClusterNode> nodes) {
if (nodes.stream().anyMatch(n -> locNodeName.equals(n.name())))
raftServer.stopRaftGroup(groupId);
}
+
+ /**
+ * Creates a raft group service providing operations on a raft group.
+ * If {@code deltaNodes} contains the current node, then raft group starts
on the current node.
+ * @param groupId Raft group id.
+ * @param nodes Full set of raft group nodes.
+ * @param deltaNodes New raft group nodes.
+ * @param lsnrSupplier Raft group listener supplier.
+ * @return Future representing pending completion of the operation.
+ * @return
+ */
+ public CompletableFuture<RaftGroupService> updateRaftGroup(
Review comment:
No. We need to set nodes to the client as peer list and run **only new
nodes**, comparing to the previous assignment
##########
File path: modules/api/src/main/java/org/apache/ignite/Ignite.java
##########
@@ -44,4 +45,11 @@
* @return Ignite transactions.
*/
IgniteTransactions transactions();
+
+ /**
+ * Set new baseline nodes for table assignments.
+ *
+ * @param baselineNodes Names of baseline nodes.
+ */
+ void setBaseline(Set<String> baselineNodes);
Review comment:
@vldpyatkov ClusterNode is not the part of public API, am I right?
##########
File path: modules/raft/src/main/java/org/apache/ignite/internal/raft/Loza.java
##########
@@ -125,14 +135,23 @@ public Loza(ClusterService clusterNetSvc, Path dataPath) {
groupId,
clusterNetSvc,
FACTORY,
- TIMEOUT,
+ clientTimeout,
+ networkTimeout,
peers,
true,
DELAY,
executor
);
}
+ public CompletableFuture<RaftGroupService> prepareRaftGroup(
+ String groupId,
+ List<ClusterNode> nodes,
+ Supplier<RaftGroupListener> lsnrSupplier) {
+
+ return prepareRaftGroup(groupId, nodes, lsnrSupplier, TIMEOUT,
NETWORK_TIMEOUT);
Review comment:
Because we need the version with params and constants as defaults -
simple overloading. Maybe I didn't understand the question...
##########
File path:
modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ITBaselineChangesTest.java
##########
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.runner.app;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import com.google.common.collect.Lists;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import
org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter;
+import org.apache.ignite.internal.testframework.WorkDirectory;
+import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.schema.definition.TableDefinition;
+import org.apache.ignite.table.RecordView;
+import org.apache.ignite.table.Table;
+import org.apache.ignite.table.Tuple;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import static
org.apache.ignite.internal.testframework.IgniteTestUtils.testNodeName;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Test for baseline changes
+ */
+@ExtendWith(WorkDirectoryExtension.class)
+public class ITBaselineChangesTest {
+ /** Start network port for test nodes. */
+ private static final int BASE_PORT = 3344;
+
+ /** Nodes bootstrap configuration. */
+ private final Map<String, String> initClusterNodes = new LinkedHashMap<>();
+
+ /** */
+ private final List<Ignite> clusterNodes = new ArrayList<>();
+
+ /** */
+ @WorkDirectory
+ private Path workDir;
+
+ /** */
+ @BeforeEach
+ void setUp(TestInfo testInfo) {
+ String node0Name = testNodeName(testInfo, BASE_PORT);
+ String node1Name = testNodeName(testInfo, BASE_PORT + 1);
+ String node2Name = testNodeName(testInfo, BASE_PORT + 2);
+
+ initClusterNodes.put(
+ node0Name,
+ buildConfig(node0Name, 0)
+ );
+
+ initClusterNodes.put(
+ node1Name,
+ buildConfig(node0Name, 1)
+ );
+
+ initClusterNodes.put(
+ node2Name,
+ buildConfig(node0Name, 2)
+ );
+ }
+
+ /** */
+ @AfterEach
+ void tearDown() throws Exception {
+ IgniteUtils.closeAll(Lists.reverse(clusterNodes));
+ }
+
+ /**
+ * Check dynamic table creation.
+ */
+ @Test
+ void testBaselineExtending(TestInfo testInfo) {
+ initClusterNodes.forEach((nodeName, configStr) ->
+ clusterNodes.add(IgnitionManager.start(nodeName, configStr,
workDir.resolve(nodeName)))
+ );
+
+ assertEquals(3, clusterNodes.size());
+
+ // Create table on node 0.
+ TableDefinition schTbl1 = SchemaBuilders.tableBuilder("PUBLIC",
"tbl1").columns(
+ SchemaBuilders.column("key", ColumnType.INT64).asNonNull().build(),
+ SchemaBuilders.column("val", ColumnType.INT32).asNullable().build()
+ ).withPrimaryKey("key").build();
+
+ clusterNodes.get(0).tables().createTable(schTbl1.canonicalName(),
tblCh ->
+ SchemaConfigurationConverter.convert(schTbl1, tblCh)
+ .changeReplicas(5)
+ .changePartitions(1)
+ );
+
+ // Put data on node 1.
+ Table tbl1 =
clusterNodes.get(1).tables().table(schTbl1.canonicalName());
+ RecordView<Tuple> recView1 = tbl1.recordView();
+
+ recView1.insert(Tuple.create().set("key", 1L).set("val", 111));
+
+ // Get data on node 2.
+ Table tbl2 =
clusterNodes.get(2).tables().table(schTbl1.canonicalName());
+ RecordView<Tuple> recView2 = tbl2.recordView();
+
+ final Tuple keyTuple1 = Tuple.create().set("key", 1L);
+
+ assertEquals(1, (Long)recView2.get(keyTuple1).value("key"));
+
+ var metaStoreNode = clusterNodes.get(0);
+
+ var node3Name = testNodeName(testInfo, nodePort(3));
+ var node4Name = testNodeName(testInfo, nodePort(4));
+
+ // Start 2 new nodes after
+ var node3 = IgnitionManager.start(
+ node3Name, buildConfig(metaStoreNode.name(), 3),
workDir.resolve(node3Name));
+ var node4 = IgnitionManager.start(
+ node4Name, buildConfig(metaStoreNode.name(), 4),
workDir.resolve(node4Name));
+
+ clusterNodes.add(node3);
+ clusterNodes.add(node4);
+
+ // Update baseline to nodes 1,4,5
+ metaStoreNode.setBaseline(Set.of(metaStoreNode.name(), node3Name,
node4Name));
+
+ IgnitionManager.stop(clusterNodes.get(1).name());
+ IgnitionManager.stop(clusterNodes.get(2).name());
+
+ Table tbl4 = node4.tables().table(schTbl1.canonicalName());
+
+ assertEquals(1, (Long) tbl4.recordView().get(keyTuple1).value("key"));
Review comment:
If it didn't see reassignment - it means, that the raft node for the
table group is not started yet too (it starts inside assignment listener) - it
means, that changePeers must fail above. But anyway - we have small gap between
starting raft node and updating
##########
File path:
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
##########
@@ -824,4 +885,141 @@ private void dropTableLocally(String name, IgniteUuid
tblId, List<List<ClusterNo
private boolean isTableConfigured(String name) {
return tableNamesConfigured().contains(name);
}
+
+ public void setBaseline(Set<String> nodes) {
+ var newAssignments = baselineMgr
Review comment:
Added in javadoc
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]