Class Spore<I,​O>

java.lang.Object
org.nustaq.kontraktor.Spore<I,​O>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public abstract class Spore<I,​O>
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
A Spore is sent to a foreign actor executes on its data and sends results back to caller.
See Also:
Serialized Form
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected Callback cb  
    protected boolean finished  
  • Constructor Summary

    Constructors 
    Constructor Description
    Spore()  
  • Method Summary

    Modifier and Type Method Description
    Spore clone()  
    void complete​(O res, java.lang.Object err)
    to called from remote site. directly send stuff to remote site via callback.
    void finish()
    to be called at remote side when using streaming to deliver multiple results, call this in order to signal no further results are expected.
    boolean isFinished()
    to be read at remote side in order to decide wether to stop e.g. iteration.
    Spore<I,​O> onFinish​(java.lang.Runnable toRun)  
    abstract void remote​(I input)
    implements code to be executed at receiver side
    void setExpectedFinishCount​(int count)  
    Spore<I,​O> setForEach​(Callback<O> cb)
    use local (sender side).
    protected void stream​(O result)  
    protected void streamError​(java.lang.Object err)
    note that sending an error implicitely will close the backstream.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • setExpectedFinishCount

      public void setExpectedFinishCount​(int count)
    • remote

      public abstract void remote​(I input)
      implements code to be executed at receiver side
      Parameters:
      input -
    • setForEach

      public Spore<I,​O> setForEach​(Callback<O> cb)
      use local (sender side). Register and receive data streamed back from remote spore execution.
      Parameters:
      cb -
    • onFinish

      public Spore<I,​O> onFinish​(java.lang.Runnable toRun)
    • finish

      public void finish()
      to be called at remote side when using streaming to deliver multiple results, call this in order to signal no further results are expected.
    • streamError

      protected void streamError​(java.lang.Object err)
      note that sending an error implicitely will close the backstream.
      Parameters:
      err -
    • stream

      protected void stream​(O result)
    • complete

      public void complete​(O res, java.lang.Object err)
      to called from remote site. directly send stuff to remote site via callback. Warning: prefer stream(), streamError() and finish(). this can be used for generic exception catching etc. Take care to not accidentally introduce multithreading .. Any error != 'CONT' will shut down the backchannel to remote callee afterwards.
      Parameters:
      res -
      err -
    • isFinished

      public boolean isFinished()
      to be read at remote side in order to decide wether to stop e.g. iteration.
      Returns:
    • clone

      public Spore clone()
      Overrides:
      clone in class java.lang.Object