6951661: Eliminate jvmstat dependency on sun.management.counter
Jvmstat keeps its own copy of Units and Variability class Reviewed-by: alanb
This commit is contained in:
parent
3adf1d8538
commit
5ef47408fb
@ -25,9 +25,6 @@
|
||||
|
||||
package sun.jvmstat.monitor;
|
||||
|
||||
import sun.management.counter.Units;
|
||||
import sun.management.counter.Variability;
|
||||
|
||||
/**
|
||||
* The base class for Instrumentation Monitoring Objects. This base class
|
||||
* provides implementations of the {@link Monitor} methods that are common
|
||||
|
@ -25,9 +25,6 @@
|
||||
|
||||
package sun.jvmstat.monitor;
|
||||
|
||||
import sun.management.counter.Units;
|
||||
import sun.management.counter.Variability;
|
||||
|
||||
/**
|
||||
* Interface provided by Instrumentation Monitoring Objects.
|
||||
*
|
||||
|
128
jdk/src/share/classes/sun/jvmstat/monitor/Units.java
Normal file
128
jdk/src/share/classes/sun/jvmstat/monitor/Units.java
Normal file
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.jvmstat.monitor;
|
||||
|
||||
/**
|
||||
* Provides a typesafe enumeration for describing units of measurement
|
||||
* attribute for instrumentation objects.
|
||||
*
|
||||
* @author Brian Doherty
|
||||
*/
|
||||
public class Units implements java.io.Serializable {
|
||||
|
||||
/* The enumeration values for this typesafe enumeration must be
|
||||
* kept in synchronization with the Units enum in the perfData.hpp file
|
||||
* in the HotSpot source base.
|
||||
*/
|
||||
|
||||
private static final int NUNITS=8;
|
||||
|
||||
private static Units[] map = new Units[NUNITS];
|
||||
|
||||
private final String name;
|
||||
private final int value;
|
||||
|
||||
/**
|
||||
* An Invalid Units value.
|
||||
*/
|
||||
public static final Units INVALID = new Units("Invalid", 0);
|
||||
|
||||
/**
|
||||
* Units attribute representing unit-less quantities.
|
||||
*/
|
||||
public static final Units NONE = new Units("None", 1);
|
||||
|
||||
/**
|
||||
* Units attribute representing Bytes.
|
||||
*/
|
||||
public static final Units BYTES = new Units("Bytes", 2);
|
||||
|
||||
/**
|
||||
* Units attribute representing Ticks.
|
||||
*/
|
||||
public static final Units TICKS = new Units("Ticks", 3);
|
||||
|
||||
/**
|
||||
* Units attribute representing a count of events.
|
||||
*/
|
||||
public static final Units EVENTS = new Units("Events", 4);
|
||||
|
||||
/**
|
||||
* Units attribute representing String data. Although not really
|
||||
* a unit of measure, this Units value serves to distinguish String
|
||||
* instrumentation objects from instrumentation objects of other types.
|
||||
*/
|
||||
public static final Units STRING = new Units("String", 5);
|
||||
|
||||
/**
|
||||
* Units attribute representing Hertz (frequency).
|
||||
*/
|
||||
public static final Units HERTZ = new Units("Hertz", 6);
|
||||
|
||||
/**
|
||||
* Returns a string describing this Unit of measurement attribute
|
||||
*
|
||||
* @return String - a descriptive string for this enum.
|
||||
*/
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer representation of this Units attribute
|
||||
*
|
||||
* @return int - an integer representation of this Units attribute.
|
||||
*/
|
||||
public int intValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps an integer value to its corresponding Units attribute.
|
||||
* If the integer value does not have a corresponding Units enum
|
||||
* value, then {@link Units#INVALID} is returned.
|
||||
*
|
||||
* @param value an integer representation of counter Units
|
||||
* @return Units - the Units object for the given <code>value</code>
|
||||
* or {@link Units#INVALID} if out of range.
|
||||
*/
|
||||
public static Units toUnits(int value) {
|
||||
|
||||
if (value < 0 || value >= map.length || map[value] == null) {
|
||||
return INVALID;
|
||||
}
|
||||
|
||||
return map[value];
|
||||
}
|
||||
|
||||
private Units(String name, int value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
map[value] = this;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 6992337162326171013L;
|
||||
}
|
111
jdk/src/share/classes/sun/jvmstat/monitor/Variability.java
Normal file
111
jdk/src/share/classes/sun/jvmstat/monitor/Variability.java
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.jvmstat.monitor;
|
||||
|
||||
/**
|
||||
* Provides a typesafe enumeration for the Variability attribute for
|
||||
* instrumentation objects.
|
||||
*
|
||||
* @author Brian Doherty
|
||||
*/
|
||||
public class Variability implements java.io.Serializable {
|
||||
|
||||
/* The enumeration values for this typesafe enumeration must be
|
||||
* kept in synchronization with the Variability enum in the perfData.hpp file
|
||||
* in the HotSpot source base.
|
||||
*/
|
||||
|
||||
private static final int NATTRIBUTES = 4;
|
||||
private static Variability[] map = new Variability[NATTRIBUTES];
|
||||
|
||||
private String name;
|
||||
private int value;
|
||||
|
||||
/**
|
||||
* An invalid Variablity value.
|
||||
*/
|
||||
public static final Variability INVALID = new Variability("Invalid",0);
|
||||
|
||||
/**
|
||||
* Variability attribute representing Constant counters.
|
||||
*/
|
||||
public static final Variability CONSTANT = new Variability("Constant",1);
|
||||
|
||||
/**
|
||||
* Variability attribute representing a Monotonically changing counters.
|
||||
*/
|
||||
public static final Variability MONOTONIC = new Variability("Monotonic",2);
|
||||
|
||||
/**
|
||||
* Variability attribute representing Variable counters.
|
||||
*/
|
||||
public static final Variability VARIABLE = new Variability("Variable",3);
|
||||
|
||||
/**
|
||||
* Returns a string describing this Variability attribute.
|
||||
*
|
||||
* @return String - a descriptive string for this enum.
|
||||
*/
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer representation of this Variability attribute.
|
||||
*
|
||||
* @return int - an integer representation of this Variability attribute.
|
||||
*/
|
||||
public int intValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps an integer value its corresponding Variability attribute.
|
||||
* If the integer value does not have a corresponding Variability enum
|
||||
* value, the {@link Variability#INVALID} is returned
|
||||
*
|
||||
* @param value an integer representation of a Variability attribute
|
||||
* @return Variability - The Variability object for the given
|
||||
* <code>value</code> or {@link Variability#INVALID}
|
||||
* if out of range.
|
||||
*/
|
||||
public static Variability toVariability(int value) {
|
||||
|
||||
if (value < 0 || value >= map.length || map[value] == null) {
|
||||
return INVALID;
|
||||
}
|
||||
|
||||
return map[value];
|
||||
}
|
||||
|
||||
private Variability(String name, int value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
map[value]=this;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 6992337162326171013L;
|
||||
}
|
@ -26,8 +26,6 @@
|
||||
package sun.jvmstat.perfdata.monitor;
|
||||
|
||||
import sun.jvmstat.monitor.*;
|
||||
import sun.management.counter.Units;
|
||||
import sun.management.counter.Variability;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
|
@ -26,8 +26,6 @@
|
||||
package sun.jvmstat.perfdata.monitor;
|
||||
|
||||
import sun.jvmstat.monitor.*;
|
||||
import sun.management.counter.Units;
|
||||
import sun.management.counter.Variability;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
/**
|
||||
|
@ -26,8 +26,6 @@
|
||||
package sun.jvmstat.perfdata.monitor;
|
||||
|
||||
import sun.jvmstat.monitor.*;
|
||||
import sun.management.counter.Units;
|
||||
import sun.management.counter.Variability;
|
||||
import java.nio.LongBuffer;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.jvmstat.perfdata.monitor;
|
||||
|
||||
import sun.jvmstat.monitor.*;
|
||||
import sun.management.counter.Variability;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
|
@ -26,8 +26,6 @@
|
||||
package sun.jvmstat.perfdata.monitor;
|
||||
|
||||
import sun.jvmstat.monitor.*;
|
||||
import sun.management.counter.Units;
|
||||
import sun.management.counter.Variability;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.jvmstat.perfdata.monitor;
|
||||
|
||||
import sun.jvmstat.monitor.*;
|
||||
import sun.management.counter.Variability;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
|
@ -25,8 +25,6 @@
|
||||
|
||||
package sun.jvmstat.perfdata.monitor.v1_0;
|
||||
|
||||
import sun.management.counter.Units;
|
||||
import sun.management.counter.Variability;
|
||||
import sun.jvmstat.monitor.*;
|
||||
import sun.jvmstat.perfdata.monitor.*;
|
||||
import java.util.*;
|
||||
|
@ -27,8 +27,6 @@ package sun.jvmstat.perfdata.monitor.v2_0;
|
||||
|
||||
import sun.jvmstat.monitor.*;
|
||||
import sun.jvmstat.perfdata.monitor.*;
|
||||
import sun.management.counter.Units;
|
||||
import sun.management.counter.Variability;
|
||||
import java.util.*;
|
||||
import java.util.regex.*;
|
||||
import java.nio.*;
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.tools.jstat;
|
||||
|
||||
import sun.jvmstat.monitor.*;
|
||||
import sun.management.counter.Variability;
|
||||
|
||||
/**
|
||||
* A class implementing the ExpressionEvaluator to resolve unresolved
|
||||
|
@ -29,8 +29,6 @@ import java.util.*;
|
||||
import java.io.*;
|
||||
import sun.jvmstat.monitor.*;
|
||||
import sun.jvmstat.monitor.event.*;
|
||||
import sun.management.counter.Units;
|
||||
import sun.management.counter.Variability;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
/**
|
||||
|
@ -28,8 +28,6 @@ package sun.tools.jstat;
|
||||
import java.util.*;
|
||||
import sun.jvmstat.monitor.*;
|
||||
import sun.jvmstat.monitor.event.*;
|
||||
import sun.management.counter.Variability;
|
||||
import sun.management.counter.Units;
|
||||
|
||||
/**
|
||||
* Application to output jvmstat statistics exported by a target Java
|
||||
|
Loading…
Reference in New Issue
Block a user