Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeUnit;
Expand Down Expand Up @@ -70,7 +71,13 @@ public class RemoteClusterPortSettings {
Setting.Property.NodeScope
);

public static final Setting<Integer> PORT = intSetting(REMOTE_CLUSTER_PREFIX + "port", 9443, 0, 65535, Setting.Property.NodeScope);
public static final Setting<Integer> PORT = intSetting(
REMOTE_CLUSTER_PREFIX + "port",
(settings) -> DiscoveryNode.isStateless(settings) ? "9400" : "9443",
0,
65535,
Setting.Property.NodeScope
);

// The default value of -1 means it will use the default bind port as shown above
public static final Setting<Integer> PUBLISH_PORT = intSetting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

package org.elasticsearch.transport;

import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.network.NetworkAddress;
import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.settings.Setting;
Expand Down Expand Up @@ -204,4 +205,11 @@ public void testPortSettingsConstruction() {
assertThat(profileSettings.isDefaultProfile, equalTo(false));
}

public void testRemoteClusterPortDefaultValue() {
assertThat(RemoteClusterPortSettings.PORT.getDefault(Settings.EMPTY), equalTo(9443));
assertThat(
RemoteClusterPortSettings.PORT.getDefault(Settings.builder().put(DiscoveryNode.STATELESS_ENABLED_SETTING_NAME, true).build()),
equalTo(9400)
);
}
}