Package org.apache.uima.util

Examples of org.apache.uima.util.ProcessTrace


   * Construct a ProcessTrace object that represents the last execution of this AnalysisEngine. This
   * is used so that we can return a ProcessTrace object from each process() call for backwards
   * compatibility with version 1.x.
   */
  protected ProcessTrace buildProcessTraceFromMBeanStats() {
    ProcessTrace trace = new ProcessTrace_impl(getPerformanceTuningSettings());
    buildProcessTraceFromMBeanStats(trace);
    return trace;
  }
View Full Code Here


      // now add subevents for each component
      Iterator<AnalysisEngine> aeIter = _getASB().getComponentAnalysisEngines().values().iterator();
      while (aeIter.hasNext()) {
        AnalysisEngine ae = aeIter.next();
        if (ae instanceof AnalysisEngineImplBase) {
          ProcessTrace subPT = ((AnalysisEngineImplBase) ae).buildProcessTraceFromMBeanStats();
          if (subPT.getEvents().size() > 0) {
            procEvt.addSubEvent((ProcessTraceEvent) subPT.getEvents().get(0));
          }
        }
      }
      // and also FlowController
      FlowControllerContainer fcc = ((ASB_impl) _getASB()).getFlowControllerContainer();
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)) {
        logFinest("UIMA_CPM_use_custom_timer__FINEST", timer.getClass().getName());
      }
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

    // Dequeue first bundle
    artifact = workQueue.dequeue();
    maybeLogFinest("UIMA_CPM_dequeued_artifact__FINEST", 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)) {
            maybeLogFinest("UIMA_CPM_call_processNext__FINEST");
View Full Code Here

       
        if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
          logFinest("UIMA_CPM_container_status__FINEST",
              container.getName(), String.valueOf(container.getStatus()));
        }
        ProcessTrace pTrTemp = new ProcessTrace_impl(cpm.getPerformanceTuningSettings());
        pTrTemp.startEvent(container.getName(), "End of Batch", "");
        try {
          CasProcessorDeployer deployer = container.getDeployer();

          if (deployer != null) {
            if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
              logFinest("UIMA_CPM_undeploy_cp_instances__FINEST", container.getName(), deployer.getClass().getName());
            }
            deployer.undeploy();
          }
          container.destroy();
        } catch (Exception e) {

          logWarning("UIMA_CPM_exception_during_cp_stop__WARNING", container.getName(), e.getMessage());
        } finally {
          pTrTemp.endEvent(container.getName(), "End of Batch", "");
          if (processingUnitProcessTrace != null) {
            this.processingUnitProcessTrace.aggregate(pTrTemp);
          }
        }
      }
View Full Code Here

   */
  private void restoreFromCheckpoint(String component, String aEvType) {
    if (checkpointData == null) {
      return; // nothing to restore
    }
    ProcessTrace restoredProcTr = checkpointData.getProcessTrace();
    try {
      // Retrieve all events associated with a named component
      List eList = restoredProcTr.getEventsByComponentName(component, true);
      if (!eList.isEmpty()) {
        // Copy named events found in checkpoint to the current procTr
        copyComponentEvents(aEvType, eList, procTr);
        eList.clear();
      }
View Full Code Here

   */
  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

        ((CASImpl)cas).restoreClassLoaderUnlockCas();
    }
  } 
 
  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

   *
   * @return the results of analysis
   */
  public ServiceDataCargo process(ServiceDataCargo aData, ResultSpecification aResultSpec)
          throws ResourceServiceException {
    ProcessTrace trace = aData.getProcessTrace();
    if (trace == null) {
      trace = new ProcessTrace_impl();
    }

    String resourceName = getMetaData().getName();
    trace.startEvent(resourceName, ProcessTraceEvent.SERVICE, "");

    CAS cas = null;
    String resultMessage = "success";
    try {
      // get CAS instance from pool
      cas = getCasFromPool(mTimeout);

      if (cas == null) {
        throw new ResourceServiceException(ResourceServiceException.RESOURCE_UNAVAILABLE,
                new Object[0]);
      }

      // deserialize CAS data into this CAS instance
      aData.unmarshalCas(cas, true);

      // run the AnalysisEngine's process method
      getAnalysisEngine().process(cas, aResultSpec, trace);

      // return results
      return new ServiceDataCargo(cas, trace);
    } catch (Exception e) {
      resultMessage = e.getLocalizedMessage();
      if (e instanceof ResourceServiceException) {
        throw (ResourceServiceException) e;
      } else {
        throw new ResourceServiceException(e);
      }
    } finally {
      // release CAS
      if (cas != null) {
        getCasPool().releaseCas(cas);
      }
      trace.endEvent(resourceName, ProcessTraceEvent.SERVICE, resultMessage);
    }
  }
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.