Methods Summary |
---|
public java.util.Vector | getClusterNodes()
Vector view = null;
try
{
InitialContext ctx = new InitialContext();
String jndiName = "/HAPartition/" + partitionName;
HAPartition partition = (HAPartition) ctx.lookup(jndiName);
view = partition.getCurrentView();
}
catch(Exception e)
{
log.error("Failed to access HAPartition state", e);
}
return view;
|
private org.jboss.ha.framework.server.util.TopologyMonitorService$AddressPort | getMemberAddress(java.lang.Object addr)Use reflection to access the address InetAddress and port if they exist
in the Address implementation
AddressPort info = null;
try
{
org.jboss.ha.framework.interfaces.ClusterNode node =
(org.jboss.ha.framework.interfaces.ClusterNode)addr;
InetAddress inetAddr = node.getOriginalJGAddress().getIpAddress();
Integer port = new Integer(node.getOriginalJGAddress().getPort());
info = new AddressPort(inetAddr, port);
}
catch(Exception e)
{
log.warn("Failed to obtain InetAddress/port from addr: "+addr, e);
}
return info;
|
public java.lang.String | getPartitionName()
return partitionName;
|
public javax.management.ObjectName | getTriggerServiceName()
return triggerServiceName;
|
public void | membershipChanged(java.util.Vector deadMembers, java.util.Vector newMembers, java.util.Vector allMembers)Called when a new partition topology occurs.
MDC.put("RegexEventEvaluator", "End membershipChange.*");
ArrayList removed = new ArrayList();
ArrayList added = new ArrayList();
ArrayList members = new ArrayList();
changeLog.info("Begin membershipChanged info, hostname="+hostname);
changeLog.info("DeadMembers: size="+deadMembers.size());
for(int m = 0; m < deadMembers.size(); m ++)
{
AddressPort addrInfo = getMemberAddress(deadMembers.get(m));
removed.add(addrInfo);
changeLog.info(addrInfo);
}
changeLog.info("NewMembers: size="+newMembers.size());
for(int m = 0; m < newMembers.size(); m ++)
{
AddressPort addrInfo = getMemberAddress(newMembers.get(m));
added.add(addrInfo);
changeLog.info(addrInfo);
}
changeLog.info("AllMembers: size="+allMembers.size());
for(int m = 0; m < allMembers.size(); m ++)
{
AddressPort addrInfo = getMemberAddress(allMembers.get(m));
members.add(addrInfo);
changeLog.info(addrInfo);
}
// Notify the trigger MBean
if( triggerServiceName != null )
{
changeLog.info("Invoking trigger service: "+triggerServiceName);
try
{
Object[] params = {removed, added, members, CHANGE_NAME};
String[] sig = {"java.util.ArrayList", "java.util.ArrayList",
"java.util.ArrayList", "java.lang.String"};
server.invoke(triggerServiceName, "membershipChanged", params, sig);
}
catch(Throwable t)
{
changeLog.error("Failed to notify trigger service: "+triggerServiceName, t);
log.debug("Failed to notify trigger service: "+triggerServiceName, t);
}
}
changeLog.info("End membershipChanged info, hostname="+hostname);
MDC.remove("RegexEventEvaluator");
|
public void | setPartitionName(java.lang.String name)
this.partitionName = name;
|
public void | setTriggerServiceName(javax.management.ObjectName triggerServiceName)
this.triggerServiceName = triggerServiceName;
|
protected void | startService()
InitialContext ctx = new InitialContext();
String partitionJndiName = "/HAPartition/" + partitionName;
partition = (HAPartition) ctx.lookup(partitionJndiName);
// Register as a listener of cluster membership changes
partition.registerMembershipListener(this);
log.info("Registered as MembershipListener");
try
{
hostname = InetAddress.getLocalHost().getHostName();
}
catch(IOException e)
{
log.warn("Failed to lookup local hostname", e);
hostname = "<unknown>";
}
|
protected void | stopService()
partition.unregisterMembershipListener(this);
|