Skip to content

Allow proxy mode server name to be updated #54107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2020
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 @@ -157,7 +157,9 @@ protected boolean shouldOpenMoreConnections() {
protected boolean strategyMustBeRebuilt(Settings newSettings) {
String address = PROXY_ADDRESS.getConcreteSettingForNamespace(clusterAlias).get(newSettings);
int numOfSockets = REMOTE_SOCKET_CONNECTIONS.getConcreteSettingForNamespace(clusterAlias).get(newSettings);
return numOfSockets != maxNumConnections || configuredAddress.equals(address) == false;
String serverName = SERVER_NAME.getConcreteSettingForNamespace(clusterAlias).get(newSettings);
return numOfSockets != maxNumConnections || configuredAddress.equals(address) == false ||
Objects.equals(serverName, configuredServerName) == false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public void testProxyStrategyWillResolveAddressesEachConnect() throws Exception
}
}

public void testProxyStrategyWillNeedToBeRebuiltIfNumOfSocketsOrAddressesChange() {
public void testProxyStrategyWillNeedToBeRebuiltIfNumOfSocketsOrAddressesOrServerNameChange() {
try (MockTransportService remoteTransport = startTransport("node1", Version.CURRENT)) {
TransportAddress remoteAddress = remoteTransport.boundAddress().publishAddress();

Expand All @@ -280,7 +280,7 @@ public void testProxyStrategyWillNeedToBeRebuiltIfNumOfSocketsOrAddressesChange(
int numOfConnections = randomIntBetween(4, 8);
try (RemoteConnectionManager remoteConnectionManager = new RemoteConnectionManager(clusterAlias, connectionManager);
ProxyConnectionStrategy strategy = new ProxyConnectionStrategy(clusterAlias, localService, remoteConnectionManager,
numOfConnections, remoteAddress.toString())) {
numOfConnections, remoteAddress.toString(), "server-name")) {
PlainActionFuture<Void> connectFuture = PlainActionFuture.newFuture();
strategy.connect(connectFuture);
connectFuture.actionGet();
Expand All @@ -295,11 +295,14 @@ public void testProxyStrategyWillNeedToBeRebuiltIfNumOfSocketsOrAddressesChange(
.getConcreteSettingForNamespace("cluster-alias");
Setting<?> socketConnections = ProxyConnectionStrategy.REMOTE_SOCKET_CONNECTIONS
.getConcreteSettingForNamespace("cluster-alias");
Setting<?> serverName = ProxyConnectionStrategy.SERVER_NAME
.getConcreteSettingForNamespace("cluster-alias");

Settings noChange = Settings.builder()
.put(modeSetting.getKey(), "proxy")
.put(addressesSetting.getKey(), remoteAddress.toString())
.put(socketConnections.getKey(), numOfConnections)
.put(serverName.getKey(), "server-name")
.build();
assertFalse(strategy.shouldRebuildConnection(noChange));
Settings addressesChanged = Settings.builder()
Expand All @@ -313,6 +316,13 @@ public void testProxyStrategyWillNeedToBeRebuiltIfNumOfSocketsOrAddressesChange(
.put(socketConnections.getKey(), numOfConnections + 1)
.build();
assertTrue(strategy.shouldRebuildConnection(socketsChanged));
Settings serverNameChange = Settings.builder()
.put(modeSetting.getKey(), "proxy")
.put(addressesSetting.getKey(), remoteAddress.toString())
.put(socketConnections.getKey(), numOfConnections)
.put(serverName.getKey(), "server-name2")
.build();
assertTrue(strategy.shouldRebuildConnection(serverNameChange));
}
}
}
Expand Down