Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jgroups.protocols.pbcast
Class PBCAST  view PBCAST download PBCAST.java

java.lang.Object
  extended byorg.jgroups.stack.Protocol
      extended byorg.jgroups.protocols.pbcast.PBCAST
All Implemented Interfaces:
java.lang.Runnable

public class PBCAST
extends org.jgroups.stack.Protocol
implements java.lang.Runnable

Implementation of probabilistic broadcast. Sends group messages via unreliable multicast. Gossips regularly to a random subset of group members to retransmit missing messages. Gossiping is used both for bringing all members to the same state (having received the same messages) and to garbage-collect messages seen by all members (gc is piggybacked in gossip messages). See DESIGN for more details.


Nested Class Summary
private static class PBCAST.GossipEntry
           
private  class PBCAST.GossipHandler
          Handles gossip and retransmission requests.
 
Field Summary
(package private)  long desired_avg_gossip
           
(package private)  java.util.Hashtable digest
           
(package private)  boolean dynamic
           
(package private)  int gc_lag
           
(package private)  PBCAST.GossipHandler gossip_handler
           
(package private)  long gossip_interval
           
(package private)  org.jgroups.util.List gossip_list
           
(package private)  org.jgroups.util.Queue gossip_queue
           
(package private)  long gossip_round
           
(package private)  java.lang.Thread gossip_thread
           
(package private)  java.util.Hashtable invalid_gossipers
           
(package private)  org.jgroups.Address local_addr
           
(package private)  int max_gossip_cache
           
(package private)  int max_invalid_gossips
           
(package private)  int max_queue
           
(package private)  boolean mcast_gossip
           
(package private)  java.util.Vector members
           
(package private)  boolean operational
           
(package private)  java.util.Vector seen_list
           
(package private)  long seqno
           
(package private)  boolean shun
           
(package private)  boolean skip_sleep
           
(package private)  double subset
           
 
Fields inherited from class org.jgroups.stack.Protocol
down_handler, down_prot, down_queue, down_thread, down_thread_prio, log, observer, props, stack, stats, trace, up_handler, up_prot, up_queue, up_thread, up_thread_prio, warn
 
Constructor Summary
PBCAST()
           
 
Method Summary
(package private)  long computeGossipInterval(int num_mbrs, double desired_avg_gossip)
          Computes the gossip_interval.
 void down(org.jgroups.Event evt)
          An event is to be sent down the stack.
(package private)  void garbageCollect(Digest d)
           
(package private)  Digest getDigest()
          Returns for each sender the 'highest seen' seqno from the digest.
 java.lang.String getName()
           
(package private)  long getRandom(long range)
           
(package private)  void handleGossip(Gossip gossip)
          MOST IMPORTANT METHOD IN THIS CLASS !! This guy really decides how a gossip reaches all members, or whether it will flood the network !
(package private)  void handleUpMessage(org.jgroups.Message m, PbcastHeader hdr)
          Ensures that FIFO is observed for all messages for a certain member.
(package private)  void handleXmitRequest(org.jgroups.Address requester, java.util.Hashtable xmit_reqs)
          Find the messages indicated in xmit_reqs and re-send them to requester
(package private)  void handleXmitRsp(org.jgroups.util.List xmit_msgs)
           
(package private)  java.lang.String printDigest()
           
(package private)  java.lang.String printIncomingMessageQueue()
           
(package private)  java.lang.String printXmitReqs(java.util.Hashtable xmit_reqs)
           
 java.util.Vector providedUpServices()
          List of events that are provided to layers above (they will be handled when sent down from above).
 void run()
          Gossip thread.
(package private)  void sendGossip()
          Send a gossip message with a message digest of the highest seqnos seen per sender to a subset of the current membership.
(package private)  void setDigest(Digest d)
          Sets (or resets) the contents of the 'digest' table.
 boolean setProperties(java.util.Properties props)
          Setup the Protocol instance acording to the configuration string
(package private)  void shunInvalidGossiper(org.jgroups.Address invalid_gossiper)
          If sender of gossip is not a member, send a NOT_MEMBER to sender (after n gossips received).
(package private)  void startGossipHandler()
           
(package private)  void startGossipThread()
           
 void stop()
          This method is called on a Channel.disconnect()>Channel.disconnect() 55 .
(package private)  void stopGossipHandler()
           
(package private)  void stopGossipThread()
           
 void up(org.jgroups.Event evt)
          An event was received from the layer below.
 
Methods inherited from class org.jgroups.stack.Protocol
destroy, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getDownQueue, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, init, isTrace, isWarn, passDown, passUp, printStats, providedDownServices, receiveDownEvent, receiveUpEvent, requiredDownServices, requiredUpServices, resetStats, setDownProtocol, setObserver, setPropertiesInternal, setProtocolStack, setTrace, setUpProtocol, setWarn, start, startDownHandler, startUpHandler, statsEnabled, stopInternal, upThreadEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

operational

boolean operational

seqno

long seqno

gossip_round

long gossip_round

local_addr

org.jgroups.Address local_addr

digest

final java.util.Hashtable digest

gossip_thread

java.lang.Thread gossip_thread

gossip_handler

PBCAST.GossipHandler gossip_handler

gossip_queue

final org.jgroups.util.Queue gossip_queue

max_queue

int max_queue

gossip_interval

long gossip_interval

subset

double subset

desired_avg_gossip

long desired_avg_gossip

members

final java.util.Vector members

gossip_list

final org.jgroups.util.List gossip_list

max_gossip_cache

int max_gossip_cache

gc_lag

int gc_lag

invalid_gossipers

final java.util.Hashtable invalid_gossipers

max_invalid_gossips

final int max_invalid_gossips
See Also:
Constant Field Values

seen_list

java.util.Vector seen_list

shun

boolean shun

dynamic

boolean dynamic

skip_sleep

boolean skip_sleep

mcast_gossip

boolean mcast_gossip
Constructor Detail

PBCAST

public PBCAST()
Method Detail

getName

public java.lang.String getName()

providedUpServices

public java.util.Vector providedUpServices()
Description copied from class: org.jgroups.stack.Protocol
List of events that are provided to layers above (they will be handled when sent down from above).


stop

public void stop()
Description copied from class: org.jgroups.stack.Protocol
This method is called on a Channel.disconnect()>Channel.disconnect() 55 . 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


up

public void up(org.jgroups.Event evt)
Description copied from class: org.jgroups.stack.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 passDown() or c) the event (or another event) is sent up the stack using passUp().


down

public void down(org.jgroups.Event evt)
Description copied from class: org.jgroups.stack.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 passDown(). 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 passUp().


run

public void run()
Gossip thread. Sends gossips containing a message digest every gossip_interval msecs

Specified by:
run in interface java.lang.Runnable

setProperties

public boolean setProperties(java.util.Properties props)
Setup the Protocol instance acording to the configuration string


handleUpMessage

void handleUpMessage(org.jgroups.Message m,
                     PbcastHeader hdr)
Ensures that FIFO is observed for all messages for a certain member. The NakReceiverWindow corresponding to a certain sender is looked up in a hashtable. Then, the message is added to the NakReceiverWindow. As many messages as possible are then removed from the table and passed up.


getDigest

Digest getDigest()
Returns for each sender the 'highest seen' seqno from the digest. Highest seen means the highest seqno without any gaps, e.g. if for a sender P the messages 2 3 4 6 7 were received, then only 2, 3 and 4 can be delivered, so 4 is the highest seen. 6 and 7 cannot because there 5 is missing. If there are no message, the highest seen seqno is -1.


setDigest

void setDigest(Digest d)
Sets (or resets) the contents of the 'digest' table. Its current messages will be deleted and the NakReceiverTables reset.


printDigest

java.lang.String printDigest()

printIncomingMessageQueue

java.lang.String printIncomingMessageQueue()

startGossipThread

void startGossipThread()

stopGossipThread

void stopGossipThread()

startGossipHandler

void startGossipHandler()

stopGossipHandler

void stopGossipHandler()

sendGossip

void sendGossip()
Send a gossip message with a message digest of the highest seqnos seen per sender to a subset of the current membership. Exclude self (I receive all mcasts sent by myself).


handleGossip

void handleGossip(Gossip gossip)
MOST IMPORTANT METHOD IN THIS CLASS !! This guy really decides how a gossip reaches all members, or whether it will flood the network !

Scrutinize the gossip received and request retransmission of messages that we haven't received yet. A gossip has a digest which carries for each sender the lowest and highest seqno seen. We check this range against our own digest and request retransmission of missing messages if needed.
See DESIGN for a description of this method


handleXmitRequest

void handleXmitRequest(org.jgroups.Address requester,
                       java.util.Hashtable xmit_reqs)
Find the messages indicated in xmit_reqs and re-send them to requester


handleXmitRsp

void handleXmitRsp(org.jgroups.util.List xmit_msgs)

printXmitReqs

java.lang.String printXmitReqs(java.util.Hashtable xmit_reqs)

garbageCollect

void garbageCollect(Digest d)

shunInvalidGossiper

void shunInvalidGossiper(org.jgroups.Address invalid_gossiper)
If sender of gossip is not a member, send a NOT_MEMBER to sender (after n gossips received). This will cause that member to leave the group and possibly re-join.


computeGossipInterval

long computeGossipInterval(int num_mbrs,
                           double desired_avg_gossip)
Computes the gossip_interval. See DESIGN for details


getRandom

long getRandom(long range)