Example #1
0
 private static void dump(
     List<TransportConfiguration> sortedExpected, List<DiscoveryEntry> sortedActual) {
   System.out.println("wrong broadcasts received");
   System.out.println("expected");
   System.out.println("----------------------------");
   for (TransportConfiguration transportConfiguration : sortedExpected) {
     System.out.println("transportConfiguration = " + transportConfiguration);
   }
   System.out.println("----------------------------");
   System.out.println("actual");
   System.out.println("----------------------------");
   for (DiscoveryEntry discoveryEntry : sortedActual) {
     System.out.println("transportConfiguration = " + discoveryEntry.getConnector());
   }
   System.out.println("----------------------------");
 }
  public synchronized void connectorsChanged() {
    List<DiscoveryEntry> newConnectors = discoveryGroup.getDiscoveryEntries();

    TransportConfiguration[] newInitialconnectors =
        (TransportConfiguration[])
            Array.newInstance(TransportConfiguration.class, newConnectors.size());

    int count = 0;
    for (DiscoveryEntry entry : newConnectors) {
      newInitialconnectors[count++] = entry.getConnector();

      if (ha && topology.getMember(entry.getNodeID()) == null) {
        TopologyMember member = new TopologyMember(entry.getConnector(), null);
        // on this case we set it as zero as any update coming from server should be accepted
        topology.updateMember(0, entry.getNodeID(), member);
      }
    }

    this.initialConnectors = newInitialconnectors;

    if (clusterConnection && !receivedTopology && initialConnectors.length > 0) {
      // The node is alone in the cluster. We create a connection to the new node
      // to trigger the node notification to form the cluster.

      Runnable connectRunnable =
          new Runnable() {
            public void run() {
              try {
                connect();
              } catch (HornetQException e) {
                HornetQLogger.LOGGER.errorConnectingToNodes(e);
              }
            }
          };
      if (startExecutor != null) {
        startExecutor.execute(connectRunnable);
      } else {
        connectRunnable.run();
      }
    }
  }