org.jgroups.protocols
Class TP.ProtocolAdapter

java.lang.Object
  extended by org.jgroups.stack.Protocol
      extended by org.jgroups.protocols.TP.ProtocolAdapter
All Implemented Interfaces:
DiagnosticsHandler.ProbeHandler
Enclosing class:
TP

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

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


Field Summary
protected  SocketFactory socket_factory
           
 
Fields inherited from class org.jgroups.stack.Protocol
down_prot, ergonomics, id, log, name, stack, stats, up_prot
 
Constructor Summary
TP.ProtocolAdapter(java.lang.String cluster_name, Address local_addr, short transport_id, Protocol up, Protocol down, java.lang.String pattern)
           
 
Method Summary
 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()
           
 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()
           
 java.lang.Object up(Event evt)
          An event was received from the layer below.
 
Methods inherited from class org.jgroups.stack.Protocol
destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getProtocolStack, getTransport, getUpProtocol, getUpServices, getValue, init, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setUpProtocol, setValue, setValues, statsEnabled
 
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

up

public java.lang.Object up(Event evt)
Description copied from class: Protocol
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 down_prot.down() or c) the event (or another event) is sent up the stack using up_prot.up().

Overrides:
up in class Protocol

getName

public java.lang.String getName()
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: DiagnosticsHandler.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 DiagnosticsHandler.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: DiagnosticsHandler.ProbeHandler
Returns a list of supported keys

Specified by:
supportedKeys in interface DiagnosticsHandler.ProbeHandler


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