private void checkTopology(
      final HornetQServer serverParameter,
      final String clusterName,
      final String nodeId1,
      final String nodeId2,
      final TransportConfiguration cfg1,
      final TransportConfiguration cfg2) {
    Topology topology =
        serverParameter.getClusterManager().getClusterConnection(clusterName).getTopology();

    TopologyMemberImpl member1 = topology.getMember(nodeId1);
    TopologyMemberImpl member2 = topology.getMember(nodeId2);
    Assert.assertEquals(member1.getLive().getParams().toString(), cfg1.getParams().toString());
    Assert.assertEquals(member2.getLive().getParams().toString(), cfg2.getParams().toString());
  }
Beispiel #2
0
  private boolean isLiveDown() {
    Collection<TopologyMemberImpl> nodes = topology.getMembers();
    Collection<ServerLocator> locatorsList = new LinkedList<ServerLocator>();
    AtomicInteger pingCount = new AtomicInteger(0);
    int total = 0;
    for (TopologyMemberImpl tm : nodes) if (useIt(tm)) total++;

    if (total < 1) return true;

    final CountDownLatch voteLatch = new CountDownLatch(total);
    try {
      for (TopologyMemberImpl tm : nodes) {
        Pair<TransportConfiguration, TransportConfiguration> pair = tm.getConnector();

        TransportConfiguration serverTC = pair.getA();
        if (useIt(tm)) {
          ServerLocatorImpl locator =
              (ServerLocatorImpl) HornetQClient.createServerLocatorWithoutHA(serverTC);
          locatorsList.add(locator);
          executor.submit(
              new QuorumVoteServerConnect(voteLatch, total, pingCount, locator, serverTC));
        }
      }

      try {
        voteLatch.await(LATCH_TIMEOUT, TimeUnit.SECONDS);
      } catch (InterruptedException interruption) {
        // No-op. The best the quorum can do now is to return the latest number it has
      }
      // -1: because the live server is not being filtered out.
      boolean vote = nodeIsDown(total, pingCount.get());
      HornetQServerLogger.LOGGER.trace(
          "quorum vote is liveIsDown=" + vote + ", count=" + pingCount);
      return vote;
    } finally {
      for (ServerLocator locator : locatorsList) {
        try {
          locator.close();
        } catch (Exception e) {
          // no-op
        }
      }
    }
  }
  public void nodeAnnounced(
      final long uniqueEventID,
      final String nodeID,
      final String nodeName,
      final Pair<TransportConfiguration, TransportConfiguration> connectorPair,
      final boolean backup) {
    if (HornetQServerLogger.LOGGER.isDebugEnabled()) {
      HornetQServerLogger.LOGGER.debug(
          this + "::NodeAnnounced, backup=" + backup + nodeID + connectorPair);
    }

    TransportConfiguration live = connectorPair.getA();
    TransportConfiguration backupTC = connectorPair.getB();
    TopologyMemberImpl newMember = new TopologyMemberImpl(nodeID, nodeName, live, backupTC);
    newMember.setUniqueEventID(uniqueEventID);
    if (backup) {
      topology.updateBackup(new TopologyMemberImpl(nodeID, nodeName, live, backupTC));
    } else {
      topology.updateMember(uniqueEventID, nodeID, newMember);
    }
  }
Beispiel #4
0
 /**
  * @param tm
  * @return
  */
 private boolean useIt(TopologyMemberImpl tm) {
   return tm.getLive() != null && !targetServerID.equals(tm.getLive().getName());
 }