Methods Summary |
---|
public org.jgroups.Channel | createMultiplexerChannel(java.lang.String stack_name, java.lang.String id, boolean register_for_state_transfer, java.lang.String substate_id)Overrides the superclass version by generating a unique node id
and passing it down the Channel as additional_data.
Channel channel = super.createMultiplexerChannel(stack_name, id, register_for_state_transfer, substate_id);
setChannelUniqueId(channel);
return channel;
|
public org.jgroups.Channel | createMultiplexerChannel(java.lang.String stack_name, java.lang.String id)Overrides the superclass version by generating a unique node id
and passing it down the Channel as additional_data.
Channel channel = super.createMultiplexerChannel(stack_name, id);
setChannelUniqueId(channel);
return channel;
|
private java.lang.String | generateUniqueNodeName()
// we first try to find a simple meaningful name:
// 1st) "local-IP:JNDI_PORT" if JNDI is running on this machine
// 2nd) "local-IP:JMV_GUID" otherwise
// 3rd) return a fully GUID-based representation
//
// Before anything we determine the local host IP (and NOT name as this could be
// resolved differently by other nodes...)
// But use the specified node address for multi-homing
String hostIP = null;
InetAddress address = ServerConfigUtil.fixRemoteAddress(nodeAddress);
if (address == null)
{
log.debug ("unable to create a GUID for this cluster, check network configuration is correctly setup (getLocalHost has returned an exception)");
log.debug ("using a full GUID strategy");
return new VMID().toString();
}
else
{
hostIP = address.getHostAddress();
}
// 1st: is JNDI up and running?
//
try
{
MBeanServer server = MBeanServerLocator.locateJBoss();
AttributeList al = server.getAttributes(NamingServiceMBean.OBJECT_NAME,
new String[] {"State", "Port"});
int status = ((Integer)((Attribute)al.get(0)).getValue()).intValue();
if (status == ServiceMBean.STARTED)
{
// we can proceed with the JNDI trick!
int port = ((Integer)((Attribute)al.get(1)).getValue()).intValue();
return hostIP + ":" + port;
}
else
{
log.debug("JNDI has been found but the service wasn't started so we cannot " +
"be entirely sure we are the only one that wants to use this PORT " +
"as a GUID on this host.");
}
}
catch (InstanceNotFoundException e)
{
log.debug ("JNDI not running here, cannot use this strategy to find a node GUID for the cluster");
}
catch (ReflectionException e)
{
log.debug ("JNDI querying has returned an exception, cannot use this strategy to find a node GUID for the cluster");
}
// 2nd: host-GUID strategy
//
String uid = new UID().toString();
return hostIP + ":" + uid;
|
public java.net.InetAddress | getNodeAddress()
return nodeAddress;
|
public java.lang.String | getNodeName()
return nodeName;
|
private void | setChannelUniqueId(org.jgroups.Channel channel)
IpAddress address = (IpAddress) channel.getLocalAddress();
if (address == null)
{
// We push the independent name in the protocol stack before connecting to the cluster
if (this.nodeName == null || "".equals(this.nodeName)) {
this.nodeName = generateUniqueNodeName();
}
log.debug("Passing unique node id " + nodeName + " to the channel as additional data");
java.util.HashMap staticNodeName = new java.util.HashMap();
staticNodeName.put("additional_data", this.nodeName.getBytes());
channel.down(new Event(Event.CONFIG, staticNodeName));
}
else if (address.getAdditionalData() == null)
{
Channel testee = channel;
if (channel instanceof MuxChannel)
{
testee = ((MuxChannel) channel).getChannel();
}
if (testee.isConnected())
{
throw new IllegalStateException("Underlying JChannel was " +
"connected before additional_data was set");
}
}
else if (this.nodeName == null || "".equals(this.nodeName))
{
this.nodeName = new String(address.getAdditionalData());
log.warn("Field nodeName was not set but mux channel already had " +
"additional data -- setting nodeName to " + nodeName);
}
|
public void | setNodeAddress(java.net.InetAddress nodeAddress)
this.nodeAddress = nodeAddress;
|
public void | setNodeName(java.lang.String nodeName)
this.nodeName = nodeName;
|