Ejemplo n.º 1
0
  private void createNewRecord(
      final long eventUID,
      final String targetNodeID,
      final TransportConfiguration connector,
      final SimpleString queueName,
      final Queue queue,
      final boolean start)
      throws Exception {
    String nodeId;

    synchronized (this) {
      if (!started) {
        return;
      }

      if (serverLocator == null) {
        return;
      }

      nodeId = serverLocator.getNodeID();
    }

    final ServerLocatorInternal targetLocator = new ServerLocatorImpl(topology, true, connector);

    targetLocator.setReconnectAttempts(0);

    targetLocator.setInitialConnectAttempts(0);
    targetLocator.setClientFailureCheckPeriod(clientFailureCheckPeriod);
    targetLocator.setConnectionTTL(connectionTTL);
    targetLocator.setInitialConnectAttempts(0);

    targetLocator.setConfirmationWindowSize(confirmationWindowSize);
    targetLocator.setBlockOnDurableSend(!useDuplicateDetection);
    targetLocator.setBlockOnNonDurableSend(!useDuplicateDetection);

    targetLocator.setRetryInterval(retryInterval);
    targetLocator.setMaxRetryInterval(maxRetryInterval);
    targetLocator.setRetryIntervalMultiplier(retryIntervalMultiplier);
    targetLocator.setMinLargeMessageSize(minLargeMessageSize);

    // No producer flow control on the bridges, as we don't want to lock the queues
    targetLocator.setProducerWindowSize(-1);

    targetLocator.setAfterConnectionInternalListener(this);

    targetLocator.setNodeID(nodeId);

    targetLocator.setClusterTransportConfiguration(
        serverLocator.getClusterTransportConfiguration());

    if (retryInterval > 0) {
      targetLocator.setRetryInterval(retryInterval);
    }

    targetLocator.disableFinalizeCheck();
    targetLocator.addIncomingInterceptor(
        new IncomingInterceptorLookingForExceptionMessage(manager, executorFactory.getExecutor()));
    MessageFlowRecordImpl record =
        new MessageFlowRecordImpl(
            targetLocator, eventUID, targetNodeID, connector, queueName, queue);

    ClusterConnectionBridge bridge =
        new ClusterConnectionBridge(
            this,
            manager,
            targetLocator,
            serverLocator,
            reconnectAttempts,
            retryInterval,
            retryIntervalMultiplier,
            maxRetryInterval,
            nodeManager.getUUID(),
            record.getEventUID(),
            record.getTargetNodeID(),
            record.getQueueName(),
            record.getQueue(),
            executorFactory.getExecutor(),
            null,
            null,
            scheduledExecutor,
            null,
            useDuplicateDetection,
            clusterUser,
            clusterPassword,
            server.getStorageManager(),
            managementService.getManagementAddress(),
            managementService.getManagementNotificationAddress(),
            record,
            record.getConnector());

    targetLocator.setIdentity(
        "(Cluster-connection-bridge::" + bridge.toString() + "::" + this.toString() + ")");

    if (HornetQServerLogger.LOGGER.isDebugEnabled()) {
      HornetQServerLogger.LOGGER.debug(
          "creating record between " + this.connector + " and " + connector + bridge);
    }

    record.setBridge(bridge);

    records.put(targetNodeID, record);

    if (start) {
      bridge.start();
    }
  }
Ejemplo n.º 2
0
  private synchronized void activate() throws Exception {
    if (!started) {
      return;
    }

    if (HornetQServerLogger.LOGGER.isDebugEnabled()) {
      HornetQServerLogger.LOGGER.debug(
          "Activating cluster connection nodeID="
              + nodeManager.getNodeId()
              + " for server="
              + this.server);
    }

    liveNotifier = new LiveNotifier();
    liveNotifier.updateAsLive();
    liveNotifier.schedule();

    serverLocator = clusterConnector.createServerLocator();

    if (serverLocator != null) {

      if (!useDuplicateDetection) {
        HornetQServerLogger.LOGGER.debug(
            "DuplicateDetection is disabled, sending clustered messages blocked");
      }

      final TopologyMember currentMember = topology.getMember(manager.getNodeId());

      if (currentMember == null) {
        // sanity check only
        throw new IllegalStateException(
            "InternalError! The ClusterConnection doesn't know about its own node = " + this);
      }

      serverLocator.setNodeID(nodeManager.getNodeId().toString());
      serverLocator.setIdentity("(main-ClusterConnection::" + server.toString() + ")");
      serverLocator.setReconnectAttempts(0);
      serverLocator.setClusterConnection(true);
      serverLocator.setClusterTransportConfiguration(connector);
      serverLocator.setInitialConnectAttempts(-1);
      serverLocator.setClientFailureCheckPeriod(clientFailureCheckPeriod);
      serverLocator.setConnectionTTL(connectionTTL);
      serverLocator.setConfirmationWindowSize(confirmationWindowSize);
      // if not using duplicate detection, we will send blocked
      serverLocator.setBlockOnDurableSend(!useDuplicateDetection);
      serverLocator.setBlockOnNonDurableSend(!useDuplicateDetection);
      serverLocator.setCallTimeout(callTimeout);
      serverLocator.setCallFailoverTimeout(callFailoverTimeout);
      // No producer flow control on the bridges, as we don't want to lock the queues
      serverLocator.setProducerWindowSize(-1);

      if (retryInterval > 0) {
        this.serverLocator.setRetryInterval(retryInterval);
      }

      addClusterTopologyListener(this);

      serverLocator.setAfterConnectionInternalListener(this);

      serverLocator.start(server.getExecutorFactory().getExecutor());
    }

    if (managementService != null) {
      TypedProperties props = new TypedProperties();
      props.putSimpleStringProperty(new SimpleString("name"), name);
      Notification notification =
          new Notification(
              nodeManager.getNodeId().toString(),
              NotificationType.CLUSTER_CONNECTION_STARTED,
              props);
      HornetQServerLogger.LOGGER.debug("sending notification: " + notification);
      managementService.sendNotification(notification);
    }
  }