コード例 #1
0
  /**
   * This is directly called when the connection to the node is gone, or when the node sends a
   * disconnection. Look for callers of this method!
   */
  public void notifyNodeDown(final long eventTime, final String nodeID) {

    if (!ha) {
      // there's no topology here
      return;
    }

    if (HornetQLogger.LOGGER.isDebugEnabled()) {
      HornetQLogger.LOGGER.debug(
          "nodeDown " + this + " nodeID=" + nodeID + " as being down", new Exception("trace"));
    }

    topology.removeMember(eventTime, nodeID);

    if (clusterConnection) {
      updateArraysAndPairs();
    } else {
      synchronized (this) {
        if (topology.isEmpty()) {
          // Resetting the topology to its original condition as it was brand new
          receivedTopology = false;
          topologyArray = null;
        } else {
          updateArraysAndPairs();

          if (topology.nodes() == 1 && topology.getMember(this.nodeID) != null) {
            // Resetting the topology to its original condition as it was brand new
            receivedTopology = false;
          }
        }
      }
    }
  }
コード例 #2
0
  public void notifyNodeUp(
      long uniqueEventID,
      final String nodeID,
      final Pair<TransportConfiguration, TransportConfiguration> connectorPair,
      final boolean last) {
    if (!ha) {
      // there's no topology
      return;
    }

    if (HornetQLogger.LOGGER.isDebugEnabled()) {
      HornetQLogger.LOGGER.debug(
          "NodeUp " + this + "::nodeID=" + nodeID + ", connectorPair=" + connectorPair,
          new Exception("trace"));
    }

    TopologyMember member = new TopologyMember(connectorPair.getA(), connectorPair.getB());

    topology.updateMember(uniqueEventID, nodeID, member);

    TopologyMember actMember = topology.getMember(nodeID);

    if (actMember != null
        && actMember.getConnector().getA() != null
        && actMember.getConnector().getB() != null) {
      HashSet<ClientSessionFactory> clonedFactories = new HashSet<ClientSessionFactory>();
      synchronized (factories) {
        clonedFactories.addAll(factories);
      }

      for (ClientSessionFactory factory : clonedFactories) {
        ((ClientSessionFactoryInternal) factory)
            .setBackupConnector(actMember.getConnector().getA(), actMember.getConnector().getB());
      }
    }

    updateArraysAndPairs();

    if (last) {
      synchronized (this) {
        receivedTopology = true;
        // Notify if waiting on getting topology
        notifyAll();
      }
    }
  }