Examples of UimaTransport


Examples of org.apache.uima.aae.spi.transport.UimaTransport

    // Notify the parent of the exception
    if (anEndpoint != null && aCasReferenceId != null && !anEndpoint.isCasMultiplier()) {
      try {
        if (!anEndpoint.isRemote()) {
          anEndpoint.setReplyEndpoint(true);
          UimaTransport vmTransport = aController.getTransport(anEndpoint.getEndpoint());
          UimaMessage message = vmTransport.produceMessage(AsynchAEMessage.Process,
                  AsynchAEMessage.Response, aController.getName());
          message.addIntProperty(AsynchAEMessage.Payload, AsynchAEMessage.Exception);
          message.addStringProperty(AsynchAEMessage.CasReference, aCasReferenceId);

          Throwable wrapper = null;
          if (!(t instanceof UimaEEServiceException)) {
            // Strip off AsyncAEException and replace with UimaEEServiceException
            if (t instanceof AsynchAEException && t.getCause() != null) {
              wrapper = new UimaEEServiceException(t.getCause());
            } else {
              wrapper = new UimaEEServiceException(t);
            }
          }
          if (wrapper == null) {
            message.addObjectProperty(AsynchAEMessage.Cargo, t);
          } else {
            message.addObjectProperty(AsynchAEMessage.Cargo, wrapper);
          }
          if (!aController.isStopped()) {
            vmTransport.getUimaMessageDispatcher(anEndpoint.getEndpoint()).dispatch(message);
          }
        } else {
          CasStateEntry stateEntry = null;
          String parentCasReferenceId = null;
          try {
View Full Code Here

Examples of org.apache.uima.aae.spi.transport.UimaTransport

    }
    return getTransport(asContext, endpointName);
  }

  public UimaTransport getTransport(UimaAsContext asContext, String aKey) throws Exception {
    UimaTransport transport = null;
    if (!transports.containsKey(aKey)) {
      transport = new VmTransport(asContext, this);
      if (isStopped()) {
        throw new ServiceShutdownException();
      }
View Full Code Here

Examples of org.apache.uima.aae.spi.transport.UimaTransport

              + " Concurrent Consumers");

      uimaAsContext.setConcurrentConsumerCount(concurrentRequestConsumers);
      uimaAsContext.put("EndpointName", endpointName);

      UimaTransport vmTransport = getTransport(uimaAsContext);
      // Creates delegate Listener for receiving requests from the parent
      UimaMessageListener messageListener = vmTransport.produceUimaMessageListener();
      // Plug in message handlers
      messageListener.initialize(uimaAsContext);
      // Store the listener
      messageListeners.put(getName(), messageListener);
      // Creates parent controller dispatcher for this delegate. The dispatcher is wired
      // with this delegate's listener.
      UimaAsContext uimaAsContext2 = new UimaAsContext();
      // Set up as many reply threads as there are threads to process requests
      uimaAsContext2.setConcurrentConsumerCount(concurrentReplyConsumers);
      uimaAsContext2.put("EndpointName", endpointName);
      UimaTransport parentVmTransport = parentController.getTransport(uimaAsContext2, endpointName);

      parentVmTransport.produceUimaMessageDispatcher(vmTransport);
      // Creates parent listener for receiving replies from this delegate.
      UimaMessageListener parentListener = parentVmTransport.produceUimaMessageListener();
      // Plug in message handlers
      parentListener.initialize(uimaAsContext2);
      // Creates delegate's dispatcher. It is wired to send replies to the parent's listener.
      vmTransport.produceUimaMessageDispatcher(parentVmTransport);
      // Register input queue with JMX. This is an internal (non-jms) queue where clients
      // send requests to this service.
      vmTransport.registerWithJMX(this, "VmInputQueue");
      parentVmTransport.registerWithJMX(this, "VmReplyQueue");
    }

  }
View Full Code Here

Examples of org.apache.uima.aae.spi.transport.UimaTransport

  protected void stopTransportLayer() {
    if (transports.size() > 0) {
      Set<Entry<String, UimaTransport>> set = transports.entrySet();
      for (Entry<String, UimaTransport> entry : set) {
        UimaTransport transport = entry.getValue();
        try {

          UimaMessage message = transport.produceMessage(AsynchAEMessage.Stop,
                  AsynchAEMessage.Request, getName());
          transport.getUimaMessageDispatcher(entry.getKey()).dispatch(message);
          transport.stopIt();
          System.out.println("Service:" + getComponentName() + " Stopped Delegate Transport:"
                  + entry.getKey());
        } catch (Exception e) {
          if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
            UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(),
View Full Code Here

Examples of org.apache.uima.aae.spi.transport.UimaTransport

        if (!anEndpoint.isRemote()) {
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          try {

            UimaTransport transport = null;
            transport = getTransport(anEndpoint.getEndpoint());
            UimaMessage message = transport.produceMessage(AsynchAEMessage.GetMeta,
                    AsynchAEMessage.Response, getName());
            metadata.toXML(bos);
            message.addStringCargo(bos.toString());
            transport.getUimaMessageDispatcher(anEndpoint.getEndpoint()).dispatch(message);
          } catch (Exception e) {
            if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
              UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(),
                      "sendMetadata", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
                      "UIMAEE_exception__WARNING", new Object[] { e });
View Full Code Here

Examples of org.apache.uima.aae.spi.transport.UimaTransport

                "collectionProcessComplete", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
                "UIMAEE_cpc_all_cases_processed__FINEST", new Object[] { getComponentName() });
      }
      getServicePerformance().incrementAnalysisTime(super.getCpuTime() - start);
      if (!anEndpoint.isRemote()) {
        UimaTransport transport = getTransport(anEndpoint.getEndpoint());
        UimaMessage message = transport.produceMessage(AsynchAEMessage.CollectionProcessComplete,
                AsynchAEMessage.Response, getName());
        // Send CPC completion reply back to the client. Use internal (non-jms) transport
        transport.getUimaMessageDispatcher(anEndpoint.getEndpoint()).dispatch(message);
      } else {
        getOutputChannel().sendReply(AsynchAEMessage.CollectionProcessComplete, anEndpoint, null, false);
      }

      if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
View Full Code Here

Examples of org.apache.uima.aae.spi.transport.UimaTransport

          }
          // Increment number of CASes processed by this service
          sequence++;
        }
        if (!anEndpoint.isRemote()) {
          UimaTransport transport = getTransport(anEndpoint.getEndpoint());
          UimaMessage message = transport.produceMessage(AsynchAEMessage.Process,
                  AsynchAEMessage.Request, getName());
          message.addStringProperty(AsynchAEMessage.CasReference, newEntry.getCasReferenceId());
          message.addStringProperty(AsynchAEMessage.InputCasReference, aCasReferenceId);
          message.addLongProperty(AsynchAEMessage.CasSequence, sequence);
          ServicePerformance casStats = getCasStatistics(aCasReferenceId);

          message.addLongProperty(AsynchAEMessage.TimeToSerializeCAS, casStats
                  .getRawCasSerializationTime());
          message.addLongProperty(AsynchAEMessage.TimeToDeserializeCAS, casStats
                  .getRawCasDeserializationTime());
          message.addLongProperty(AsynchAEMessage.TimeInProcessCAS, casStats.getRawAnalysisTime());
          long iT = getIdleTimeBetweenProcessCalls(AsynchAEMessage.Process);
          message.addLongProperty(AsynchAEMessage.IdleTime, iT);
          if (!stopped) {
            transport.getUimaMessageDispatcher(anEndpoint.getEndpoint()).dispatch(message);
            dropStats(newEntry.getCasReferenceId(), getName());
          }
        } else {
          // Send generated CAS to the remote client
          if (!stopped) {
              getOutputChannel().sendReply(newEntry, anEndpoint);
           
              //  Check for delivery failure. The client may have terminated while an input CAS was being processed
            if ( childCasStateEntry.deliveryToClientFailed() ) {
              clientUnreachable = true;
              if ( cmOutstandingCASes.containsKey(childCasStateEntry.getCasReferenceId())) {
                  cmOutstandingCASes.remove(childCasStateEntry.getCasReferenceId());
              }
              //  Stop generating new CASes. We failed to send a CAS to a client. Most likely
              //  the client has terminated.
              moreCASesToProcess = false; // exit the while loop
             
              dropCAS(childCasStateEntry.getCasReferenceId(), true);
            }
          }
        }
        // Remove new CAS state entry from the local cache if this is a top level primitive.
        // If not top level, the client (an Aggregate) will remove this entry when this new
        // generated CAS reaches Final State.
        if (isTopLevelComponent()) {
          try {
            localCache.lookupEntry(newEntry.getCasReferenceId()).setDropped(true);
          } catch (Exception e) {
          }
          localCache.remove(newEntry.getCasReferenceId());
        }

        // Remove Stats from the global Map associated with the new CAS
        // These stats for this CAS were added to the response message
        // and are no longer needed
        dropCasStatistics(newEntry.getCasReferenceId());
      } // while

      if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINEST)) {
        UIMAFramework.getLogger(CLASS_NAME).logrb(
                Level.FINEST,
                getClass().getName(),
                "process",
                UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
                "UIMAEE_completed_analysis__FINEST",
                new Object[] { Thread.currentThread().getName(), getComponentName(),
                    aCasReferenceId, (double) (super.getCpuTime() - time) / (double) 1000000 });
      }
      getMonitor().resetCountingStatistic("", Monitor.ProcessErrorCount);
      // Set total number of children generated from this CAS
      // Store total time spent processing this input CAS
      getCasStatistics(aCasReferenceId).incrementAnalysisTime(totalProcessTime);

      //  Fetch AE's management information that includes per component performance stats
      //  These stats are internally maintained in a Map. If the AE is an aggregate
      //  the Map will contain AnalysisEngineManagement instance for each AE.
      AnalysisEngineManagement aem = ae.getManagementInterface();
      if ( aem.getComponents().size() > 0) {
          //  Flatten the hierarchy by recursively (if this AE is an aggregate) extracting 
          //  primitive AE's AnalysisEngineManagement instance and placing it in
          //  afterAnalysisManagementObjects List.
          getLeafManagementObjects(aem, afterAnalysisManagementObjects);
      } else {
          //  Add the top level AnalysisEngineManagement instance.
          afterAnalysisManagementObjects.add(deepCopyMetrics(aem));   
      }

      //  Create a List to hold per CAS analysisTime and total number of CASes processed
      //  by each AE. This list will be serialized and sent to the client
      List<AnalysisEnginePerformanceMetrics> performanceList =
        new ArrayList<AnalysisEnginePerformanceMetrics>();
      //  Diff the before process() performance metrics with post process performance
      //  metrics
      for (AnalysisEnginePerformanceMetrics after : afterAnalysisManagementObjects) {
        for( AnalysisEnginePerformanceMetrics before: beforeAnalysisManagementObjects) {
          if ( before.getUniqueName().equals(after.getUniqueName())) {
            AnalysisEnginePerformanceMetrics metrics =
              new AnalysisEnginePerformanceMetrics(after.getName(),
                      after.getUniqueName(),
                      after.getAnalysisTime()- before.getAnalysisTime(),
                      after.getNumProcessed());
            performanceList.add(metrics);
            break;
          }
        }
      }
      //  Save this component performance metrics
      parentCasStateEntry.getAEPerformanceList().addAll(performanceList);
     
      if (!anEndpoint.isRemote()) {
        inputCASReturned = true;
        UimaTransport transport = getTransport(anEndpoint.getEndpoint());

        if (getInProcessCache() != null && getInProcessCache().getSize() > 0
                && getInProcessCache().entryExists(aCasReferenceId)) {
          try {
            CacheEntry ancestor =
                      getInProcessCache().
                        getTopAncestorCasEntry(getInProcessCache().getCacheEntryForCAS(aCasReferenceId));
            if ( ancestor != null ) {
                // Set a flag on the input CAS to indicate that the processing was aborted
               ancestor.addDelegateMetrics(getKey(), performanceList);
            }
          } catch (Exception e) {
            // An exception be be thrown here if the service is being stopped.
            // The top level controller may have already cleaned up the cache
            // and the getCacheEntryForCAS() will throw an exception. Ignore it
            // here, we are shutting down.
          }
        }         
       
        UimaMessage message = transport.produceMessage(AsynchAEMessage.Process,
                AsynchAEMessage.Response, getName());
        message.addStringProperty(AsynchAEMessage.CasReference, aCasReferenceId);
        ServicePerformance casStats = getCasStatistics(aCasReferenceId);

        message.addLongProperty(AsynchAEMessage.TimeToSerializeCAS, casStats
                .getRawCasSerializationTime());
        message.addLongProperty(AsynchAEMessage.TimeToDeserializeCAS, casStats
                .getRawCasDeserializationTime());
        message.addLongProperty(AsynchAEMessage.TimeInProcessCAS, casStats.getRawAnalysisTime());
        long iT = getIdleTimeBetweenProcessCalls(AsynchAEMessage.Process);
        message.addLongProperty(AsynchAEMessage.IdleTime, iT);
        // Send reply back to the client. Use internal (non-jms) transport
        if (!stopped) {
          transport.getUimaMessageDispatcher(anEndpoint.getEndpoint()).dispatch(message);
          dropStats(aCasReferenceId, getName());
        }
      } else {
        try {
         
View Full Code Here

Examples of org.apache.uima.aae.spi.transport.UimaTransport

    }
    return getTransport(asContext, endpointName);
  }

  public UimaTransport getTransport(UimaAsContext asContext, String aKey) throws Exception {
    UimaTransport transport = null;
    if (!transports.containsKey(aKey)) {
      transport = new VmTransport(asContext, this);
      if (isStopped()) {
        throw new ServiceShutdownException();
      }
View Full Code Here

Examples of org.apache.uima.aae.spi.transport.UimaTransport

                  "UIMAEE_starting_colocated_listener__INFO", new Object[] {getComponentName(),concurrentRequestConsumers,concurrentReplyConsumers });
      }
      uimaAsContext.setConcurrentConsumerCount(concurrentRequestConsumers);
      uimaAsContext.put("EndpointName", endpointName);

      UimaTransport vmTransport = getTransport(uimaAsContext);
      // Creates delegate Listener for receiving requests from the parent
      UimaMessageListener messageListener = vmTransport.produceUimaMessageListener();
      // Plug in message handlers
      messageListener.initialize(uimaAsContext);
      // Store the listener
      messageListeners.put(getName(), messageListener);
      // Creates parent controller dispatcher for this delegate. The dispatcher is wired
      // with this delegate's listener.
      UimaAsContext uimaAsContext2 = new UimaAsContext();
      // Set up as many reply threads as there are threads to process requests
      uimaAsContext2.setConcurrentConsumerCount(concurrentReplyConsumers);
      uimaAsContext2.put("EndpointName", endpointName);
      UimaTransport parentVmTransport = parentController.getTransport(uimaAsContext2, endpointName);

      parentVmTransport.produceUimaMessageDispatcher(vmTransport);
      // Creates parent listener for receiving replies from this delegate.
      UimaMessageListener parentListener = parentVmTransport.produceUimaMessageListener();
      // Plug in message handlers
      parentListener.initialize(uimaAsContext2);
      // Creates delegate's dispatcher. It is wired to send replies to the parent's listener.
      vmTransport.produceUimaMessageDispatcher(parentVmTransport);
      // Register input queue with JMX. This is an internal (non-jms) queue where clients
      // send requests to this service.
      vmTransport.registerWithJMX(this, "VmInputQueue");
      parentVmTransport.registerWithJMX(this, "VmReplyQueue");
    }

  }
View Full Code Here

Examples of org.apache.uima.aae.spi.transport.UimaTransport

  protected void stopTransportLayer() {
    if (transports.size() > 0) {
      Set<Entry<String, UimaTransport>> set = transports.entrySet();
      for (Entry<String, UimaTransport> entry : set) {
        UimaTransport transport = entry.getValue();
        try {
          transport.stopIt();
        } catch (Exception e) {
          if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
            UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
                    "stopTransportLayer", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
                    "UIMAEE_service_exception_WARNING", getComponentName());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.