/** * Returns the current NailStats object for the specified class, creating a * new one if necessary * * @param nailClass the class for which we're gathering stats * @return a NailStats object for the specified class */ private NailStats getOrCreateStatsFor(Class nailClass) { NailStats result = null; synchronized (allNailStats) { result = (NailStats) allNailStats.get(nailClass); if (result == null) { result = new NailStats(nailClass); allNailStats.put(nailClass, result); } } return (result); }
/** * Returns a String representation of this <code>NailStats</code> * object, in the form "classname: runcount/refcount". * *return a String representation of this <code>NailStats</code> * object. */ public String toString() { return (nailclass.getName() + ": " + getRunCount() + "/" + getRefCount()); } }
/** * Provides a means for an NGSession to register the completion of a nails * execution with the server. * * @param nailClass the nail class that finished */ void nailFinished(Class nailClass) { NailStats stats = (NailStats) allNailStats.get(nailClass); stats.nailFinished(); }
/** * Provides a means for an NGSession to register the starting of a nail * execution with the server. * * @param nailClass the nail class that was launched */ void nailStarted(Class nailClass) { NailStats stats = getOrCreateStatsFor(nailClass); stats.nailStarted(); }
/** * Returns a snapshot of this NGServer's nail statistics. The result is a * <code>java.util.Map</code>, keyed by class name, with <a * href="NailStats.html">NailStats</a> objects as values. * * @return a snapshot of this NGServer's nail statistics. */ public Map getNailStats() { Map result = new java.util.TreeMap(); synchronized (allNailStats) { for (Iterator i = allNailStats.keySet().iterator(); i.hasNext();) { Class nailclass = (Class) i.next(); result.put(nailclass.getName(), ((NailStats) allNailStats.get(nailclass)).clone()); } } return (result); }
for (Iterator i = allNailStats.values().iterator(); i.hasNext();) { NailStats ns = (NailStats) i.next(); Class nailClass = ns.getNailClass();