TOP

Akka(10): 分布式运算:集群-Cluster(二)
2017-10-09 13:50:40 】 浏览:10564
Tags:Akka 分布式 运算 集群 -Cluster

s(seedNodes: immutable.Seq[Address]): Unit
= clusterCore ! InternalClusterAction.JoinSeedNodes(seedNodes.toVector.map(fillLocal))

集群节点Leave和Down实现方法如下: 

/** * Send command to issue state transition to LEAVING for the node specified by 'address'. * The member will go through the status changes [[MemberStatus]] `Leaving` (not published to * subscribers) followed by [[MemberStatus]] `Exiting` and finally [[MemberStatus]] `Removed`. * * Note that this command can be issued to any member in the cluster, not necessarily the * one that is leaving. The cluster extension, but not the actor system or JVM, of the * leaving member will be shutdown after the leader has changed status of the member to * Exiting. Thereafter the member will be removed from the cluster. Normally this is * handled automatically, but in case of network failures during this process it might * still be necessary to set the node’s status to Down in order to complete the removal. */ def leave(address: Address): Unit = clusterCore ! ClusterUserAction.Leave(fillLocal(address)) /** * Send command to DOWN the node specified by 'address'. * * When a member is considered by the failure detector to be unreachable the leader is not * allowed to perform its duties, such as changing status of new joining members to 'Up'. * The status of the unreachable member must be changed to 'Down', which can be done with * this method. */ def down(address: Address): Unit = clusterCore ! ClusterUserAction.Down(fillLocal(address))

Akka-Cluster的集群节点状态转换可以作为事件在Akka的EventBus上发布:

  /** * Marker interface for membership events. * Published when the state change is first seen on a node. * The state change was performed by the leader when there was * convergence on the leader node, i.e. all members had seen previous * state. */
  sealed trait MemberEvent extends ClusterDomainEvent { def member: Member } /** * Member status changed to Joining. */ final case class MemberJoined(member: Member) extends MemberEvent { if (member.status != Joining) throw new IllegalArgumentException("Expected Joining status, got: " + member) } /** * Member status changed to WeaklyUp. * A joining member can be moved to `WeaklyUp` if convergence * cannot be reached, i.e. there are unreachable nodes. * It will be moved to `Up` when convergence is reached. */ final case class MemberWeaklyUp(member: Member) extends MemberEvent { if (member.status != WeaklyUp) throw new IllegalArgumentException("Expected WeaklyUp status, got: " + member) } /** * Member status changed to Up. */ final case class MemberUp(member: Member) extends MemberEvent { if (member.status != Up) throw new IllegalArgumentException("Expected Up status, got: " + member) } /** * Member status changed to Leaving. */ final case class MemberLeft(member: Member) extends MemberEvent { if (member.status != Leaving) throw new IllegalArgumentException("Expected Leaving status, got: " + member) } /** * Member status changed to `MemberStatus.Exiting` and will be removed * when all members have seen the `Exiting` status. */ final case class MemberExited(member: Member) extends MemberEvent { if (member.status != Exiting) throw new IllegalArgumentException("Expected Exiting status, got: " + member) } /** * Member completely removed from the cluster. * When `previousStatus` is `MemberStatus.Down` the node was removed * after being detected as unreachable and downed. * When `previousStatus` is `MemberStatus.Exiting` the node was removed * a  
		
Akka(10): 分布式运算:集群-Cluster(二) https://www.cppentry.com/bencandy.php?fid=90&id=124492

首页 上一页 1 2 3 4 5 6 7 下一页 尾页 2/7/7
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Akka(9): 分布式运算:Remotin.. 下一篇Akka(12): 分布式运算:Cluste..