next up previous contents
Next: ViewId Up: Channel and related classes Previous: Message   Contents


View

A View (View) is a list of the current members of a group. It consists of a ViewId, which uniquely identifies the view (see below), and a list of members. Views are set in a channel automatically by the underlying protocol stack whenever a new member joins or an existing one leaves (or crashes). All members of a group see the same sequence of views.

Note that there is a comparison function which orders all the members of a group in the same way. Usually, the first member of the list is the coordinator (the one who emits new views). Thus, whenever the membership changes, every member can determine the coordinator easily and without having to contact other members.

The code below shows how to send a (unicast) message to the first member of a view (error checking code omitted):

  View    myview=channel.getView();
  Address first=myview.getMembers().first();
  Message msg=new Message(first, null, "Hello world");
  channel.send(msg);

Whenever an application is notified that a new view has been installed (e.g. by MembershipListener.viewAccepted() or Channel.receive()), the view is already set in the channel. For example, calling Channel.getView() in a viewAccepted() callback would return the same view (or possibly the next one in case there has already been a new view !).



Subsections
next up previous contents
Next: ViewId Up: Channel and related classes Previous: Message   Contents
Bela Ban 2002-11-16