Class MyReceiver<T>

java.lang.Object
org.jgroups.util.MyReceiver<T>
All Implemented Interfaces:
Closeable, AutoCloseable, Receiver

public class MyReceiver<T> extends Object implements Receiver, Closeable
Generic receiver for a JChannel
Since:
3.3
  • Field Details

    • list

      protected final List<T> list
    • name

      protected String name
    • verbose

      protected boolean verbose
    • raw_msgs

      protected boolean raw_msgs
    • state

      protected final Map<String,String> state
  • Constructor Details

    • MyReceiver

      public MyReceiver()
  • Method Details

    • receive

      public void receive(Message msg)
      Description copied from interface: Receiver
      Called when a message is received.
      Specified by:
      receive in interface Receiver
      Parameters:
      msg - The message
    • viewAccepted

      public void viewAccepted(View new_view)
      Description copied from interface: Receiver
      Called when a change in membership has occurred. No long running actions, sending of messages or anything that could block should be done in this callback. If some long running action needs to be performed, it should be done in a separate thread.

      Note that on reception of the first view (a new member just joined), the channel will not yet be in the connected state. This only happens when JChannel.connect(String) returns.

      Specified by:
      viewAccepted in interface Receiver
    • getState

      public void getState(OutputStream out) throws Exception
      Description copied from interface: Receiver
      Allows an application to write the state to an OutputStream. After the state has been written, the OutputStream doesn't need to be closed as stream closing is automatically done when a calling thread returns from this callback.
      Specified by:
      getState in interface Receiver
      Parameters:
      out - The OutputStream
      Throws:
      Exception - If the streaming fails, any exceptions should be thrown so that the state requester can re-throw them and let the caller know what happened
    • setState

      public void setState(InputStream input) throws Exception
      Description copied from interface: Receiver
      Allows an application to read the state from an InputStream. After the state has been read, the InputStream doesn't need to be closed as stream closing is automatically done when a calling thread returns from this callback.
      Specified by:
      setState in interface Receiver
      Parameters:
      input - The InputStream
      Throws:
      Exception - If the streaming fails, any exceptions should be thrown so that the state requester can catch them and thus know what happened
    • rawMsgs

      public MyReceiver<T> rawMsgs(boolean flag)
    • list

      public List<T> list()
    • list

      public List<String> list(Function<T,String> f)
    • state

      public Map<String,String> state()
    • verbose

      public MyReceiver<T> verbose(boolean flag)
    • name

      public String name()
    • name

      public MyReceiver<T> name(String name)
    • reset

      public MyReceiver<T> reset()
    • size

      public int size()
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object