Project JXTA

net.jxta.impl.rendezvous.rpv
Class PeerViewElement

java.lang.Object
  extended by net.jxta.impl.rendezvous.rpv.PeerViewDestination
      extended by net.jxta.impl.rendezvous.rpv.PeerViewElement
All Implemented Interfaces:
Comparable, EventListener, OutgoingMessageEventListener

public final class PeerViewElement
extends PeerViewDestination
implements OutgoingMessageEventListener

An element of the PeerView.

The destination address (peerID) is part of PeerViewDestination, which implements the comparable interface. That makes it possible to sort and create ordered lists of PeerViewElements, and to search these lists while knowing only a destination address.


Constructor Summary
PeerViewElement(EndpointService endpoint, RdvAdvertisement radv)
          Initialize from a RdvAdvertisement.
 
Method Summary
(package private)  long getLastUpdateTime()
          Return the time in absolute milliseconds at which we last updated this peer.
 RdvAdvertisement getRdvAdvertisement()
          Get the encapsulated Peer Advertisement.
(package private)  boolean isAlive()
          Return true if the remote peer is known to be alive, false otherwise.
(package private)  boolean isInPeerView()
           
 void messageSendFailed(OutgoingMessageEvent e)
          
 void messageSendSucceeded(OutgoingMessageEvent e)
          
 boolean sendMessage(Message msg, String serviceName, String serviceParam)
          Send a message to the peer which is represented by the current PeerViewElement.
(package private)  void setAlive(boolean live)
          Update the connection status based upon the result of the last message send.
(package private)  void setLastUpdateTime(long last)
          Sets the time in absolute milliseconds at which we last updated this peer.
(package private)  void setPeerView(PeerView pv)
          Sets the peerview
(package private)  RdvAdvertisement setRdvAdvertisement(RdvAdvertisement adv)
          Set the encapsulated Peer Advertisement.
 String toString()
          
 
Methods inherited from class net.jxta.impl.rendezvous.rpv.PeerViewDestination
compareTo, equals, getDestAddress, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PeerViewElement

PeerViewElement(EndpointService endpoint,
                RdvAdvertisement radv)
Initialize from a RdvAdvertisement.

Parameters:
rendezvous - The rendezvous the element works for.
adv - the RdvAdvertisement from which to initialize
Method Detail

toString

public String toString()

Overrides:
toString in class Object

messageSendSucceeded

public void messageSendSucceeded(OutgoingMessageEvent e)

Specified by:
messageSendSucceeded in interface OutgoingMessageEventListener

messageSendFailed

public void messageSendFailed(OutgoingMessageEvent e)

Specified by:
messageSendFailed in interface OutgoingMessageEventListener

isAlive

boolean isAlive()
Return true if the remote peer is known to be alive, false otherwise.

Returns:
Return true if the remote peer is known to be alive, false otherwise.

setAlive

void setAlive(boolean live)
Update the connection status based upon the result of the last message send.

We track the current dead-alive state and If we're in a peerview notify it of the transitions from alive to dead.


isInPeerView

boolean isInPeerView()

setPeerView

void setPeerView(PeerView pv)
Sets the peerview


getLastUpdateTime

long getLastUpdateTime()
Return the time in absolute milliseconds at which we last updated this peer.


setLastUpdateTime

void setLastUpdateTime(long last)
Sets the time in absolute milliseconds at which we last updated this peer.


sendMessage

public boolean sendMessage(Message msg,
                           String serviceName,
                           String serviceParam)
Send a message to the peer which is represented by the current PeerViewElement.

Parameters:
msg - the message to send
serviceName - the service name on the destination peer to which the message will be demultiplexed
serviceParam - the service param on the destination peer to which the message will be demultiplexed
Returns:
true if the message was successfully handed off to the endpoint for delivery, false otherwise

getRdvAdvertisement

public RdvAdvertisement getRdvAdvertisement()
Get the encapsulated Peer Advertisement.

Returns:
the Advertisement of the Peer represented by this object

setRdvAdvertisement

RdvAdvertisement setRdvAdvertisement(RdvAdvertisement adv)
Set the encapsulated Peer Advertisement.

Parameters:
adv - is the RdvAdvertisement to be set.
Returns:
RdvAdvertisement the old Advertisement of the Peer represented by this object

JXTA J2SE