Class LargeState

  • All Implemented Interfaces:
    Receiver

    public class LargeState
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      (package private) JChannel channel  
      (package private) long delay  
      (package private) java.lang.String props  
      (package private) boolean provider  
      (package private) boolean provider_fails  
      (package private) boolean rc  
      (package private) boolean requester_fails  
      (package private) int size  
      (package private) long start  
      (package private) byte[] state  
      (package private) long stop  
      (package private) int total_received  
    • Constructor Summary

      Constructors 
      Constructor Description
      LargeState()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static byte[] createLargeState​(int size)  
      void getState​(java.io.OutputStream ostream)
      Allows an application to write the state to an OutputStream.
      (package private) static void help()  
      static void main​(java.lang.String[] args)  
      void receive​(Message msg)
      Called when a message is received.
      void setState​(java.io.InputStream istream)
      Allows an application to read the state from an InputStream.
      void start​(boolean provider, int size, java.lang.String props, boolean provider_fails, boolean requester_fails, long delay, java.lang.String name)  
      void viewAccepted​(View new_view)
      Called when a change in membership has occurred.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • state

        byte[] state
      • rc

        boolean rc
      • props

        java.lang.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 Detail

      • LargeState

        public LargeState()
    • Method Detail

      • start

        public void start​(boolean provider,
                          int size,
                          java.lang.String props,
                          boolean provider_fails,
                          boolean requester_fails,
                          long delay,
                          java.lang.String name)
                   throws java.lang.Exception
        Throws:
        java.lang.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​(java.io.InputStream istream)
                      throws java.lang.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:
        java.lang.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​(java.io.OutputStream ostream)
                      throws java.lang.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:
        java.lang.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​(java.lang.String[] args)
      • help

        static void help()