patterntesting.runtime.monitor.JamonMonitor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of patterntesting-rt Show documentation
Show all versions of patterntesting-rt Show documentation
PatternTesting Runtime (patterntesting-rt) is the runtime component for
the PatternTesting framework. It provides the annotations and base classes
for the PatternTesting testing framework (e.g. patterntesting-check,
patterntesting-concurrent or patterntesting-exception) but can be also
used standalone for classpath monitoring or profiling.
It uses AOP and AspectJ to perform this feat.
/**
* $Id: JamonMonitor.java,v 1.4 2014/04/28 17:36:37 oboehm Exp $
*
* Copyright (c) 2008 by Oliver Boehm
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express orimplied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* (c)reated 25.12.2008 by oliver ([email protected])
*/
package patterntesting.runtime.monitor;
import java.util.Date;
import patterntesting.runtime.annotation.UnsupportedOperation;
import com.jamonapi.*;
/**
* This is a thin wrapper for com.jamonapi.Monitor
*
* @see com.jamonapi.Monitor
* @author oliver
* @since 25.12.2008
* @version $Revision: 1.4 $
*/
public final class JamonMonitor extends AbstractProfileMonitor {
private final Monitor monitor;
/**
* Instantiates a new monitor.
*
* @param monitor the monitor
*/
public JamonMonitor(final Monitor monitor) {
this.monitor = monitor;
}
/**
* @param arg0 argument
* @see com.jamonapi.Monitor#add(double)
*/
public void add(final double arg0) {
monitor.add(arg0);
}
/**
* Disable.
*
* @see com.jamonapi.Monitor#disable()
*/
public void disable() {
monitor.disable();
}
/**
* @see com.jamonapi.Monitor#enable()
*/
public void enable() {
monitor.enable();
}
/**
* Tests if given object is equal.
*
* @param other the other object to compare
* @return true if objects are equal
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(final Object other) {
if (other == null) {
return false;
}
try {
return equals((JamonMonitor) other);
} catch (ClassCastException cce) {
return true;
}
}
/**
* Tests if given object is equal.
*
* @param other the other object to compare
* @return true if objects are equal
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(final JamonMonitor other) {
return this.monitor.equals(other.monitor);
}
/**
* Gets the active.
*
* @return active
*
* @see com.jamonapi.Monitor#getActive()
*/
public double getActive() {
return monitor.getActive();
}
/**
* Gets the average
*
* @return average
*
* @see com.jamonapi.Monitor#getAvg()
*/
public double getAvg() {
return monitor.getAvg();
}
/**
* Gets the active average
*
* @return average active
*
* @see com.jamonapi.Monitor#getAvgActive()
*/
public double getAvgActive() {
return monitor.getAvgActive();
}
/**
* Gets the global active average
*
* @return average global active
*
* @see com.jamonapi.Monitor#getAvgGlobalActive()
*/
public double getAvgGlobalActive() {
return monitor.getAvgGlobalActive();
}
/**
* Gets the primary active average.
*
* @return average primary active
*
* @see com.jamonapi.Monitor#getAvgPrimaryActive()
*/
public double getAvgPrimaryActive() {
return monitor.getAvgPrimaryActive();
}
/**
* Gets the first access.
*
* @return first access
*
* @see com.jamonapi.Monitor#getFirstAccess()
*/
public Date getFirstAccess() {
return monitor.getFirstAccess();
}
/**
* Gets the hits.
*
* @return number of hits
*
* @see com.jamonapi.Monitor#getHits()
*/
public int getHits() {
return (int) monitor.getHits();
}
/**
* Gets the label.
*
* @return label
*
* @see com.jamonapi.Monitor#getLabel()
*/
public String getLabel() {
return monitor.getLabel();
}
/**
* Gets the last access.
*
* @return last access
*
* @see com.jamonapi.Monitor#getLastAccess()
*/
public Date getLastAccess() {
return monitor.getLastAccess();
}
/**
* Gets the last value.
*
* @return last value
*
* @see com.jamonapi.Monitor#getLastValue()
*/
public double getLastValue() {
return monitor.getLastValue();
}
/**
* Gets the listener type.
*
* @param listenerType the listener type
*
* @return listener type
*
* @see com.jamonapi.Monitor#getListenerType(java.lang.String)
*/
public ListenerType getListenerType(final String listenerType) {
return monitor.getListenerType(listenerType);
}
/**
* Gets the max.
*
* @return maximum
*
* @see com.jamonapi.Monitor#getMax()
*/
public double getMax() {
return monitor.getMax();
}
/**
* Gets the max active.
*
* @return maximal active
*
* @see com.jamonapi.Monitor#getMaxActive()
*/
public double getMaxActive() {
return monitor.getMaxActive();
}
/**
* Gets the min.
*
* @return minimum
*
* @see com.jamonapi.Monitor#getMin()
*/
public double getMin() {
return monitor.getMin();
}
/**
* Gets the monitors.
*
* @return monitors
*
* @see com.jamonapi.MonitorComposite#getMonitors()
*/
@UnsupportedOperation
public ProfileMonitor[] getMonitors() {
return null;
}
/**
* Gets the mon key.
*
* @return monitor key
*
* @see com.jamonapi.Monitor#getMonKey()
*/
public MonKey getMonKey() {
return monitor.getMonKey();
}
/**
* Gets the range.
*
* @return range
*
* @see com.jamonapi.Monitor#getRange()
*/
public Range getRange() {
return monitor.getRange();
}
/**
* Gets the std dev.
*
* @return standard dev
*
* @see com.jamonapi.Monitor#getStdDev()
*/
public double getStdDev() {
return monitor.getStdDev();
}
/**
* Gets the total.
*
* @return total
*
* @see com.jamonapi.Monitor#getTotal()
*/
public double getTotal() {
return monitor.getTotal();
}
/**
* Gets the units.
*
* @return units
*
* @see com.jamonapi.Monitor#getUnits()
*/
public String getUnits() {
return monitor.getUnits();
}
/**
* Hash code.
*
* @return hash code
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return monitor.hashCode();
}
/**
* Checks for listeners.
*
* @return true if object has listeners
*
* @see com.jamonapi.Monitor#hasListeners()
*/
public boolean hasListeners() {
return monitor.hasListeners();
}
/**
* Checks if is activity tracking.
*
* @return activity tracking
*
* @see com.jamonapi.Monitor#isActivityTracking()
*/
public boolean isActivityTracking() {
return monitor.isActivityTracking();
}
/**
* Checks if is enabled.
*
* @return true if enabled
*
* @see com.jamonapi.Monitor#isEnabled()
*/
public boolean isEnabled() {
return monitor.isEnabled();
}
/**
* Checks if is primary.
*
* @return true if primary
*
* @see com.jamonapi.Monitor#isPrimary()
*/
public boolean isPrimary() {
return monitor.isPrimary();
}
/**
* Reset.
*
* @see com.jamonapi.Monitor#reset()
*/
public void reset() {
monitor.reset();
}
/**
* Sets the access stats.
*
* @param now the now
*
* @see com.jamonapi.Monitor#setAccessStats(long)
*/
public void setAccessStats(final long now) {
monitor.setAccessStats(now);
}
/**
* Sets the active.
*
* @param arg0 the arg0
*
* @see com.jamonapi.Monitor#setActive(double)
*/
public void setActive(final double arg0) {
monitor.setActive(arg0);
}
/**
* Sets the activity tracking.
*
* @param arg0 the arg0
*
* @see com.jamonapi.Monitor#setActivityTracking(boolean)
*/
public void setActivityTracking(final boolean arg0) {
monitor.setActivityTracking(arg0);
}
/**
* Sets the first access.
*
* @param arg0 the arg0
*
* @see com.jamonapi.Monitor#setFirstAccess(java.util.Date)
*/
public void setFirstAccess(final Date arg0) {
monitor.setFirstAccess(arg0);
}
/**
* Sets the hits.
*
* @param arg0 the arg0
*
* @see com.jamonapi.Monitor#setHits(double)
*/
public void setHits(final double arg0) {
monitor.setHits(arg0);
}
/**
* Sets the last access.
*
* @param arg0 the arg0
*
* @see com.jamonapi.Monitor#setLastAccess(java.util.Date)
*/
public void setLastAccess(final Date arg0) {
monitor.setLastAccess(arg0);
}
/**
* Sets the last value.
*
* @param arg0 the arg0
*
* @see com.jamonapi.Monitor#setLastValue(double)
*/
public void setLastValue(final double arg0) {
monitor.setLastValue(arg0);
}
/**
* Sets the max.
*
* @param arg0 the arg0
*
* @see com.jamonapi.Monitor#setMax(double)
*/
public void setMax(final double arg0) {
monitor.setMax(arg0);
}
/**
* Sets the max active.
*
* @param arg0 the arg0
*
* @see com.jamonapi.Monitor#setMaxActive(double)
*/
public void setMaxActive(final double arg0) {
monitor.setMaxActive(arg0);
}
/**
* Sets the min.
*
* @param arg0 the arg0
*
* @see com.jamonapi.Monitor#setMin(double)
*/
public void setMin(final double arg0) {
monitor.setMin(arg0);
}
/**
* Sets the primary.
*
* @param arg0 the arg0
*
* @see com.jamonapi.Monitor#setPrimary(boolean)
*/
public void setPrimary(final boolean arg0) {
monitor.setPrimary(arg0);
}
/**
* Sets the total.
*
* @param arg0 the arg0
*
* @see com.jamonapi.Monitor#setTotal(double)
*/
public void setTotal(final double arg0) {
monitor.setTotal(arg0);
}
/**
* Sets the total active.
*
* @param arg0 the arg0
*
* @see com.jamonapi.Monitor#setTotalActive(double)
*/
public void setTotalActive(final double arg0) {
monitor.setTotalActive(arg0);
}
/**
* Start.
*
* @see com.jamonapi.Monitor#start()
*/
public void start() {
monitor.start();
}
/**
* Stop.
*
* @see com.jamonapi.Monitor#stop()
*/
public void stop() {
monitor.stop();
}
/**
* To string.
*
* @return e.g. "JAMon Label=void patterntesting.runtime.monitor.ProfileTest.testProfiler(), Units=ms.:"
* + " (LastValue=8.0, Hits=1.0, Avg=8.0, Total=8.0, Min=8.0, Max=8.0, Active=1.0, Avg Active=3.0,"
* + " Max Active=2.0, First Access=Sat Dec 27 17:31:09 CET 2008, Last Access=Sat Dec 27 17:31:09 CET 2008)"
*
* @see com.jamonapi.Monitor#toString()
*/
@Override
public String toString() {
return monitor.toString();
}
/**
* @see patterntesting.runtime.monitor.ProfileMonitor#toShortString()
*/
public String toShortString() {
return "Hits=" + (long) monitor.getHits() + ", Avg=" + monitor.getAvg()
+ ", Total=" + monitor.getTotal() + ", Max=" + monitor.getMax()
+ ", Unit=" + monitor.getUnits();
}
/**
* @see patterntesting.runtime.monitor.ProfileMonitor#toCsvHeadline()
*/
public String toCsvHeadline() {
return "Label; Unit; LastValue; Hits; Avg; Total; Min; Max; Active; Avg Active; Max Active; First Access; Last Access;";
}
/**
* @see patterntesting.runtime.monitor.ProfileMonitor#toCsvString()
*/
public String toCsvString() {
return '"' + monitor.getLabel() + "\"; " + monitor.getUnits() + "; "
+ monitor.getLastValue() + "; " + (long) monitor.getHits()
+ "; " + monitor.getAvg() + "; " + monitor.getTotal() + "; "
+ monitor.getMin() + "; " + monitor.getMax() + "; "
+ monitor.getActive() + "; " + monitor.getAvgActive() + "; "
+ monitor.getMaxActive() + "; " + monitor.getFirstAccess()
+ "; " + monitor.getLastAccess() + ";";
}
}
/**
* $Log: JamonMonitor.java,v $
* Revision 1.4 2014/04/28 17:36:37 oboehm
* label is now quoted by dumpStatistic...
*
* Revision 1.3 2010/06/08 21:32:53 oboehm
* nearly half of the checkstyle warnings fixed
*
* Revision 1.2 2010/04/22 18:27:19 oboehm
* code cleanup of src/main/java
*
* Revision 1.1 2010/01/05 13:26:17 oboehm
* begin with 1.0
*
* Revision 1.13 2009/12/28 10:07:23 oboehm
* missing Javadocs completed
*
* Revision 1.12 2009/12/20 15:18:10 oboehm
* FindBugs and Checkstyle warnings fixed
* ready for delivery
*
* Revision 1.11 2009/12/19 22:34:09 oboehm
* trailing spaces removed
*
* Revision 1.10 2009/12/05 22:46:29 oboehm
* RunTestsParallel annotation added
*
* Revision 1.9 2009/11/26 21:19:25 oboehm
* some findbugs fixed
*
* Revision 1.8 2009/09/25 14:49:43 oboehm
* javadocs completed with the help of JAutodoc
*
* Revision 1.7 2009/09/18 13:54:52 oboehm
* javadoc warnings fixed
*
* Revision 1.6 2009/09/03 14:10:06 oboehm
* support for JAMon 2.7 added
*
* $Source: /cvsroot/patterntesting/PatternTesting10/patterntesting-rt/src/main/java/patterntesting/runtime/monitor/JamonMonitor.java,v $
*/