T - the type of the extracted source dataS - the type of the transformed documentspublic abstract class AbstractETL<T,S> extends Object implements IEventListener
ILoader. This most basic
ETL class offers functions that can be controlled via REST requests
from the ETLRestResource, as well as some utility objects that are
required by all harvests. Subclasses must implement the concrete harvesting
process.| Modifier and Type | Field and Description |
|---|---|
protected BooleanParameter |
enabledParameter |
protected IExtractor<T> |
extractor |
protected String |
hash |
protected TimestampedList<ETLHealth> |
healthHistory |
protected ILoader<S> |
loader |
protected org.slf4j.Logger |
logger |
protected String |
name |
protected TimestampedList<ETLState> |
stateHistory |
protected ITransformer<T,S> |
transformer |
| Constructor and Description |
|---|
AbstractETL()
Constructor that initializes helper classes and fields.
|
AbstractETL(String name)
Constructor that initializes helper classes and fields.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abortHarvest()
Aborts the harvesting process, allowing a new harvest to be started.
|
void |
addEventListeners()
Adds event listeners.
|
void |
cancelHarvest()
Cancels the ETL if it is queued to harvest,
cleaning up readers and writers if necessary.
|
protected abstract IExtractor<T> |
createExtractor()
Creates an IExtractor for retrieving elements from
the harvested repository to be used by the ITransformer.
|
protected ILoader<S> |
createLoader()
Creates an ILoader for sending the harvested documents
to a search index.
|
protected abstract ITransformer<T,S> |
createTransformer()
Creates an ITransformer for transforming source elements
to documents that can be used by the ILoader.
|
protected void |
finishHarvestExceptionally(Throwable reason)
This method is called after an ongoing harvest failed due to an
exception.
|
ETLJson |
getAsJson()
Returns a simplified JSON representation of the ETL.
|
Charset |
getCharset()
Returns the charset of the harvested data.
|
abstract int |
getHarvestedCount()
Retrieves the number of documents that have been loaded.
|
String |
getHash()
Returns the checksum hash of the documents which are to be harvested.
|
ETLHealth |
getHealth()
Returns an enum that represents the health status of the ETL.
|
int |
getMaxNumberOfDocuments()
Returns the total number of documents that can possibly be harvested.
|
String |
getName()
Returns the name of the ETL.
|
ETLState |
getState()
Returns an enum that represents what the ETL is currently doing.
|
void |
harvest()
Starts the harvest.
|
void |
init(String moduleName)
Initializes the ETL, calculating the hash and maximum number of
harvestable documents.
|
protected String |
initHash()
Computes a hash value of the files that are to be harvested, which is
used for checking if the files have changed.
|
protected int |
initMaxNumberOfDocuments()
Calculates the total number of harvested documents.
|
boolean |
isEnabled()
Returns true if this ETL is enabled and initialized.
|
void |
loadFromJson(ETLJson json)
Loads the state from a JSON representation of this ETL.
|
protected void |
onContextDestroyed(ContextDestroyedEvent event)
The implementation of the context destroyed callback.
|
protected void |
onHarvestFinished(HarvestFinishedEvent event)
The implementation of the harvest finished callback.
|
protected void |
onParameterChanged(ParameterChangedEvent event)
The implementation of the parameter changed callback.
|
protected void |
onResetContext(ResetContextEvent event)
The implementation of the service reset callback.
|
void |
prepareHarvest()
Checks pre-conditions required for starting a harvest and updates the data
that is to be extracted.
|
protected void |
registerParameters()
Registers all configurable parameters.
|
void |
removeEventListeners()
Removes all event listeners of this class.
|
void |
setHealth(ETLHealth health)
Changes the health status.
|
void |
setName(String name)
Changes the name of the ETL.
|
void |
setStatus(ETLState state)
Changes the status that represents what the ETL is currently doing.
|
protected void |
skipHarvest()
Marks the harvest as done.
|
String |
toString() |
void |
update()
Updates the harvested source documents, calculating the hash and maximum number of
harvestable documents.
|
protected IExtractor<T> extractor
protected ITransformer<T,S> transformer
protected volatile BooleanParameter enabledParameter
protected final org.slf4j.Logger logger
protected String name
protected volatile String hash
protected final TimestampedList<ETLHealth> healthHistory
protected final TimestampedList<ETLState> stateHistory
public AbstractETL()
public AbstractETL(String name)
name - the name of this ETLprotected abstract IExtractor<T> createExtractor()
protected abstract ITransformer<T,S> createTransformer()
protected ILoader<S> createLoader()
protected void registerParameters()
public void addEventListeners()
IEventListeneraddEventListeners in interface IEventListenerpublic void removeEventListeners()
IEventListenerremoveEventListeners in interface IEventListenerpublic void loadFromJson(ETLJson json)
json - a simplified JSON representation of the ETLpublic ETLJson getAsJson()
public void abortHarvest()
throws IllegalStateException
IllegalStateException - if the current process cannot be abortedpublic void init(String moduleName) throws IllegalStateException
moduleName - the name of the harvester serviceIllegalStateException - thrown if init is called after the ETL is initializedprotected int initMaxNumberOfDocuments()
protected String initHash()
public void update()
throws ETLPreconditionException
ETLPreconditionExceptionpublic int getMaxNumberOfDocuments()
public void prepareHarvest()
throws ETLPreconditionException
ETLPreconditionException - thrown if the harvest cannot startpublic void cancelHarvest()
protected void skipHarvest()
public final void harvest()
protected void finishHarvestExceptionally(Throwable reason)
reason - the exception that caused the harvest to failpublic String getHash()
public ETLState getState()
public void setStatus(ETLState state)
state - a new statuspublic ETLHealth getHealth()
public void setHealth(ETLHealth health)
health - the new health status valuepublic abstract int getHarvestedCount()
public final String getName()
public final void setName(String name)
name - the new name of the ETLpublic Charset getCharset()
public boolean isEnabled()
protected void onResetContext(ResetContextEvent event)
event - the event that triggered the callbackprotected void onHarvestFinished(HarvestFinishedEvent event)
event - the event that triggered the callbackprotected void onParameterChanged(ParameterChangedEvent event)
event - the event that triggered the callbackprotected void onContextDestroyed(ContextDestroyedEvent event)
event - the event that triggered the callbackCopyright © 2017–2019. All rights reserved.