From 857c9e48c50d00e55438a00551b1c94c63ac8e1d Mon Sep 17 00:00:00 2001 From: Jason Goodwin Date: Tue, 2 May 2017 03:10:38 -0400 Subject: [PATCH] filter selfnode from nodeslist (#162) --- .../heikoseeberger/constructr/ConstructrMachine.scala | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/de/heikoseeberger/constructr/ConstructrMachine.scala b/core/src/main/scala/de/heikoseeberger/constructr/ConstructrMachine.scala index 4140981..64b04fe 100644 --- a/core/src/main/scala/de/heikoseeberger/constructr/ConstructrMachine.scala +++ b/core/src/main/scala/de/heikoseeberger/constructr/ConstructrMachine.scala @@ -112,13 +112,19 @@ final class ConstructrMachine( onTransition { case _ -> State.GettingNodes => log.debug("Transitioning to GettingNodes") - coordination.getNodes().pipeTo(self) + coordination.getNodes().map { nodes => + if(nodes.contains(selfNode)) + log.warning(s"Selfnode received in list of nodes $nodes. Will filter to prevent forming an island.") + + nodes.filterNot(_ == selfNode) + } pipeTo self } when(State.GettingNodes, coordinationTimeout) { case Event(nodes: Set[Address] @unchecked, _) if nodes.isEmpty => log.debug("Received empty nodes, going to Locking") - goto(State.Locking).using(stateData.copy(nrOfRetriesLeft = nrOfRetries)) + goto(State.Locking) + .using(stateData.copy(nrOfRetriesLeft = nrOfRetries)) case Event(nodes: Set[Address] @unchecked, _) => log.debug(s"Received nodes $nodes, going to Joining")