Пример #1
0
  public ClientSessionFactory createSessionFactory(String nodeID) throws Exception {
    TopologyMember topologyMember = topology.getMember(nodeID);

    if (HornetQLogger.LOGGER.isTraceEnabled()) {
      HornetQLogger.LOGGER.trace(
          "Creating connection factory towards "
              + nodeID
              + " = "
              + topologyMember
              + ", topology="
              + topology.describe());
    }

    if (topologyMember == null) {
      return null;
    } else if (topologyMember.getA() != null) {
      ClientSessionFactoryInternal factory =
          (ClientSessionFactoryInternal) createSessionFactory(topologyMember.getA());
      if (topologyMember.getB() != null) {
        factory.setBackupConnector(topologyMember.getA(), topologyMember.getB());
      }
      return factory;
    } else if (topologyMember.getA() == null && topologyMember.getB() != null) {
      // This shouldn't happen, however I wanted this to consider all possible cases
      ClientSessionFactoryInternal factory =
          (ClientSessionFactoryInternal) createSessionFactory(topologyMember.getB());
      return factory;
    } else {
      // it shouldn't happen
      return null;
    }
  }
Пример #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();
      }
    }
  }
Пример #3
0
  private void addFactory(ClientSessionFactoryInternal factory) {
    if (factory == null) {
      return;
    }

    if (isClosed()) {
      factory.close();
      return;
    }

    TransportConfiguration backup = null;

    if (ha) {
      backup = topology.getBackupForConnector(factory.getConnectorConfiguration());
    }

    factory.setBackupConnector(factory.getConnectorConfiguration(), backup);

    synchronized (factories) {
      factories.add(factory);
    }
  }