Issue 40 is about being able to choose a particular network interface on
a machine( where there are multiple interfaces) for group communication.
I have made some changes to NetworkManager.java so that the client can
define the interface which Shoal should bind to.
Attached are the diffs and the sources.
Please let me know if there are an comments/suggestions.
Thanks
Sheetal
--
Index: src/java/com/sun/enterprise/jxtamgmt/NetworkManager.java
===================================================================
RCS file: /cvs/shoal/gms/src/java/com/sun/enterprise/jxtamgmt/NetworkManager.java,v
retrieving revision 1.35
diff -u -r1.35 NetworkManager.java
--- src/java/com/sun/enterprise/jxtamgmt/NetworkManager.java 17 Jan 2008 00:27:00 -0000 1.35
+++ src/java/com/sun/enterprise/jxtamgmt/NetworkManager.java 7 Feb 2008 20:23:05 -0000
@@ -72,6 +72,8 @@
import java.util.logging.Logger;
import java.net.URI;
+import static com.sun.enterprise.jxtamgmt.JxtaConfigConstants.*;
+
/**
* 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
@@ -125,6 +127,7 @@
private int mcastPort = 0;
private List<String> rendezvousSeedURIs = new ArrayList<String>();
private boolean isRendezvousSeed = false;
+ private String tcpAddress;
/**
* NetworkManager provides a simple interface to configuring and managing the lifecycle
@@ -142,7 +145,7 @@
NetworkManager(final String groupName,
final String instanceName,
final Map properties) {
- System.setProperty(Logging.JXTA_LOGGING_PROPERTY, Level.OFF.toString());
+ System.setProperty(Logging.JXTA_LOGGING_PROPERTY, Level.INFO.toString());
this.groupName = groupName;
this.instanceName = instanceName;
@@ -157,11 +160,11 @@
socketID = getSocketID(instanceName);
pipeID = getPipeID(instanceName);
if (properties != null && !properties.isEmpty()) {
- final String ma = (String)properties.get(JxtaConfigConstants.MULTICASTADDRESS.toString());
+ final String ma = (String)properties.get(MULTICASTADDRESS.toString());
if (ma != null) {
mcastAddress = ma;
}
- final Object mp = properties.get(JxtaConfigConstants.MULTICASTPORT.toString());
+ final Object mp = properties.get(MULTICASTPORT.toString());
if (mp != null) {
if (mp instanceof String) {
mcastPort = Integer.parseInt((String) mp);
@@ -169,7 +172,7 @@
mcastPort = (Integer) mp;
}
}
- final Object virtualMulticastURIList = properties.get(JxtaConfigConstants.VIRTUAL_MULTICAST_URI_LIST.toString());
+ final Object virtualMulticastURIList = properties.get(VIRTUAL_MULTICAST_URI_LIST.toString());
if (virtualMulticastURIList != null) {
//if this object has multiple addresses that are comma separated
if (((String) virtualMulticastURIList).indexOf(",") > 0) {
@@ -182,11 +185,15 @@
rendezvousSeedURIs.add(((String) virtualMulticastURIList));
}
}
- Object isVirtualMulticastNode = properties.get(JxtaConfigConstants.IS_BOOTSTRAPPING_NODE.toString());
+ Object isVirtualMulticastNode = properties.get(IS_BOOTSTRAPPING_NODE.toString());
if (isVirtualMulticastNode != null) {
isRendezvousSeed = Boolean.parseBoolean((String) isVirtualMulticastNode);
LOG.fine("isRendezvousSeed is set to " + isRendezvousSeed);
}
+
+ tcpAddress = (String)properties.get(BIND_INTERFACE_ADDRESS.toString());
+
+
}
}
@@ -607,6 +614,7 @@
config.setUseMulticast(true);
config.setMulticastSize(64 * 1024);
config.setInfrastructureDescriptionStr(groupName + " Infrastructure Group Name");
+
if (mcastAddress != null) {
config.setMulticastAddress(mcastAddress);
}
@@ -626,6 +634,13 @@
throw new PeerGroupException("Could not construct domain ModuleImplAdvertisement", failed);
}
+ //if a machine has multiple network interfaces,
+ //specify which interface the group communication should start on
+
+ if (tcpAddress != null && !tcpAddress.equals("")) {
+ config.setTcpInterfaceAddress(tcpAddress);
+ }
+
// Configure the domain
NetPeerGroupFactory factory = new NetPeerGroupFactory(worldPG, config.getPlatformConfig(), npgImplAdv);
netPeerGroup = factory.getInterface();
Index: src/java/com/sun/enterprise/jxtamgmt/JxtaConfigConstants.java
===================================================================
RCS file: /cvs/shoal/gms/src/java/com/sun/enterprise/jxtamgmt/JxtaConfigConstants.java,v
retrieving revision 1.6
diff -u -r1.6 JxtaConfigConstants.java
--- src/java/com/sun/enterprise/jxtamgmt/JxtaConfigConstants.java 5 Oct 2007 21:27:29 -0000 1.6
+++ src/java/com/sun/enterprise/jxtamgmt/JxtaConfigConstants.java 7 Feb 2008 20:23:05 -0000
@@ -63,5 +63,7 @@
IS_BOOTSTRAPPING_NODE,
//comma separated list of tcp/http rendezvous seed uri endpoints
VIRTUAL_MULTICAST_URI_LIST,
- LOOPBACK
+ LOOPBACK,
+ BIND_INTERFACE_ADDRESS //used for specifying which interface to use for group communication
+ // This is the address which Shoal should bind to for communication.
}
Index: src/java/com/sun/enterprise/ee/cms/core/ServiceProviderConfigurationKeys.java
===================================================================
RCS file: /cvs/shoal/gms/src/java/com/sun/enterprise/ee/cms/core/ServiceProviderConfigurationKeys.java,v
retrieving revision 1.6
diff -u -r1.6 ServiceProviderConfigurationKeys.java
--- src/java/com/sun/enterprise/ee/cms/core/ServiceProviderConfigurationKeys.java 5 Oct 2007 21:27:29 -0000 1.6
+++ src/java/com/sun/enterprise/ee/cms/core/ServiceProviderConfigurationKeys.java 7 Feb 2008 20:23:05 -0000
@@ -54,5 +54,7 @@
DISCOVERY_TIMEOUT,
LOOPBACK,
IS_BOOTSTRAPPING_NODE, //set true if this node will be an initial host for other members to use for discovery
- VIRTUAL_MULTICAST_URI_LIST // a comma separated list of initial tcp/http addresses that is known to all joining members when not using Multicast over UDP.
+ VIRTUAL_MULTICAST_URI_LIST, // a comma separated list of initial tcp/http addresses that is known to all joining members when not using Multicast over UDP.
+ BIND_INTERFACE_ADDRESS // provide ability to choose network interface on which to have group communication.
+ // This is the address which Shoal should bind to for communication.
}