11package io .scalecube .cluster .utils ;
22
33import io .scalecube .cluster .transport .api .Message ;
4+ import java .lang .System .Logger ;
5+ import java .lang .System .Logger .Level ;
46import java .time .Duration ;
57import java .util .Arrays ;
68import java .util .Collection ;
911import java .util .concurrent .ConcurrentHashMap ;
1012import java .util .concurrent .ThreadLocalRandom ;
1113import java .util .concurrent .atomic .AtomicLong ;
12- import org .slf4j .Logger ;
13- import org .slf4j .LoggerFactory ;
1414import reactor .core .publisher .Mono ;
1515
1616/**
2424 */
2525public final class NetworkEmulator {
2626
27- private static final Logger LOGGER = LoggerFactory .getLogger (NetworkEmulator .class );
27+ private static final Logger LOGGER = System .getLogger (NetworkEmulator .class . getName () );
2828
2929 private volatile OutboundSettings defaultOutboundSettings = new OutboundSettings (0 , 0 );
3030 private volatile InboundSettings defaultInboundSettings = new InboundSettings (true );
@@ -69,7 +69,8 @@ public OutboundSettings outboundSettings(String destination) {
6969 public void outboundSettings (String destination , int lossPercent , int meanDelay ) {
7070 OutboundSettings settings = new OutboundSettings (lossPercent , meanDelay );
7171 outboundSettings .put (destination , settings );
72- LOGGER .debug ("[{}] Set outbound settings {} to {}" , address , settings , destination );
72+ LOGGER .log (
73+ Level .DEBUG , "[{0}] Set outbound settings {1} to {2}" , address , settings , destination );
7374 }
7475
7576 /**
@@ -80,21 +81,22 @@ public void outboundSettings(String destination, int lossPercent, int meanDelay)
8081 */
8182 public void setDefaultOutboundSettings (int lossPercent , int meanDelay ) {
8283 defaultOutboundSettings = new OutboundSettings (lossPercent , meanDelay );
83- LOGGER .debug ("[{}] Set default outbound settings {}" , address , defaultOutboundSettings );
84+ LOGGER .log (
85+ Level .DEBUG , "[{0}] Set default outbound settings {1}" , address , defaultOutboundSettings );
8486 }
8587
8688 /** Blocks outbound messages to all destinations. */
8789 public void blockAllOutbound () {
8890 outboundSettings .clear ();
8991 setDefaultOutboundSettings (100 , 0 );
90- LOGGER .debug ( "[{}] Blocked outbound to all destinations" , address );
92+ LOGGER .log ( Level . DEBUG , "[{0 }] Blocked outbound to all destinations" , address );
9193 }
9294
9395 /** Unblocks outbound messages to all destinations. */
9496 public void unblockAllOutbound () {
9597 outboundSettings .clear ();
9698 setDefaultOutboundSettings (0 , 0 );
97- LOGGER .debug ( "[{}] Unblocked outbound to all destinations" , address );
99+ LOGGER .log ( Level . DEBUG , "[{0 }] Unblocked outbound to all destinations" , address );
98100 }
99101
100102 /**
@@ -115,7 +117,7 @@ public void blockOutbound(Collection<String> destinations) {
115117 for (String destination : destinations ) {
116118 outboundSettings .put (destination , new OutboundSettings (100 , 0 ));
117119 }
118- LOGGER .debug ( "[{}] Blocked outbound to {}" , address , destinations );
120+ LOGGER .log ( Level . DEBUG , "[{0 }] Blocked outbound to {1 }" , address , destinations );
119121 }
120122
121123 /**
@@ -134,7 +136,7 @@ public void unblockOutbound(String... destinations) {
134136 */
135137 public void unblockOutbound (Collection <String > destinations ) {
136138 destinations .forEach (outboundSettings ::remove );
137- LOGGER .debug ( "[{}] Unblocked outbound {}" , address , destinations );
139+ LOGGER .log ( Level . DEBUG , "[{0 }] Unblocked outbound {1 }" , address , destinations );
138140 }
139141
140142 /**
@@ -220,7 +222,8 @@ public InboundSettings inboundSettings(String destination) {
220222 public void inboundSettings (String destination , boolean shallPass ) {
221223 InboundSettings settings = new InboundSettings (shallPass );
222224 inboundSettings .put (destination , settings );
223- LOGGER .debug ("[{}] Set inbound settings {} to {}" , address , settings , destination );
225+ LOGGER .log (
226+ Level .DEBUG , "[{0}] Set inbound settings {1} to {2}" , address , settings , destination );
224227 }
225228
226229 /**
@@ -230,21 +233,22 @@ public void inboundSettings(String destination, boolean shallPass) {
230233 */
231234 public void setDefaultInboundSettings (boolean shallPass ) {
232235 defaultInboundSettings = new InboundSettings (shallPass );
233- LOGGER .debug ("[{}] Set default inbound settings {}" , address , defaultInboundSettings );
236+ LOGGER .log (
237+ Level .DEBUG , "[{0}] Set default inbound settings {1}" , address , defaultInboundSettings );
234238 }
235239
236240 /** Blocks inbound messages from all destinations. */
237241 public void blockAllInbound () {
238242 inboundSettings .clear ();
239243 setDefaultInboundSettings (false );
240- LOGGER .debug ( "[{}] Blocked inbound from all destinations" , address );
244+ LOGGER .log ( Level . DEBUG , "[{0 }] Blocked inbound from all destinations" , address );
241245 }
242246
243247 /** Unblocks inbound messages to all destinations. */
244248 public void unblockAllInbound () {
245249 inboundSettings .clear ();
246250 setDefaultInboundSettings (true );
247- LOGGER .debug ( "[{}] Unblocked inbound from all destinations" , address );
251+ LOGGER .log ( Level . DEBUG , "[{0 }] Unblocked inbound from all destinations" , address );
248252 }
249253
250254 /**
@@ -265,7 +269,7 @@ public void blockInbound(Collection<String> destinations) {
265269 for (String destination : destinations ) {
266270 inboundSettings .put (destination , new InboundSettings (false ));
267271 }
268- LOGGER .debug ( "[{}] Blocked inbound from {}" , address , destinations );
272+ LOGGER .log ( Level . DEBUG , "[{0 }] Blocked inbound from {1 }" , address , destinations );
269273 }
270274
271275 /**
@@ -284,7 +288,7 @@ public void unblockInbound(String... destinations) {
284288 */
285289 public void unblockInbound (Collection <String > destinations ) {
286290 destinations .forEach (inboundSettings ::remove );
287- LOGGER .debug ( "[{}] Unblocked inbound from {}" , address , destinations );
291+ LOGGER .log ( Level . DEBUG , "[{0 }] Unblocked inbound from {1 }" , address , destinations );
288292 }
289293
290294 /**
0 commit comments