Class ModelFarmOnDemand<KEYTYPE,DATATYPE,ROWDATAMANAGERTYPE extends RowDataManager<KEYTYPE,DATATYPE>>

java.lang.Object
io.deephaven.modelfarm.ModelFarmBase<DATATYPE>
io.deephaven.modelfarm.ModelFarmOnDemand<KEYTYPE,DATATYPE,ROWDATAMANAGERTYPE>
Type Parameters:
KEYTYPE - The type of keys.
DATATYPE - The type of data.
ROWDATAMANAGERTYPE - The type of RowDataManager.
All Implemented Interfaces:
ModelFarm

public class ModelFarmOnDemand<KEYTYPE,DATATYPE,ROWDATAMANAGERTYPE extends RowDataManager<KEYTYPE,DATATYPE>> extends ModelFarmBase<DATATYPE>
A ModelFarm implementation for evaluating a model upon request, retrieving a snapshot of data for all keys under a single PeriodicUpdateGraph lock.
  • Constructor Details

    • ModelFarmOnDemand

      public ModelFarmOnDemand(int nThreads, Model<DATATYPE> model)
      Create a multithreaded resource to execute data driven models on demand.
      Parameters:
      nThreads - number of worker threads.
      model - model to execute.
  • Method Details

    • requestUpdate

      public void requestUpdate(ROWDATAMANAGERTYPE dataManager, Runnable callback)
      Submit a request to execute the ModelFarmBase.model. Can be called either with or without a PeriodicUpdateGraph lock -- the decision of whether/how to acquire a lock is left to the DO_LOCKED_FUNCTION. All keys represented by the data in the dataManager will be processed.
      Parameters:
      dataManager - The RowDataManager that will provide data for the pricing requests.
      callback - A callback function to run after all keys have been processed. Can be null, in which case it will be ignored.
    • requestUpdate

      public void requestUpdate(ROWDATAMANAGERTYPE dataManager, Runnable callback, Set<KEYTYPE> keys)
      Submit a request to execute the ModelFarmBase.model. Can be called either with or without a PeriodicUpdateGraph lock -- the decision of whether/how to acquire a lock is left to the DO_LOCKED_FUNCTION.
      Parameters:
      dataManager - The RowDataManager that will provide data for the pricing requests.
      callback - A callback function to run after all keys have been processed. Can be null, in which case it will be ignored.
      keys - They keys for which data should be passed to the model. If keys == null, then all keys represented by the data in the dataManager will be processed.
    • execute

      protected void execute() throws InterruptedException
      Description copied from class: ModelFarmBase
      Executes the next task in the work queue.
      Specified by:
      execute in class ModelFarmBase<DATATYPE>
      Throws:
      InterruptedException - if interrupted while executing
    • modelFarmStarted

      protected void modelFarmStarted()
      Description copied from class: ModelFarmBase
      Method called after the model farm threads have been started. Implementing classes can override this to perform additional setup (e.g. creating and starting listeners). The default implementation does nothing.
      Specified by:
      modelFarmStarted in class ModelFarmBase<DATATYPE>
    • isQueueEmpty

      protected boolean isQueueEmpty()
      Description copied from class: ModelFarmBase
      Returns true if the model farm queue is empty and false if the queue contains elements to execute.
      Specified by:
      isQueueEmpty in class ModelFarmBase<DATATYPE>
      Returns:
      true if the model farm queue is empty and false if the queue contains elements to execute.