valepakh commented on code in PR #5255:
URL: https://github.com/apache/ignite-3/pull/5255#discussion_r1979572340
##########
modules/cluster-management/src/test/java/org/apache/ignite/internal/cluster/management/ClusterInitializerTest.java:
##########
@@ -200,11 +196,10 @@ void testInitNoCancel() {
"cluster"
);
- InternalInitException e =
assertFutureThrows(InternalInitException.class, initFuture);
-
- assertThat(e.getMessage(), containsString(String.format("Got error
response from node \"%s\": foobar", cmgNode.name())));
+ String errorMessageFragment = String.format("Got error response from
node \"%s\": foobar", cmgNode.name());
+ assertThat(initFuture, willThrow(InternalInitException.class,
errorMessageFragment));
- verify(messagingService, never()).send(eq(metastorageNode),
any(CancelInitMessage.class));
+ verify(messagingService, never()).send(eq(cmgNode),
any(CancelInitMessage.class));
Review Comment:
It was a copy-paste error, the line below was exactly the same
##########
modules/cluster-management/src/test/java/org/apache/ignite/internal/cluster/management/ClusterInitializerTest.java:
##########
@@ -235,16 +230,21 @@ void testInitIllegalArguments() {
void testUnresolvableNode() {
CompletableFuture<Void> initFuture =
clusterInitializer.initCluster(List.of("foo"), List.of("bar"), "cluster");
- IllegalArgumentException e =
assertFutureThrows(IllegalArgumentException.class, initFuture);
-
- assertThat(e.getMessage(), containsString("Node \"foo\" is not present
in the physical topology"));
+ assertThat(initFuture, willThrow(IllegalArgumentException.class, "Node
\"foo\" is not present in the physical topology"));
}
- private static <T extends Throwable> T assertFutureThrows(Class<T>
expected, CompletableFuture<?> future) {
- ExecutionException e = assertThrows(ExecutionException.class, () ->
future.get(1, TimeUnit.SECONDS));
+ @Test
+ void testDuplicateConsistentId() {
+ // Different nodes with same consistent ids
+ ClusterNode node1 = new ClusterNodeImpl(randomUUID(), "node", new
NetworkAddress("foo", 123));
+ ClusterNode node2 = new ClusterNodeImpl(randomUUID(), "node", new
NetworkAddress("bar", 456));
+
+ when(topologyService.allMembers()).thenReturn(List.of(node1, node2));
+
+ CompletableFuture<Void> initFuture =
clusterInitializer.initCluster(List.of(node1.name()), List.of(node1.name()),
"cluster");
- assertThat(e.getCause(), isA(expected));
+ assertThat(initFuture, willThrow(InternalInitException.class,
"Duplicate consistent id \"node\""));
- return expected.cast(e.getCause());
+ verify(messagingService, never()).invoke(any(ClusterNode.class),
any(NetworkMessage.class), anyLong());
Review Comment:
Checked all overloads
##########
modules/network/src/main/java/org/apache/ignite/internal/network/netty/ConnectionManager.java:
##########
@@ -111,8 +111,8 @@ public class ConnectionManager implements
ChannelCreationListener {
/** Message listeners. */
private final List<Consumer<InNetworkObject>> listeners = new
CopyOnWriteArrayList<>();
- /** Node consistent id. */
- private final String consistentId;
+ /** Node id. */
Review Comment:
Fixed
##########
modules/network/src/main/java/org/apache/ignite/internal/network/netty/ConnectionManager.java:
##########
@@ -297,32 +302,32 @@ public InetSocketAddress localAddress() {
/**
* Gets a {@link NettySender}, that sends data from this node to another
node with the specified address.
*
- * @param consistentId Another node's consistent id.
- * @param address Another node's address.
+ * @param nodeId Another node's id.
+ * @param address Another node's address.
* @return Sender.
*/
- public OrderingFuture<NettySender> channel(@Nullable String consistentId,
ChannelType type, InetSocketAddress address) {
- return getChannelWithRetry(consistentId, type, address, 0);
+ public OrderingFuture<NettySender> channel(UUID nodeId, ChannelType type,
InetSocketAddress address) {
+ return getChannelWithRetry(nodeId, type, address, 0);
}
private OrderingFuture<NettySender> getChannelWithRetry(
- @Nullable String consistentId,
+ UUID nodeId,
ChannelType type,
InetSocketAddress address,
int attempt
) {
if (attempt > MAX_RETRIES_TO_OPEN_CHANNEL) {
- return OrderingFuture.failedFuture(new IllegalStateException("Too
many attempts to open channel to " + consistentId));
+ return OrderingFuture.failedFuture(new IllegalStateException("Too
many attempts to open channel to " + nodeId));
Review Comment:
Done
--
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]