Package org.apache.uima.aae.InProcessCache

Examples of org.apache.uima.aae.InProcessCache.CacheEntry


        }
        OutOfTypeSystemData otsd = getInProcessCache().getOutOfTypeSystemData(aCasReferenceId);
        MessageContext mContext = getInProcessCache().getMessageAccessorByReference(aCasReferenceId);
        sequence++;
        newCasReferenceId = getInProcessCache().register( casProduced, mContext, otsd);
        CacheEntry newEntry = getInProcessCache().getCacheEntryForCAS(newCasReferenceId);
/*
        if ( parentCasReferenceId == null )
        {
          newEntry.setInputCasReferenceId(aCasReferenceId);
        }
        else
        {
          newEntry.setInputCasReferenceId(parentCasReferenceId);
        }
*/
        newEntry.setInputCasReferenceId(aCasReferenceId);
        //  Add to the cache how long it took to process the generated (subordinate) CAS
        getCasStatistics(newCasReferenceId).incrementAnalysisTime(timeToProcessCAS);
        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, getClass().getName(), "process", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_produced_new_cas__FINE", new Object[] { Thread.currentThread().getName(),getComponentName(),newCasReferenceId, aCasReferenceId });
        synchronized(syncObject)
        {
View Full Code Here


  }

  private synchronized void cacheStats(String aCasReferenceId, long aTimeWaitingForCAS, long aTimeToDeserializeCAS )
  throws Exception
  {
    CacheEntry entry = getController().getInProcessCache().getCacheEntryForCAS(aCasReferenceId);
    entry.incrementTimeWaitingForCAS( aTimeWaitingForCAS);
    entry.incrementTimeToDeserializeCAS(aTimeToDeserializeCAS);
  }
View Full Code Here

        //  Set the flag to indicate that the CAS been generated by CM
        isNewCAS = true;
        //  Fetch the actual input CAS Reference Id from which the CAS being processed was generated from
        inputCasReferenceId = aMessageContext.getMessageStringProperty(AsynchAEMessage.InputCasReference);
        //  Fetch input CAS Cache entry
        CacheEntry inputCasCacheEntry = getController().
            getInProcessCache().
              getCacheEntryForCAS(inputCasReferenceId);
        //  This CAS came in from the CAS Multiplier. Treat it differently than the
        //  input CAS. First, in case the Aggregate needs to send this CAS to the
        //  client, retrieve the client destination by looking up the client endpoint
        //  using input CAS reference id. CASes generated by the CAS multiplier will have
        //  the same Cas Reference id.
        Endpoint replyToEndpoint = inputCasCacheEntry.getMessageOrigin();
        if ( getController() instanceof AggregateAnalysisEngineController )
        {
          newCASProducedBy = inputCasCacheEntry.getCasMultiplierKey();
          //  increment number of subordinate CASes that are currently being processed
          //  The input CAS (parent) will be held by the aggregate until all of its
          //  subordinate CASes are fully processed. Only then, the aggregate can return
          //  it back to the client
          synchronized( inputCasCacheEntry )
          {
            inputCasCacheEntry.incrementSubordinateCasInPlayCount();
          }
          if ( ((AggregateAnalysisEngineController)getController()).sendRequestToReleaseCas() )
          {
            try
            {
              //  Change the name of the queue where the request to free a CAS will be sent.
              aMessageContext.getEndpoint().setEndpoint(aMessageContext.getEndpoint().getEndpoint()+"CasSync");

              getController().getOutputChannel().sendRequest(AsynchAEMessage.ReleaseCAS, casReferenceId, aMessageContext.getEndpoint());
              requestToFreeCasSent = true;
            }
            catch( Exception e){}
          }
        }
        //  MessageContext contains endpoint set by the CAS Multiplier service. Overwrite
        //  this with the endpoint of the client who sent the input CAS. In case this
        //  aggregate is configured to send new CASes to the client we know where to send them.
        aMessageContext.getEndpoint().setEndpoint(replyToEndpoint.getEndpoint());
        aMessageContext.getEndpoint().setServerURI(replyToEndpoint.getServerURI());
        //  Set this to null so that the new CAS gets its own Cas Reference Id below
        casReferenceId = null;
      }
      else if ( getController().isTopLevelComponent())
      {
        Endpoint replyToEndpoint = aMessageContext.getEndpoint();

        if ( getController() instanceof AggregateAnalysisEngineController )
        {
          ((AggregateAnalysisEngineController)getController()).addMessageOrigin(casReferenceId, replyToEndpoint);
        }

      }
      //  To prevent processing multiple messages with the same CasReferenceId, check the CAS cache
      //  to see if the message with a given CasReferenceId is already being processed. It is, the
      //  message contains the same request possibly issued by the caller due to timeout. Also this
      //  mechanism helps with dealing with scenario when this service is not up when the client sends
      //  request. The client can keep re-sending the same request until its timeout thresholds are
      //  exceeded. By that time, there may be multiple messages in this service queue with the same
      //  CasReferenceId. When the service finally comes back up, it will have multiple messages in
      //  its queue possibly from the same client. Only the first message for any given CasReferenceId
      //  should be processed.
      if ( casReferenceId == null || !getController().getInProcessCache().entryExists(casReferenceId) )
      {
        String xmi = aMessageContext.getStringMessage();
       
        //  *****************************************************************
        // ***** NO XMI In Message. Kick this back to sender with exception
        //  *****************************************************************
        if ( xmi == null )
        {
          UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(),
                      "handleProcessRequestWithXMI", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_message_has_no_cargo__INFO",
                      new Object[] { aMessageContext.getEndpoint().getEndpoint() });
          getController().
            getOutputChannel().
              sendReply(new InvalidMessageException("No XMI data in message"), casReferenceId, aMessageContext.getEndpoint(),AsynchAEMessage.Process);
          //  Dont process this empty message
          return;
        }
       
        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINEST, CLASS_NAME.getName(),
                    "handleProcessRequestWithXMI", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_request_cas__FINEST",
                    new Object[] { aMessageContext.getEndpoint().getEndpoint() });
          long t1 = System.nanoTime();
          if ( isNewCAS )
          {
          cas = getController().getCasManagerWrapper().getNewCas(newCASProducedBy);
          }
          else
          {
            cas = getController().getCasManagerWrapper().getNewCas();
          }
        long timeWaitingForCAS = System.nanoTime() - t1;
 
        if ( getController().isStopped() )
        {
          //  The Controller is in shutdown state.
          getController().dropCAS(cas);
          return;
        }
        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
                    "handleProcessRequestWithXMI", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_request_cas_granted__FINE",
                    new Object[] { aMessageContext.getEndpoint().getEndpoint() });
          t1 = System.nanoTime();
        XmiSerializationSharedData deserSharedData = new XmiSerializationSharedData();
        UimaSerializer.deserializeCasFromXmi(xmi, cas, deserSharedData, true, -1);
       
        long timeToDeserializeCAS = System.nanoTime() - t1;
        LongNumericStatistic statistic;
        if ( (statistic = getController().getMonitor().getLongNumericStatistic("",Monitor.TotalDeserializeTime)) != null )
        {
          statistic.increment(timeToDeserializeCAS);
        }

        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
            "handleProcessRequestWithXMI", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_deserialize_cas_time_FINE",
            new Object[] { timeToDeserializeCAS / 1000 });
            ServicePerformance casStats = null;
       
       
        if (casReferenceId == null)
        {
          if (getController() instanceof PrimitiveAnalysisEngineController)
          {
            inputCasReferenceId = getController().getInProcessCache().register(cas, aMessageContext, deserSharedData);
          }
          else
          {
            casReferenceId = getController().getInProcessCache().register(cas, aMessageContext, deserSharedData);
            if ( inputCasReferenceId == null )
            {
              inputCasReferenceId = casReferenceId;
            }
          }
          casStats = getController().getCasStatistics(inputCasReferenceId);

        }
        else
        {
          getController().getInProcessCache().register(cas, aMessageContext, deserSharedData, casReferenceId);
/*
          if ( aMessageContext.propertyExists(AsynchAEMessage.InputCasReference))
          {
            CacheEntry cacheEntry = getController().getInProcessCache().getCacheEntryForCAS(casReferenceId);
            String parentCasId = aMessageContext.getMessageStringProperty(AsynchAEMessage.InputCasReference);
            cacheEntry.setInputCasReferenceId(parentCasId);
          }
*/         
          casStats = getController().getCasStatistics(casReferenceId);
        }
        casStats.incrementCasDeserializationTime(timeToDeserializeCAS);
        if ( getController().isTopLevelComponent() )
        {
          getController().getServicePerformance().incrementCasDeserializationTime(timeToDeserializeCAS);
        }
        //  Set a local flag to indicate that the CAS has been added to the cache. This will be usefull when handling an exception
        //  If an exception happens before the CAS is added to the cache, the CAS needs to be dropped immediately.
        casRegistered = true;
        if ( casReferenceId == null )
        {
          getController().saveTime(inTime, inputCasReferenceId,  getController().getName());
        }
        else
        {
          getController().saveTime(inTime, casReferenceId,  getController().getName());
        }
       
        CacheEntry entry = null;
        if ( getController() instanceof AggregateAnalysisEngineController )
        {
          entry = getController().getInProcessCache().getCacheEntryForCAS(casReferenceId);
          if ( isNewCAS )
          {
            if ( newCASProducedBy != null )
            {
              entry.setCasMultiplierKey(newCASProducedBy);
            }
            if ( remoteCasReferenceId != null )
            {
              entry.setRemoteCMCasReferenceId(remoteCasReferenceId);
            }
            if ( requestToFreeCasSent )
            {
              entry.setSendRequestToFreeCas(false);
            }
            //  associate this subordinate CAS with the parent CAS
            entry.setInputCasReferenceId(inputCasReferenceId);
            entry.setReplyReceived();
          }
          DelegateStats stats = new DelegateStats();
          if ( entry.getStat() == null )
          {
            entry.setStat(stats);
            //  Add entry for self (this aggregate). MessageContext.getEndpointName()
            //  returns the name of the queue receiving the message.
            stats.put(getController().getServiceEndpointName(), new TimerStats());
          }
          else
          {
            if (!stats.containsKey(getController().getServiceEndpointName()))
            {
              stats.put(getController().getServiceEndpointName(), new DelegateStats());
            }
          }
        }
       
        cacheStats( inputCasReferenceId, timeWaitingForCAS, timeToDeserializeCAS);
        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
                    "handleProcessRequestWithXMI", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_deserialized_cas_ready_to_process_FINE",
                    new Object[] { aMessageContext.getEndpoint().getEndpoint() });

       
        cacheProcessCommandInClientEndpoint();
       
        if ( getController().isStopped() )
        {
          if ( entry != null )
          {
            //  The Controller is in shutdown state.
            getController().dropCAS( entry.getCasReferenceId(), true);
            return;
          }
        }
        invokeProcess(cas, inputCasReferenceId, casReferenceId, aMessageContext, newCASProducedBy);
      }
View Full Code Here

            ((AggregateAnalysisEngineController)getController()).lookUpDelegateKey(casMultiplierEndpoint.getEndpoint());
          casMultiplierEndpoint.setIsCasMultiplier(true);
          ((AggregateAnalysisEngineController)getController()).
            getServicePerformance(newCASProducedBy).
              incrementNumberOfCASesProcessed();
          CacheEntry subordinateCasCacheEntry = getController().getInProcessCache().getCacheEntryForCAS(casReferenceId);
          subordinateCasCacheEntry.setReplyReceived();

          CacheEntry inputCasCacheEntry = getController().
            getInProcessCache().
              getCacheEntryForCAS(subordinateCasCacheEntry.getInputCasReferenceId());
          if ( inputCasCacheEntry != null )
          {
            synchronized( inputCasCacheEntry )
            {
//              System.out.println("++++++++ Incrementing Delegate:"+casReferenceId+" Count For Input Cas::"+subordinateCasCacheEntry.getInputCasReferenceId());           
              inputCasCacheEntry.incrementSubordinateCasInPlayCount();
            }
          }
        }
        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
                    "handleProcessRequestWithCASReference", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_new_cas__FINE",
View Full Code Here

    String delegateKey = "";
    try
    {
     
      delegateKey = ((AggregateAnalysisEngineController)getController()).lookUpDelegateKey(aMessageContext.getEndpoint().getEndpoint());
      CacheEntry entry = getController().getInProcessCache().getCacheEntryForCAS(aCasReferenceId);
      if ( entry == null )
      {
        throw new AsynchAEException("CasReferenceId:"+aCasReferenceId+" Not Found in the Cache.");
      }
      CacheEntry inputCasEntry = null;
      String inputCasReferenceId = entry.getInputCasReferenceId();
      ServicePerformance casStats =
        ((AggregateAnalysisEngineController)getController()).getCasStatistics(aCasReferenceId);
      if ( inputCasReferenceId != null &&
         getController().getInProcessCache().entryExists(inputCasReferenceId) )
      {
        String casProducerKey = entry.getCasProducerKey();
        if ( casProducerKey != null &&
          ((AggregateAnalysisEngineController)getController()).
            isDelegateKeyValid(casProducerKey) )
        {
          //  Get entry for the input CAS
          inputCasEntry = getController().
                getInProcessCache().
                  getCacheEntryForCAS(inputCasReferenceId);
        }
       
      }
      ServicePerformance delegateServicePerformance =
        ((AggregateAnalysisEngineController)getController()).getServicePerformance(delegateKey);

      if (aMessageContext.propertyExists(AsynchAEMessage.TimeToSerializeCAS))
      {
        long timeToSerializeCAS = ((Long) aMessageContext.getMessageLongProperty(AsynchAEMessage.TimeToSerializeCAS)).longValue();
        if ( timeToSerializeCAS > 0)
        {
          casStats.incrementCasSerializationTime(timeToSerializeCAS);
          if ( delegateServicePerformance != null )
          {
            delegateServicePerformance.
            incrementCasSerializationTime(timeToSerializeCAS);
          }
          getController().getServicePerformance().
            incrementCasSerializationTime(timeToSerializeCAS);
        }
      }
      if (aMessageContext.propertyExists(AsynchAEMessage.TimeToDeserializeCAS))
      {
        long timeToDeserializeCAS = ((Long) aMessageContext.getMessageLongProperty(AsynchAEMessage.TimeToDeserializeCAS)).longValue();
        if ( timeToDeserializeCAS > 0 )
        {
          casStats.incrementCasDeserializationTime(timeToDeserializeCAS);

          if ( delegateServicePerformance != null )
          {
            delegateServicePerformance.
              incrementCasDeserializationTime(timeToDeserializeCAS);
          }
          getController().getServicePerformance().
            incrementCasDeserializationTime(timeToDeserializeCAS);
        }
      }

      if (aMessageContext.propertyExists(AsynchAEMessage.IdleTime))
      {
        long idleTime = ((Long) aMessageContext.getMessageLongProperty(AsynchAEMessage.IdleTime)).longValue();
        if ( idleTime > 0 )
        {
          casStats.incrementIdleTime(idleTime);
          if ( delegateServicePerformance != null )
          {
            delegateServicePerformance.
              incrementIdleTime(idleTime);
          }
        }
      }
     
      if (aMessageContext.propertyExists(AsynchAEMessage.TimeWaitingForCAS))
      {
        long timeWaitingForCAS = ((Long) aMessageContext.getMessageLongProperty(AsynchAEMessage.TimeWaitingForCAS)).longValue();
        if ( aMessageContext.getEndpoint().isRemote())
        {
          entry.incrementTimeWaitingForCAS(timeWaitingForCAS);
          if ( inputCasEntry != null )
          {
            inputCasEntry.incrementTimeWaitingForCAS(timeWaitingForCAS);
          }
        }
      }
      if (aMessageContext.propertyExists(AsynchAEMessage.TimeInProcessCAS))
      {
View Full Code Here

      }
     
      String xmi = aMessageContext.getStringMessage();

      //  Fetch entry from the cache for a given Cas Id. The entry contains a CAS that will be used during deserialization
      CacheEntry cacheEntry = getController().getInProcessCache().getCacheEntryForCAS(casReferenceId);
      cacheEntry.setReplyReceived();
      cas = cacheEntry.getCas()
      int totalNumberOfParallelDelegatesProcessingCas = cacheEntry.getNumberOfParallelDelegates();
      UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
                  "handleProcessResponseWithXMI", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_number_parallel_delegates_FINE",
                  new Object[] { totalNumberOfParallelDelegatesProcessingCas});

      if (cas == null)
      {
        throw new AsynchAEException(Thread.currentThread().getName()+"-Cache Does not contain a CAS. Cas Reference Id::"+casReferenceId);
      }
      if ( UIMAFramework.getLogger().isLoggable(Level.FINEST) )
      {
        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINEST, CLASS_NAME.getName(),
                    "handleProcessResponseWithXMI", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_rcvd_reply_FINEST",
                    new Object[] { aMessageContext.getEndpoint().getEndpoint(), casReferenceId, xmi });
      }
     
      long t1 = System.nanoTime();
     
      synchronized (monitor)
      {
        XmiSerializationSharedData deserSharedData;
        if (totalNumberOfParallelDelegatesProcessingCas > 1 && cacheEntry.howManyDelegatesResponded() > 0)
        {
          // process secondary reply from a parallel step
          UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINEST, CLASS_NAME.getName(),
                      "handleProcessResponseWithXMI", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_delegate_responded_count_FINEST",
                      new Object[] { cacheEntry.howManyDelegatesResponded(), casReferenceId});
         
          int highWaterMark = cacheEntry.getHighWaterMark();
          UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINEST, CLASS_NAME.getName(),
                      "handleProcessResponseWithXMI", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_high_water_mark_FINEST",
                      new Object[] { highWaterMark, casReferenceId });

          deserSharedData = getController().getInProcessCache().getCacheEntryForCAS(casReferenceId).getDeserSharedData();
          UimaSerializer.deserializeCasFromXmi(xmi, cas, deserSharedData, true, highWaterMark);
        }
        else // general case, or first reply from a parallel step
        {
          //  Processing the reply from a standard, non-parallel delegate
          deserSharedData = getController().getInProcessCache().getCacheEntryForCAS(casReferenceId).getDeserSharedData();
          if (deserSharedData == null) {
            deserSharedData = new XmiSerializationSharedData();
            getController().getInProcessCache().getCacheEntryForCAS(casReferenceId).setXmiSerializationData(deserSharedData);
          }
          UimaSerializer.deserializeCasFromXmi(xmi, cas, deserSharedData, true, -1);
        }
      }

     
      if ( cacheEntry != null && totalNumberOfParallelDelegatesProcessingCas > 1 )
      {
        synchronized( cacheEntry )
        {
          cacheEntry.incrementHowManyDelegatesResponded();
        }
      }
   
      long timeToDeserializeCAS = System.nanoTime() - t1;

            getController().
              getServicePerformance().
                incrementCasDeserializationTime(timeToDeserializeCAS);

            ServicePerformance casStats =
              getController().getCasStatistics(casReferenceId);
      casStats.incrementCasDeserializationTime(timeToDeserializeCAS);
      LongNumericStatistic statistic;
      if ( (statistic = getController().getMonitor().getLongNumericStatistic("",Monitor.TotalDeserializeTime)) != null )
      {
        statistic.increment(timeToDeserializeCAS);
      }

      computeStats(aMessageContext, casReferenceId);

      cancelTimer(aMessageContext, casReferenceId, true);

      // Send CAS for processing when all delegates reply
      // totalNumberOfParallelDelegatesProcessingCas indicates how many delegates are processing CAS in parallel. Default is 1, meaning only
      // one delegate processes the CAS at the same. Otherwise, check if all delegates responded before passing CAS on to the Flow Controller.
      // The idea is that all delegates processing one CAS concurrently must respond, before the CAS is allowed to move on to the next step.
      // HowManyDelegatesResponded is incremented every time a parallel delegate sends response.
      if (totalNumberOfParallelDelegatesProcessingCas == 1 || ( cacheEntry.howManyDelegatesResponded() == totalNumberOfParallelDelegatesProcessingCas) )
      {
        cacheEntry.resetDelegateResponded();
        super.invokeProcess(cas, casReferenceId, null, aMessageContext, null);
      }

    }
    catch ( Exception e)
View Full Code Here

  }
  private void handleProcessResponseWithCASReference(MessageContext aMessageContext )
  {
    String casReferenceId = null;
    CacheEntry cacheEntry = null;

    try
    {
      casReferenceId = aMessageContext.getMessageStringProperty(AsynchAEMessage.CasReference);
      cacheEntry = getController().getInProcessCache().getCacheEntryForCAS(casReferenceId);
      cacheEntry.setReplyReceived();
      CAS cas = cacheEntry.getCas();
      String endpointName = aMessageContext.getEndpoint().getEndpoint();
      String delegateKey = ((AggregateAnalysisEngineController)getController()).
                  lookUpDelegateKey(endpointName);
      ServicePerformance delegateServicePerformance =
        ((AggregateAnalysisEngineController)getController()).
          getServicePerformance(delegateKey);
      if ( delegateServicePerformance != null )
      {
        delegateServicePerformance.incrementNumberOfCASesProcessed();
      }

      //CAS cas = getController().getInProcessCache().getCasByReference(casReferenceId);
      if (cas != null)
      {
        cancelTimerAndProcess(aMessageContext, casReferenceId, cas);
      }
      else
      {
        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(),
                    "handleProcessResponseWithCASReference", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_cas_not_in_cache__INFO",
                    new Object[] { getController().getName(), casReferenceId, aMessageContext.getEndpoint().getEndpoint() });
        throw new AsynchAEException("CAS with Reference Id:" + casReferenceId + " Not Found in CasManager's CAS Cache");
      }
    }
    catch ( Exception e)
    {
     
      e.printStackTrace();
      ErrorContext errorContext = new ErrorContext();
      errorContext.add(AsynchAEMessage.Command, AsynchAEMessage.Process);
      errorContext.add(AsynchAEMessage.CasReference, casReferenceId );
      errorContext.add(AsynchAEMessage.Endpoint, aMessageContext.getEndpoint());
      getController().getErrorHandlerChain().handle(e, errorContext, getController());
    }
    finally
    {
      incrementDelegateProcessCount(aMessageContext);
      if ( getController() instanceof AggregateAnalysisEngineController )
      {
        try
        {
          String endpointName = aMessageContext.getEndpoint().getEndpoint();
          String delegateKey =
            ((AggregateAnalysisEngineController)getController()).lookUpDelegateKey(endpointName);
          if ( delegateKey != null )
          {
            Endpoint endpoint =
              ((AggregateAnalysisEngineController)getController()).lookUpEndpoint(delegateKey, false);

            //  Check if the multiplier aborted during processing of this input CAS
            if ( endpoint != null && endpoint.isCasMultiplier() && cacheEntry.isAborted() )
            {
              if ( !getController().getInProcessCache().isEmpty() )
              {
                getController().getInProcessCache().registerCallbackWhenCacheEmpty(getController().getEventListener());
              }
View Full Code Here

            UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception_while_sending_reply_to_client__FINE", new Object[] { aController.getComponentName(), endpt.getEndpoint(), casReferenceId });
      }
    }
   
    int totalNumberOfParallelDelegatesProcessingCas = 1; // default
    CacheEntry cacheEntry = null;
    try
    {
      cacheEntry = aController.getInProcessCache().getCacheEntryForCAS(casReferenceId);
      if ( cacheEntry != null )
      {
        totalNumberOfParallelDelegatesProcessingCas = cacheEntry.getNumberOfParallelDelegates();
      }

    }
    catch( Exception e) {}
    //  Determine where to send the message
    Endpoint endpoint = getDestination(aController, anErrorContext);
/*
    //  Notify the parent of the exception
    if ( endpoint != null && casReferenceId != null && !endpoint.isCasMultiplier())
    {
      try
      {
        aController.getOutputChannel().sendReply(t, casReferenceId, endpoint, AsynchAEMessage.Process);
        aController.dropStats(casReferenceId, endpoint.getEndpoint());
      }
      catch( Exception e)
      {
        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "handleError",
            UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", e);
      }
    }
*/   
    //  If the error occured during parallel step, treat the exception as response from the delegate
    //  When all responses from delegates are accounted for we allow the CAS to move on to the next
    //  step in the flow
    if ( cacheEntry != null && totalNumberOfParallelDelegatesProcessingCas > 1 && ( cacheEntry.howManyDelegatesResponded() < totalNumberOfParallelDelegatesProcessingCas))
    {
      synchronized( cacheEntry )
      {
        cacheEntry.incrementHowManyDelegatesResponded();
      }
    }

    if (aController instanceof AggregateAnalysisEngineController && t instanceof Exception)
    {
      boolean flowControllerContinueFlag = false;
      // if the deployment descriptor says no retries, dont care what the Flow Controller says
      if ( threshold != null && threshold.getContinueOnRetryFailure() )
      {
        try
        {
          //  Consult Flow Controller to determine if it is ok to continue despite the error
          flowControllerContinueFlag =
            ((AggregateAnalysisEngineController) aController).continueOnError(casReferenceId, key, (Exception) t );
        }
        catch( Exception exc) {}
      }
 
      //  Check if the caller has already decremented number of subordinates. This property is only
      //  set in the Aggregate's finalStep() method before the CAS is sent back to the client. If
      //  there was a problem sending the CAS to the client, we dont want to update the counter
      //  again. If an exception is reported elsewhere ( not in finalStep()), the default action is
      //  to decrement the number of subordinates associated with the parent CAS.
      if ( !anErrorContext.containsKey(AsynchAEMessage.SkipSubordinateCountUpdate))
      {
        //  Check if the CAS is a subordinate (has parent CAS).
        if ( cacheEntry != null && cacheEntry.isSubordinate())
        {
          String parentCasReferenceId = cacheEntry.getInputCasReferenceId();
          if ( parentCasReferenceId != null )
          {
            try
            {
              CacheEntry parentCasCacheEntry = aController.getInProcessCache().
                                getCacheEntryForCAS(parentCasReferenceId);
              synchronized( parentCasCacheEntry )
              {
                ((AggregateAnalysisEngineController)aController).
                decrementCasSubordinateCount( parentCasCacheEntry);
                if ( parentCasCacheEntry.getSubordinateCasInPlayCount() == 0 &&
                   parentCasCacheEntry.isPendingReply())
                {
                  //  Complete processing of the Input CAS
                  if ( flowControllerContinueFlag ==  false )
                  {
                    aController.process(parentCasCacheEntry.getCas(), parentCasCacheEntry.getCasReferenceId());
                  }
                }
              }
            }
            catch( Exception ex)
View Full Code Here

        Exception ex = (Exception)anErrorContext.get(ErrorContext.THROWABLE_ERROR);
        boolean continueOnError =
          ((AggregateAnalysisEngineController)this).continueOnError(casReferenceId, key, ex);
        if ( continueOnError )
        {
          CacheEntry entry = null;
          try
          {
            entry = getInProcessCache().getCacheEntryForCAS(casReferenceId);
          }
          catch( AsynchAEException e) {}
                    CAS cas = null;
          //  Make sure that the ErrorHandler did not drop the cache entry and the CAS
          if ( entry != null && (( cas = entry.getCas()) != null ) )
          {
            ((AggregateAnalysisEngineController)this).process(cas, casReferenceId);
          }
        }
      }
View Full Code Here

        }
        Exception ex = (Exception) anErrorContext.get(ErrorContext.THROWABLE_ERROR);
        boolean continueOnError = ((AggregateAnalysisEngineController) this).continueOnError(
                casReferenceId, key, ex);
        if (continueOnError) {
          CacheEntry entry = null;
          try {
            entry = getInProcessCache().getCacheEntryForCAS(casReferenceId);
          } catch (AsynchAEException e) {
            if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
                UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(),
                        "handleAction", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
                        "UIMAEE_parent_cas_notin_cache__INFO", new Object[] { getComponentName(), casReferenceId});
              }
           
           
          }
          CAS cas = null;
          // Make sure that the ErrorHandler did not drop the cache entry and the CAS
          if (entry != null && ((cas = entry.getCas()) != null)) {
            //  Add a flag to the ErrorContext to indicate that the CAS exception was handled
            //  and the CAS was allowed to continue. The ErrorHandler who called this method
            //  will simply return after the completion of this method.
            anErrorContext.add(ErrorContext.ERROR_HANDLED, Boolean.valueOf(true));
            //  Continue processing the CAS
View Full Code Here

TOP

Related Classes of org.apache.uima.aae.InProcessCache.CacheEntry

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.