p2ps.imp.rendezvous
Class RendezvousServiceImp

java.lang.Object
  extended byp2ps.imp.rendezvous.RendezvousServiceImp
All Implemented Interfaces:
RendezvousService

public class RendezvousServiceImp
extends java.lang.Object
implements RendezvousService

An implementation of the rendezvous service interface. Actively attempts to create connections to rendezvous other services. The default number of connections required is defined in REQUIRED_RENDEZVOUS_CONNECTIONS.

If the rendezvous service is acting as a rendezvous itself, then it will accept connections from other rendezvous above the number it actively attempts to create. The defauly maximum number of connections (both those created and accepted) is defined in MAXIMUM_RENDEZVOUS_CONNECTIONS.

Also, if acting as a rendezvous, the service will accept connections from standard peers. The default maximum of peer connections accepted is defined in MAXIMUM_PEER_CONNECTIONS.

Version:
$Revision: 295 $
Author:
Ian Wang

Field Summary
static int MAXIMUM_PEER_CONNECTIONS
           
static int MAXIMUM_RENDEZVOUS_CONNECTIONS
           
static int REQUIRED_RENDEZVOUS_CONNECTIONS
           
 
Fields inherited from interface p2ps.rendezvous.RendezvousService
RENDEZVOUS_SERVICE
 
Constructor Summary
RendezvousServiceImp(Peer peer)
           
 
Method Summary
 void connectToRendezvous(RendezvousAdvertisement advert)
          Connects to a rendezvous service
 java.lang.String connectToRendezvous(java.net.URI uri)
          Connects to a rendezvous service.
 java.lang.String[] getConnectedRendezvous()
           
 java.net.URI[] getLocalURI()
           
 RendezvousAdvertisement getRendezvousAdvertisement()
           
 void init(java.net.URI[] localuri)
          Initialises the rendezvous service
 boolean isRendezvous()
           
 void send(Advertisement advert)
          Send an advertisement to all the rendezvous to which the peer is connected.
 void setRendezvous(boolean state)
          Toggles between the rendezvous service acting as a rendezvous and just acting as a standard peer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUIRED_RENDEZVOUS_CONNECTIONS

public static int REQUIRED_RENDEZVOUS_CONNECTIONS

MAXIMUM_RENDEZVOUS_CONNECTIONS

public static int MAXIMUM_RENDEZVOUS_CONNECTIONS

MAXIMUM_PEER_CONNECTIONS

public static int MAXIMUM_PEER_CONNECTIONS
Constructor Detail

RendezvousServiceImp

public RendezvousServiceImp(Peer peer)
Method Detail

init

public void init(java.net.URI[] localuri)
          throws InitializationException,
                 java.io.IOException
Initialises the rendezvous service

Specified by:
init in interface RendezvousService
Parameters:
localuri -
Throws:
InitializationException
java.io.IOException

isRendezvous

public boolean isRendezvous()
Specified by:
isRendezvous in interface RendezvousService
Returns:
true if acting as a rendezvous

setRendezvous

public void setRendezvous(boolean state)
                   throws InitializationException,
                          java.io.IOException
Toggles between the rendezvous service acting as a rendezvous and just acting as a standard peer.

Specified by:
setRendezvous in interface RendezvousService
Throws:
InitializationException
java.io.IOException

getLocalURI

public java.net.URI[] getLocalURI()
Specified by:
getLocalURI in interface RendezvousService
Returns:
the local uri for the rendezvous

getRendezvousAdvertisement

public RendezvousAdvertisement getRendezvousAdvertisement()
Specified by:
getRendezvousAdvertisement in interface RendezvousService
Returns:
an advert for the rendezvous service, or null if not acting as a rendezvous

getConnectedRendezvous

public java.lang.String[] getConnectedRendezvous()
Specified by:
getConnectedRendezvous in interface RendezvousService
Returns:
the peer ids of all the connected rendezvous

connectToRendezvous

public void connectToRendezvous(RendezvousAdvertisement advert)
                         throws InitializationException,
                                java.io.IOException
Connects to a rendezvous service

Specified by:
connectToRendezvous in interface RendezvousService
Throws:
InitializationException
java.io.IOException

connectToRendezvous

public java.lang.String connectToRendezvous(java.net.URI uri)
                                     throws InitializationException,
                                            java.io.IOException
Connects to a rendezvous service. A rendezvous advert is created for this service using a dummy peer id.

Specified by:
connectToRendezvous in interface RendezvousService
Returns:
the dummy id assigned to the rendezvous
Throws:
InitializationException
java.io.IOException

send

public void send(Advertisement advert)
          throws java.io.IOException
Send an advertisement to all the rendezvous to which the peer is connected.

Specified by:
send in interface RendezvousService
Throws:
java.io.IOException