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 ;
64import java .time .Duration ;
75import java .util .Arrays ;
86import java .util .Collection ;
119import java .util .concurrent .ConcurrentHashMap ;
1210import java .util .concurrent .ThreadLocalRandom ;
1311import 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 = System .getLogger (NetworkEmulator .class . getName () );
27+ private static final Logger LOGGER = LoggerFactory .getLogger (NetworkEmulator .class );
2828
2929 private volatile OutboundSettings defaultOutboundSettings = new OutboundSettings (0 , 0 );
3030 private volatile InboundSettings defaultInboundSettings = new InboundSettings (true );
@@ -69,8 +69,7 @@ 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 .log (
73- Level .DEBUG , "[{0}] Set outbound settings {1} to {2}" , address , settings , destination );
72+ LOGGER .debug ("[{}] Set outbound settings {} to {}" , address , settings , destination );
7473 }
7574
7675 /**
@@ -81,22 +80,21 @@ public void outboundSettings(String destination, int lossPercent, int meanDelay)
8180 */
8281 public void setDefaultOutboundSettings (int lossPercent , int meanDelay ) {
8382 defaultOutboundSettings = new OutboundSettings (lossPercent , meanDelay );
84- LOGGER .log (
85- Level .DEBUG , "[{0}] Set default outbound settings {1}" , address , defaultOutboundSettings );
83+ LOGGER .debug ("[{}] Set default outbound settings {}" , address , defaultOutboundSettings );
8684 }
8785
8886 /** Blocks outbound messages to all destinations. */
8987 public void blockAllOutbound () {
9088 outboundSettings .clear ();
9189 setDefaultOutboundSettings (100 , 0 );
92- LOGGER .log ( Level . DEBUG , "[{0 }] Blocked outbound to all destinations" , address );
90+ LOGGER .debug ( "[{}] Blocked outbound to all destinations" , address );
9391 }
9492
9593 /** Unblocks outbound messages to all destinations. */
9694 public void unblockAllOutbound () {
9795 outboundSettings .clear ();
9896 setDefaultOutboundSettings (0 , 0 );
99- LOGGER .log ( Level . DEBUG , "[{0 }] Unblocked outbound to all destinations" , address );
97+ LOGGER .debug ( "[{}] Unblocked outbound to all destinations" , address );
10098 }
10199
102100 /**
@@ -117,7 +115,7 @@ public void blockOutbound(Collection<String> destinations) {
117115 for (String destination : destinations ) {
118116 outboundSettings .put (destination , new OutboundSettings (100 , 0 ));
119117 }
120- LOGGER .log ( Level . DEBUG , "[{0 }] Blocked outbound to {1 }" , address , destinations );
118+ LOGGER .debug ( "[{}] Blocked outbound to {}" , address , destinations );
121119 }
122120
123121 /**
@@ -136,7 +134,7 @@ public void unblockOutbound(String... destinations) {
136134 */
137135 public void unblockOutbound (Collection <String > destinations ) {
138136 destinations .forEach (outboundSettings ::remove );
139- LOGGER .log ( Level . DEBUG , "[{0 }] Unblocked outbound {1 }" , address , destinations );
137+ LOGGER .debug ( "[{}] Unblocked outbound {}" , address , destinations );
140138 }
141139
142140 /**
@@ -222,8 +220,7 @@ public InboundSettings inboundSettings(String destination) {
222220 public void inboundSettings (String destination , boolean shallPass ) {
223221 InboundSettings settings = new InboundSettings (shallPass );
224222 inboundSettings .put (destination , settings );
225- LOGGER .log (
226- Level .DEBUG , "[{0}] Set inbound settings {1} to {2}" , address , settings , destination );
223+ LOGGER .debug ("[{}] Set inbound settings {} to {}" , address , settings , destination );
227224 }
228225
229226 /**
@@ -233,22 +230,21 @@ public void inboundSettings(String destination, boolean shallPass) {
233230 */
234231 public void setDefaultInboundSettings (boolean shallPass ) {
235232 defaultInboundSettings = new InboundSettings (shallPass );
236- LOGGER .log (
237- Level .DEBUG , "[{0}] Set default inbound settings {1}" , address , defaultInboundSettings );
233+ LOGGER .debug ("[{}] Set default inbound settings {}" , address , defaultInboundSettings );
238234 }
239235
240236 /** Blocks inbound messages from all destinations. */
241237 public void blockAllInbound () {
242238 inboundSettings .clear ();
243239 setDefaultInboundSettings (false );
244- LOGGER .log ( Level . DEBUG , "[{0 }] Blocked inbound from all destinations" , address );
240+ LOGGER .debug ( "[{}] Blocked inbound from all destinations" , address );
245241 }
246242
247243 /** Unblocks inbound messages to all destinations. */
248244 public void unblockAllInbound () {
249245 inboundSettings .clear ();
250246 setDefaultInboundSettings (true );
251- LOGGER .log ( Level . DEBUG , "[{0 }] Unblocked inbound from all destinations" , address );
247+ LOGGER .debug ( "[{}] Unblocked inbound from all destinations" , address );
252248 }
253249
254250 /**
@@ -269,7 +265,7 @@ public void blockInbound(Collection<String> destinations) {
269265 for (String destination : destinations ) {
270266 inboundSettings .put (destination , new InboundSettings (false ));
271267 }
272- LOGGER .log ( Level . DEBUG , "[{0 }] Blocked inbound from {1 }" , address , destinations );
268+ LOGGER .debug ( "[{}] Blocked inbound from {}" , address , destinations );
273269 }
274270
275271 /**
@@ -288,7 +284,7 @@ public void unblockInbound(String... destinations) {
288284 */
289285 public void unblockInbound (Collection <String > destinations ) {
290286 destinations .forEach (inboundSettings ::remove );
291- LOGGER .log ( Level . DEBUG , "[{0 }] Unblocked inbound from {1 }" , address , destinations );
287+ LOGGER .debug ( "[{}] Unblocked inbound from {}" , address , destinations );
292288 }
293289
294290 /**
0 commit comments