Package bbflow

Class defaultJob<T,U>

java.lang.Object
bbflow.defaultJob<T,U>
Type Parameters:
T - Custom type of the channels
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
complete_farm_testOutnode, complete_farm_testWorker, defaultCollector, defaultEmitter, defaultWorker, myjob

public class defaultJob<T,U> extends Object implements Runnable
default Job extecuted by the bbflow.ff_node. Should be extended and reimplemented with the custom code. Take a look to examples to choose what you prefer. check if there are at least one input or output channel For more details see run() function doc
  • Field Details

  • Constructor Details

    • defaultJob

      public defaultJob()
    • defaultJob

      public defaultJob(int id)
      default constructor
      Parameters:
      id - id of the job
  • Method Details

    • preload

      public static void preload()
    • setId

      public void setId(int id)
      set id
      Parameters:
      id -
    • init

      public void init()
      function to override called after start()
    • uniqueJob

      public static defaultJob uniqueJob(defaultJob obj)
      function to clone an object, using serialization
      Parameters:
      obj - object to clone
      Returns:
      cloned object
    • uniqueJob

      public static defaultJob uniqueJob(defaultJob obj, int id)
      clone a defaultJob and make it unique (it's not a reference).
      Parameters:
      obj - job to clone
      id - id to assign to the new job
      Returns:
      return the new cloned job
    • sendOut

      public void sendOut(U element)
      send element to the next out channel in ROUNDROBIN manner
      Parameters:
      element - element to send
    • sendOut

      public void sendOut(U element, int combined_side)
    • sendOutTo

      public void sendOutTo(U element, int combined_side, int index)
    • sendOutToAll

      public void sendOutToAll(U element)
      send element to all output channels
      Parameters:
      element - element to send
    • sendOutTo

      public void sendOutTo(U element, int index)
      send element to the channel 'index'
      Parameters:
      element - element to send
      index - index of the out channel
    • sendEOS

      public void sendEOS()
      send EOS to all output channels
    • sendEOS

      public void sendEOS(int combined_side)
      method overwritten by ff_comb
      Parameters:
      combined_side - combined side (left/right)
    • run

      public void run()
      default Runnable run method This method runs only if there are at least 1 input channel and 1 output channel Regarding output channel: if there isn't any node on the other side, just don't send anything in the output channel in runJob
      Specified by:
      run in interface Runnable
    • runJob

      blank function that should be overwritten by class extending bbflow.defaultJob. Here main computation task is done once we're sure there's data in at least one of the input channels Lists 'in' and 'out' must be used manually and EOS() must be managed by the user.
      Throws:
      InterruptedException
      InstantiationException
      IllegalAccessException
      NoSuchMethodException
      InvocationTargetException
    • runJob

      runJob(T element) function to override
      Parameters:
      element - element received from first input channel
      Returns:
      return element to send to the first output channel or null if nothing
      Throws:
      InterruptedException
      InstantiationException
      IllegalAccessException
      NoSuchMethodException
      InvocationTargetException
    • runJobMulti

      public void runJobMulti(T element, LinkedList<ff_queue<U>> channels_output)
      runJobMulti(T element, LinkedList channels_output) function to override
      Parameters:
      element - element received from input in ROUNDROBIN
      channels_output - output channels list is manual usage needed. sendOut, sendOutTo, sendOutToAll available anyway.
    • addInputChannel

      public void addInputChannel(ff_queue<T> input)
      add new input channel to the Runnable node
      Parameters:
      input - input channel
    • addOutputChannel

      public void addOutputChannel(ff_queue<U> output)
      add new output channel to the Runnable node
      Parameters:
      output - output channel
    • removeInputChannel

      public boolean removeInputChannel(int index)
      remove input channel
      Parameters:
      index - index to remove
      Returns:
      result
    • removeOutputChannel

      public boolean removeOutputChannel(int index)
      remove output channel
      Parameters:
      index - index to remove
      Returns:
      result
    • getOutputChannel

      public ff_queue<U> getOutputChannel(int index)
      get output channel
      Parameters:
      index - index to get
      Returns:
      queue requested or null
    • getInputChannel

      public ff_queue<T> getInputChannel(int index)
      get input channel
      Parameters:
      index - index to get
      Returns:
      queue requested or null
    • EOS

      public void EOS()
      EOS() function to override