Package org.apache.uima.collection.impl

Examples of org.apache.uima.collection.impl.EntityProcessStatusImpl$EventLog


  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) {
            eps.addEventStatus("Process", "Failed", t);
          }
          ((StatusCallbackListener) statCL).entityProcessComplete(null, eps);
        } else {
          for (int i = 0; i < entity.length; i++) {
            if (t != null) {
              eps.addEventStatus("Process", "Failed", t);
            }
            if (entity[i] != null && entity[i] instanceof CAS) {
              callEntityProcessCompleteWithCAS((StatusCallbackListener)statCL, (CAS)entity[i], eps);
//              ((StatusCallbackListener) statCL).entityProcessComplete((CAS) entity[i], eps);
            } else {
View Full Code Here


   */
  private void notifyListeners(CAS aCas, Exception anException) {
    for (int i = 0; callbackListeners != null && i < callbackListeners.size(); i++) {
      StatusCallbackListener statCL = (StatusCallbackListener) callbackListeners.get(i);
      ProcessTrace prTrace = new ProcessTrace_impl(cpm.getPerformanceTuningSettings());
      EntityProcessStatusImpl aEntityProcStatus = new EntityProcessStatusImpl(prTrace);
      aEntityProcStatus.addEventStatus("Collection Reader Failure", "failed", anException);
      // Notify the listener that the Cas has been processed
      CPMEngine.callEntityProcessCompleteWithCAS(statCL, aCas, aEntityProcStatus);
//      statCL.entityProcessComplete(aCas, aEntityProcStatus);
    }
  }
View Full Code Here

          if (((WorkUnit) entity).isTimedOut() && artifact instanceof CAS[]) {

            for (int i = 0; i < artifact.length && artifact[i] != null; i++) {
              ChunkMetadata meta = CPMUtils.getChunkMetadata((CAS) artifact[i]);
              if (meta != null) {
                EntityProcessStatusImpl enProcSt = new EntityProcessStatusImpl(
                        processingUnitProcessTrace);
                enProcSt.addEventStatus("Process", "Failed", new SkipCasException(
                        "Dropping CAS due chunk Timeout. Doc Id::" + meta.getDocId() + " Sequence:"
                                + meta.getSequence()));
                doNotifyListeners(artifact[i], true, enProcSt);
              } else {
                EntityProcessStatusImpl enProcSt = new EntityProcessStatusImpl(
                        processingUnitProcessTrace);
                enProcSt.addEventStatus("Process", "Failed", new SkipCasException(
                        "Dropping CAS due chunk Timeout. Chunk Metadata is not available."));
                doNotifyListeners(artifact[i], true, enProcSt);
              }
              releaseTimedOutCases(artifact);
            }
View Full Code Here

          // Release the CAS and notify listeners if the end of the
          // pipeline is reached.
          if ((releaseCAS) && (i == (processContainers.size() - 1))) {
            // This flag is used to prevent multiple notifications
            doneAlready = true;
            EntityProcessStatus aEntityProcStatus = new EntityProcessStatusImpl(pTrTemp);
            if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {

              UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST,
                      this.getClass().getName(), "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_notify_listeners__FINEST",
                      new Object[] { Thread.currentThread().getName() });
            }
            threadState = 2007;

            notifyListeners(aCasObjectList, isCasObject, aEntityProcStatus);
            if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
              UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST,
                      this.getClass().getName(), "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_done_notify_listeners__FINEST",
                      new Object[] { Thread.currentThread().getName() });

              UIMAFramework.getLogger(this.getClass()).logrb(
                      Level.FINEST,
                      this.getClass().getName(),
                      "process",
                      CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_releasing_cases__FINEST",
                      new Object[] { Thread.currentThread().getName(), container.getName(),
                          String.valueOf(releaseCAS), String.valueOf(true) });
            }
            if (casCache != null) {
              clearCasCache();
            }
            // Release CAS's.
            if (aCasObjectList instanceof CAS[]) {
              cpm.releaseCASes((CAS[]) aCasObjectList);
            }

            if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
              UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST,
                      this.getClass().getName(), "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_done_releasing_cases__FINEST",
                      new Object[] { Thread.currentThread().getName(), container.getName() });
            }
          }

          if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {

            UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                    "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                    "UIMA_CPM_pipeline_completed__FINEST",
                    new Object[] { Thread.currentThread().getName() });
          }
          retry = false;
          // On successfull processing reset the restart counter. Restart counter determines how
          // many times to restart Cas Processor on the same CAS
          // Do this conditionally. If the CAS is to be dropped on Exception this restart counter
          // scope extends to the entire collection not just one CAS
          if (!cpm.dropCasOnException()) {
            container.resetRestartCount();
          }
        } catch (Exception e) {
          e.printStackTrace();
          if (UIMAFramework.getLogger().isLoggable(Level.SEVERE)) {

            UIMAFramework.getLogger(this.getClass()).logrb(
                    Level.SEVERE,
                    this.getClass().getName(),
                    "process",
                    CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                    "UIMA_CPM_pipeline_exception__SEVERE",
                    new Object[] { Thread.currentThread().getName(), container.getName(),
                        e.getMessage() });

            UIMAFramework.getLogger(this.getClass()).log(Level.SEVERE,
                    Thread.currentThread().getName(), e);

            UIMAFramework.getLogger(this.getClass()).logrb(
                    Level.FINEST,
                    this.getClass().getName(),
                    "process",
                    CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                    "UIMA_CPM_pipeline_exception__FINEST",
                    new Object[] { Thread.currentThread().getName(), container.getName(),
                        String.valueOf(container.isPaused()) });
          }

          EntityProcessStatusImpl enProcSt = new EntityProcessStatusImpl(pTrTemp);
          enProcSt.addEventStatus("Process", "Failed", e);
          threadState = 2008;

          notifyListeners(aCasObjectList, isCasObject, enProcSt);
          doneAlready = true;
          threadState = 2009;
View Full Code Here

                  "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_notify_listeners__FINEST",
                  new Object[] { Thread.currentThread().getName() });
        }
        threadState = 2013;
        // Notif Listeners
        EntityProcessStatus aEntityProcStatus = new EntityProcessStatusImpl(aProcessTr);
        notifyListeners(aCasObjectList, isCasObject, aEntityProcStatus);
        threadState = 2014;
        if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
          UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                  "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
View Full Code Here

              "UIMA_CPM_handle_exception__SEVERE",
              new Object[] { Thread.currentThread().getName(), containerName,
                  aProcessor.getClass().getName(), e.getMessage() });
    }

    EntityProcessStatusImpl enProcSt = new EntityProcessStatusImpl(aProcessTrace);
    enProcSt.addEventStatus("Process", "Failed", e);
    threadState = 2008;
    // Send exception notifications to all registered listeners
    notifyListeners(aCasObjectList, isCasObject, enProcSt);
    threadState = 2009;
View Full Code Here

    public void open() {
        for (int i = 0; i < eventLogs.length; i++) {
            try {
                if (eventLogs[i] == null) {
                    eventLogs[i] = new EventLog();
                    eventLogs[i].open(logNames[i]);

                    // note, the first processed event will be the next one generated, this one
                    // was generated in the past, prior to this call to open().
                    lastCollectedEventId[i] = eventLogs[i].getNewestRecord();
View Full Code Here

import org.hyperic.sigar.win32.Win32Exception;

public class EventLogTail {

    private static void tail(String name, Tail tail) throws Win32Exception {
        EventLog log = new EventLog();
        log.open(name);
        int max = log.getNumberOfRecords();
        if (tail.number < max) {
            max = tail.number;
        }
        int last = log.getNewestRecord()+1;
        int first = last - max;

        for (int i=first; i<last; i++) {
            EventLogRecord record = log.read(i);
            System.out.println(record);
        }
        log.close();
    }
View Full Code Here

    public TestEventLog(String name) {
        super(name);
    }

    public void testOpenClose() throws Exception {
        EventLog log = new EventLog();

        // Try to close an event log that isn't open
        try {
            log.close();
            fail("Closing an unopened event log succeeded");
        } catch (Win32Exception e) {
            // OK
        }

        log.open(EventLog.APPLICATION);
        log.close();

        // Try to reopen using the System log
        log.open(EventLog.SYSTEM);
        log.close();
    }
View Full Code Here

        log.close();
    }

    public void testGetNumberOfRecords() throws Exception {
        int numRecords;
        EventLog log = new EventLog();

        log.open(EventLog.APPLICATION);
        try {
            numRecords = log.getNumberOfRecords();
        } catch (Exception e) {
            fail("Unable to get the number of records");
        }

        log.close();
    }
View Full Code Here

TOP

Related Classes of org.apache.uima.collection.impl.EntityProcessStatusImpl$EventLog

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.