@@ -611,6 +611,100 @@ public void testJoinClusterWithRemoteStateNodeJoiningRemoteStateCluster() {
611
611
JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ());
612
612
}
613
613
614
+ public void testJoinRemotePublicationClusterWithNonRemoteNodes () {
615
+ final DiscoveryNode existingNode = new DiscoveryNode (
616
+ UUIDs .base64UUID (),
617
+ buildNewFakeTransportAddress (),
618
+ remotePublicationNodeAttributes (),
619
+ DiscoveryNodeRole .BUILT_IN_ROLES ,
620
+ Version .CURRENT
621
+ );
622
+ ClusterState currentState = ClusterState .builder (ClusterName .DEFAULT )
623
+ .nodes (DiscoveryNodes .builder ().add (existingNode ).localNodeId (existingNode .getId ()).build ())
624
+ .build ();
625
+
626
+ DiscoveryNode joiningNode = newDiscoveryNode (new HashMap <>());
627
+ JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ());
628
+ }
629
+
630
+ public void testJoinRemotePublicationCluster () {
631
+ final DiscoveryNode existingNode = new DiscoveryNode (
632
+ UUIDs .base64UUID (),
633
+ buildNewFakeTransportAddress (),
634
+ remotePublicationNodeAttributes (),
635
+ DiscoveryNodeRole .BUILT_IN_ROLES ,
636
+ Version .CURRENT
637
+ );
638
+ ClusterState currentState = ClusterState .builder (ClusterName .DEFAULT )
639
+ .nodes (DiscoveryNodes .builder ().add (existingNode ).localNodeId (existingNode .getId ()).build ())
640
+ .build ();
641
+
642
+ DiscoveryNode joiningNode = newDiscoveryNode (remotePublicationNodeAttributes ());
643
+ JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ());
644
+ }
645
+
646
+ public void testJoinRemotePubClusterWithRemoteStoreNodes () {
647
+ final DiscoveryNode existingNode = new DiscoveryNode (
648
+ UUIDs .base64UUID (),
649
+ buildNewFakeTransportAddress (),
650
+ remotePublicationNodeAttributes (),
651
+ DiscoveryNodeRole .BUILT_IN_ROLES ,
652
+ Version .CURRENT
653
+ );
654
+ ClusterState currentState = ClusterState .builder (ClusterName .DEFAULT )
655
+ .nodes (DiscoveryNodes .builder ().add (existingNode ).localNodeId (existingNode .getId ()).build ())
656
+ .build ();
657
+
658
+ Map <String , String > newNodeAttributes = new HashMap <>();
659
+ newNodeAttributes .putAll (remoteStateNodeAttributes (CLUSTER_STATE_REPO ));
660
+ newNodeAttributes .putAll (remoteRoutingTableAttributes (ROUTING_TABLE_REPO ));
661
+ newNodeAttributes .putAll (remoteStoreNodeAttributes (SEGMENT_REPO , TRANSLOG_REPO ));
662
+
663
+ DiscoveryNode joiningNode = newDiscoveryNode (newNodeAttributes );
664
+ Exception e = assertThrows (
665
+ IllegalStateException .class ,
666
+ () -> JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ())
667
+ );
668
+ assertTrue (e .getMessage ().equals ("a remote store node [" + joiningNode + "] is trying to join a non remote store cluster" ));
669
+ }
670
+
671
+ public void testPreventJoinRemotePublicationClusterWithIncompatibleAttributes () {
672
+ Map <String , String > existingNodeAttributes = remotePublicationNodeAttributes ();
673
+ Map <String , String > remoteStoreNodeAttributes = remotePublicationNodeAttributes ();
674
+ final DiscoveryNode existingNode = new DiscoveryNode (
675
+ UUIDs .base64UUID (),
676
+ buildNewFakeTransportAddress (),
677
+ existingNodeAttributes ,
678
+ DiscoveryNodeRole .BUILT_IN_ROLES ,
679
+ Version .CURRENT
680
+ );
681
+ ClusterState currentState = ClusterState .builder (ClusterName .DEFAULT )
682
+ .nodes (DiscoveryNodes .builder ().add (existingNode ).localNodeId (existingNode .getId ()).build ())
683
+ .build ();
684
+
685
+ for (Map .Entry <String , String > nodeAttribute : existingNodeAttributes .entrySet ()) {
686
+ remoteStoreNodeAttributes .put (nodeAttribute .getKey (), null );
687
+ DiscoveryNode joiningNode = newDiscoveryNode (remoteStoreNodeAttributes );
688
+ Exception e = assertThrows (
689
+ IllegalStateException .class ,
690
+ () -> JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ())
691
+ );
692
+ assertTrue (
693
+ e .getMessage ().equals ("joining node [" + joiningNode + "] doesn't have the node attribute [" + nodeAttribute .getKey () + "]" )
694
+ || e .getMessage ()
695
+ .equals (
696
+ "a remote store node ["
697
+ + joiningNode
698
+ + "] is trying to join a remote store cluster with incompatible node attributes in comparison with existing node ["
699
+ + currentState .getNodes ().getNodes ().values ().stream ().findFirst ().get ()
700
+ + "]"
701
+ )
702
+ );
703
+
704
+ remoteStoreNodeAttributes .put (nodeAttribute .getKey (), nodeAttribute .getValue ());
705
+ }
706
+ }
707
+
614
708
public void testPreventJoinClusterWithRemoteStateNodeJoiningRemoteStoreCluster () {
615
709
Map <String , String > existingNodeAttributes = remoteStoreNodeAttributes (SEGMENT_REPO , TRANSLOG_REPO );
616
710
final DiscoveryNode existingNode = new DiscoveryNode (
@@ -628,16 +722,7 @@ public void testPreventJoinClusterWithRemoteStateNodeJoiningRemoteStoreCluster()
628
722
IllegalStateException .class ,
629
723
() -> JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ())
630
724
);
631
- assertTrue (
632
- e .getMessage ()
633
- .equals (
634
- "a remote store node ["
635
- + joiningNode
636
- + "] is trying to join a remote store cluster with incompatible node attributes in comparison with existing node ["
637
- + currentState .getNodes ().getNodes ().values ().stream ().findFirst ().get ()
638
- + "]"
639
- )
640
- );
725
+ assertTrue (e .getMessage ().equals ("a non remote store node [" + joiningNode + "] is trying to join a remote store cluster" ));
641
726
}
642
727
643
728
public void testPreventJoinClusterWithRemoteStoreNodeJoiningRemoteStateCluster () {
@@ -657,16 +742,7 @@ public void testPreventJoinClusterWithRemoteStoreNodeJoiningRemoteStateCluster()
657
742
IllegalStateException .class ,
658
743
() -> JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ())
659
744
);
660
- assertTrue (
661
- e .getMessage ()
662
- .equals (
663
- "a remote store node ["
664
- + joiningNode
665
- + "] is trying to join a remote store cluster with incompatible node attributes in comparison with existing node ["
666
- + currentState .getNodes ().getNodes ().values ().stream ().findFirst ().get ()
667
- + "]"
668
- )
669
- );
745
+ assertTrue (e .getMessage ().equals ("a remote store node [" + joiningNode + "] is trying to join a non remote store cluster" ));
670
746
}
671
747
672
748
public void testUpdatesClusterStateWithSingleNodeCluster () throws Exception {
@@ -1077,6 +1153,39 @@ public void testRemoteRoutingTableNodeJoinNodeWithRemoteAndRoutingRepoDifference
1077
1153
JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ());
1078
1154
}
1079
1155
1156
+ public void testJoinRemoteStoreClusterWithRemotePublicationNodeInMixedMode () {
1157
+ final DiscoveryNode remoteStoreNode = new DiscoveryNode (
1158
+ UUIDs .base64UUID (),
1159
+ buildNewFakeTransportAddress (),
1160
+ remoteStoreNodeAttributes (SEGMENT_REPO , TRANSLOG_REPO ),
1161
+ DiscoveryNodeRole .BUILT_IN_ROLES ,
1162
+ Version .CURRENT
1163
+ );
1164
+
1165
+ final DiscoveryNode nonRemoteStoreNode = new DiscoveryNode (
1166
+ UUIDs .base64UUID (),
1167
+ buildNewFakeTransportAddress (),
1168
+ new HashMap <>(),
1169
+ DiscoveryNodeRole .BUILT_IN_ROLES ,
1170
+ Version .CURRENT
1171
+ );
1172
+
1173
+ final Settings settings = Settings .builder ()
1174
+ .put (MIGRATION_DIRECTION_SETTING .getKey (), RemoteStoreNodeService .Direction .REMOTE_STORE )
1175
+ .put (REMOTE_STORE_COMPATIBILITY_MODE_SETTING .getKey (), "mixed" )
1176
+ .build ();
1177
+ final Settings nodeSettings = Settings .builder ().put (REMOTE_STORE_MIGRATION_EXPERIMENTAL , "true" ).build ();
1178
+ FeatureFlags .initializeFeatureFlags (nodeSettings );
1179
+ Metadata metadata = Metadata .builder ().persistentSettings (settings ).build ();
1180
+ ClusterState currentState = ClusterState .builder (ClusterName .DEFAULT )
1181
+ .nodes (DiscoveryNodes .builder ().add (remoteStoreNode ).add (nonRemoteStoreNode ).localNodeId (remoteStoreNode .getId ()).build ())
1182
+ .metadata (metadata )
1183
+ .build ();
1184
+
1185
+ DiscoveryNode joiningNode = newDiscoveryNode (remotePublicationNodeAttributes ());
1186
+ JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ());
1187
+ }
1188
+
1080
1189
private void validateRepositoryMetadata (ClusterState updatedState , DiscoveryNode existingNode , int expectedRepositories )
1081
1190
throws Exception {
1082
1191
@@ -1115,6 +1224,7 @@ private DiscoveryNode newDiscoveryNode(Map<String, String> attributes) {
1115
1224
}
1116
1225
1117
1226
private static final String SEGMENT_REPO = "segment-repo" ;
1227
+
1118
1228
private static final String TRANSLOG_REPO = "translog-repo" ;
1119
1229
private static final String CLUSTER_STATE_REPO = "cluster-state-repo" ;
1120
1230
private static final String COMMON_REPO = "remote-repo" ;
@@ -1161,6 +1271,13 @@ private Map<String, String> remoteStoreNodeAttributes(String segmentRepoName, St
1161
1271
};
1162
1272
}
1163
1273
1274
+ private Map <String , String > remotePublicationNodeAttributes () {
1275
+ Map <String , String > existingNodeAttributes = new HashMap <>();
1276
+ existingNodeAttributes .putAll (remoteStateNodeAttributes (CLUSTER_STATE_REPO ));
1277
+ existingNodeAttributes .putAll (remoteRoutingTableAttributes (ROUTING_TABLE_REPO ));
1278
+ return existingNodeAttributes ;
1279
+ }
1280
+
1164
1281
private Map <String , String > remoteStateNodeAttributes (String clusterStateRepo ) {
1165
1282
String clusterStateRepositoryTypeAttributeKey = String .format (
1166
1283
Locale .getDefault (),
0 commit comments