Class PingPong

  • All Implemented Interfaces:
    Receiver

    public class PingPong
    extends java.lang.Object
    implements Receiver
    Simple protocol to test round trip times. Requests are [PING], responses are [PONG]. Start multiple instances and press to get the round trip times for all nodes in the cluster

    See PingPongDatagram for the same program using MulticastSockets

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) JChannel ch  
      (package private) java.util.List<Address> members  
      (package private) static byte PING  
      (package private) static byte[] PING_REQ  
      (package private) static byte PONG  
      (package private) static byte[] PONG_RSP  
      (package private) long start  
    • Constructor Summary

      Constructors 
      Constructor Description
      PingPong()  
    • Constructor Detail

      • PingPong

        public PingPong()
    • Method Detail

      • start

        public void start​(java.lang.String props,
                          java.lang.String name,
                          boolean unicast)
                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • 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
      • 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
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception