From: Frederic Suter Date: Wed, 19 Jul 2017 15:41:50 +0000 (+0200) Subject: try to please codacy and reduce NPath complexity X-Git-Tag: v3_17~363^2~2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/2778c271391e76f66703d556bc710b406ec15746 try to please codacy and reduce NPath complexity --- diff --git a/examples/java/dht/chord/Node.java b/examples/java/dht/chord/Node.java index f29ead5690..2ef023c1d2 100644 --- a/examples/java/dht/chord/Node.java +++ b/examples/java/dht/chord/Node.java @@ -64,47 +64,49 @@ public class Node extends Process { joinSuccess = join(knownId); } - if (joinSuccess) { - double currentClock = Msg.getClock(); - while (currentClock < (initTime + deadline) && currentClock < Common.MAX_SIMULATION_TIME) { - if (commReceive == null) { - commReceive = Task.irecv(this.mailbox); - } - try { - if (!commReceive.test()) { - if (currentClock >= nextStabilizeDate) { - stabilize(); - nextStabilizeDate = Msg.getClock() + Common.PERIODIC_STABILIZE_DELAY; - } else if (currentClock >= nextFixFingersDate) { - fixFingers(); - nextFixFingersDate = Msg.getClock() + Common.PERIODIC_FIX_FINGERS_DELAY; - } else if (currentClock >= nextCheckPredecessorDate) { - this.checkPredecessor(); - nextCheckPredecessorDate = Msg.getClock() + Common.PERIODIC_CHECK_PREDECESSOR_DELAY; - } else if (currentClock >= nextLookupDate) { - this.randomLookup(); - nextLookupDate = Msg.getClock() + Common.PERIODIC_LOOKUP_DELAY; - } else { - waitFor(5); - } - currentClock = Msg.getClock(); + + if (!joinSuccess) { + Msg.info("I couldn't join the ring"); + return; + } + + double currentClock = Msg.getClock(); + while (currentClock < (initTime + deadline) && currentClock < Common.MAX_SIMULATION_TIME) { + if (commReceive == null) { + commReceive = Task.irecv(this.mailbox); + } + try { + if (!commReceive.test()) { + if (currentClock >= nextStabilizeDate) { + stabilize(); + nextStabilizeDate = Msg.getClock() + Common.PERIODIC_STABILIZE_DELAY; + } else if (currentClock >= nextFixFingersDate) { + fixFingers(); + nextFixFingersDate = Msg.getClock() + Common.PERIODIC_FIX_FINGERS_DELAY; + } else if (currentClock >= nextCheckPredecessorDate) { + this.checkPredecessor(); + nextCheckPredecessorDate = Msg.getClock() + Common.PERIODIC_CHECK_PREDECESSOR_DELAY; + } else if (currentClock >= nextLookupDate) { + this.randomLookup(); + nextLookupDate = Msg.getClock() + Common.PERIODIC_LOOKUP_DELAY; } else { - handleTask(commReceive.getTask()); - currentClock = Msg.getClock(); - commReceive = null; + waitFor(5); } - } - catch (Exception e) { + currentClock = Msg.getClock(); + } else { + handleTask(commReceive.getTask()); currentClock = Msg.getClock(); commReceive = null; } } - leave(); - if (commReceive != null) { + catch (Exception e) { + currentClock = Msg.getClock(); commReceive = null; } - } else { - Msg.info("I couldn't join the ring"); + } + leave(); + if (commReceive != null) { + commReceive = null; } }