Examples of BaseStatusCallbackListener


Examples of org.apache.uima.collection.base_cpm.BaseStatusCallbackListener

          EntityProcessStatus aEntityProcStatus) {
    // Notify Listener that the entity has been processed
    Object casObjectCopy = aCas;
    // Notify ALL listeners
    for (int j = 0; j < statusCbL.size(); j++) {
      BaseStatusCallbackListener statCL = (BaseStatusCallbackListener) statusCbL.get(j);
      // Based on type of listener do appropriate conversions of Cas if necessary
      if (statCL instanceof CasDataStatusCallbackListener) {
        // The Cas is of type CAS, need to convert it to CasData
        if (isCasObject == true) {
          // Convert CAS to CasData object
View Full Code Here

Examples of org.apache.uima.collection.base_cpm.BaseStatusCallbackListener

    // e is the actual exception.
    enProcSt.addEventStatus("CPM", "Failed", e);

    // Notify all listeners that the CPM has finished processing
    for (int j = 0; statusCbL != null && j < statusCbL.size(); j++) {
      BaseStatusCallbackListener st = (BaseStatusCallbackListener) statusCbL.get(j);
      if (st instanceof StatusCallbackListener) {
        ((StatusCallbackListener) st).entityProcessComplete(null, enProcSt);
      }
    }
View Full Code Here

Examples of org.apache.uima.collection.base_cpm.BaseStatusCallbackListener

      // collect stats in shared instance
      producer.setCPMStatTable(stats);

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

      // Just in case check if the CPM has the right state to start
      if (isKilled()) {
        return;
      }

      // Nov 2005, postpone starting the Producer Thread until all other threads are up.
      // This prevents a problem when the Producer Thread starts, grabs all CASes, fills the
      // input queue and there is an exception BEFORE Processing Units starts. This may lead
      // to a hang, because the CR is waiting on the CAS Pool and no-one consumes the Input Queue.
      // Name the thread
      producer.setName("[CollectionReader Thread]::");

      // Create Cas Consumer Thread
      if (consumerList != null && consumerList.size() > 0) {
        // Create a CasConsumer Processing Unit if there is at least one CasConsumer configured in a
        // CPE descriptor
        casConsumerPU = new ProcessingUnit(this, outputQueue, null);

        casConsumerPU.setProcessingUnitProcessTrace(procTr);
        casConsumerPU.setContainers(consumerList);
        casConsumerPU.setCasPool(casPool);
        casConsumerPU.setReleaseCASFlag(true);
        casConsumerPU.setCasConsumerPipelineIdentity();
        // Add Callback Listeners
        for (int j = 0; j < statusCbL.size(); j++) {
          BaseStatusCallbackListener statCL = (BaseStatusCallbackListener) statusCbL.get(j);
          if (statCL != null) {
            casConsumerPU.addStatusCallbackListener(statCL);
          }
        }
        // Notify Callback Listeners when done processing entity
        casConsumerPU.setNotifyListeners(true);
        // Add custom timer
        try {
          casConsumerPU.setUimaTimer(getTimer());
        } catch (Exception e) {
          // Use default Timer
          casConsumerPU.setUimaTimer(new JavaTimer());
        }
        // name the thread
        casConsumerPU.setName("[CasConsumer Pipeline Thread]::");
        // start the CasConsumer Thread
        casConsumerPU.start();
        consumerThreadStarted = true;
      }
      if (UIMAFramework.getLogger().isLoggable(Level.CONFIG)) {
        UIMAFramework.getLogger(this.getClass()).logrb(
                Level.CONFIG,
                this.getClass().getName(),
                "initialize",
                CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                "UIMA_CPM_create_pus__CONFIG",
                new Object[] { Thread.currentThread().getName(),
                    String.valueOf(workQueue.getCurrentSize()) });
      }

      // Adjust number of pipelines. Adjustment may be necessary in deployments using exclusive
      // service access. The adjustment is
      // based on number of available services that the CPM will connect to. If a static
      // configuration calls for 5 processing
      // pipelines but only three services are available (assuming exclusive access ), the CPM will
      // reduce number of processing
      // pipelines to 3.
      for (int indx = 0; indx < annotatorList.size(); indx++) {
        ProcessingContainer prContainer = (ProcessingContainer) annotatorList.get(indx);
        CasProcessorConfiguration configuration = prContainer.getCasProcessorConfiguration();

        if (configuration == null) {
          UIMAFramework.getLogger(this.getClass()).logrb(Level.SEVERE, this.getClass().getName(),
                  "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_cp_configuration_not_defined__SEVERE",
                  new Object[] { Thread.currentThread().getName(), prContainer.getName() });
          return;
        }
        String serviceAccess = configuration.getDeploymentParameter("service-access");
        if (serviceAccess != null && serviceAccess.equalsIgnoreCase("exclusive")) {
          if (prContainer.getPool() != null) {
            int totalInstanceCount = prContainer.getPool().getSize();

            if (totalInstanceCount == 0) {
              UIMAFramework.getLogger(this.getClass()).logrb(Level.SEVERE,
                      this.getClass().getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_no_proxies__SEVERE",
                      new Object[] { Thread.currentThread().getName(), prContainer.getName() });
              return;
            }
            if (totalInstanceCount < concurrentThreadCount) {
              concurrentThreadCount = totalInstanceCount; // override
              UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG,
                      this.getClass().getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_reduce_pipelines__CONFIG",
                      new Object[] { Thread.currentThread().getName(), prContainer.getName() });
            }
          }
        }
      }

      // Setup Processing Pipelines
      processingUnits = new ProcessingUnit[concurrentThreadCount];
      synchronized (this) {
        activeProcessingUnits = concurrentThreadCount; // keeps track of how many threads are still
        // active. -Adam
      }

      // Capture the state of the pipelines. Initially the state is -1, meaning Not Started
      processingThreadsState = new int[concurrentThreadCount];
      for (int inx = 0; inx < concurrentThreadCount; inx++) {
        processingThreadsState[inx] = -1; // Not Started
      }

      // Configure Processing Pipelines, and start each running in a seperate thread
      for (int i = 0; i < concurrentThreadCount; i++) {
        // casList = new CAS[readerFetchSize];
        if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
          UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                  "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_initialize_pipeline__FINEST",
                  new Object[] { Thread.currentThread().getName(), String.valueOf(i) });
        }
        // Plug in custom ProcessingUnit via -DPROCESSING_PIPELINE_IMPL=class
        // Initialize Processing Pipeline with input and output queues
        if (System.getProperty("PROCESSING_PIPELINE_IMPL") != null) {
          String puClass = System.getProperty("PROCESSING_PIPELINE_IMPL");
          try {
            processingUnits[i] = producePU(puClass);
            processingUnits[i].setInputQueue(workQueue);
            processingUnits[i].setOutputQueue(outputQueue);
            processingUnits[i].setCPMEngine(this);
          } catch (Exception e) {
            UIMAFramework.getLogger(this.getClass()).log(Level.SEVERE, e.getMessage(), e);
            if (dbgCtrlThread != null) {
              dbgCtrlThread.stop();
            }
            return; // / DONE HERE !!!
          }
        } else {
          processingUnits[i] = new ProcessingUnit(this, workQueue, outputQueue);
        }
        // If there are no consumers in the pipeline, instruct the pipeline to release a CAS at the
        // end of processing
        if (consumerList == null || consumerList.size() == 0) {
          processingUnits[i].setReleaseCASFlag(true);
        }

        if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
          UIMAFramework.getLogger(this.getClass()).logrb(
                  Level.FINEST,
                  this.getClass().getName(),
                  "initialize",
                  CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_pipeline_impl_class__FINEST",
                  new Object[] { Thread.currentThread().getName(),
                      processingUnits[i].getClass().getName() });
        }
        // Add tracing instance so that performance and stats are globally aggregated for all
        // processing pipelines
        processingUnits[i].setProcessingUnitProcessTrace(procTr);
        // Add all annotators to the processing pipeline
        processingUnits[i].setContainers(annotatorList);
        // pass initialized list of cases to processing units in case cas conversion is required
        // between
        // CasData and CASObject based annotators.
        processingUnits[i].setCasPool(casPool);
        try {
          processingUnits[i].setUimaTimer(getTimer());
        } catch (Exception e) {
          processingUnits[i].setUimaTimer(new JavaTimer());
        }
        // Add Callback Listeners
        for (int j = 0; j < statusCbL.size(); j++) {
          BaseStatusCallbackListener statCL = (BaseStatusCallbackListener) statusCbL.get(j);
          if (statCL != null)
            processingUnits[i].addStatusCallbackListener(statCL);
        }

        // Start the Processing Unit thread
View Full Code Here

Examples of org.apache.uima.collection.base_cpm.BaseStatusCallbackListener

    }

    nonThreadedProcessingUnit.setContainers(annotatorList);
    nonThreadedProcessingUnit.setCasPool(casPool);
    for (int j = 0; j < statusCbL.size(); j++) {
      BaseStatusCallbackListener statCL = (BaseStatusCallbackListener) statusCbL.get(j);
      if (statCL != null)
        nonThreadedProcessingUnit.addStatusCallbackListener(statCL);
    }
  }
View Full Code Here

Examples of org.apache.uima.collection.base_cpm.BaseStatusCallbackListener

      nonThreadedCasConsumerProcessingUnit.setCasPool(casPool);
      nonThreadedCasConsumerProcessingUnit.setReleaseCASFlag(false);

      // Add Callback Listeners
      for (int j = 0; j < statusCbL.size(); j++) {
        BaseStatusCallbackListener statCL = (BaseStatusCallbackListener) statusCbL.get(j);
        if (statCL != null)
          nonThreadedCasConsumerProcessingUnit.addStatusCallbackListener(statCL);
      }
      // Notify Callback Listeners when done processing entity
      nonThreadedCasConsumerProcessingUnit.setNotifyListeners(false);
View Full Code Here

Examples of org.apache.uima.collection.base_cpm.BaseStatusCallbackListener

    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.
View Full Code Here

Examples of org.apache.uima.collection.base_cpm.BaseStatusCallbackListener

  }

  private void notifyListeners(int aMsgType, Object[] entity, ProcessTrace aPTrace, Throwable t) {
    // Add Callback Listeners
    for (int j = 0; j < statusCbL.size(); j++) {
      BaseStatusCallbackListener statCL = (BaseStatusCallbackListener) statusCbL.get(j);
      if (statCL != null) {
        EntityProcessStatusImpl eps = new EntityProcessStatusImpl(aPTrace);
        // eps = new EntityProcessStatusImpl(aPTrace);
        if (entity == null) {
          if (t != null) {
View Full Code Here

Examples of org.apache.uima.collection.base_cpm.BaseStatusCallbackListener

          EntityProcessStatus aEntityProcStatus) {
    // Notify Listener that the entity has been processed
    Object casObjectCopy = aCas;
    // Notify ALL listeners
    for (int j = 0; j < statusCbL.size(); j++) {
      BaseStatusCallbackListener statCL = (BaseStatusCallbackListener) statusCbL.get(j);
      // Based on type of listener do appropriate conversions of Cas if necessary
      if (statCL instanceof CasDataStatusCallbackListener) {
        // The Cas is of type CAS, need to convert it to CasData
        if (isCasObject == true) {
          // Convert CAS to CasData object
View Full Code Here

Examples of org.apache.uima.collection.base_cpm.BaseStatusCallbackListener

      // e is the actual exception.
      enProcSt.addEventStatus("CPM", "Failed", e);

      // Notify all listeners that the CPM has finished processing
      for (int j = 0; j < statusCbL.size(); j++) {
        BaseStatusCallbackListener st = (BaseStatusCallbackListener) statusCbL.get(j);
        if (st instanceof StatusCallbackListener) {
          ((StatusCallbackListener) st).entityProcessComplete(null, enProcSt);
        }
      }
    }

    if (cpEngine.isKilled()) {
      killed = true;
    }

    if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
      UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
              "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_cpm_stopped__FINEST",
              new Object[] { Thread.currentThread().getName(), String.valueOf(killed) });
    }
    ArrayList statusCbL = cpEngine.getCallbackListeners();
    // Notify all listeners that the CPM has finished processing
    for (int j = 0; j < statusCbL.size(); j++) {
      BaseStatusCallbackListener st = (BaseStatusCallbackListener) statusCbL.get(j);
      if (!killed) {
        st.collectionProcessComplete();
      } else {
        st.aborted();
      }
    }
  }
View Full Code Here

Examples of org.apache.uima.collection.base_cpm.BaseStatusCallbackListener

          EntityProcessStatus aEntityProcStatus) {
    // Notify Listener that the entity has been processed
    Object casObjectCopy = aCas;
    // Notify ALL listeners
    for (int j = 0; j < statusCbL.size(); j++) {
      BaseStatusCallbackListener statCL = (BaseStatusCallbackListener) statusCbL.get(j);
      // Based on type of listener do appropriate conversions of Cas if necessary
      if (statCL instanceof CasDataStatusCallbackListener) {
        // The Cas is of type CAS, need to convert it to CasData
        if (isCasObject == true) {
          // Convert CAS to CasData object
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.