Ejemplo n.º 1
0
 public void onRestart() {
   joined.set(false);
   joiner.reset();
   final String uuid = UuidUtil.createMemberUuid(address);
   logger.finest("Generated new UUID for local member: " + uuid);
   localMember.setUuid(uuid);
 }
Ejemplo n.º 2
0
 public void join() {
   final long joinStartTime = joiner != null ? joiner.getStartTime() : Clock.currentTimeMillis();
   final long maxJoinMillis = getGroupProperties().MAX_JOIN_SECONDS.getInteger() * 1000;
   try {
     if (joiner == null) {
       logger.warning("No join method is enabled! Starting standalone.");
       setAsMaster();
     } else {
       joiner.join(joined);
     }
   } catch (Exception e) {
     if (Clock.currentTimeMillis() - joinStartTime < maxJoinMillis) {
       logger.warning("Trying to rejoin: " + e.getMessage());
       rejoin();
     } else {
       logger.severe("Could not join cluster, shutting down!", e);
       shutdown(false, true);
     }
   }
 }
Ejemplo n.º 3
0
  public ConfigCheck createConfigCheck() {
    final ConfigCheck configCheck = new ConfigCheck();
    final GroupConfig groupConfig = config.getGroupConfig();
    final PartitionGroupConfig partitionGroupConfig = config.getPartitionGroupConfig();
    final boolean partitionGroupEnabled =
        partitionGroupConfig != null && partitionGroupConfig.isEnabled();

    PartitionGroupConfig.MemberGroupType memberGroupType =
        partitionGroupEnabled
            ? partitionGroupConfig.getGroupType()
            : PartitionGroupConfig.MemberGroupType.PER_MEMBER;
    configCheck
        .setGroupName(groupConfig.getName())
        .setGroupPassword(groupConfig.getPassword())
        .setJoinerType(joiner != null ? joiner.getType() : "")
        .setPartitionGroupEnabled(partitionGroupEnabled)
        .setMemberGroupType(memberGroupType);
    return configCheck;
  }
Ejemplo n.º 4
0
  public void join() {
    if (joiner == null) {
      logger.warning("No join method is enabled! Starting standalone.");
      setAsMaster();
      return;
    }

    try {
      masterAddress = null;
      joined.set(false);
      clusterService.reset();

      joiner.join();
    } catch (Throwable e) {
      logger.severe("Error while joining the cluster!", e);
    }

    if (!joined()) {
      long maxJoinTimeMillis = groupProperties.getMillis(GroupProperty.MAX_JOIN_SECONDS);
      logger.severe("Could not join cluster in " + maxJoinTimeMillis + " ms. Shutting down now!");
      shutdownNodeByFiringEvents(Node.this, true);
    }
  }
Ejemplo n.º 5
0
 public ConfigCheck createConfigCheck() {
   String joinerType = joiner == null ? "" : joiner.getType();
   return new ConfigCheck(config, joinerType);
 }
Ejemplo n.º 6
0
 /**
  * Resets the internal cluster-state of the Node to be able to make it ready to join a new
  * cluster. After this method is called, a new join process can be triggered by calling {@link
  * #join()}.
  *
  * <p>This method is called during merge process after a split-brain is detected.
  */
 public void reset() {
   setMasterAddress(null);
   joined.set(false);
   joiner.reset();
 }