Ejemplo n.º 1
0
 public void sendMemberListToMember(Address target) {
   if (!isMaster()) {
     return;
   }
   if (thisAddress.equals(target)) {
     return;
   }
   Collection<MemberImpl> members = getMemberImpls();
   MemberInfoUpdateOperation op =
       new MemberInfoUpdateOperation(
           createMemberInfoList(members), clusterClock.getClusterTime(), false);
   nodeEngine.getOperationService().send(op, target);
 }
Ejemplo n.º 2
0
  private void assignNewMaster() {
    Address oldMasterAddress = node.getMasterAddress();
    if (node.joined()) {
      Collection<Member> members = getMembers();
      Member newMaster = null;
      int size = members.size();
      if (size > 1) {
        Iterator<Member> iterator = members.iterator();
        Member member = iterator.next();
        if (member.getAddress().equals(oldMasterAddress)) {
          newMaster = iterator.next();
        } else {
          logger.severe(
              format(
                  "Old master %s is dead, but the first of member list is a different member %s!",
                  oldMasterAddress, member));
          newMaster = member;
        }
      } else {
        logger.warning(
            format(
                "Old master %s is dead and this node is not master, "
                    + "but member list contains only %d members: %s",
                oldMasterAddress, size, members));
      }
      logger.info(
          format(
              "Old master %s left the cluster, assigning new master %s",
              oldMasterAddress, newMaster));
      if (newMaster != null) {
        node.setMasterAddress(newMaster.getAddress());
      } else {
        node.setMasterAddress(null);
      }
    } else {
      node.setMasterAddress(null);
    }

    if (logger.isFinestEnabled()) {
      logger.finest(
          format("Old master: %s, new master: %s ", oldMasterAddress, node.getMasterAddress()));
    }

    if (node.isMaster()) {
      clusterHeartbeatManager.resetMemberMasterConfirmations();
      clusterClock.reset();
    } else {
      clusterHeartbeatManager.sendMasterConfirmation();
    }
  }
Ejemplo n.º 3
0
 @Override
 public long getClusterTime() {
   return clusterClock.getClusterTime();
 }