Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ACE_RMCast_Membership Class Reference

Track peer membership. More...

#include <RMCast_Membership.h>

Inheritance diagram for ACE_RMCast_Membership:

Inheritance graph
[legend]
Collaboration diagram for ACE_RMCast_Membership:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_RMCast_Membership (void)
 Constructor. More...

virtual ~ACE_RMCast_Membership (void)
 Destructor. More...

int has_members (void)
 Return 1 if there are still members in the group. More...

virtual int ack (ACE_RMCast::Ack &)
 Receive an process an Ack message. More...

virtual int join (ACE_RMCast::Join &)
 Add a new member to the collection, using the <source> field in the Join message. More...

virtual int leave (ACE_RMCast::Leave &)
 Remove a member from the collection, using the <source> field in the Join message. More...


Protected Types

typedef ACE_Unbounded_Set<
ACE_RMCast_Proxy * > 
Proxy_Collection
 Use an unbounded set to maintain the collection of proxies. More...

typedef ACE_Unbounded_Set_Iterator<
ACE_RMCast_Proxy * > 
Proxy_Iterator

Protected Attributes

Proxy_Collection proxies_
 The collection of proxies. More...

ACE_UINT32 next_expected_
 The smallest value of
Parameters:
next_expected  for all the proxies.
More...


ACE_UINT32 highest_received_
 The highest value of
Parameters:
highest_received  for all the proxies.
More...


ACE_SYNCH_MUTEX mutex_
 Synchronization. More...


Private Methods

int generate_ack (ACE_RMCast_Proxy *proxy)
 Generate an Ack message, normally due to changes in the collection, such as new proxys joining or leaving. More...

int compute_ack_i (ACE_RMCast_Proxy *source, ACE_RMCast::Ack &next_ack)
 Compute an Ack message to propagate to the upper layers. More...


Detailed Description

Track peer membership.

Reliable senders of events need to know exactly how many peers are receiving the events, and how many events has each peer received so far. This class uses the Join, Leave and Ack messages to build that information, it also summarizes the Ack events and propagate only the global info to the upper layer.

Definition at line 40 of file RMCast_Membership.h.


Member Typedef Documentation

typedef ACE_Unbounded_Set<ACE_RMCast_Proxy*> ACE_RMCast_Membership::Proxy_Collection [protected]
 

Use an unbounded set to maintain the collection of proxies.

Definition at line 82 of file RMCast_Membership.h.

typedef ACE_Unbounded_Set_Iterator<ACE_RMCast_Proxy*> ACE_RMCast_Membership::Proxy_Iterator [protected]
 

Definition at line 83 of file RMCast_Membership.h.


Constructor & Destructor Documentation

ACE_INLINE ACE_RMCast_Membership::ACE_RMCast_Membership void   
 

Constructor.

Definition at line 4 of file RMCast_Membership.i.

00005   : next_expected_ (0)
00006   , highest_received_ (0)
00007 {
00008 }

ACE_RMCast_Membership::~ACE_RMCast_Membership void    [virtual]
 

Destructor.

Definition at line 14 of file RMCast_Membership.cpp.

00015 {
00016 }


Member Function Documentation

int ACE_RMCast_Membership::ack ACE_RMCast::Ack   [virtual]
 

Receive an process an Ack message.

After receiving the Ack message we find out what is the lowest sequence number received in order among all the acks received by the proxies in the collection. We also find out what is the highest sequence number received by any proxy. We only propagate that information back to the upper layer, and then only if there are any news since the last Ack.

Reimplemented from ACE_RMCast_Module.

Definition at line 29 of file RMCast_Membership.cpp.

References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, ACE_RMCast_Module::ack, compute_ack_i, ACE_RMCast::Ack::next_expected, next_expected_, and ACE_RMCast::Ack::source.

00030 {
00031   //ACE_DEBUG ((LM_DEBUG, "ACE_RMCast_Membership::ack (%d:%d)\n",
00032   //            ack.next_expected, ack.highest_received));
00033 
00034   ACE_RMCast::Ack next_ack;
00035   {
00036     ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, -1);
00037     if (ack.next_expected < this->next_expected_)
00038       {
00039         // @@ This violates an invariant of the class, shouldn't
00040         // happen...
00041         //ACE_DEBUG ((LM_DEBUG, "ACE_RMCast_Membership::ack[2]\n"));
00042         return 0;
00043       }
00044     else if (ack.next_expected == this->next_expected_)
00045       {
00046         // Nothing new, just continue....
00047         //ACE_DEBUG ((LM_DEBUG, "ACE_RMCast_Membership::ack[3]\n"));
00048         return 0;
00049       }
00050 
00051     int r = this->compute_ack_i (ack.source, next_ack);
00052     if (r < 0)
00053       return r;
00054     if (r == 1)
00055       return 0;
00056   }
00057 
00058   //ACE_DEBUG ((LM_DEBUG, "ACE_RMCast_Membership::ack[4] (%d:%d)\n",
00059   //            next_ack.next_expected, next_ack.highest_received));
00060 
00061   return this->ACE_RMCast_Module::ack (next_ack);
00062 }

int ACE_RMCast_Membership::compute_ack_i ACE_RMCast_Proxy   source,
ACE_RMCast::Ack   next_ack
[private]
 

Compute an Ack message to propagate to the upper layers.

Definition at line 119 of file RMCast_Membership.cpp.

References ACE_DEBUG, ACE_Unbounded_Set< ACE_RMCast_Proxy * >::begin, ACE_Unbounded_Set< ACE_RMCast_Proxy * >::end, ACE_RMCast::Ack::highest_received, highest_received_, LM_DEBUG, ACE_RMCast::Ack::next_expected, next_expected_, proxies_, and ACE_RMCast::Ack::source.

Referenced by ack, and generate_ack.

00121 {
00122   Proxy_Iterator end = this->proxies_.end ();
00123   Proxy_Iterator i = this->proxies_.begin ();
00124   if (i == end)
00125     return 1;
00126 
00127   //ACE_DEBUG ((LM_DEBUG,
00128   //            "RMCast_Membership::generate_ack[1] - %d -> (%d:%d)\n",
00129   //            long(*i),
00130   //            (*i)->next_expected (),
00131   //            (*i)->highest_received ()));
00132 
00133   ACE_UINT32 next_expected = (*i)->next_expected ();
00134   ACE_UINT32 highest_received = (*i)->highest_received ();
00135   ++i;
00136 
00137   for (; i != end; ++i)
00138     {
00139       //    ACE_DEBUG ((LM_DEBUG,
00140       //            "RMCast_Membership::generate_ack[2] - %d -> (%d:%d)\n",
00141       //            long(*i),
00142       //            (*i)->next_expected (),
00143       //            (*i)->highest_received ()));
00144 
00145       ACE_UINT32 s = (*i)->next_expected ();
00146       if (s < next_expected)
00147         next_expected = s;
00148       ACE_UINT32 r = (*i)->highest_received ();
00149       if (r > highest_received)
00150         highest_received = r;
00151     }
00152 #if 0
00153   // @@TODO: this is an important feature, disabled until it is
00154   // fully debugged
00155   if (this->next_expected_ >= next_expected
00156       || this->highest_received_ >= highest_received)
00157     {
00158       // No change....
00159       ACE_DEBUG ((LM_DEBUG,
00160                   "RMCast_Membership::generate_ack[3]\n"));
00161       return 1;
00162     }
00163 #endif /* 0 */
00164   this->next_expected_ = next_expected;
00165   this->highest_received_ = highest_received;
00166   next_ack.source = source;
00167   next_ack.next_expected = this->next_expected_;
00168   next_ack.highest_received = this->highest_received_;
00169 
00170   //ACE_DEBUG ((LM_DEBUG,
00171   //            "RMCast_Membership::generate_ack[4] - (%d:%d)\n",
00172   //            next_ack.next_expected,
00173   //            next_ack.highest_received));
00174 
00175   return 0;
00176 }

int ACE_RMCast_Membership::generate_ack ACE_RMCast_Proxy   proxy [private]
 

Generate an Ack message, normally due to changes in the collection, such as new proxys joining or leaving.

Definition at line 100 of file RMCast_Membership.cpp.

References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, ACE_RMCast_Module::ack, and compute_ack_i.

Referenced by join, and leave.

00101 {
00102   ACE_RMCast::Ack next_ack;
00103   {
00104     ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, -1);
00105     int r = this->compute_ack_i (proxy, next_ack);
00106     if (r < 0)
00107       return r;
00108     if (r == 1)
00109       return 0;
00110   }
00111 
00112   //ACE_DEBUG ((LM_DEBUG, "ACE_RMCast_Membership::ack[6] (%d:%d)\n",
00113   //            next_ack.next_expected, next_ack.highest_received));
00114 
00115   return this->ACE_RMCast_Module::ack (next_ack);
00116 }

int ACE_RMCast_Membership::has_members void   
 

Return 1 if there are still members in the group.

Definition at line 19 of file RMCast_Membership.cpp.

References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, ACE_Unbounded_Set< ACE_RMCast_Proxy * >::begin, ACE_Unbounded_Set< ACE_RMCast_Proxy * >::end, and proxies_.

Referenced by ACE_RMCast_UDP_Reliable_Sender::has_members.

00020 {
00021   ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, -1);
00022 
00023   Proxy_Iterator end = this->proxies_.end ();
00024   Proxy_Iterator i = this->proxies_.begin ();
00025   return (i != end);
00026 }

int ACE_RMCast_Membership::join ACE_RMCast::Join   [virtual]
 

Add a new member to the collection, using the <source> field in the Join message.

Reimplemented from ACE_RMCast_Module.

Definition at line 65 of file RMCast_Membership.cpp.

References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, generate_ack, ACE_Unbounded_Set< ACE_RMCast_Proxy * >::insert, ACE_RMCast_Module::join, proxies_, and ACE_RMCast::Join::source.

00066 {
00067   if (join.source == 0)
00068     return 0;
00069 
00070   {
00071     //  ACE_DEBUG ((LM_DEBUG,
00072     //            "RMCast_Membership::join - %d\n",
00073     //            long(join.source)));
00074 
00075     ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, -1);
00076     if (this->proxies_.insert (join.source) == -1)
00077       return -1;
00078   }
00079   (void) this->generate_ack (join.source);
00080 
00081   return this->ACE_RMCast_Module::join (join);
00082 }

int ACE_RMCast_Membership::leave ACE_RMCast::Leave   [virtual]
 

Remove a member from the collection, using the <source> field in the Join message.

Reimplemented from ACE_RMCast_Module.

Definition at line 85 of file RMCast_Membership.cpp.

References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, generate_ack, ACE_RMCast_Module::leave, proxies_, ACE_Unbounded_Set< ACE_RMCast_Proxy * >::remove, and ACE_RMCast::Leave::source.

00086 {
00087   if (leave.source == 0)
00088     return 0;
00089 
00090   {
00091     ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, -1);
00092     (void) this->proxies_.remove (leave.source);
00093   }
00094   (void) this->generate_ack (leave.source);
00095 
00096   return this->ACE_RMCast_Module::leave (leave);
00097 }


Member Data Documentation

ACE_UINT32 ACE_RMCast_Membership::highest_received_ [protected]
 

The highest value of

Parameters:
highest_received  for all the proxies.

Definition at line 92 of file RMCast_Membership.h.

Referenced by compute_ack_i.

ACE_SYNCH_MUTEX ACE_RMCast_Membership::mutex_ [protected]
 

Synchronization.

Definition at line 95 of file RMCast_Membership.h.

ACE_UINT32 ACE_RMCast_Membership::next_expected_ [protected]
 

The smallest value of

Parameters:
next_expected  for all the proxies.

Definition at line 89 of file RMCast_Membership.h.

Referenced by ack, and compute_ack_i.

Proxy_Collection ACE_RMCast_Membership::proxies_ [protected]
 

The collection of proxies.

Definition at line 86 of file RMCast_Membership.h.

Referenced by compute_ack_i, has_members, join, and leave.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 13:14:03 2003 for ACE_RMCast by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002