Class AbstractSystemAdapter

All Implemented Interfaces:
Closeable, AutoCloseable, CommandReceivingComponent, Component, GeneratedDataReceivingComponent, PlatformConnector, TaskReceivingComponent

public abstract class AbstractSystemAdapter extends AbstractPlatformConnectorComponent implements GeneratedDataReceivingComponent, TaskReceivingComponent
This abstract class implements basic functions that can be used to implement a system adapter.
Author:
Michael Röder (roeder@informatik.uni-leipzig.de)
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • DEFAULT_MAX_PARALLEL_PROCESSED_MESSAGES

      private static final int DEFAULT_MAX_PARALLEL_PROCESSED_MESSAGES
      Default value of the maxParallelProcessedMsgs attribute.
      See Also:
    • terminateMutex

      private Semaphore terminateMutex
      Mutex used to wait for the terminate signal.
    • cause

      private Exception cause
      The cause for an unusual termination.
    • causeMutex

      private Semaphore causeMutex
      Mutex used to manage access to the cause object.
    • maxParallelProcessedMsgs

      private final int maxParallelProcessedMsgs
      The maximum number of incoming messages of a single queue that are processed in parallel. Additional messages have to wait.
    • dataGenReceiver

      protected DataReceiver dataGenReceiver
      Receiver for data coming from the data generator.
    • taskGenReceiver

      protected DataReceiver taskGenReceiver
      Receiver for tasks coming from the task generator.
    • sender2EvalStore

      protected DataSender sender2EvalStore
      Sender for sending messages from the benchmarked system to the evaluation storage.
    • systemParamModel

      protected org.apache.jena.rdf.model.Model systemParamModel
      The RDF model containing the system parameters.
  • Constructor Details

    • AbstractSystemAdapter

      public AbstractSystemAdapter()
    • AbstractSystemAdapter

      public AbstractSystemAdapter(int maxParallelProcessedMsgs)
      Constructor setting the maximum number of messages processed in parallel.
      Parameters:
      maxParallelProcessedMsgs - The maximum number of incoming messages of a single queue that are processed in parallel. Additional messages have to wait.
  • Method Details

    • init

      public void init() throws Exception
      Description copied from interface: Component
      This method initializes the component.
      Specified by:
      init in interface Component
      Overrides:
      init in class AbstractCommandReceivingComponent
      Throws:
      Exception - if an error occurs during the initialization
    • run

      public void run() throws Exception
      Description copied from interface: Component
      This method executes the component.
      Specified by:
      run in interface Component
      Throws:
      Exception - if an error occurs during the execution
    • receiveCommand

      public void receiveCommand(byte command, byte[] data)
      Description copied from interface: CommandReceivingComponent
      This method is called if a command is received and might be interesting for this particular component.
      Specified by:
      receiveCommand in interface CommandReceivingComponent
      Overrides:
      receiveCommand in class AbstractPlatformConnectorComponent
      Parameters:
      command - the byte encoding the command
      data - additional data that was sent together with the command
    • sendResultToEvalStorage

      protected void sendResultToEvalStorage(String taskIdString, byte[] data) throws IOException
      This method sends the given result data for the task with the given task id to the evaluation storage.
      Parameters:
      taskIdString - the id of the task
      data - the data of the task
      Throws:
      IOException - if there is an error during the sending
    • terminate

      protected void terminate(Exception cause)
      Starts termination of the main thread of this system adapter. If a cause is given, it will be thrown causing an abortion from the main thread instead of a normal termination.
      Parameters:
      cause - the cause for an abortion of the process or {code null} if the component should terminate in a normal way.
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class AbstractCommandReceivingComponent
      Throws:
      IOException