java - Search nodes in network using akka. -


is there way search nodes in network if node down can reconnect again when becomes up. using mdns want achieve akka. using akka java.

you may use 2 approaches here:

1) external - run instance of consul.io along cluster. reading status of consul cluster know machines connected cluster - give idea total set of nodes , ip addresses. use jmx anywhere retrieve status of akka cluster - you're looking akka:type=cluster bean here , it's property members or clusterstatus. return cluster status - hence know set of nodes available in akka cluster. if subtract set of nodes in akka cluster nodes in consul cluster - removed/quarantined akka cluster quorum, , has restarted.

2) internal - once have added thisactorsystemquarantinedevent akka remoting. event fired when node removed cluster, , put in quarantine - can't reconnect cluster automatically. can create this:

  object clusterwatcher {      private class defaultclusterwatcher extends actor clusterwatcher {       override def receive = handlequarantinedrestart     }      def registerrestartjvmwatcheractor(sys: actorsystem) = {       val ref = sys.actorof(props[defaultclusterwatcher])       sys.eventstream.subscribe(ref, classof[thisactorsystemquarantinedevent])     }    }    trait clusterwatcher {      _: actor ⇒      def handlequarantinedrestart: actor.receive = {       case err: thisactorsystemquarantinedevent ⇒         import slacknotification._         slackemergency(s"actor system ${err.localaddress} quarantined ${err.remoteaddress}, restarting")         sys.exit(1)     }    } 

and use after you've created actor system:

val sys = actorsystem("mycluster", config) clusterwatcher.registerrestartjvmwatcheractor(sys) 

then, whenever defaultclusterwatcher receive quarantine event - restart entire jvm (or else actor system - you).

i find combination of methods robust - in setup allows me run self-sustained distributed cluster of 30 nodes in different data centers modest network connection.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -