com.endeca.edf.adapter
Class AdapterHandler

java.lang.Object
  extended by com.endeca.edf.adapter.AdapterHandler

public abstract class AdapterHandler
extends java.lang.Object

A functor used by an adapter to emit records.


Method Summary
abstract  void emit(Record record)
          Send a record off to be processed by this handler.
abstract  void flushLog()
          Flush any log messages that have been buffered.
abstract  java.lang.String getInputDirectory()
          Gets the input, state, or tmp directory used by forge.
abstract  java.lang.String getName()
           
abstract  int getNumInputs()
           
abstract  double getPercentComplete()
          Get the current completion level for this adapter.
abstract  double getPercentComplete(int recordSource)
           
 Record getRecord()
           
abstract  Record getRecord(int recordSource)
          Get a record from the specified record input in forge.
abstract  Record getRecord(java.lang.String recordSource)
          Get a record from the specified input in forge.
abstract  java.lang.String getStateDirectory()
           
abstract  java.lang.String getTmpDirectory()
           
 long getTotalNumberOfRecordsToEmit()
          Get the total number of records that are to be emitted.
abstract  void setAutoFlushLog(boolean autoFlush)
          Set whether log messages are flushed as soon as they are logged.
abstract  void setPercentComplete(double pc)
          Set the current completion level for this adapter.
 void setTotalNumberOfRecordsToEmit(long numberToEmit)
          Sets the total number of records that are to be emitted.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

emit

public abstract void emit(Record record)
                   throws AdapterException
Send a record off to be processed by this handler.

Parameters:
record - the record to process.
Throws:
AdapterException - if this handler fails to process the record. A sub-class of AdapterException, ShutdownRequestAdapterException, maybe thrown by AdapterHandler to notify the caller that it will not process anymore records emitted.

flushLog

public abstract void flushLog()
                       throws AdapterException
Flush any log messages that have been buffered.

Throws:
AdapterException

setAutoFlushLog

public abstract void setAutoFlushLog(boolean autoFlush)
Set whether log messages are flushed as soon as they are logged. Setting this to true causes log messages to be sent as soon as they are logged; this is good in that it gets the messages to their final destination quickly, but bad in that it can significantly increase the overhead of logging. This should be turned on only when performing explicit flushLog() calls is not possible.

Parameters:
autoFlush - whether to flush messages as soon as thery are logged.

getRecord

public abstract Record getRecord(int recordSource)
                          throws AdapterException
Get a record from the specified record input in forge.

Parameters:
recordSource - The record source from which to get the record. Record sources are numbered from zero. Sources are numbered in the order they appear as inputs in the pipeline file.
Returns:
the record, or null if there are no more records available from that source
Throws:
AdapterException - if this handler fails to get a Record. A sub-class of AdapterException, ShutdownRequestAdapterException, maybe thrown by AdapterHandler to notify the caller that it will not process anymore records emitted.

getRecord

public abstract Record getRecord(java.lang.String recordSource)
                          throws AdapterException
Get a record from the specified input in forge. This method allows you to specify an input by the name of the input component in forge rather than the input number.

Throws:
AdapterException

getRecord

public final Record getRecord()
                       throws AdapterException
Throws:
AdapterException

getPercentComplete

public abstract double getPercentComplete(int recordSource)
                                   throws AdapterException
Throws:
AdapterException

getNumInputs

public abstract int getNumInputs()
Returns:
the number of record inputs hooked up to this java manipulator component in forge.

getInputDirectory

public abstract java.lang.String getInputDirectory()
Gets the input, state, or tmp directory used by forge. The directories may be set by running forge with the --inputDir, --stateDir, or --tmpDir commandline argument.

Returns:
the requested directory, or the empty string if it wasn't specified.

getStateDirectory

public abstract java.lang.String getStateDirectory()

getTmpDirectory

public abstract java.lang.String getTmpDirectory()

getName

public abstract java.lang.String getName()
Returns:
the forge component name of this manipulator

setTotalNumberOfRecordsToEmit

public void setTotalNumberOfRecordsToEmit(long numberToEmit)
Sets the total number of records that are to be emitted. This parameter is used to estimate processing time. In general this parameter should be set by an adapter prior to emitting a record, though the value can be set or changed at any time.

Parameters:
numberToEmit - the number of records that the adapter will emit.

getTotalNumberOfRecordsToEmit

public long getTotalNumberOfRecordsToEmit()
Get the total number of records that are to be emitted.

Returns:
the total number of records that are to be emitted, or -1 if unset.

setPercentComplete

public abstract void setPercentComplete(double pc)
Set the current completion level for this adapter. This is used to estimate processing time.

Parameters:
pc - The current completion level, between 0 and 100.

getPercentComplete

public abstract double getPercentComplete()
Get the current completion level for this adapter.

Returns:
The current completion level, between 0 and 100.


© 2010 Endeca Technologies, Inc.
Endeca Confidential