org.jgroups.protocols

## Class TP.ProtocolAdapter

- java.lang.Object
- - org.jgroups.stack.Protocol
  - - org.jgroups.protocols.TP.ProtocolAdapter

- All Implemented Interfaces:
    TP.ProbeHandler
  Enclosing class:
    TP

      public static class TP.ProtocolAdapter
      extends Protocol
      implements TP.ProbeHandler

  Used when the transport is shared (singleton_name is not null). Maintains the cluster name, local address and view

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected SocketFactory` | `socket_factory`

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

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

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TP.ProtocolAdapter(java.lang.String cluster_name, Address local_addr, short transport_id, Protocol up, Protocol down, java.lang.String pattern)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `down(Event evt)` An event is to be sent down the stack.
    `Address` | `getAddress()`
    `java.lang.String` | `getAddressAsString()`
    `java.lang.String` | `getAddressAsUUID()`
    `java.lang.String` | `getClusterName()`
    `java.util.Set<Address>` | `getMembers()`
    `java.lang.String` | `getName()` All protocol names have to be unique !
    `SocketFactory` | `getSocketFactory()` Returns the SocketFactory associated with this protocol, if overridden in a subclass, or passes the call down
    `ThreadFactory` | `getThreadFactory()` Supposed to be overwritten by subclasses.
    `short` | `getTransportName()`
    `java.util.Map<java.lang.String,java.lang.String>` | `handleProbe(java.lang.String... keys)` Handles a probe.
    `void` | `setSocketFactory(SocketFactory factory)` Sets a SocketFactory.
    `void` | `start()` This method is called on a `Channel.connect(String)`.
    `void` | `stop()` This method is called on a `Channel.disconnect()`.
    `java.lang.String[]` | `supportedKeys()` Returns a list of supported keys
    `java.lang.String` | `toString()`

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

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

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

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

- - ### Field Detail

    - #### socket_factory

          protected SocketFactory socket_factory

  - ### Constructor Detail

    - #### TP.ProtocolAdapter

          public TP.ProtocolAdapter(java.lang.String cluster_name,
                            Address local_addr,
                            short transport_id,
                            Protocol up,
                            Protocol down,
                            java.lang.String pattern)

  - ### Method Detail

    - #### getClusterName

          public java.lang.String getClusterName()

    - #### getAddress

          public Address getAddress()

    - #### getAddressAsString

          public java.lang.String getAddressAsString()

    - #### getAddressAsUUID

          public java.lang.String getAddressAsUUID()

    - #### getTransportName

          public short getTransportName()

    - #### getMembers

          public java.util.Set<Address> getMembers()

    - #### getThreadFactory

          public ThreadFactory getThreadFactory()

      Description copied from class: `Protocol`
      Supposed to be overwritten by subclasses. Usually the transport returns a valid non-null thread factory, but thread factories can also be created by individual protocols
      Overrides:
        `getThreadFactory` in class `Protocol`
      Returns:

    - #### getSocketFactory

          public SocketFactory getSocketFactory()

      Description copied from class: `Protocol`
      Returns the SocketFactory associated with this protocol, if overridden in a subclass, or passes the call down
      Overrides:
        `getSocketFactory` in class `Protocol`
      Returns:
        SocketFactory

    - #### setSocketFactory

          public void setSocketFactory(SocketFactory factory)

      Description copied from class: `Protocol`
      Sets a SocketFactory. Socket factories are typically provided by the transport (`TP`) or `TP.ProtocolAdapter`
      Overrides:
        `setSocketFactory` in class `Protocol`

    - #### start

          public void start()
                     throws java.lang.Exception

      Description copied from class: `Protocol`
      This method is called on a `Channel.connect(String)`. Starts work. Protocols are connected and queues are ready to receive events. Will be called from bottom to top. This call will replace the START and START_OK events.
      Overrides:
        `start` in class `Protocol`
      Throws:
        `java.lang.Exception` - Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, so `Channel.connect(String)` will throw an exception

    - #### 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 `Protocol`

    - #### down

          public java.lang.Object down(Event evt)

      Description copied from class: `Protocol`
      An event is to be sent down the stack. The layer may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the layer may need to add a header to it (or do nothing at all) before sending it down the stack using `down_prot.down()`. In case of a GET_ADDRESS event (which tries to retrieve the stack's address from one of the bottom layers), the layer may need to send a new response event back up the stack using `up_prot.up()`.
      Overrides:
        `down` in class `Protocol`

    - #### getName

          public java.lang.String getName()

      Description copied from class: `Protocol`
      All protocol names have to be unique !
      Overrides:
        `getName` in class `Protocol`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### handleProbe

          public java.util.Map<java.lang.String,java.lang.String> handleProbe(java.lang.String... keys)

      Description copied from interface: `TP.ProbeHandler`
      Handles a probe. For each key that is handled, the key and its result should be in the returned map.
      Specified by:
        `handleProbe` in interface `TP.ProbeHandler`
      Returns:
        Map. A map of keys and values. A null return value is permissible.

    - #### supportedKeys

          public java.lang.String[] supportedKeys()

      Description copied from interface: `TP.ProbeHandler`
      Returns a list of supported keys
      Specified by:
        `supportedKeys` in interface `TP.ProbeHandler`

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