Package org.apache.uima.aae.delegate

Examples of org.apache.uima.aae.delegate.Delegate


    if (endpoint != null && aController instanceof AggregateAnalysisEngineController) {
      Threshold threshold = super.getThreshold(endpoint, delegateMap, aController);
      String key = ((AggregateAnalysisEngineController) aController).lookUpDelegateKey(endpoint
              .getEndpoint());
      Delegate delegate = ((AggregateAnalysisEngineController) aController).lookupDelegate(key);
      if (delegate != null
              && delegate.isAwaitingPingReply()
              || threshold == null
              || threshold.getMaxRetries() == 0
              || (super.retryLastCommand(AsynchAEMessage.GetMeta, endpoint, aController, key,
                      threshold, anErrorContext) == false)) {
        if (terminate(threshold)) {
          System.out.println("!!!!!!!!!!!! Exceeded Threshold Terminating !!!!!!!!!!!!!!");
          if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
            UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
                    "handleError", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
                    "UIMAEE_terminate_service__INFO",
                    new Object[] { aController.getComponentName(), endpoint.getEndpoint() });
          }
          aController.terminate();
          // Notify if the error occurred during initialization of the service.
          // If the ping times out, there is no need to notify the listener. We
          // use getMeta request as a ping to check if the service is running.
          if (delegate != null && !delegate.isAwaitingPingReply() && t instanceof Exception) {
            aController.notifyListenersWithInitializationStatus((Exception) t);
          }
        } else {
          aController.takeAction(threshold.getAction(), endpoint.getEndpoint(), anErrorContext);
        }
View Full Code Here


   * sends a ping message to check delegate's availability. If the delegate responds to the ping,
   * all CASes in the pending dispatch list will be immediately dispatched.
   **/
  public boolean delayCasIfDelegateInTimedOutState(String aCasReferenceId, String aDelegateKey)
          throws AsynchAEException {
    Delegate delegate = lookupDelegate(aDelegateKey);
    if (delegate != null && delegate.getState() == Delegate.TIMEOUT_STATE) {
      // Add CAS id to the list of delayed CASes.
      int listSize = delegate.addCasToPendingDispatchList(aCasReferenceId);
      // If the list was empty (before the add), send the GetMeta request
      // as a PING to see if the delegate service is alive.
      if (listSize == 1) {
        delegate.setAwaitingPingReply();
        if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
          UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(),
                  "delayCasIfDelegateInTimedOutState", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
                  "UIMAEE_aggregate_sending_ping__INFO",
                  new Object[] { getComponentName(), delegate.getKey() });
        }
        retryMetadataRequest(delegate.getEndpoint());
      }
      return true;
    }
    return false; // Cas Not Delayed
  }
View Full Code Here

      this.isRequest = isRequest;
      outputChannel = channel;
    }

    public void run() {
      Delegate delegate = outputChannel.lookupDelegate(endpoint.getDelegateKey());
      // Removes the failed CAS from the list of CASes pending reply. This also
      // cancels the timer if this CAS was the oldest pending CAS, and if there
      // are other CASes pending a fresh timer is started.
      outputChannel.removeCasFromOutstandingList(entry, isRequest, endpoint.getDelegateKey());
      if (delegate != null) {
        // Mark this delegate as Failed
        delegate.getEndpoint().setStatus(Endpoint.FAILED);
        // Destroy listener associated with a reply queue for this delegate
        InputChannel ic = controller.getInputChannel(delegate.getEndpoint().getDestination()
                .toString());
        if (ic != null && delegate != null && delegate.getEndpoint() != null) {
          ic.destroyListener(delegate.getEndpoint().getDestination().toString(), endpoint
                  .getDelegateKey());
        }
      }
      // Setup error context and handle failure in the error handler
      ErrorContext errorContext = new ErrorContext();
      errorContext.add(AsynchAEMessage.Command, AsynchAEMessage.Process);
      errorContext.add(AsynchAEMessage.CasReference, entry.getCasReferenceId());
      errorContext.add(AsynchAEMessage.Endpoint, endpoint);
      errorContext.handleSilently(true); // dont dump exception to the log
      // Failure on send treat as timeout
      delegate.handleError(new MessageTimeoutException(), errorContext);

    }
View Full Code Here

        }
        return;
      }
      String delegateKey = ((AggregateAnalysisEngineController) getController())
              .lookUpDelegateKey(aMessageContext.getEndpoint().getEndpoint());
      Delegate delegate = ((AggregateAnalysisEngineController) getController())
              .lookupDelegate(delegateKey);
      boolean casRemovedFromOutstandingList = delegate.removeCasFromOutstandingList(casReferenceId);

      // Check if this process reply message is expected. A message is expected if the Cas Id
      // in the message matches an entry in the delegate's outstanding list. This list stores
      // ids of CASes sent to the remote delegate pending reply.
      if (!casRemovedFromOutstandingList) {
View Full Code Here

              .getLocalCache().lookupEntry(casReferenceId);

      CAS cas = cacheEntry.getCas();
      String delegateKey = ((AggregateAnalysisEngineController) getController())
              .lookUpDelegateKey(aMessageContext.getEndpoint().getEndpoint());
      Delegate delegate = ((AggregateAnalysisEngineController) getController())
              .lookupDelegate(delegateKey);
      if (casStateEntry != null) {
        casStateEntry.setReplyReceived();
        casStateEntry.setLastDelegate(delegate);
      }
      delegate.removeCasFromOutstandingList(casReferenceId);

      if (cas != null) {
        cancelTimerAndProcess(aMessageContext, casReferenceId, cas);
      } else {
        if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
View Full Code Here

          String delegateInputQueueName = aMessageContext
                  .getMessageStringProperty(AsynchAEMessage.MessageFrom);
          String delegateKey = ((AggregateAnalysisEngineController) getController())
                  .lookUpDelegateKey(delegateInputQueueName); // aMessageContext.getEndpoint().getEndpoint());
          if (delegateKey != null) {
            Delegate delegate = ((AggregateAnalysisEngineController) getController())
                    .lookupDelegate(delegateKey);
            // Save the last delegate handling this CAS
            cse.setLastDelegate(delegate);
            // If there is one thread receiving messages from Cas Multiplier increment number of
            // child Cases
            // of the parent CAS. If there are more threads (consumers) a special object
            // ConcurrentMessageListener
            // has already incremented the count. This special object enforces order of processing
            // for CASes
            // coming in from the Cas Multiplier.
            if (!delegate.hasConcurrentConsumersOnReplyQueue()) {
              inputCasStateEntry.incrementSubordinateCasInPlayCount();
            }
          }
        }
View Full Code Here

            return;
          }

          String delegateKey = ((AggregateAnalysisEngineController) getController())
                  .lookUpDelegateKey(aMessageContext.getEndpoint().getEndpoint());
          Delegate delegate = ((AggregateAnalysisEngineController) getController())
                  .lookupDelegate(delegateKey);
          cse.setLastDelegate(delegate);
          newCASProducedBy = delegate.getKey();
          casMultiplierEndpoint.setIsCasMultiplier(true);
          try {
            // Save the endpoint of the CM which produced the Cas
            getController().getInProcessCache().setCasProducer(casReferenceId, newCASProducedBy);
          } catch (Exception e) {
View Full Code Here

                        "handle", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
                        "UIMAEE_override_serialization__WARNING",
                        new Object[] { getController().getComponentName(), delegateKey });
              }
            }
            Delegate delegate = ((AggregateAnalysisEngineController) getController())
                    .lookupDelegate(delegateKey);
            if (delegate.getEndpoint().isRemote()) {
              delegate.cancelDelegateTimer();
              delegate.setState(Delegate.OK_STATE);
              delegate.setNotificationEndpoint(((MessageContext) anObjectToHandle).getEndpoint());

              if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
                UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, this.getClass().getName(),
                        "handle", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
                        "UIMAEE_cancelled_timer_FINE",
                        new Object[] { getController().getComponentName(), delegateKey });
              }
              String casReferenceId = null;
              // Check if the GetMeta reply was actually a PING message to check
              // delegate's availability. This would be the case if the delegate
              // has previously timed out waiting for Process CAS reply.
              if (delegate.isAwaitingPingReply() && delegate.getState() == Delegate.OK_STATE) {
                // Since this is a reply to a ping we may have delayed some
                // CASes waiting for the ping to come back. Drain the list
                // of delayed CASes and send each CAS to the delegate.
                while ((casReferenceId = delegate.removeOldestFromPendingDispatchList()) != null) {
                  ((AggregateAnalysisEngineController) getController()).retryLastCommand(
                          AsynchAEMessage.Process, delegate.getEndpoint(), casReferenceId);
                }

                if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
                  UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, this.getClass().getName(),
                          "handle", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
                          "UIMAEE_aggregate_rcvd_ping_reply__FINE",
                          new Object[] { getController().getComponentName(), delegateKey });
                }
                // Reset delegate flag to indicate that the ping reply was received
                delegate.resetAwaitingPingReply();
                // No need to merge typesystem. We've received a reply to a ping
                return;
              }
            }
            if (AsynchAEMessage.Exception == payload) {
View Full Code Here

        Endpoint endpoint = (Endpoint) entry.getValue();
        // Fetch an Endpoint for the corresponding delegate key
        // Check if the delegate is a Cas Multiplier
        if (endpoint != null && endpoint.isCasMultiplier()) {
          // Fetch the Delegate object corresponding to the current key
          Delegate delegate = ((AggregateAnalysisEngineController) this)
                  .lookupDelegate((String) entry.getKey());

          if (delegate != null) {
            // Get a list of all CASes this aggregate has dispatched to the Cas Multiplier
            List<DelegateEntry> pendingList = delegate.getDelegateCasesPendingReply();
            if (pendingList != null) {
              Iterator<DelegateEntry> it2 = pendingList.iterator();
              // For each CAS pending reply send a Stop message to the CM
              while (it2.hasNext()) {
                DelegateEntry delegateEntry = it2.next();
View Full Code Here

            concurrentListener.setAnalysisEngineController(controller);
          }
          // Save number of concurrent consumers on the temp reply queue in case we need to
          // recreate a new listener on a new temp queue created during recovery
          if (endpoint != null && controller instanceof AggregateAnalysisEngineController) {
            Delegate delegate = ((AggregateAnalysisEngineController) controller)
                    .lookupDelegate(endpoint.getDelegateKey());
            if (delegate != null) {
              delegate.getEndpoint().setConcurrentReplyConsumers(cc);
            }
          }
          //  Show ready message on the console only if this listener is *not* listening
          //  on an input queue. Input queue listeners are not started until the service
          //  is fully initialized
View Full Code Here

TOP

Related Classes of org.apache.uima.aae.delegate.Delegate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.