Package com.illumon.modelfarm
Class ModelFarmRealTime<KEYTYPE,DATATYPE,ROWDATAMANAGERTYPE extends RowDataManager<KEYTYPE,DATATYPE>>
java.lang.Object
com.illumon.modelfarm.ModelFarmBase<DATATYPE>
com.illumon.modelfarm.RDMModelFarm<KEYTYPE,DATATYPE,ROWDATAMANAGERTYPE>
com.illumon.modelfarm.ModelFarmRealTime<KEYTYPE,DATATYPE,ROWDATAMANAGERTYPE>
- Type Parameters:
KEYTYPE- unique ID key typeDATATYPE- data type
- All Implemented Interfaces:
ModelFarm
public class ModelFarmRealTime<KEYTYPE,DATATYPE,ROWDATAMANAGERTYPE extends RowDataManager<KEYTYPE,DATATYPE>>
extends RDMModelFarm<KEYTYPE,DATATYPE,ROWDATAMANAGERTYPE>
A multithreaded resource to execute data driven models.
Every time a row of the data table ticks, the unique identifier is queued for execution.
Once the security reaches the top of the execution queue, the most recent data for the unique identifier is used for execution.
This is useful for real-time processing, where executing unique identifiers as fast as possible is desired.
The execution priority is determined by how long it has been since the data changed. The prioritizer can be used to bump a unique identifier to a higher execution priority.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.illumon.modelfarm.ModelFarmBase
ModelFarmBase.GetDataLockType, ModelFarmBase.State -
Field Summary
Fields inherited from class com.illumon.modelfarm.RDMModelFarm
dataManagerFields inherited from class com.illumon.modelfarm.ModelFarmBase
model -
Constructor Summary
ConstructorsConstructorDescriptionModelFarmRealTime(int nThreads, Model<DATATYPE> model, ROWDATAMANAGERTYPE dataManager, ExecPrioritizer<KEYTYPE, DATATYPE, ROWDATAMANAGERTYPE> prioritizer) Create a multithreaded resource to execute data driven models. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidexecute()Executes the next task in the work queue.protected booleanReturns true if the model farm queue is empty and false if the queue contains elements to execute.protected voidonDataUpdate(Index added, Index removed, Index modified) Process a change to the data table.booleanrequestUpdate(KEYTYPE key, int priority) Request an update for the givenkeywith the specified priority level.booleanRequest an update for the givenkeywith the maximum priority level.Methods inherited from class com.illumon.modelfarm.RDMModelFarm
getMostRecentDataFactory, modelFarmStartedMethods inherited from class com.illumon.modelfarm.ModelFarmBase
awaitTermination, awaitTermination, getDoLockedConsumer, getState, shutdown, shutdownAndAwaitTermination, shutdownAndAwaitTermination, start, terminate, toString
-
Constructor Details
-
ModelFarmRealTime
public ModelFarmRealTime(int nThreads, Model<DATATYPE> model, ROWDATAMANAGERTYPE dataManager, ExecPrioritizer<KEYTYPE, DATATYPE, ROWDATAMANAGERTYPE> prioritizer) Create a multithreaded resource to execute data driven models.- Parameters:
nThreads- number of worker threads.model- model to execute.dataManager- interface for accessing and querying data contained in rows of a dynamic table.prioritizer- utility for computing the execution priority.
-
-
Method Details
-
onDataUpdate
Description copied from class:RDMModelFarmProcess a change to the data table. If the data table is being accessed, use the protected column source fields.- Specified by:
onDataUpdatein classRDMModelFarm<KEYTYPE,DATATYPE, ROWDATAMANAGERTYPE extends RowDataManager<KEYTYPE, DATATYPE>> - Parameters:
added- new indexes added to the data tableremoved- indexes removed from the data tablemodified- indexes modified in the data table.
-
isQueueEmpty
protected boolean isQueueEmpty()Description copied from class:ModelFarmBaseReturns true if the model farm queue is empty and false if the queue contains elements to execute.- Specified by:
isQueueEmptyin classModelFarmBase<DATATYPE>- Returns:
- true if the model farm queue is empty and false if the queue contains elements to execute.
-
execute
Description copied from class:ModelFarmBaseExecutes the next task in the work queue.- Specified by:
executein classModelFarmBase<DATATYPE>- Throws:
InterruptedException- if interrupted while executing
-
requestUpdateMaxPriority
Request an update for the givenkeywith the maximum priority level.- Parameters:
key- The key to update.- Returns:
trueif theelementwas newly inserted to the queue or reinserted with a higher priority, otherwisefalse.
-
requestUpdate
Request an update for the givenkeywith the specified priority level.- Parameters:
key- The key to update.priority- The priority with which the key should be updated.- Returns:
trueif theelementwas newly inserted to the queue or reinserted with a higher priority, otherwisefalse.
-