Title: The JXTA Protocols
1The JXTA Protocols
- Di Valerio Carboni e Jonathan Sartori
- Corso di Sistemi Di Elaborazione a.a. 2003/2004
- Prof. G. Conte
2What is JXTA ?
Di Valerio Carboni e Jonathan Sartori
- JXTA is a set of open, generalized peer-to-peer
(P2P) protocols that allow any connected device
on the network to communicate and collaborate as
peers. - The JXTA protocols are independent of any
programming language,and multiple implementations
(called bindings in Project JXTA) exist for
different environments. - Now we will focus on the Java implementation of
JXTA
3A JXTA Overview
Di Valerio Carboni e Jonathan Sartori
4JXTA Protocols
Di Valerio Carboni e Jonathan Sartori
- Core Specification Protocols (lower level)
- Endpoint Routing Protocol (ERP)
- Peer Resolver Protocol (PRP)
- Standard Service Protocols (higher level)
- Peer Discovery Protocol (PDP)
- Peer Information Protocol (PIP)
- Pipe Binding Protocol (PBP)
- RendezVous Protocol (RVP)
- They allow to
- Discover resources through the whole JXTA
network - Get information about peers in the network
- Directly connect peers in order to exchange data
5Peer Discovery Protocol (PDP)
Di Valerio Carboni e Jonathan Sartori
- The Peer Discovery Protocol (PDP) is a protocol
designed to allow the discovery of advertisements
published by peers within a peer group. - Advertisements are used to describe and make
available a wide variety of resources, including
other peers, peer groups, pipes to exchange data,
and ordinary content. All resources must have an
advertisement associated with them. - In the Java reference implementation, the
DiscoveryService class allows peers associated
with a particular group to publish and discover
advertisements. - The NetPeerGroup,the default group that all peers
belong to, provides a discovery service to all
peers without individual peers having to write
their own service.
6PDP Overview
Di Valerio Carboni e Jonathan Sartori
7PDP Java Bindings
Di Valerio Carboni e Jonathan Sartori
interface
implements
1
extends
- PDP also has a DiscoveryListener Interface, who
calls the - discoveryEvent method, called to handle an event
from the Discovery Service.
8PDP principal methods
Di Valerio Carboni e Jonathan Sartori
From the DiscoveryServiceImpl class public
Enumeration  getLocalAdvertisements(String
attribute, String value) public int
getRemoteAdvertisements(String peerid,
String attribute,String value,                   Â
                   int threshold,
DiscoveryListener listener) public void
publish(Advertisement adv)   public void
publish(Advertisement adv,long tdv,
long tdvForOthers)  public void remotePublish(Ad
vertisement adv)
- Its an high-level protocol
- Its built on top of the Peer Resolver Protocol
and Enpoint Routing Protocol - May serve as a basis for more intelligent and
high-level discovery services
9Peer Resolver Protocol (PRP)
Di Valerio Carboni e Jonathan Sartori
- Has the purpose of laying out a framework for
generic query and response - communication between peers
- Does not define any type of peer searching or
discover service, but expects that - such a service would be built using the framework
- Its a Core Specification Protocol (lower-level),
so all the Standard Service - Protocols are the beneficiaries of this service
- For example, the discovery service relies on the
resolver service to handle the - exchange of the query and response messages
necessary for publishing and - Discovery
10PRP Overview
Di Valerio Carboni e Jonathan Sartori
11PRP Java Bindings
Di Valerio Carboni e Jonathan Sartori
The PRP has defined 3 interfaces
- The ResolverService does not process the queries,
nor does it not compose reponses. - Handling of queries, and composition of responses
are left up to the registered handlers. - Services that wish to handle queries, and
generate reponses must implement QueryHandler
12Endpoint Routing Protocol (ERP)
Di Valerio Carboni e Jonathan Sartori
- The Endpoint Routing Protocol (ERP) is a
protocol designed to allow a peer to discover a
possible route to send messages to another peer. - A route is a sequence of hops (i.e. edge peers
or rendez-vous). - Why does JXTA need ERP?JXTA provides a dynamic
network, where peers may enter or leave it
spontaneously. So, peers need a routing mechanism
that works even in situations in which the route
between them is constantly changing. - ERP is a core protocol, used by all others
higher level. User can ignore how does it work,
cause its functions are masked in a small set of
methods.
13ERP Overview
Di Valerio Carboni e Jonathan Sartori
Peer 2
1. Peer 1 wants to send a message to Peer 4, but
is unable to connect to it directly. Peer 1 sends
a Route Query Message to its known simple peers
and rendezvous peers to try to determine a route
to Peer 4.
2. Rendezvous Peer 1, knowing a route to Peer 4,
sends a Route Response Message to Peer 1.
Peer 1
Rendezvous Peer 1
3. Peer 1 receives the Route Response Message and
adds an Endpoint Router Message to the message it
wants to send to Peer 4. It sends this message to
the first Endpoint Address provided in the
returned route information.
5. Peer 4 receives the Endpoint Router Message
and determines that it is the final destination
for the message. The original message is
extracted and sent to the appropriate service.
Peer 3
Peer 4
4. Peer 3 receives the Endpoint Router Message,
determines the next peer in the route (reading
the message header) and sends the message on to
the next Endpoint Address in the route.
14ERP Java Bindings
Di Valerio Carboni e Jonathan Sartori
extends
- ERP has a main class who provides all possible
needed operations. This class - uses many other subclasses to perform lower
level operations. - Under all, there is the transport layer (such as
HTTP or TCP), which services - are used by ERP to physically send messages from
a peer to another.
15ERP principal methods
Di Valerio Carboni e Jonathan Sartori
public boolean ping(EndpointAddress
addr) public Messenger getMessenger(EndpointAddr
ess addr, Object hint) Users need only to know a
few methods, in fact all operations are
masked if (myEndpointService.ping(endpointAddress
)) Message message myEndpointService.newMessa
ge() message.setString("Message text", Hello
world!") EndpointMessenger messenger
myEndpointService.getMessenger(endpointAddress)
messenger.sendMessage(message)
When the getMessenger method is called,
EndpointRouter transparently determines route
information, either from cached information or
from sending Route Query Messages. Then the
method returns the appropriate messenger. The
implemented transport protocol used (such as
HTTP, TCP, etc.) provides the sendMessage method
who takes care about the physical transport.
16Rendez-Vous Protocol (RVP)
Di Valerio Carboni e Jonathan Sartori
- The Rendez-Vous Protocol (RVP) allows an edge
peer to propagate messages across the JXTA
network, beyond local subnetwork. - RVP provides a virtual broadcast function
independently of the underlying network
capabilities. - Before peers can use a rendezvous peer to
propagate messages, they must connect to it and
obtain a lease. - RVP allows rendez-vous to choose their own
policy about connection lease (implementing the
RendezVousManager interface). - RVP allows edge peers to customize their action
when a connection is established or cut off
(implementing RendezVousMonitor interface).
17RVP Overview
Di Valerio Carboni e Jonathan Sartori
2. Upon receiving the Lease Request Message, the
rendezvous peer decides whether to grant a
connection lease. If it does, it generates a
connection lease and sends a Lease Granted
Message to the requesting peer.
1. Peer 1 wants to use Rendezvous Peer 1 to
propagate a message within a peer group on its
behalf. It must first obtain a connection lease
with the rendezvous peer by sending a Lease
Request Message.
5. Peers receive the propagated message and route
the received message to the service specified by
the message's RendezVousPropagateMessage element.
7. Even peers not acting as rendezvous peers will
propagate messages. In this case, the propagation
will be limited to the local LAN segment.
4. When the rendezvous peer receives a message to
propagate, it checks that the source has already
been granted a lease. If it has, the rendezvous
peer propagates the message to each of the other
peers that currently hold a connection lease with
the rendezvous peer.
3. Peer 1 receives the Lease Granted Message. It
can now send messages to the rendezvous peer for
propagation to other peers.
6. A rendezvous peer might be a client of other
rendezvous peers. In this scenario, Rendezvous
Peer 1 is connected to Rendezvous Peer 2 and uses
Rendezvous Peer 2 to propagate the message to
peers that are also connected to Rendezvous Peer
2.
18RVP Java Bindings
Di Valerio Carboni e Jonathan Sartori
interface
implements
- Other interfaces net.jxta.rendezvous.RendezVous
Monitor (implemented by the - class net.jxta.impl.rendezvous.RdvMonitor, and
- net.jxta.rendezvous.RendezVousManager
(implemented by the class - net.jxta.impl.rendezvous.RdvManager)
- RVP has a RendezvousListener Interface too, who
handles the events - (such as connections, disconnections) fired by
the RendezVous Service.
19RVP principal methods
Di Valerio Carboni e Jonathan Sartori
public void  connectToRendezVous(
PeerAdvertisement adv )public void
 disconnectFromRendezVous( PeerID peerID
) public void propagateToNeighbors(
Message msg, String serviceName, String
serviceParam, int TTL, String prunePeer ) public
void propagateInGroup( Message msg,
String serviceName, String serviceParam,
int TTL, String prunePeer ) public void
propagate( Message msg, String serviceName,
String serviceParam, int TTL ) public void
propagate( Enumeration destPeerIDs,
Message msg, String serviceName, String
serviceParam, int TTL ) public
boolean addPropagateListener(String
ServiceNameParams, EndpointListener
listener) public boolean removePropagateListener(S
tring name, EndpointListener listener)
- Latest version of RVP introduced the concept of
Rendez-Vous Peer View (RPV). - R.V. publish local advertisements on one (or
more) R.V. peer, choosing them from their own
Peer View, applying a hash function. - R.V. who need an advertisement, use the same
hash function on their RPV and obtains a R.V. If
the RPV converges, the R.V. obtained will be the
right one. Otherwise a Limited Range Walk will
be performed.
20Peer Information Protocol (PIP)
Di Valerio Carboni e Jonathan Sartori
- The Peer Information Protocol (PIP) is a
protocol that allows a peer to monitor a remote
peer and obtain information on its current
status. - Reasons for monitoring
- make services more efficients
- in commercial applications, determine the usage
of a service and bill the service consumers for
their use. - Actually, the status informations provided are
limited to the uptime of the peer and the amount
of traffic processed in both incoming and
outgoing directions. - Peer Information Protocol is an optional JXTA
protocol. This means that a target peer could not
have implemented PIP service. In this case, all
queries addressed to him would not have a
response message.
21PIP Overview
Di Valerio Carboni e Jonathan Sartori
1. Peer 1 sends a Peer Info Query Message to a
specific peer, Simple Peer 2.
2. The Peer Info service on a simple peer
receiving the query searches and checks to see if
the querys targetPid matches the local peer ID.
If there is a match, the simple peer responds to
the source peer with a Peer Info Response
Message. Otherwise, the Peer Info service
propagate the query.
3. When the answer is notified, Peer 1 adds it to
his local cache.
22PIP Java Bindings
Di Valerio Carboni e Jonathan Sartori
interface
implements
1
extends
- PIP has a PeerInfoListener Interface too, who
allow the user to perform - customized action each time a PeerInfoEvent is
fired (by the PeerInfo Service) - to signal a new query is incoming.
23PIP principal methods
Di Valerio Carboni e Jonathan Sartori
public void  getRemotePeerInfo(ID peerID,
PeerInfoListener listener) public int
getRemotePeerInfo(IDÂ peerID) public
PeerInfoResponseMessage getPeerInfoService()Â pub
lic Enumeration getLocalPeerInfo(ID
peerID) public void flushAdverrtisement(ID
peerID) public void addPeerInfoListener(PeerInf
oListener listener) public boolean removePeerInfo
Listener(PeerInfoListener listener)
- Its the higher level and most work in progress
protocol - Its built on top of the PRP and RVP, which
services are used to send messages - PIPs functionality can be improved by the user
(using the listener to handle request element in
Query Messages)
24Pipe Binding Protocol (PBP)
Di Valerio Carboni e Jonathan Sartori
- It is based on assumption that a peer will
create an input pipe and want to have remote
peers connected to the pipe for information
transfer - The PBP defines a pipe, and specifies how the
pipe can be used for communication between peers
within a group. - The pipe is an abstract communication channel
built on an Internet transport protocol (such as
HTTP or TCP/IP). - It defines two ends of the pipe an input, or
receiving, end and the output, or sending, end. - It defines 3 type of pipe Unicast,
UnicastSecure Propagate type
25PBP Overview
Di Valerio Carboni e Jonathan Sartori
26PBP Java Bindings
Di Valerio Carboni e Jonathan Sartori
- The PBP is an high-level protocol, built on top
of the Endpoint Routing Protocol - It implements interfaces from the Peer Resolver
Protocol - Its one of the most used protocols of the JXTA
specification
27The future of JXTA
Di Valerio Carboni e Jonathan Sartori
- Implementation of new higher-level classes
- Substitution, correction and integration of old
methods - JXTA and Grid
28JXTA and Grid
Di Valerio Carboni e Jonathan Sartori
29Example creation of an input pipe
- public class CreatePipe
- public static void main(String args)
- Â Â Â try
- Â Â Â Â Â Â Â PeerGroup netPG PeerGroupFactory.newNetP
eerGroup() - Â Â Â Â Â Â Â catch (PeerGroupException e) /
Unable to initialize the Peer Group / - Â
- Â Â Â PipeService myPipeS netPG.getPipeService()
- Â Â Â DiscoveryService myDiscoveryS
netPG.getDiscoveryService() - Â
- Â Â Â PipeAdvertisement pipeAdv (PipeAdvertisement)
- Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â AdvertisementFactor
y.newAdvertisement(PipeAdvertisement.getAdvertisem
entType()) - Â Â Â pipeAdv.setName("JXTAJWGProjectPropagatePipe
") - Â Â Â pipeAdv.setType(PipeService.PropagateType)
- Â Â Â pipeAdv.setPipeID((ID) net.jxta.id.IDFactory.n
ewPipeID(netPG.getPeerGroupID())) - Â
- Â Â Â PipeMsgListener pipeListener new
PipeMsgListener() - Â Â Â Â Â Â Â public void pipeMsgEvent(PipeMsgEvent e)Â
- Â Â Â Â Â Â Â Â Â Â Â try
- Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Message msg e.getMessage()
30Example search of an input pipe and connection
of an output pipe
- public class FindPipe
- public static void main (String args) Â Â Â
- try
- Â Â Â Â Â Â Â PeerGroup netPG PeerGroupFactory.newNetP
eerGroup() - Â Â Â Â Â Â Â catch (PeerGroupException e) /
Unable to initialize the Peer Group / - Â
- Â Â Â PipeService myPipeS netPG.getPipeService()
- Â Â Â DiscoveryService myDiscoveryS
netPG.getDiscoveryService() - Â
- Â Â Â DiscoveryListener myDiscoveryLis new
DiscoveryListener - Â Â Â Â Â Â Â public void discoveryEvent(DiscoveryEvent
e) - Â Â Â Â Â Â Â Â Â Â Â DiscoveryResponseMsg myMessage
e.getResponse() - Â Â Â Â Â Â Â Â Â Â Â Enumeration enum myMessage.getRespon
ses() - Â Â Â Â Â Â Â Â Â Â Â try
- Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â PipeAdvertisement pipeAdv
(PipeAdvertisement)enum.nextElement() - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â OutputPipe myOutputPipe
myPipeS.createOutputPipe(pipeAdv,0) - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â catch(Exception ee)Â /
errore / - Â
- Â Â Â myDiscoveryS.getRemoteAdvertisement(null,
"Name", "JXTAJWGProjectPropagatePipe",1,
myDiscoveryListener)