The
DataSourceRuntime is the runtime representation of a data
source instance. It is created by
DataSource.createDataSourceRuntime() and exists for the
life span of the data source.
CAS Server creates and passes a
PipelineComponentRuntimeContext class to
DataSource.createDataSourceRuntime(). The
PipelineComponentRuntimeContext specifies an output
channel, error channel, a state directory, and several other runtime
properties.
The
ErrorChannel.discard() method discards any invalid
records from the record acquisition process. Also, in addition to discarding
records, the
ErrorChannel class processes exceptions that you
catch. This processing includes incrementing the appropriate metric for a
record and also logging a record in the
cas-service.log file. The
ErrorChannel logs events at level
WARN and higher.
To create a runtime class for a data source:
In the Java project that contains the
DataSourceimplementation, create a subclass ofDataSourceRuntime.For example:
public class CsvDataSourceRuntime extends DataSourceRuntime { }Implement the abstract method
runFullAcquisition()to define how to acquire content from the data source. The implementation depends on your custom data source.Within your implementation of
runFullAcquisition(), callErrorChannel.discard()as necessary to discard any records that are invalid or have errors, and also callOutputChannel.output()for each record that has been processed.Optionally, implement either the
BinaryContentFileProviderinterface or theBinaryContentInputStreamProviderinterface if the data source needs to support text extraction.Optionally, implement the
IncrementalDataSourceRuntimeinterface calculate the changes in your data source extension, rather than have the Content Acquisition System determine the changes for you.Optionally, handle requests to stop an acquisition by providing a mechanism to stop an extension's runtime object in a timely way. This may include polling
PipelineComponentRuntimeContext.isStopped()and may include overridingPipelineComponentRuntime.stop(). For guidance, see Stopping an extension when an acquisition stops .Optionally, override
PipelineComponentRuntime.endAcquisition()to clean up any resources used byPipelineComponentRuntime. For guidance, see Cleaning up resources used by an extension.
Example 3. Example of a data source runtime
To see many of the steps above, refer to the sample data source
extension in
<install
path>\CAS\.
version\sample\cas-extensions\src\main\com\endeca\cas\
extension\sample\datasource\csv

