com.sun.enterprise.mgmt.transport.jxta
Class JxtaNetworkManager

java.lang.Object
  extended by com.sun.enterprise.mgmt.transport.AbstractNetworkManager
      extended by com.sun.enterprise.mgmt.transport.jxta.JxtaNetworkManager
All Implemented Interfaces:
MessageSender, MulticastMessageSender, NetworkManager, ShoalMessageSender

public class JxtaNetworkManager
extends AbstractNetworkManager

NetworkManager wraps the JXTA plaform lifecycle into a single object. Using the instance name, it encodes a node Peer ID, and provides utilities to derive Peer ID's from an instance name. Given an instance name, this allows any node to independently interpolate a Peer ID.

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?


Field Summary
 
Fields inherited from class com.sun.enterprise.mgmt.transport.AbstractNetworkManager
localPeerID
 
Fields inherited from interface com.sun.enterprise.mgmt.transport.ShoalMessageSender
TCP_TRANSPORT, UDP_TRANSPORT
 
Constructor Summary
JxtaNetworkManager()
           
 
Method Summary
 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(RouteAdvertisement route)
          Caches a route for an instance
 PipeID getAppServicePipeID()
          Returns the Pipe ID that will be used for application layer to send and receive messages.
 RouteAdvertisement getCachedRoute(net.jxta.peer.PeerID peerid)
          returns the cached route if any, null otherwise
 PipeID getHealthPipeID()
          Returns the HealthMonitor PipeID, used for health monitoring purposes.
 File getHome()
          Returns the home directory.
 PeerGroupID getInfraPeerGroupID()
          Contructs and returns the Infrastructure PeerGroupID for the ClusterManager.
 String getInstanceName()
          Returns this instance name.
 net.jxta.peer.PeerID getJxtaPeerID(String instanceName)
           
 PipeID getMasterPipeID()
          Returns the MasterNode protocol PipeID.
 MessageSender getMessageSender(int transport)
          Returns a MessageSender corresponding with transport type
 MulticastMessageSender getMulticastMessageSender()
          Returns a MulticastMessageSender
 PeerGroup getNetPeerGroup()
          Returns the netPeerGroup instance for this Cluster.
 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.
 PipeAdvertisement getPipeAdvertisement(String instanceName)
          Creates a JxtaBiDiPipe pipe advertisement with a SHA1 encoded instance name pipe ID.
 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.
 PipeID getSessionQueryPipeID()
          Returns the SessionQeuryPipe ID.
 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(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.
 
Methods inherited from class com.sun.enterprise.mgmt.transport.AbstractNetworkManager
addMessageListener, getInstance, getLocalPeerID, getLogger, receiveMessage, removeMessageListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JxtaNetworkManager

public JxtaNetworkManager()
Method Detail

initialize

public void initialize(String groupName,
                       String instanceName,
                       Map properties)
                throws IOException
NetworkManager provides a simple interface to configuring and managing the lifecycle of the JXTA platform. In addition, it provides logical addressing by means of name encoded PeerID, and communication channels. This allows the application to utilize simple addressing. Therefore it is key that these names are chosen carefully to avoid collision.

Specified by:
initialize in interface NetworkManager
Overrides:
initialize in class AbstractNetworkManager
Parameters:
groupName - 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.
Throws:
IOException - if an unexpected error occurs

getPipeID

public net.jxta.pipe.PipeID getPipeID(String instanceName)
Given a instance name, it returns a name encoded PipeID to for binding JxtaBiDiPipes.

Parameters:
instanceName - instance name
Returns:
The pipeID value

getSocketID

public net.jxta.pipe.PipeID getSocketID(String instanceName)
Given a instance name, it returns a name encoded PipeID to for binding JxtaSockets.

Parameters:
instanceName - instance name value
Returns:
The scoket PipeID value

getPeerID

public PeerID getPeerID(String instanceName)
Given a instance name, it returns a name encoded PeerID to for binding to specific instance.

Parameters:
instanceName - instance name value
Returns:
The peerID value

removePeerID

public void removePeerID(PeerID peerID)
Description copied from interface: NetworkManager
Removes the peerID from this network manager


isConnected

public boolean isConnected(PeerID peerID)
Description copied from interface: NetworkManager
Check whether the suspicious peer is alive or not This API is mainly used in HealthMonitor in order to determine the failure member

Parameters:
peerID - peer id
Returns:
true if the peer is still alive, otherwise false

getJxtaPeerID

public net.jxta.peer.PeerID getJxtaPeerID(String instanceName)

getPeerGroupID

public PeerGroupID getPeerGroupID(String groupName)
Given a instance name, it returns a name encoded PeerID to for binding to specific instance.

Parameters:
groupName - instance name value
Returns:
The peerID value

getHealthPipeID

public PipeID getHealthPipeID()
Returns the HealthMonitor PipeID, used for health monitoring purposes.

Returns:
The HealthPipe Pipe ID

getMasterPipeID

public PipeID getMasterPipeID()
Returns the MasterNode protocol PipeID. used for dynamic organization of nodes.

Returns:
The MasterPipe PipeID

getSessionQueryPipeID

public PipeID getSessionQueryPipeID()
Returns the SessionQeuryPipe ID. Used to query for a session replication

Returns:
The SessionQuery PipeID

getAppServicePipeID

public PipeID getAppServicePipeID()
Returns the Pipe ID that will be used for application layer to send and receive messages.

Returns:
The Application Service Pipe ID

getSocketAdvertisement

public PipeAdvertisement getSocketAdvertisement(String instanceName)
Creates a JxtaSocket pipe advertisement with a SHA1 encoded instance name pipe ID.

Parameters:
instanceName - instance name
Returns:
a JxtaSocket Pipe Advertisement

getPipeAdvertisement

public PipeAdvertisement getPipeAdvertisement(String instanceName)
Creates a JxtaBiDiPipe pipe advertisement with a SHA1 encoded instance name pipe ID.

Parameters:
instanceName - instance name
Returns:
PipeAdvertisement a JxtaBiDiPipe Pipe Advertisement

getInfraPeerGroupID

public PeerGroupID getInfraPeerGroupID()
Contructs and returns the Infrastructure PeerGroupID for the ClusterManager. This ensures scoping and isolation of ClusterManager deployments.

Returns:
The infraPeerGroupID PeerGroupID

start

public void start()
           throws IOException
Creates and starts the JXTA NetPeerGroup using a platform configuration template. This class also registers a listener for rendezvous events

Specified by:
start in interface NetworkManager
Specified by:
start in interface ShoalMessageSender
Overrides:
start in class AbstractNetworkManager
Throws:
IOException - if an io error occurs during creation of the cache directory

stop

public void stop()
Stops the NetworkManager and the JXTA platform.

Specified by:
stop in interface NetworkManager
Specified by:
stop in interface ShoalMessageSender
Overrides:
stop in class AbstractNetworkManager

send

public boolean send(PeerID peerID,
                    Message message)
             throws IOException
Description copied from interface: MessageSender
Sends the given Message to the destination

Parameters:
peerID - the destination PeerID. null is not allowed
message - a message which is sent to the peer
Returns:
true if the message is sent to the destination successfully, otherwise false
Throws:
IOException - if I/O error occurs or given parameters are not valid

broadcast

public boolean broadcast(Message message)
                  throws IOException
Description copied from interface: MulticastMessageSender
Broadcasts or Multicasts the given Message to all members

Parameters:
message - a message which is sent to all members
Returns:
true if the message is sent to all members successfully, otherwise false
Throws:
IOException - if I/O error occurs or given parameters are not valid

beforeDispatchingMessage

protected void beforeDispatchingMessage(MessageEvent messageEvent,
                                        Map piggyback)
Description copied from class: AbstractNetworkManager
Before executing MessageListener.receiveMessageEvent(MessageEvent)} callback, this method will be called

Specified by:
beforeDispatchingMessage in class AbstractNetworkManager
Parameters:
messageEvent - a received MessageEvent
piggyback - piggyback

afterDispatchingMessage

protected void afterDispatchingMessage(MessageEvent messageEvent,
                                       Map piggyback)
Description copied from class: AbstractNetworkManager
After executing MessageListener.receiveMessageEvent(MessageEvent)} callback, this method will be called

Specified by:
afterDispatchingMessage in class AbstractNetworkManager
Parameters:
messageEvent - a received MessageEvent
piggyback - piggyback

getNetPeerGroup

public PeerGroup getNetPeerGroup()
Returns the netPeerGroup instance for this Cluster.

Returns:
The netPeerGroup value

waitForRendezvousConnection

public boolean waitForRendezvousConnection(long timeout)
Blocks until a connection to rendezvous node occurs. Returns immediately if a connection is already established. This is useful to ensure the widest network exposure.

Parameters:
timeout - timeout in milliseconds
Returns:
connection state

rendezvousEvent

public void rendezvousEvent(RendezvousEvent event)


getPeerID

public net.jxta.peer.PeerID getPeerID()
Gets this instance's PeerID

Returns:
The peerID value

getPipeID

public PipeID getPipeID()
Returns this instance name encoded PipeID.

Returns:
The pipeID value

getInstanceName

public String getInstanceName()
Returns this instance name.

Returns:
The instance name value

getHome

public File getHome()
Returns the home directory. An instance home directory is used to persists an instance configuration and cache.

Returns:
The instance name value

cacheRoute

public void cacheRoute(RouteAdvertisement route)
Caches a route for an instance

Parameters:
route - the route advertisement

getCachedRoute

public RouteAdvertisement getCachedRoute(net.jxta.peer.PeerID peerid)
returns the cached route if any, null otherwise

Parameters:
peerid - the instance id
Returns:
the cached route if any, null otherwise

getMessageSender

public MessageSender getMessageSender(int transport)
Description copied from interface: NetworkManager
Returns a MessageSender corresponding with transport type

Parameters:
transport - transport type. ShoalMessageSender.TCP_TRANSPORT or ShoalMessageSender.UDP_TRANSPORT's integer value
Returns:
a MessageSender's instance which this network manager contains

getMulticastMessageSender

public MulticastMessageSender getMulticastMessageSender()
Description copied from interface: NetworkManager
Returns a MulticastMessageSender

Returns:
a MulticastMessageSender's instance which this network manager contains

addRemotePeer

public void addRemotePeer(PeerID id)
Description copied from interface: NetworkManager
Add the peerID to this network manager



Copyright © 2012. All Rights Reserved.