Methods Summary |
---|
private StatsHolder | addChild(StatsHolder sh)Add a child node or leaf to this node.
// The name of the child is the unique key
assert (sh != null) : "Null StatsHolder to be added";
if(!children.containsKey(sh.getName())){
children.put(sh.getName(), sh);
logger.fine("StatsHolder.addChild: New key created with statsHolder key name = " + sh.getName() + " type = " + sh.getType().toString());
}
else {
sh = this.getChild(sh.getName());
logger.fine("Not adding, StatsHolder.addChild: Child exists, name = " + sh.getName() + " type = " + sh.getType().toString());
//Ideally an exception should be thrown
}
return ( sh );
|
public StatsHolder | addChild(java.lang.String name, MonitoredObjectType type)Add a child node or leaf to this node
assert ( name != null && type != null) : "Asked to add a null name-type child";
StatsHolder child = this.getChild(name);
if (child == null)
child = this.addChild(new StatsHolderImpl(name, type));
return ( child );
|
private javax.management.MBeanServer | findMBeanServer()finds and returns an MBeanServer instance
MBeanServer server = null;
ArrayList servers = MBeanServerFactory.findMBeanServer(null);
if(!servers.isEmpty()){
server = (MBeanServer)servers.get(0);
}
return server;
|
public java.util.Collection | getAllChildren()return an array of StatHolder objects each representing a child
of this node.
return children.values();
|
public StatsHolder | getChild(java.lang.String name)
final StatsHolder child = (StatsHolder) children.get(name);
if (child == null) {
logger.fine("SH.getChild - child is null with name = " + name);
}
return ( child );
|
public java.lang.String | getDottedName()
return dottedName;
|
public java.lang.String | getName()Returns name of this hierarchical node
return name;
|
public javax.management.ObjectName | getObjectName()
return objectName;
|
public Stats | getStats()
return ( this.stats );
|
public java.lang.Class | getStatsClass()
return ( this.statsClass );
|
public java.lang.String | getStatsClassName()
return ( this.statsClassName );
|
public MonitoredObjectType | getType()Returns type of this hierarchical node
return type;
|
public void | registerMBean()registers a monitoring MBean with the MBeanServer
try {
if (server.isRegistered(this.objectName)) {
logger.fine("ObjectName obj is already registered - this is an error, ignoring for now : " + this.objectName);
return;
}
//final DynamicMBean mbean = MonitoringMBeansFactory.generateMonitoringMBean(stats);
//server.registerMBean(mbean, this.objectName);
final StatsHolderMBean mbean = new StatsHolderMBeanImpl(this);
server.registerMBean(mbean, this.objectName);
logger.finer("Registered the MBean for this StatsHolder: " + this.objectName);
}
catch(Exception e) {
logger.fine("SH.registerMBean: Exception for object-name " + this.objectName);
logger.throwing(StatsHolderImpl.class.getName(), "registerMBean()", e);
//squelching it for now - throw RuntimeException
}
|
public void | removeAllChildren()removes all children belonging to this node.
//removes all the children, grandchildren etc. recursively and deregisters mbeans
if (children.isEmpty()) {
this.unregisterMBean();
}
else {
final Enumeration e = children.elements();
while (e.hasMoreElements()) {
final StatsHolder sh = (StatsHolder)e.nextElement();
sh.removeAllChildren();
}
children.clear();
}
|
public void | removeChild(java.lang.String name)Remove a child node or leaf from this node.
children.remove(name);
|
public void | setDottedName(java.lang.String dottedName)
this.dottedName = dottedName;
|
public void | setObjectName(javax.management.ObjectName name)sets the hierarchically denoted dotted name for this node.
this.objectName = name;
|
public void | setStats(Stats stats)sets this hierarchical node's associated stats object. Used when node was
originally created without a Stats implementation or a new monitoring
level has been set requiring a new Stats registration
this.stats=stats;
|
public void | setStatsClass(java.lang.Class c)
if (! javax.management.j2ee.statistics.Stats.class.isAssignableFrom(c)) {
final String msg = sm.getString("sh.not_a_stats_interface", c.getName());
throw new IllegalArgumentException(msg);
}
//the given class has to be an interface.
if (! c.isInterface()) {
final String msg = sm.getString("sh.should_be_an_interface", c.getName());
throw new IllegalArgumentException(msg);
}
this.statsClass = c;
this.statsClassName = c.getName();
|
public void | setStatsClassName(java.lang.String cName)
Class c = null;
try {
c = Class.forName(cName);
} catch (ClassNotFoundException cnfe) {
final String msg = sm.getString("invalidclassname.statsholder",
cName);
throw new IllegalArgumentException(msg);
}
if (! javax.management.j2ee.statistics.Stats.class.isAssignableFrom(c)) {
final String msg = sm.getString("sh.not_a_stats_interface", c.getName());
throw new IllegalArgumentException(msg);
}
//the given class has to be an interface.
if (! c.isInterface()) {
final String msg = sm.getString("sh.should_be_an_interface", c.getName());
throw new IllegalArgumentException(msg);
}
this.statsClass = c;
this.statsClassName = cName;
|
public void | setType(MonitoredObjectType type)
this.type = type;
|
public void | unregisterMBean()unregisters a monitoring MBean from the MBean Server
String msg = null;
try {
if (server.isRegistered(this.objectName)) {
server.unregisterMBean(this.objectName);
logger.fine("SH.unregisterMonitoringMBean(): unregistered - " + objectName);
}
else {
logger.fine("SH.unregisterMonitoringMBean(): never registered - so not unregistering" + objectName);
}
}
catch(Exception e){
logger.fine("SH.unregisterMBeanUnregistration failed, objectName = " + objectName);
//squelching for now - throw RuntimeException
}
|
void | write()this is just a convenience - debugging method
//new DumpThread().start();
|