org.jgroups.protocols

## Class PING

- java.lang.Object
- - org.jgroups.stack.Protocol
  - - org.jgroups.protocols.Discovery
    - - org.jgroups.protocols.PING

- Direct Known Subclasses:
    BPING, MPING

      public class PING
      extends Discovery

  The PING protocol layer retrieves the initial membership (used by the GMS when started by sending event FIND_INITIAL_MBRS down the stack). We do this by mcasting PING requests to an IP MCAST address. The responses should allow us to determine the coordinator whom we have to contact, e.g. in case we want to join the group. When we are a server (after having received the BECOME_SERVER event), we'll respond to PING requests with a PING response.
  Author:
    Bela Ban

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.jgroups.protocols.Discovery

      `Discovery.Responses`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Promise<java.lang.Boolean>` | `discovery_reception`

    - ### Fields inherited from class org.jgroups.protocols.Discovery

      `group_addr, local_addr, members, ping_responses, rank, timer, view`

    - ### Fields inherited from class org.jgroups.stack.Protocol

      `down_prot, ergonomics, id, log, name, stack, stats, up_prot`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PING()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `sendGetMembersRequest(java.lang.String cluster_name, Promise promise, boolean return_views_only)`
    `void` | `stop()` This method is called on a `Channel.disconnect()`.
    `java.lang.Object` | `up(Event evt)` An event was received from the layer below.
    `protected void` | `waitForDiscoveryRequestReception()`

    - ### Methods inherited from class org.jgroups.protocols.Discovery

      `discoveryRequestReceived, down, findAllMembers, findAllViews, findAllViewsAsString, findInitialMembers, findInitialMembers, findInitialMembersAsString, getNumberOfDiscoveryRequestsSent, getNumInitialMembers, getNumPingRequests, getTimeout, getView, handleConnect, handleDisconnect, init, makeView, providedUpServices, resetStats, setNumInitialMembers, setNumPingRequests, setTimeout, start`

    - ### Methods inherited from class org.jgroups.stack.Protocol

      `destroy, downThreadEnabled, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getId, getLevel, getName, getProperties, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getValue, isErgonomics, printStats, providedDownServices, requiredDownServices, requiredUpServices, setDownProtocol, setErgonomics, setId, setLevel, setProperties, setPropertiesInternal, setProperty, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled, upThreadEnabled`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### discovery_reception

          protected final Promise<java.lang.Boolean> discovery_reception

  - ### Constructor Detail

    - #### PING

          public PING()

  - ### Method Detail

    - #### stop

          public void stop()

      Description copied from class: `Protocol`
      This method is called on a `Channel.disconnect()`. Stops work (e.g. by closing multicast socket). Will be called from top to bottom. This means that at the time of the method invocation the neighbor protocol below is still working. This method will replace the STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that when this method is called all messages in the down queue will have been flushed
      Overrides:
        `stop` in class `Discovery`

    - #### sendGetMembersRequest

          public void sendGetMembersRequest(java.lang.String cluster_name,
                                   Promise promise,
                                   boolean return_views_only)
                                     throws java.lang.Exception

      Specified by:
        `sendGetMembersRequest` in class `Discovery`
      Throws:
        `java.lang.Exception`

    - #### up

          public java.lang.Object up(Event evt)

      Description copied from class: `Discovery`
      An event was received from the layer below. Usually the current layer will want to examine the event type and - depending on its type - perform some computation (e.g. removing headers from a MSG event type, or updating the internal membership list when receiving a VIEW_CHANGE event). Finally the event is either a) discarded, or b) an event is sent down the stack using `PassDown` or c) the event (or another event) is sent up the stack using `PassUp`.

      For the PING protocol, the Up operation does the following things. 1. If the event is a Event.MSG then PING will inspect the message header. If the header is null, PING simply passes up the event If the header is PingHeader.GET_MBRS_REQ then the PING protocol will PassDown a PingRequest message If the header is PingHeader.GET_MBRS_RSP we will add the message to the initial members vector and wake up any waiting threads. 2. If the event is Event.SET_LOCAL_ADDR we will simple set the local address of this protocol 3. For all other messages we simple pass it up to the protocol above
      Overrides:
        `up` in class `Discovery`
      Parameters:
        `evt` - - the event that has been sent from the layer below

    - #### waitForDiscoveryRequestReception

          protected void waitForDiscoveryRequestReception()

Copyright © 1998-2009 Bela Ban / Red Hat. All Rights Reserved.