Package org.apache.uima.util

Examples of org.apache.uima.util.ProcessTrace


   */
  public void runSingleThreaded() throws Exception {
    Object entity = null;
    isRunning = true;
    bootstrapCPE();
    ProcessTrace pTrTemp = getProcessTrace();
    boolean success = true;
    long entityCount = 0;
    // long start = System.currentTimeMillis();
    long aggTime = 0;
    long ppTime = 0;
    long ccTime = 0;
    long crTime = 0;

    for (int j = 0; j < statusCbL.size(); j++) {
      BaseStatusCallbackListener statCL = (BaseStatusCallbackListener) statusCbL.get(j);
      if (statCL != null)
        statCL.initializationComplete();
    }

    while (isRunning) {
      try {
        // Check if processed all entities as defined in the Cpe Descriptor.
        if (endOfProcessingReached(entityCount)) {
          break;
        }
        waitForCpmToResumeIfPaused(); // blocks if CPM is paused
        // check again the state of the cpm after pause
        if (!isRunning)
          break;
        readerState = 1000;
        if (!collectionReader.hasNext())
          break;
        long st0 = System.currentTimeMillis();
        entity = getCasWithSOFA(entity, pTrTemp);
        crTime += (System.currentTimeMillis() - st0);

        if (entity == null) {
          success = false;
          continue;
        }

        if (entity instanceof CAS[] && skipDroppedDocument((Object[]) entity)) {
          notifyListeners(CAS_PROCESSED_MSG, (Object[]) entity, pTrTemp, new SkipCasException(
                  "Skipping Document Due To Dropped Cas in a Sequence"));
          releaseCASes((CAS[]) entity);
          continue;
        } else {
          // Clear the cache of bad documents
          if (skippedDocs.size() > 0) {
            skippedDocs.clear();
          }
        }
        long st1 = System.currentTimeMillis();

        // If CAS has been dropped due to an exception dont call CasConsumer
        success = nonThreadedProcessingUnit.analyze((Object[]) entity, pTrTemp);
        ppTime += (System.currentTimeMillis() - st1);
        if (success) {
          long st2 = System.currentTimeMillis();
          nonThreadedCasConsumerProcessingUnit.analyze((Object[]) entity, pTrTemp);

          ccTime += (System.currentTimeMillis() - st2);
        }

      } catch (Throwable t) {
        // may change the state of the isRunning on fatal exception
        handleException(t, (Object[]) entity, pTrTemp);
        success = false;
      } finally {
        entityCount++;
        // After sucessfull analysis notify listeners. If there was an exception, it has
        // already been reported
        if (success) {
          readerState = 2007;
          if (entity == null) {
            notifyListeners(CAS_PROCESSED_MSG, null, pTrTemp);
          } else {
            notifyListeners(CAS_PROCESSED_MSG, (Object[]) entity, pTrTemp);
          }
        }
        if (entity != null && entity instanceof CAS[]) {
          releaseCASes((CAS[]) entity);
          entity = null;
        }

        // Update processing trace counts and timers
        synchronized (procTr) {
          long st = System.currentTimeMillis();
          procTr.aggregate(pTrTemp);
          pTrTemp.clear();
          aggTime += (System.currentTimeMillis() - st);
        }
      }
    } // while
    tearDownCPE();
View Full Code Here


      }
    }
  } 
 
  private ProcessTrace getProcessTrace() throws Exception {
    ProcessTrace pT = null;
    UimaTimer uTimer = getTimer();
    if (uTimer != null) {
      if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
        UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_use_custom_timer__FINEST",
View Full Code Here

   */
  protected void handleCollectionProcessCompleteReply(Message message) throws Exception {
    int payload = ((Integer) message.getIntProperty(AsynchAEMessage.Payload)).intValue();
    try {
      if (AsynchAEMessage.Exception == payload) {
        ProcessTrace pt = new ProcessTrace_impl();
        UimaASProcessStatusImpl status = new UimaASProcessStatusImpl(pt);
        Exception exception = retrieveExceptionFromMessage(message);

        status.addEventStatus("CpC", "Failed", exception);
        notifyListeners(null, status, AsynchAEMessage.CollectionProcessComplete);
View Full Code Here

                }
                sendCAS(cachedRequest.getCAS(), cachedRequest);
              }
        }
      } else {
        ProcessTrace pt = new ProcessTrace_impl();
        UimaASProcessStatusImpl status = new UimaASProcessStatusImpl(pt);
        notifyListeners(null, status, AsynchAEMessage.GetMeta);
      }
      // Handled Ping reply
      return;
    }
    int payload = ((Integer) message.getIntProperty(AsynchAEMessage.Payload)).intValue();
    removeFromCache(uniqueIdentifier);

    try {
      if (AsynchAEMessage.Exception == payload) {
        ProcessTrace pt = new ProcessTrace_impl();
        UimaASProcessStatusImpl status = new UimaASProcessStatusImpl(pt);
        Exception exception = retrieveExceptionFromMessage(message);
        clientSideJmxStats.incrementMetaErrorCount();
        status.addEventStatus("GetMeta", "Failed", exception);
        notifyListeners(null, status, AsynchAEMessage.GetMeta);
View Full Code Here

    }
    return false;
  }
  protected void handleNonProcessException(Exception exception )
  throws Exception {
    ProcessTrace pt = new ProcessTrace_impl();
    UimaASProcessStatusImpl status = new UimaASProcessStatusImpl(pt);
    clientSideJmxStats.incrementMetaErrorCount();
    status.addEventStatus("GetMeta", "Failed", exception);
    notifyListeners(null, status, AsynchAEMessage.GetMeta);
  }
View Full Code Here

                getBrokerURI(),
                casReferenceId, exception });
    }
    try {
      if (doNotify) {
        ProcessTrace pt = new ProcessTrace_impl();

        // HACK! Service should only send exceptions for CASes that we sent.
        // Check if this or its input parent is known.
        if (inputCasReferenceId != null) {
          serviceDelegate.removeCasFromOutstandingList(inputCasReferenceId);
View Full Code Here

    }
  }

  protected void notifyOnTimout(CAS aCAS, String anEndpoint, int aTimeoutKind, String casReferenceId) {

    ProcessTrace pt = new ProcessTrace_impl();
    UimaASProcessStatusImpl status = new UimaASProcessStatusImpl(pt, aCAS, casReferenceId);

    switch (aTimeoutKind) {
      case (MetadataTimeout):
        if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
View Full Code Here

   * Returns a {@link ProcessTrace} instance used by this component
   *
   * @return - ProcessTrace instance
   */
  private ProcessTrace getProcessTrace() {
    ProcessTrace pT = null;

    if (timer != null) {
      if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
        UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_use_custom_timer__FINEST",
View Full Code Here

            casCache = ((WorkUnit) entity).getCas();
          }
        } else {
          artifact = (Object[]) entity;
        }
        ProcessTrace pT = getProcessTrace();

        Object[] cases = artifact;

        // Check if the artifact is actually an EOFToken. If so, this is
        // marker that indicates end of processing. The assumption is that
View Full Code Here

              "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_dequeued_artifact__FINEST",
              new Object[] { Thread.currentThread().getName(), workQueue.getName() });
    }
    if (artifact != null) {
      try {
        ProcessTrace pT = new ProcessTrace_impl(cpm.getPerformanceTuningSettings());
        if (artifact instanceof Object[]) {
          Object[] oList = (Object[]) artifact;
          // Only consume CASs
          if (oList[0] != null && !(oList[0] instanceof EOFToken)) {
            if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
View Full Code Here

TOP

Related Classes of org.apache.uima.util.ProcessTrace

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.