Package org.apache.uima.aae.InProcessCache

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


        // enable termination. Otherwise, a hang may occur
        Iterator<String> it = cmOutstandingCASes.keySet().iterator();
        while (it.hasNext()) {
          String casId = it.next();
          try {
            CacheEntry entry = getInProcessCache().getCacheEntryForCAS(casId);
            if (entry != null && entry.getCas() != null) {
              System.out.println("Primitive:" + getComponentName() + " Forcing Release of CAS:"
                      + casId + " in stop()");
              // Force CAS release to unblock CM thread
              entry.getCas().release();
            }
          } catch (Exception e) {
            System.out.println("Controller:" + getComponentName() + " CAS:" + casId
                    + " Not Found In Cache");
View Full Code Here


    String serializedCas = null;
   
    if ( isReply || "xmi".equalsIgnoreCase(aSerializerKey ) )
    {

      CacheEntry cacheEntry =
        getAnalysisEngineController().getInProcessCache().getCacheEntryForCAS(aCasReferenceId);
        
      XmiSerializationSharedData serSharedData;
      UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
                    "serializeCAS", JmsConstants.JMS_LOG_RESOURCE_BUNDLE, "UIMAJMS_serialize_cas__FINE",
                    new Object[] {aCasReferenceId});
      if ( isReply )
      {
        serSharedData = cacheEntry.getDeserSharedData();
          serializedCas = UimaSerializer.serializeCasToXmi(aCAS, serSharedData);
      }
      else
      {
        serSharedData = cacheEntry.getDeserSharedData();//new XmiSerializationSharedData();
        if (serSharedData == null) {
          serSharedData = new XmiSerializationSharedData();
          cacheEntry.setXmiSerializationData(serSharedData);
        }
          serializedCas = UimaSerializer.serializeCasToXmi(aCAS, serSharedData);
          int maxOutgoingXmiId = serSharedData.getMaxXmiId();       
        //  Save High Water Mark in case a merge is needed
          getAnalysisEngineController().
View Full Code Here

      {
        serializedCAS = getAnalysisEngineController().getInProcessCache().getSerializedCAS( aCasReferenceId );
      }
      else
      {
        CacheEntry entry = getAnalysisEngineController().getInProcessCache().getCacheEntryForCAS(aCasReferenceId);
        long t1 = System.nanoTime();
        //  Serialize CAS for remote Delegates
        String serializer = anEndpoint.getSerializer();
        if ( serializer == null || serializer.trim().length() == 0)
        {
          serializer = "xmi";
        }
        serializedCAS = serializeCAS(isReply, cas, aCasReferenceId, serializer);
        long timeToSerializeCas = System.nanoTime()-t1;
        entry.incrementTimeToSerializeCAS(timeToSerializeCas);
        casStats.incrementCasSerializationTime(timeToSerializeCas);
        getAnalysisEngineController().getServicePerformance().
          incrementCasSerializationTime(timeToSerializeCas);
        if ( cacheSerializedCas )
        {
View Full Code Here

        {
          tm.setStringProperty(AsynchAEMessage.MessageFrom, secondaryInputEndpoint);
        }
        if ( UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE) )
        {
          CacheEntry cacheEntry = getCacheEntry(aCasReferenceId);
          if ( cacheEntry != null )
          {
            UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
                          "sendCasToCollocatedDelegate", JmsConstants.JMS_LOG_RESOURCE_BUNDLE, "UIMAJMS_send_cas_to_collocated_service_detail__FINE",
                          new Object[] {getAnalysisEngineController().getComponentName(),"Remote", anEndpoint.getEndpoint(), aCasReferenceId, anInputCasReferenceId, cacheEntry.getInputCasReferenceId() });
          }
        }
      }

      //  Add stats
View Full Code Here

        //  produced by the CAS Multiplier. The client will treat this CAS
        //  differently from the input CAS.
        tm.setIntProperty( AsynchAEMessage.MessageType, AsynchAEMessage.Request);
        if ( UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE) )
        {
          CacheEntry cacheEntry = getCacheEntry(aNewCasReferenceId);
          if ( cacheEntry != null )
          {
            UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
                          "sendCasToCollocatedDelegate", JmsConstants.JMS_LOG_RESOURCE_BUNDLE, "UIMAJMS_send_cas_to_collocated_service_detail__FINE",
                          new Object[] {getAnalysisEngineController().getComponentName(),"Collocated", anEndpoint.getEndpoint(), aNewCasReferenceId, anInputCasReferenceId, cacheEntry.getInputCasReferenceId() });
          }
        }

     
      }
View Full Code Here

   
  }

  private CacheEntry getCacheEntry( String aCasReferenceId) throws Exception
  {
    CacheEntry cacheEntry = null;
    if ( getAnalysisEngineController().getInProcessCache().entryExists(aCasReferenceId) )
    {
      cacheEntry =
        getAnalysisEngineController().getInProcessCache().getCacheEntryForCAS(aCasReferenceId);
    }
View Full Code Here

    }
    return cacheEntry;
  }
  private void addTopCASParentReferenceId( TextMessage tm, String aCasReferenceId) throws Exception
  {
    CacheEntry cacheEntry = null;
    if ( ( cacheEntry = getCacheEntry(aCasReferenceId)) != null )
    {
      if ( cacheEntry.getInputCasReferenceId() == null )
      {
        tm.setStringProperty(AsynchAEMessage.InputCasReference, aCasReferenceId);
      }
      else
      {
        tm.setStringProperty(AsynchAEMessage.InputCasReference, cacheEntry.getInputCasReferenceId());
      }
    }
   
  }
View Full Code Here

   
    //  If this is a PrimitiveController and not collocated with its aggregate
    //  drop the CAS
    if ( !( aController instanceof AggregateAnalysisEngineController ) )
    {
      CacheEntry entry = null;
     
      try
      {
        entry = aController.getInProcessCache().getCacheEntryForCAS(casReferenceId);
        if ( endpoint.isRemote() && entry != null )
View Full Code Here

                  new Object[] {getName(), aCasReferenceId });
      Collection keyList = aStep.getAnalysisEngineKeys();
      String[] analysisEngineKeys = new String[keyList.size()];
      keyList.toArray(analysisEngineKeys);

      CacheEntry cacheEntry = getInProcessCache().getCacheEntryForCAS(aCasReferenceId);
      cacheEntry.resetDelegateResponded();
      cacheEntry.setNumberOfParallelDelegates(analysisEngineKeys.length);

      Endpoint[] endpoints = new Endpoint_impl[analysisEngineKeys.length];
      for (int i = 0; i < analysisEngineKeys.length; i++)
      {
        endpoints[i] = lookUpEndpoint(analysisEngineKeys[i], true);
View Full Code Here

  private void finalStep(FinalStep aStep, String aCasReferenceId)// throws AsynchAEException
  {
    Endpoint endpoint=null;
    boolean subordinateCasInPlayCountDecremented=false;
    CacheEntry cacheEntry = null;
    try
    {
      cacheEntry = getInProcessCache().getCacheEntryForCAS(aCasReferenceId);
      if ( cacheEntry.getState() != CacheEntry.FINAL_STATE )
      {
        cacheEntry.setState(CacheEntry.FINAL_STATE);
      }
    }
    catch(Exception e)
    {
        return;
    }
   
    try
    {
      CacheEntry parentCASCacheEntry = null;
          boolean replyWithInputCAS = false;
      //  Check if the CAS has subordinates, meaning is this CAS an input CAS from which
      //  other CASes (subordinates) were produced. If so, make sure that all subordinate
      //  CASes have been fully processed. Only when all subordinates are accounted for
      //  return the input CAS back to the client. While subordinates are in-play keep
      //  the input CAS in the cache.
       
      //  Check if this CAS is an input CAS
      if (!cacheEntry.isSubordinate() || cacheEntry.getSubordinateCasInPlayCount() > 0 )
      {
        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINEST, CLASS_NAME.getName(),
            "finalStep", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_final_step_parent_cas__FINEST", new Object[] { getComponentName(),aCasReferenceId});
        synchronized( cacheEntry )
        {
          if ( cacheEntry.getSubordinateCasInPlayCount() > 0 )
          {
            UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINEST, CLASS_NAME.getName(),
                "finalStep", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_final_step_parent_cas_child_count__FINEST", new Object[] { getComponentName(),aCasReferenceId,cacheEntry.getSubordinateCasInPlayCount()});

            // Leave input CAS in pending state. It will be returned to the client
              // *only* if the last subordinate CAS is fully processed.
              cacheEntry.setPendingReply(true);
            //  Done here. There are subordinate CASes still being processed.
            return;
          }
          else
          {
            UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINEST, CLASS_NAME.getName(),
                "finalStep", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_final_step_parent_cas_no_children__FINEST", new Object[] { getComponentName(),aCasReferenceId});

            //  All subordinates have been fully processed. Set the flag so that
            //  the input is returned back to the client.
            replyWithInputCAS = true;
          }
        }
      }
      else //if ( isTopLevelComponent())
      {
        //   This is a subordinate CAS. First get cache entry for the input (parent) CAS
        parentCASCacheEntry =
          getInProcessCache().getCacheEntryForCAS(cacheEntry.getInputCasReferenceId());
        if ( getMessageOrigin(aCasReferenceId) == null )
        {
          replyWithInputCAS = decrementCasSubordinateCount( parentCASCacheEntry);
          if ( parentCASCacheEntry != null )
          {
            //  Set the flag to indicate that the cache entry for the parent CAS has been updated
            //  In case an exception happens below, the error handler will be instructed to skip
            //  decrementing subordinate count (since it's been done already)
            subordinateCasInPlayCountDecremented = true;
          }
        }
        else
        {
          replyWithInputCAS = true;
        }
       
      }
     
      // Cas Processing has been completed. Check if the CAS should be sent to
      // the client.
      // Any of the two following conditions will prevent this aggregate from
      // sending the CAS to the client:
      // 1) FinalStep is configured to drop the CAS
      // 2) If the CAS has been produced by the Cas Multiplier and the
      // aggregate is not configured to output new CASes

      String casProducer = cacheEntry.getCasProducerAggregateName();
      boolean isNewCas = (cacheEntry.isNewCas() && casProducer != null && getComponentName().equals(casProducer));

      //  If debug level=FINEST show the size of the cache
      getInProcessCache().dumpContents();
      // New CASes must be dropped if aggregate doesn't output them or if flow controller has ActionAfterCasMultiplier="drop"
      if (isNewCas && (aStep.getForceCasToBeDropped() || !aggregateMetadata.getOperationalProperties().getOutputsNewCASes()))
      {
        endpoint = getInProcessCache().getEndpoint(null, aCasReferenceId);
        if ( cacheEntry.isReplyReceived())
        {
          dropCAS(aCasReferenceId, true);
        }
       
        if ( parentCASCacheEntry != null //&& parentCASCacheEntry.isSubordinate()
              && parentCASCacheEntry.isReplyReceived()
              && parentCASCacheEntry.getState() == CacheEntry.FINAL_STATE
            && parentCASCacheEntry.getSubordinateCasInPlayCount() == 0)
        {
          //  All subordinate CASes have been processed. Process the parent
          //  CAS recursively.
          finalStep(aStep, parentCASCacheEntry.getCasReferenceId());
        }
      }
/*     
      if ( replyWithInputCAS && parentCASCacheEntry != null )
      {
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.