com.endeca.cas.extension
Class ManipulatorRuntime

java.lang.Object
  extended by com.endeca.cas.extension.PipelineComponentRuntime
      extended by com.endeca.cas.extension.ManipulatorRuntime

public abstract class ManipulatorRuntime
extends PipelineComponentRuntime

The runtime representation of a manipulator instance. A new instance of a ManipulatorRuntime is created for each manipulator instance in every acquisition.

The general life cycle of a ManipulatorRuntime is:

  1. The ManipulatorRuntime is created by Manipulator.createManipulatorRuntime(PipelineComponentConfiguration, PipelineComponentRuntimeContext).
  2. If an incremental acquisition has been requested, checkFullAcquisitionRequired() is called to ensure that the runtime has the necessary state to support an incremental acquisition.
  3. prepareForAcquisition(AcquisitionMode) to perform any runtime initialization that requires the AcquisitionMode.
  4. processRecord(Record) is called for every input record.
  5. onInputClose() is called after the runtime has processed all input records.
  6. PipelineComponentRuntime.endAcquisition(AcquisitionEndState) is called to clean up any resources used by the runtime.

Subclasses must be thread-safe. The CAS Server will invoke methods on this class from multiple-threads and potentially concurrently. Access to any mutable state must be properly synchronized. See the CAS Extension API Guide for more information about threading.


Constructor Summary
ManipulatorRuntime(PipelineComponentRuntimeContext context)
           
 
Method Summary
 boolean checkFullAcquisitionRequired()
          Indicates whether a full acquisition is required based on the state maintained by the ManipulatorRuntime.
 void onInputClose()
          Performs any post-processing necessary once processRecord() has been called and has returned for the last time.
 void prepareForAcquisition(AcquisitionMode mode)
          Performs any preparation necessary before acquisition starts.
abstract  void processRecord(Record record)
          Applies the manipulation to the given record.
 
Methods inherited from class com.endeca.cas.extension.PipelineComponentRuntime
endAcquisition, getContext, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManipulatorRuntime

public ManipulatorRuntime(PipelineComponentRuntimeContext context)
Method Detail

checkFullAcquisitionRequired

public boolean checkFullAcquisitionRequired()
Indicates whether a full acquisition is required based on the state maintained by the ManipulatorRuntime.

If CAS has already determined that a full acquisition is required, this method will not be called. For example, CAS will not call this method if the pipeline has never been run or if a configuration change requires full acquisition.

The default implementation of this method returns false indicating a full acquisition is not required.

Returns:
true if this runtime determines a full data acquisition is required, false otherwise.
See Also:
PipelineComponentConfiguration.isFullAcquisitionRequired(PipelineComponentConfiguration)

prepareForAcquisition

public void prepareForAcquisition(AcquisitionMode mode)
                           throws FatalExecutionException
Performs any preparation necessary before acquisition starts. CAS calls this method before any records are processed in the pipeline.

Parameters:
mode - indicates whether the acquisition is full or incremental
Throws:
FatalExecutionException - if preparation failed, and no processing of any records should take place.

processRecord

public abstract void processRecord(Record record)
                            throws ExecutionException
Applies the manipulation to the given record. Typical implementations transform the given Record into one or more Records and then output them using the OutputChannel obtained from the PipelineComponentRuntimeContext. The CAS Server performs no further processing on Records that are not output.

The CAS Server invokes this method concurrently for multiple records, so implementations must be thread-safe.

If a java RuntimeException or an ExecutionException that is not a FatalExecutionException is thrown, CAS discards the record using the ErrorChannel.

Parameters:
record - the record to be processed
Throws:
ExecutionException - if processing of this record failed, but that further processing of other records may continue normally.
FatalExecutionException - if processing of the current record failed, and no further processing of any records should continue.
See Also:
PipelineComponentRuntime.stop()

onInputClose

public void onInputClose()
                  throws FatalExecutionException
Performs any post-processing necessary once processRecord() has been called and has returned for the last time. The ManipulatorRuntime can still output records in this method.

Any Exceptions thrown from this method, including RuntimeExceptions, cause the acquisition to fail.

Throws:
FatalExecutionException - if post-processing failed, and no further processing of any records should continue.
See Also:
PipelineComponentRuntime.stop()


Copyright © 2007, 2012, Oracle and/or its affiliates. All rights reserved.