@@ -689,6 +689,100 @@ public void testJoinClusterWithRemoteStateNodeJoiningRemoteStateCluster() {
689
689
JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ());
690
690
}
691
691
692
+ public void testJoinRemotePublicationClusterWithNonRemoteNodes () {
693
+ final DiscoveryNode existingNode = new DiscoveryNode (
694
+ UUIDs .base64UUID (),
695
+ buildNewFakeTransportAddress (),
696
+ remotePublicationNodeAttributes (),
697
+ DiscoveryNodeRole .BUILT_IN_ROLES ,
698
+ Version .CURRENT
699
+ );
700
+ ClusterState currentState = ClusterState .builder (ClusterName .DEFAULT )
701
+ .nodes (DiscoveryNodes .builder ().add (existingNode ).localNodeId (existingNode .getId ()).build ())
702
+ .build ();
703
+
704
+ DiscoveryNode joiningNode = newDiscoveryNode (new HashMap <>());
705
+ JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ());
706
+ }
707
+
708
+ public void testJoinRemotePublicationCluster () {
709
+ final DiscoveryNode existingNode = new DiscoveryNode (
710
+ UUIDs .base64UUID (),
711
+ buildNewFakeTransportAddress (),
712
+ remotePublicationNodeAttributes (),
713
+ DiscoveryNodeRole .BUILT_IN_ROLES ,
714
+ Version .CURRENT
715
+ );
716
+ ClusterState currentState = ClusterState .builder (ClusterName .DEFAULT )
717
+ .nodes (DiscoveryNodes .builder ().add (existingNode ).localNodeId (existingNode .getId ()).build ())
718
+ .build ();
719
+
720
+ DiscoveryNode joiningNode = newDiscoveryNode (remotePublicationNodeAttributes ());
721
+ JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ());
722
+ }
723
+
724
+ public void testJoinRemotePubClusterWithRemoteStoreNodes () {
725
+ final DiscoveryNode existingNode = new DiscoveryNode (
726
+ UUIDs .base64UUID (),
727
+ buildNewFakeTransportAddress (),
728
+ remotePublicationNodeAttributes (),
729
+ DiscoveryNodeRole .BUILT_IN_ROLES ,
730
+ Version .CURRENT
731
+ );
732
+ ClusterState currentState = ClusterState .builder (ClusterName .DEFAULT )
733
+ .nodes (DiscoveryNodes .builder ().add (existingNode ).localNodeId (existingNode .getId ()).build ())
734
+ .build ();
735
+
736
+ Map <String , String > newNodeAttributes = new HashMap <>();
737
+ newNodeAttributes .putAll (remoteStateNodeAttributes (CLUSTER_STATE_REPO ));
738
+ newNodeAttributes .putAll (remoteRoutingTableAttributes (ROUTING_TABLE_REPO ));
739
+ newNodeAttributes .putAll (remoteStoreNodeAttributes (SEGMENT_REPO , TRANSLOG_REPO ));
740
+
741
+ DiscoveryNode joiningNode = newDiscoveryNode (newNodeAttributes );
742
+ Exception e = assertThrows (
743
+ IllegalStateException .class ,
744
+ () -> JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ())
745
+ );
746
+ assertTrue (e .getMessage ().equals ("a remote store node [" + joiningNode + "] is trying to join a non remote store cluster" ));
747
+ }
748
+
749
+ public void testPreventJoinRemotePublicationClusterWithIncompatibleAttributes () {
750
+ Map <String , String > existingNodeAttributes = remotePublicationNodeAttributes ();
751
+ Map <String , String > remoteStoreNodeAttributes = remotePublicationNodeAttributes ();
752
+ final DiscoveryNode existingNode = new DiscoveryNode (
753
+ UUIDs .base64UUID (),
754
+ buildNewFakeTransportAddress (),
755
+ existingNodeAttributes ,
756
+ DiscoveryNodeRole .BUILT_IN_ROLES ,
757
+ Version .CURRENT
758
+ );
759
+ ClusterState currentState = ClusterState .builder (ClusterName .DEFAULT )
760
+ .nodes (DiscoveryNodes .builder ().add (existingNode ).localNodeId (existingNode .getId ()).build ())
761
+ .build ();
762
+
763
+ for (Map .Entry <String , String > nodeAttribute : existingNodeAttributes .entrySet ()) {
764
+ remoteStoreNodeAttributes .put (nodeAttribute .getKey (), null );
765
+ DiscoveryNode joiningNode = newDiscoveryNode (remoteStoreNodeAttributes );
766
+ Exception e = assertThrows (
767
+ IllegalStateException .class ,
768
+ () -> JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ())
769
+ );
770
+ assertTrue (
771
+ e .getMessage ().equals ("joining node [" + joiningNode + "] doesn't have the node attribute [" + nodeAttribute .getKey () + "]" )
772
+ || e .getMessage ()
773
+ .equals (
774
+ "a remote store node ["
775
+ + joiningNode
776
+ + "] is trying to join a remote store cluster with incompatible node attributes in comparison with existing node ["
777
+ + currentState .getNodes ().getNodes ().values ().stream ().findFirst ().get ()
778
+ + "]"
779
+ )
780
+ );
781
+
782
+ remoteStoreNodeAttributes .put (nodeAttribute .getKey (), nodeAttribute .getValue ());
783
+ }
784
+ }
785
+
692
786
public void testPreventJoinClusterWithRemoteStateNodeJoiningRemoteStoreCluster () {
693
787
Map <String , String > existingNodeAttributes = remoteStoreNodeAttributes (SEGMENT_REPO , TRANSLOG_REPO );
694
788
final DiscoveryNode existingNode = new DiscoveryNode (
@@ -706,16 +800,7 @@ public void testPreventJoinClusterWithRemoteStateNodeJoiningRemoteStoreCluster()
706
800
IllegalStateException .class ,
707
801
() -> JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ())
708
802
);
709
- assertTrue (
710
- e .getMessage ()
711
- .equals (
712
- "a remote store node ["
713
- + joiningNode
714
- + "] is trying to join a remote store cluster with incompatible node attributes in comparison with existing node ["
715
- + currentState .getNodes ().getNodes ().values ().stream ().findFirst ().get ()
716
- + "]"
717
- )
718
- );
803
+ assertTrue (e .getMessage ().equals ("a non remote store node [" + joiningNode + "] is trying to join a remote store cluster" ));
719
804
}
720
805
721
806
public void testPreventJoinClusterWithRemoteStoreNodeJoiningRemoteStateCluster () {
@@ -735,16 +820,7 @@ public void testPreventJoinClusterWithRemoteStoreNodeJoiningRemoteStateCluster()
735
820
IllegalStateException .class ,
736
821
() -> JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ())
737
822
);
738
- assertTrue (
739
- e .getMessage ()
740
- .equals (
741
- "a remote store node ["
742
- + joiningNode
743
- + "] is trying to join a remote store cluster with incompatible node attributes in comparison with existing node ["
744
- + currentState .getNodes ().getNodes ().values ().stream ().findFirst ().get ()
745
- + "]"
746
- )
747
- );
823
+ assertTrue (e .getMessage ().equals ("a remote store node [" + joiningNode + "] is trying to join a non remote store cluster" ));
748
824
}
749
825
750
826
public void testUpdatesClusterStateWithSingleNodeCluster () throws Exception {
@@ -1159,6 +1235,39 @@ public void testRemoteRoutingTableNodeJoinNodeWithRemoteAndRoutingRepoDifference
1159
1235
JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ());
1160
1236
}
1161
1237
1238
+ public void testJoinRemoteStoreClusterWithRemotePublicationNodeInMixedMode () {
1239
+ final DiscoveryNode remoteStoreNode = new DiscoveryNode (
1240
+ UUIDs .base64UUID (),
1241
+ buildNewFakeTransportAddress (),
1242
+ remoteStoreNodeAttributes (SEGMENT_REPO , TRANSLOG_REPO ),
1243
+ DiscoveryNodeRole .BUILT_IN_ROLES ,
1244
+ Version .CURRENT
1245
+ );
1246
+
1247
+ final DiscoveryNode nonRemoteStoreNode = new DiscoveryNode (
1248
+ UUIDs .base64UUID (),
1249
+ buildNewFakeTransportAddress (),
1250
+ new HashMap <>(),
1251
+ DiscoveryNodeRole .BUILT_IN_ROLES ,
1252
+ Version .CURRENT
1253
+ );
1254
+
1255
+ final Settings settings = Settings .builder ()
1256
+ .put (MIGRATION_DIRECTION_SETTING .getKey (), RemoteStoreNodeService .Direction .REMOTE_STORE )
1257
+ .put (REMOTE_STORE_COMPATIBILITY_MODE_SETTING .getKey (), "mixed" )
1258
+ .build ();
1259
+ final Settings nodeSettings = Settings .builder ().put (REMOTE_STORE_MIGRATION_EXPERIMENTAL , "true" ).build ();
1260
+ FeatureFlags .initializeFeatureFlags (nodeSettings );
1261
+ Metadata metadata = Metadata .builder ().persistentSettings (settings ).build ();
1262
+ ClusterState currentState = ClusterState .builder (ClusterName .DEFAULT )
1263
+ .nodes (DiscoveryNodes .builder ().add (remoteStoreNode ).add (nonRemoteStoreNode ).localNodeId (remoteStoreNode .getId ()).build ())
1264
+ .metadata (metadata )
1265
+ .build ();
1266
+
1267
+ DiscoveryNode joiningNode = newDiscoveryNode (remotePublicationNodeAttributes ());
1268
+ JoinTaskExecutor .ensureNodesCompatibility (joiningNode , currentState .getNodes (), currentState .metadata ());
1269
+ }
1270
+
1162
1271
private void validateRepositoryMetadata (ClusterState updatedState , DiscoveryNode existingNode , int expectedRepositories )
1163
1272
throws Exception {
1164
1273
@@ -1197,6 +1306,7 @@ private DiscoveryNode newDiscoveryNode(Map<String, String> attributes) {
1197
1306
}
1198
1307
1199
1308
private static final String SEGMENT_REPO = "segment-repo" ;
1309
+
1200
1310
private static final String TRANSLOG_REPO = "translog-repo" ;
1201
1311
private static final String CLUSTER_STATE_REPO = "cluster-state-repo" ;
1202
1312
private static final String COMMON_REPO = "remote-repo" ;
@@ -1243,6 +1353,13 @@ private Map<String, String> remoteStoreNodeAttributes(String segmentRepoName, St
1243
1353
};
1244
1354
}
1245
1355
1356
+ private Map <String , String > remotePublicationNodeAttributes () {
1357
+ Map <String , String > existingNodeAttributes = new HashMap <>();
1358
+ existingNodeAttributes .putAll (remoteStateNodeAttributes (CLUSTER_STATE_REPO ));
1359
+ existingNodeAttributes .putAll (remoteRoutingTableAttributes (ROUTING_TABLE_REPO ));
1360
+ return existingNodeAttributes ;
1361
+ }
1362
+
1246
1363
private Map <String , String > remoteStateNodeAttributes (String clusterStateRepo ) {
1247
1364
String clusterStateRepositoryTypeAttributeKey = String .format (
1248
1365
Locale .getDefault (),
0 commit comments