public class JxtaNetworkManager extends AbstractNetworkManager implements net.jxta.rendezvous.RendezvousListener
TODO:REVISIT FOR REFACTORING AND ADDED REQUIRMENTS. TODO: WHEN SPECIFYING INSTANCENAME IN EACH METHOD, IS IT THE INTENTION THAT THE CONSUMING APP COULD POTENTIALLY TODO: PROVIDE DIFFERENT INSTANCE NAMES AT DIFFERENT TIMES DURING A GIVEN LIFETIME OF THE APP? WHAT IMPACT WOULD THERE TODO:BE IF WE REMOVE INSTANCENAME FROM THE PARAMETERS OF THESE METHODS AND BASE INSTANCE NAME FROM THE CONSTRUCTOR'S TODO: CONSTRUCTION FROM PROPERTIES OBJECT?
localPeerIDTCP_TRANSPORT, UDP_TRANSPORT| Constructor and Description |
|---|
JxtaNetworkManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
addRemotePeer(PeerID id)
Add the
peerID to this network manager |
protected void |
afterDispatchingMessage(MessageEvent messageEvent,
Map piggyback)
After executing
MessageListener.receiveMessageEvent(MessageEvent)} callback, this method will be called |
protected void |
beforeDispatchingMessage(MessageEvent messageEvent,
Map piggyback)
Before executing
MessageListener.receiveMessageEvent(MessageEvent)} callback, this method will be called |
boolean |
broadcast(Message message)
Broadcasts or Multicasts the given
Message to all members |
void |
cacheRoute(net.jxta.protocol.RouteAdvertisement route)
Caches a route for an instance
|
net.jxta.pipe.PipeID |
getAppServicePipeID()
Returns the Pipe ID that will be used for application layer to
send and receive messages.
|
net.jxta.protocol.RouteAdvertisement |
getCachedRoute(net.jxta.peer.PeerID peerid)
returns the cached route if any, null otherwise
|
net.jxta.pipe.PipeID |
getHealthPipeID()
Returns the HealthMonitor PipeID, used for health monitoring purposes.
|
File |
getHome()
Returns the home directory.
|
net.jxta.peergroup.PeerGroupID |
getInfraPeerGroupID()
Contructs and returns the Infrastructure PeerGroupID for the ClusterManager.
|
String |
getInstanceName()
Returns this instance name.
|
net.jxta.peer.PeerID |
getJxtaPeerID(String instanceName) |
net.jxta.pipe.PipeID |
getMasterPipeID()
Returns the MasterNode protocol PipeID.
|
MessageSender |
getMessageSender(int transport)
Returns a
MessageSender corresponding with transport type |
MulticastMessageSender |
getMulticastMessageSender()
Returns a
MulticastMessageSender |
net.jxta.peergroup.PeerGroup |
getNetPeerGroup()
Returns the netPeerGroup instance for this Cluster.
|
net.jxta.peergroup.PeerGroupID |
getPeerGroupID(String groupName)
Given a instance name, it returns a name encoded PeerID to for binding to specific instance.
|
net.jxta.peer.PeerID |
getPeerID()
Gets this instance's PeerID
|
PeerID |
getPeerID(String instanceName)
Given a instance name, it returns a name encoded PeerID to for binding to specific instance.
|
net.jxta.protocol.PipeAdvertisement |
getPipeAdvertisement(String instanceName)
Creates a JxtaBiDiPipe pipe advertisement with a SHA1 encoded instance name pipe ID.
|
net.jxta.pipe.PipeID |
getPipeID()
Returns this instance name encoded PipeID.
|
net.jxta.pipe.PipeID |
getPipeID(String instanceName)
Given a instance name, it returns a name encoded PipeID to for binding JxtaBiDiPipes.
|
net.jxta.pipe.PipeID |
getSessionQueryPipeID()
Returns the SessionQeuryPipe ID.
|
net.jxta.protocol.PipeAdvertisement |
getSocketAdvertisement(String instanceName)
Creates a JxtaSocket pipe advertisement with a SHA1 encoded instance name pipe ID.
|
net.jxta.pipe.PipeID |
getSocketID(String instanceName)
Given a instance name, it returns a name encoded PipeID to for binding JxtaSockets.
|
void |
initialize(String groupName,
String instanceName,
Map properties)
NetworkManager provides a simple interface to configuring and managing the lifecycle
of the JXTA platform.
|
boolean |
isConnected(PeerID peerID)
Check whether the suspicious peer is alive or not
This API is mainly used in
HealthMonitor in order to determine the failure member |
void |
removePeerID(PeerID peerID)
Removes the
peerID from this network manager |
void |
rendezvousEvent(net.jxta.rendezvous.RendezvousEvent event) |
boolean |
send(PeerID peerID,
Message message)
Sends the given
Message to the destination |
void |
start()
Creates and starts the JXTA NetPeerGroup using a platform configuration
template.
|
void |
stop()
Stops the NetworkManager and the JXTA platform.
|
boolean |
waitForRendezvousConnection(long timeout)
Blocks until a connection to rendezvous node occurs.
|
addMessageListener, getInstance, getLocalPeerID, getLogger, receiveMessage, removeMessageListenerpublic void initialize(String groupName, String instanceName, Map properties) throws IOException
initialize in interface NetworkManagerinitialize in class AbstractNetworkManagergroupName - Group Name, a logical group name that this peer is part of.instanceName - Instance Name, a logical name for this peer.properties - a Properties object that would contain every configuration
element that the employing application wants to specify values for. The
keys in this object must correspond to the constants specified in the
JxtaConfigConstants enum.IOException - if an unexpected error occurspublic net.jxta.pipe.PipeID getPipeID(String instanceName)
instanceName - instance namepublic net.jxta.pipe.PipeID getSocketID(String instanceName)
instanceName - instance name valuepublic PeerID getPeerID(String instanceName)
getPeerID in interface NetworkManagerinstanceName - instance name valuepublic void removePeerID(PeerID peerID)
NetworkManagerpeerID from this network managerremovePeerID in interface NetworkManagerpeerID - the peer Idpublic boolean isConnected(PeerID peerID)
NetworkManagerHealthMonitor in order to determine the failure memberisConnected in interface NetworkManagerpeerID - peer idpublic net.jxta.peer.PeerID getJxtaPeerID(String instanceName)
public net.jxta.peergroup.PeerGroupID getPeerGroupID(String groupName)
groupName - instance name valuepublic net.jxta.pipe.PipeID getHealthPipeID()
public net.jxta.pipe.PipeID getMasterPipeID()
public net.jxta.pipe.PipeID getSessionQueryPipeID()
public net.jxta.pipe.PipeID getAppServicePipeID()
public net.jxta.protocol.PipeAdvertisement getSocketAdvertisement(String instanceName)
instanceName - instance namepublic net.jxta.protocol.PipeAdvertisement getPipeAdvertisement(String instanceName)
instanceName - instance namepublic net.jxta.peergroup.PeerGroupID getInfraPeerGroupID()
public void start()
throws IOException
start in interface NetworkManagerstart in interface ShoalMessageSenderstart in class AbstractNetworkManagerIOException - if an io error occurs during creation of the cache directorypublic void stop()
stop in interface NetworkManagerstop in interface ShoalMessageSenderstop in class AbstractNetworkManagerpublic boolean send(PeerID peerID, Message message) throws IOException
MessageSenderMessage to the destinationsend in interface MessageSenderpeerID - the destination PeerID. null is not allowedmessage - a message which is sent to the peerIOException - if I/O error occurs or given parameters are not validpublic boolean broadcast(Message message) throws IOException
MulticastMessageSenderMessage to all membersbroadcast in interface MulticastMessageSendermessage - a message which is sent to all membersIOException - if I/O error occurs or given parameters are not validprotected void beforeDispatchingMessage(MessageEvent messageEvent, Map piggyback)
AbstractNetworkManagerMessageListener.receiveMessageEvent(MessageEvent)} callback, this method will be calledbeforeDispatchingMessage in class AbstractNetworkManagermessageEvent - a received MessageEventpiggyback - piggybackprotected void afterDispatchingMessage(MessageEvent messageEvent, Map piggyback)
AbstractNetworkManagerMessageListener.receiveMessageEvent(MessageEvent)} callback, this method will be calledafterDispatchingMessage in class AbstractNetworkManagermessageEvent - a received MessageEventpiggyback - piggybackpublic net.jxta.peergroup.PeerGroup getNetPeerGroup()
public boolean waitForRendezvousConnection(long timeout)
timeout - timeout in millisecondspublic void rendezvousEvent(net.jxta.rendezvous.RendezvousEvent event)
rendezvousEvent in interface net.jxta.rendezvous.RendezvousListenerpublic net.jxta.peer.PeerID getPeerID()
public net.jxta.pipe.PipeID getPipeID()
public String getInstanceName()
public File getHome()
public void cacheRoute(net.jxta.protocol.RouteAdvertisement route)
route - the route advertisementpublic net.jxta.protocol.RouteAdvertisement getCachedRoute(net.jxta.peer.PeerID peerid)
peerid - the instance idpublic MessageSender getMessageSender(int transport)
NetworkManagerMessageSender corresponding with transport typegetMessageSender in interface NetworkManagertransport - transport type. ShoalMessageSender.TCP_TRANSPORT or
ShoalMessageSender.UDP_TRANSPORT's integer valueMessageSender's instance which this network manager containspublic MulticastMessageSender getMulticastMessageSender()
NetworkManagerMulticastMessageSendergetMulticastMessageSender in interface NetworkManagerMulticastMessageSender's instance which this network manager containspublic void addRemotePeer(PeerID id)
NetworkManagerpeerID to this network manageraddRemotePeer in interface NetworkManagerid - the peer IdCopyright © 2017–2020 Eclipse Foundation. All rights reserved.