Class LargeState

java.lang.Object
org.jgroups.tests.LargeState
All Implemented Interfaces:
Receiver

public class LargeState extends Object implements Receiver
Tests transfer of large states. Start first instance with -provider flag and -size flag (default = 1MB). The start second instance without these flags: it should acquire the state from the first instance. Possibly tracing should be turned on for FRAG to see the fragmentation taking place, e.g.:
 trace1=FRAG DEBUG STDOUT
 

Note that because fragmentation might generate a lot of small fragments at basically the same time (e.g. size1MB, FRAG.frag-size=4096 generates a lot of fragments), the send buffer of the unicast socket in UDP might be overloaded, causing it to drop some packets (default size is 8096 bytes). Therefore the send (and receive) buffers for the unicast socket have been increased (see ucast_send_buf_size and ucast_recv_buf_size below).

If we didn't do this, we would have some retransmission, slowing the state transfer down.

  • Field Details

    • channel

      JChannel channel
    • state

      byte[] state
    • rc

      boolean rc
    • props

      String props
    • start

      long start
    • stop

      long stop
    • provider

      boolean provider
    • provider_fails

      boolean provider_fails
    • requester_fails

      boolean requester_fails
    • size

      int size
    • total_received

      int total_received
    • delay

      long delay
  • Constructor Details

    • LargeState

      public LargeState()
  • Method Details

    • start

      public void start(boolean provider, int size, String props, boolean provider_fails, boolean requester_fails, long delay, String name) throws Exception
      Throws:
      Exception
    • createLargeState

      static byte[] createLargeState(int size)
    • 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
    • setState

      public void setState(InputStream istream) 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:
      istream - 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
    • getState

      public void getState(OutputStream ostream) 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:
      ostream - 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
    • main

      public static void main(String[] args)
    • help

      static void help()