diff --git a/cluster-testlib/src/main/java/io/scalecube/cluster/utils/NetworkEmulator.java b/cluster-testlib/src/main/java/io/scalecube/cluster/utils/NetworkEmulator.java
index d51a7526..552c10bc 100644
--- a/cluster-testlib/src/main/java/io/scalecube/cluster/utils/NetworkEmulator.java
+++ b/cluster-testlib/src/main/java/io/scalecube/cluster/utils/NetworkEmulator.java
@@ -1,7 +1,6 @@
package io.scalecube.cluster.utils;
import io.scalecube.cluster.transport.api.Message;
-import io.scalecube.net.Address;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collection;
@@ -30,21 +29,21 @@ public final class NetworkEmulator {
private volatile OutboundSettings defaultOutboundSettings = new OutboundSettings(0, 0);
private volatile InboundSettings defaultInboundSettings = new InboundSettings(true);
- private final Map
outboundSettings = new ConcurrentHashMap<>();
- private final Map inboundSettings = new ConcurrentHashMap<>();
+ private final Map outboundSettings = new ConcurrentHashMap<>();
+ private final Map inboundSettings = new ConcurrentHashMap<>();
private final AtomicLong totalMessageSentCount = new AtomicLong();
private final AtomicLong totalOutboundMessageLostCount = new AtomicLong();
private final AtomicLong totalInboundMessageLostCount = new AtomicLong();
- private final Address address;
+ private final String address;
/**
* Creates new instance of network emulator.
*
* @param address local address
*/
- NetworkEmulator(Address address) {
+ NetworkEmulator(String address) {
this.address = address;
}
@@ -56,7 +55,7 @@ public final class NetworkEmulator {
* @param destination address of target endpoint
* @return network outbound settings
*/
- public OutboundSettings outboundSettings(Address destination) {
+ public OutboundSettings outboundSettings(String destination) {
return outboundSettings.getOrDefault(destination, defaultOutboundSettings);
}
@@ -67,7 +66,7 @@ public OutboundSettings outboundSettings(Address destination) {
* @param lossPercent loss in percents
* @param meanDelay mean delay
*/
- public void outboundSettings(Address destination, int lossPercent, int meanDelay) {
+ public void outboundSettings(String destination, int lossPercent, int meanDelay) {
OutboundSettings settings = new OutboundSettings(lossPercent, meanDelay);
outboundSettings.put(destination, settings);
LOGGER.debug("[{}] Set outbound settings {} to {}", address, settings, destination);
@@ -103,7 +102,7 @@ public void unblockAllOutbound() {
*
* @param destinations collection of target endpoints where to apply
*/
- public void blockOutbound(Address... destinations) {
+ public void blockOutbound(String... destinations) {
blockOutbound(Arrays.asList(destinations));
}
@@ -112,8 +111,8 @@ public void blockOutbound(Address... destinations) {
*
* @param destinations collection of target endpoints where to apply
*/
- public void blockOutbound(Collection destinations) {
- for (Address destination : destinations) {
+ public void blockOutbound(Collection destinations) {
+ for (String destination : destinations) {
outboundSettings.put(destination, new OutboundSettings(100, 0));
}
LOGGER.debug("[{}] Blocked outbound to {}", address, destinations);
@@ -124,7 +123,7 @@ public void blockOutbound(Collection destinations) {
*
* @param destinations collection of target endpoints where to apply
*/
- public void unblockOutbound(Address... destinations) {
+ public void unblockOutbound(String... destinations) {
unblockOutbound(Arrays.asList(destinations));
}
@@ -133,7 +132,7 @@ public void unblockOutbound(Address... destinations) {
*
* @param destinations collection of target endpoints where to apply
*/
- public void unblockOutbound(Collection destinations) {
+ public void unblockOutbound(Collection destinations) {
destinations.forEach(outboundSettings::remove);
LOGGER.debug("[{}] Unblocked outbound {}", address, destinations);
}
@@ -164,7 +163,7 @@ public long totalOutboundMessageLostCount() {
* @param address target address
* @return mono message
*/
- public Mono tryFailOutbound(Message msg, Address address) {
+ public Mono tryFailOutbound(Message msg, String address) {
return Mono.defer(
() -> {
totalMessageSentCount.incrementAndGet();
@@ -187,7 +186,7 @@ public Mono tryFailOutbound(Message msg, Address address) {
* @param address target address
* @return mono message
*/
- public Mono tryDelayOutbound(Message msg, Address address) {
+ public Mono tryDelayOutbound(Message msg, String address) {
return Mono.defer(
() -> {
totalMessageSentCount.incrementAndGet();
@@ -209,7 +208,7 @@ public Mono tryDelayOutbound(Message msg, Address address) {
* @param destination address of target endpoint
* @return network inbound settings
*/
- public InboundSettings inboundSettings(Address destination) {
+ public InboundSettings inboundSettings(String destination) {
return inboundSettings.getOrDefault(destination, defaultInboundSettings);
}
@@ -218,7 +217,7 @@ public InboundSettings inboundSettings(Address destination) {
*
* @param shallPass shallPass inbound flag
*/
- public void inboundSettings(Address destination, boolean shallPass) {
+ public void inboundSettings(String destination, boolean shallPass) {
InboundSettings settings = new InboundSettings(shallPass);
inboundSettings.put(destination, settings);
LOGGER.debug("[{}] Set inbound settings {} to {}", address, settings, destination);
@@ -253,7 +252,7 @@ public void unblockAllInbound() {
*
* @param destinations collection of target endpoints where to apply
*/
- public void blockInbound(Address... destinations) {
+ public void blockInbound(String... destinations) {
blockInbound(Arrays.asList(destinations));
}
@@ -262,8 +261,8 @@ public void blockInbound(Address... destinations) {
*
* @param destinations collection of target endpoints where to apply
*/
- public void blockInbound(Collection destinations) {
- for (Address destination : destinations) {
+ public void blockInbound(Collection destinations) {
+ for (String destination : destinations) {
inboundSettings.put(destination, new InboundSettings(false));
}
LOGGER.debug("[{}] Blocked inbound from {}", address, destinations);
@@ -274,7 +273,7 @@ public void blockInbound(Collection destinations) {
*
* @param destinations collection of target endpoints where to apply
*/
- public void unblockInbound(Address... destinations) {
+ public void unblockInbound(String... destinations) {
unblockInbound(Arrays.asList(destinations));
}
@@ -283,7 +282,7 @@ public void unblockInbound(Address... destinations) {
*
* @param destinations collection of target endpoints where to apply
*/
- public void unblockInbound(Collection destinations) {
+ public void unblockInbound(Collection destinations) {
destinations.forEach(inboundSettings::remove);
LOGGER.debug("[{}] Unblocked inbound from {}", address, destinations);
}
diff --git a/cluster-testlib/src/main/java/io/scalecube/cluster/utils/NetworkEmulatorTransport.java b/cluster-testlib/src/main/java/io/scalecube/cluster/utils/NetworkEmulatorTransport.java
index 381042c5..dcfbf677 100644
--- a/cluster-testlib/src/main/java/io/scalecube/cluster/utils/NetworkEmulatorTransport.java
+++ b/cluster-testlib/src/main/java/io/scalecube/cluster/utils/NetworkEmulatorTransport.java
@@ -2,7 +2,6 @@
import io.scalecube.cluster.transport.api.Message;
import io.scalecube.cluster.transport.api.Transport;
-import io.scalecube.net.Address;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -26,7 +25,7 @@ public NetworkEmulator networkEmulator() {
}
@Override
- public Address address() {
+ public String address() {
return transport.address();
}
@@ -46,7 +45,7 @@ public boolean isStopped() {
}
@Override
- public Mono send(Address address, Message message) {
+ public Mono send(String address, Message message) {
return Mono.defer(
() ->
Mono.just(enhanceWithSender(message))
@@ -56,7 +55,7 @@ public Mono send(Address address, Message message) {
}
@Override
- public Mono requestResponse(Address address, Message request) {
+ public Mono requestResponse(String address, Message request) {
return Mono.defer(
() ->
Mono.just(enhanceWithSender(request))
diff --git a/cluster-testlib/src/test/java/io/scalecube/cluster/utils/NetworkEmulatorTest.java b/cluster-testlib/src/test/java/io/scalecube/cluster/utils/NetworkEmulatorTest.java
index 1919bc6f..b65137db 100644
--- a/cluster-testlib/src/test/java/io/scalecube/cluster/utils/NetworkEmulatorTest.java
+++ b/cluster-testlib/src/test/java/io/scalecube/cluster/utils/NetworkEmulatorTest.java
@@ -1,7 +1,6 @@
package io.scalecube.cluster.utils;
import io.scalecube.cluster.utils.NetworkEmulator.OutboundSettings;
-import io.scalecube.net.Address;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -10,24 +9,23 @@ public class NetworkEmulatorTest extends BaseTest {
@Test
public void testResolveLinkSettingsBySocketAddress() {
// Init network emulator
- Address address = Address.from("localhost:1234");
- NetworkEmulator networkEmulator = new NetworkEmulator(address);
- networkEmulator.outboundSettings(Address.create("localhost", 5678), 25, 10);
- networkEmulator.outboundSettings(Address.create("192.168.0.1", 8765), 10, 20);
+ NetworkEmulator networkEmulator = new NetworkEmulator("localhost:1234");
+ networkEmulator.outboundSettings("localhost:" + 5678, 25, 10);
+ networkEmulator.outboundSettings("192.168.0.1:" + 8765, 10, 20);
networkEmulator.setDefaultOutboundSettings(0, 2);
// Check resolve by hostname:port
- OutboundSettings link1 = networkEmulator.outboundSettings(Address.create("localhost", 5678));
+ OutboundSettings link1 = networkEmulator.outboundSettings("localhost:" + 5678);
Assertions.assertEquals(25, link1.lossPercent());
Assertions.assertEquals(10, link1.meanDelay());
// Check resolve by ipaddr:port
- OutboundSettings link2 = networkEmulator.outboundSettings(Address.create("192.168.0.1", 8765));
+ OutboundSettings link2 = networkEmulator.outboundSettings("192.168.0.1:" + 8765);
Assertions.assertEquals(10, link2.lossPercent());
Assertions.assertEquals(20, link2.meanDelay());
// Check default link settings
- OutboundSettings link3 = networkEmulator.outboundSettings(Address.create("localhost", 8765));
+ OutboundSettings link3 = networkEmulator.outboundSettings("localhost:" + 8765);
Assertions.assertEquals(0, link3.lossPercent());
Assertions.assertEquals(2, link3.meanDelay());
}
diff --git a/cluster/src/main/java/io/scalecube/cluster/ClusterImpl.java b/cluster/src/main/java/io/scalecube/cluster/ClusterImpl.java
index 77942be8..ff8a67fb 100644
--- a/cluster/src/main/java/io/scalecube/cluster/ClusterImpl.java
+++ b/cluster/src/main/java/io/scalecube/cluster/ClusterImpl.java
@@ -241,7 +241,7 @@ private Mono doStart0() {
return Transport.bind(config.transportConfig())
.flatMap(
boundTransport -> {
- localMember = createLocalMember(boundTransport.address());
+ localMember = createLocalMember(Address.from(boundTransport.address()));
transport = new SenderAwareTransport(boundTransport, localMember.address());
scheduler = Schedulers.newSingle("sc-cluster-" + localMember.address().port(), true);
@@ -506,7 +506,7 @@ private SenderAwareTransport(Transport transport, Address address) {
}
@Override
- public Address address() {
+ public String address() {
return transport.address();
}
@@ -526,12 +526,12 @@ public boolean isStopped() {
}
@Override
- public Mono send(Address address, Message message) {
+ public Mono send(String address, Message message) {
return Mono.defer(() -> transport.send(address, enhanceWithSender(message)));
}
@Override
- public Mono requestResponse(Address address, Message request) {
+ public Mono requestResponse(String address, Message request) {
return Mono.defer(() -> transport.requestResponse(address, enhanceWithSender(request)));
}
@@ -541,7 +541,7 @@ public Flux listen() {
}
private Message enhanceWithSender(Message message) {
- return Message.with(message).sender(address).build();
+ return Message.with(message).sender(address.toString()).build();
}
}
}
diff --git a/cluster/src/main/java/io/scalecube/cluster/fdetector/FailureDetectorImpl.java b/cluster/src/main/java/io/scalecube/cluster/fdetector/FailureDetectorImpl.java
index c7540bc0..40860a89 100644
--- a/cluster/src/main/java/io/scalecube/cluster/fdetector/FailureDetectorImpl.java
+++ b/cluster/src/main/java/io/scalecube/cluster/fdetector/FailureDetectorImpl.java
@@ -147,7 +147,7 @@ private void doPing() {
LOGGER.debug("[{}][{}] Send Ping to {}", localMember, period, pingMember);
Address address = pingMember.address();
transport
- .requestResponse(address, pingMsg)
+ .requestResponse(address.toString(), pingMsg)
.timeout(Duration.ofMillis(config.pingTimeout()), scheduler)
.publishOn(scheduler)
.subscribe(
@@ -190,7 +190,7 @@ private void doPingReq(
pingReqMembers.forEach(
member ->
transport
- .requestResponse(member.address(), pingReqMsg)
+ .requestResponse(member.address().toString(), pingReqMsg)
.timeout(timeout, scheduler)
.publishOn(scheduler)
.subscribe(
@@ -232,7 +232,7 @@ private void onMessage(Message message) {
/** Listens to PING message and answers with ACK. */
private void onPing(Message message) {
long period = this.currentPeriod;
- Address sender = message.sender();
+ Address sender = Address.from(message.sender());
LOGGER.debug("[{}][{}] Received Ping from {}", localMember, period, sender);
PingData data = message.data();
data = data.withAckType(AckType.DEST_OK);
@@ -252,7 +252,7 @@ private void onPing(Message message) {
Address address = data.getFrom().address();
LOGGER.debug("[{}][{}] Send PingAck to {}", localMember, period, address);
transport
- .send(address, ackMessage)
+ .send(address.toString(), ackMessage)
.subscribe(
null,
ex ->
@@ -278,7 +278,7 @@ private void onPingReq(Message message) {
Address address = target.address();
LOGGER.debug("[{}][{}] Send transit Ping to {}", localMember, period, address);
transport
- .send(address, pingMessage)
+ .send(address.toString(), pingMessage)
.subscribe(
null,
ex ->
@@ -308,7 +308,7 @@ private void onTransitPingAck(Message message) {
Address address = target.address();
LOGGER.debug("[{}][{}] Resend transit PingAck to {}", localMember, period, address);
transport
- .send(address, originalAckMessage)
+ .send(address.toString(), originalAckMessage)
.subscribe(
null,
ex ->
diff --git a/cluster/src/main/java/io/scalecube/cluster/gossip/GossipProtocolImpl.java b/cluster/src/main/java/io/scalecube/cluster/gossip/GossipProtocolImpl.java
index 1acfd060..6e76bd5c 100644
--- a/cluster/src/main/java/io/scalecube/cluster/gossip/GossipProtocolImpl.java
+++ b/cluster/src/main/java/io/scalecube/cluster/gossip/GossipProtocolImpl.java
@@ -1,6 +1,6 @@
package io.scalecube.cluster.gossip;
-import static io.scalecube.reactor.RetryNonSerializedEmitFailureHandler.RETRY_NON_SERIALIZED;
+import static reactor.core.publisher.Sinks.EmitFailureHandler.busyLooping;
import io.scalecube.cluster.ClusterMath;
import io.scalecube.cluster.Member;
@@ -8,6 +8,7 @@
import io.scalecube.cluster.transport.api.Message;
import io.scalecube.cluster.transport.api.Transport;
import io.scalecube.net.Address;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -120,7 +121,7 @@ public void stop() {
actionsDisposables.dispose();
// Stop publishing events
- sink.emitComplete(RETRY_NON_SERIALIZED);
+ sink.emitComplete(busyLooping(Duration.ofSeconds(3)));
}
@Override
@@ -208,7 +209,7 @@ private void onGossipRequest(Message message) {
if (gossipState == null) { // new gossip
gossipState = new GossipState(gossip, period);
gossips.put(gossip.gossipId(), gossipState);
- sink.emitNext(gossip.message(), RETRY_NON_SERIALIZED);
+ sink.emitNext(gossip.message(), busyLooping(Duration.ofSeconds(3)));
}
}
if (gossipState != null) {
@@ -294,7 +295,7 @@ private void spreadGossipsTo(long period, Member member) {
.forEach(
message ->
transport
- .send(address, message)
+ .send(address.toString(), message)
.subscribe(
null,
ex ->
diff --git a/cluster/src/main/java/io/scalecube/cluster/membership/MembershipProtocolImpl.java b/cluster/src/main/java/io/scalecube/cluster/membership/MembershipProtocolImpl.java
index fad3bca3..ad3240d5 100644
--- a/cluster/src/main/java/io/scalecube/cluster/membership/MembershipProtocolImpl.java
+++ b/cluster/src/main/java/io/scalecube/cluster/membership/MembershipProtocolImpl.java
@@ -3,7 +3,7 @@
import static io.scalecube.cluster.membership.MemberStatus.ALIVE;
import static io.scalecube.cluster.membership.MemberStatus.DEAD;
import static io.scalecube.cluster.membership.MemberStatus.LEAVING;
-import static io.scalecube.reactor.RetryNonSerializedEmitFailureHandler.RETRY_NON_SERIALIZED;
+import static reactor.core.publisher.Sinks.EmitFailureHandler.busyLooping;
import io.scalecube.cluster.ClusterConfig;
import io.scalecube.cluster.ClusterMath;
@@ -167,7 +167,7 @@ private List cleanUpSeedMembers(Collection seedMembers) {
String hostName = localIpAddress.getHostName();
Address memberAddr = localMember.address();
- Address transportAddr = transport.address();
+ Address transportAddr = Address.from(transport.address());
Address memberAddrByHostAddress = Address.create(hostAddress, memberAddr.port());
Address transportAddrByHostAddress = Address.create(hostAddress, transportAddr.port());
Address memberAddByHostName = Address.create(hostName, memberAddr.port());
@@ -256,7 +256,8 @@ private void start0(MonoSink