Skip to content

Commit

Permalink
Merge pull request #326 from scalecube/get-rid-of-host-from-transport…
Browse files Browse the repository at this point in the history
…-config

Removed `host` from TransportConfig
  • Loading branch information
artem-v authored Jun 8, 2020
2 parents ffd7a28 + 9db58f6 commit 017cf9b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 35 deletions.
4 changes: 2 additions & 2 deletions cluster/src/test/java/io/scalecube/cluster/ClusterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void testStartStopRepeatedly() throws Exception {
.gossip(opts -> opts.gossipInterval(100))
.failureDetector(opts -> opts.pingInterval(100))
.membership(opts -> opts.syncInterval(100))
.transport(opts -> opts.host(address.host()).port(address.port()))
.transport(opts -> opts.port(address.port()))
.transport(opts -> opts.connectTimeout(CONNECT_TIMEOUT))
.startAwait();

Expand All @@ -67,7 +67,7 @@ public void testStartStopRepeatedly() throws Exception {
.gossip(opts -> opts.gossipInterval(100))
.failureDetector(opts -> opts.pingInterval(100))
.membership(opts -> opts.syncInterval(100))
.transport(opts -> opts.host(address.host()).port(address.port()))
.transport(opts -> opts.port(address.port()))
.transport(opts -> opts.connectTimeout(CONNECT_TIMEOUT))
.startAwait();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public final class TransportConfig implements Cloneable {
// Local cluster working via loopback interface (overrides default/LAN settings)
public static final int DEFAULT_LOCAL_CONNECT_TIMEOUT = 1_000;

private String host = null;
private int port = 0;
private int connectTimeout = DEFAULT_CONNECT_TIMEOUT;
private MessageCodec messageCodec = MessageCodec.INSTANCE;
Expand Down Expand Up @@ -50,23 +49,7 @@ public static TransportConfig defaultWanConfig() {
* @return new {@code MembershipConfig}
*/
public static TransportConfig defaultLocalConfig() {
return defaultConfig().connectTimeout(DEFAULT_LOCAL_CONNECT_TIMEOUT).host("localhost");
}

public String host() {
return host;
}

/**
* Sets a host.
*
* @param host host
* @return new {@code TransportConfig} instance
*/
public TransportConfig host(String host) {
TransportConfig t = clone();
t.host = host;
return t;
return defaultConfig().connectTimeout(DEFAULT_LOCAL_CONNECT_TIMEOUT);
}

public int port() {
Expand Down Expand Up @@ -145,7 +128,6 @@ public TransportConfig clone() {
@Override
public String toString() {
return new StringJoiner(", ", TransportConfig.class.getSimpleName() + "[", "]")
.add("host='" + host + "'")
.add("port=" + port)
.add("connectTimeout=" + connectTimeout)
.add("messageCodec=" + messageCodec)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,20 +334,13 @@ private Mono<Void> shutdownLoopResources() {
* @return tcp server
*/
private TcpServer newTcpServer() {
TcpServer tcpServer =
TcpServer.create()
.runOn(loopResources)
.option(ChannelOption.TCP_NODELAY, true)
.option(ChannelOption.SO_KEEPALIVE, true)
.option(ChannelOption.SO_REUSEADDR, true)
.port(config.port());

if (config.host() != null) {
tcpServer = tcpServer.host(config.host());
}

return tcpServer.bootstrap(
b -> BootstrapHandlers.updateConfiguration(b, "inbound", channelInitializer));
return TcpServer.create()
.runOn(loopResources)
.option(ChannelOption.TCP_NODELAY, true)
.option(ChannelOption.SO_KEEPALIVE, true)
.option(ChannelOption.SO_REUSEADDR, true)
.port(config.port())
.bootstrap(b -> BootstrapHandlers.updateConfiguration(b, "inbound", channelInitializer));
}

/**
Expand Down

0 comments on commit 017cf9b

Please sign in to comment.