From 3471b84099b069520c429a93c5b6178831da5f59 Mon Sep 17 00:00:00 2001 From: Bjoern Martin Date: Sun, 29 Apr 2007 18:59:13 +0000 Subject: [PATCH] added skeleton ant.jar to unify classpath added MBean impl for Swap fixed several MBeanConstructorInfo specs (were reporting SigarCpu as class) fixed possible (de)registration problem in registry bean (was not handling ObjectInstances correctly) --- bindings/java/.classpath | 2 +- bindings/java/lib/ant.jar | Bin 0 -> 24393 bytes .../org/hyperic/sigar/jmx/SigarCpuInfo.java | 6 +- .../org/hyperic/sigar/jmx/SigarCpuPerc.java | 6 +- .../src/org/hyperic/sigar/jmx/SigarMem.java | 4 +- .../org/hyperic/sigar/jmx/SigarRegistry.java | 40 +++- .../src/org/hyperic/sigar/jmx/SigarSwap.java | 208 ++++++++++++++++++ 7 files changed, 251 insertions(+), 15 deletions(-) create mode 100644 bindings/java/lib/ant.jar create mode 100644 bindings/java/src/org/hyperic/sigar/jmx/SigarSwap.java diff --git a/bindings/java/.classpath b/bindings/java/.classpath index 1c92bf0f..79cdada9 100644 --- a/bindings/java/.classpath +++ b/bindings/java/.classpath @@ -6,8 +6,8 @@ - + diff --git a/bindings/java/lib/ant.jar b/bindings/java/lib/ant.jar new file mode 100644 index 0000000000000000000000000000000000000000..1337ad427e4fbb14b004258492b42b82926777cd GIT binary patch literal 24393 zcmafZV~}oLx7}&mwr$(CZQDL=+jjTUwr$(SX`Hrg<-PfCa+6fPWY?;__Kz`Z%~gBW zsEMH{0|E;D>pz|}uR-Sj{_&qL(0_IZXA1_!e~Wp`SXXYh#me8xhD%4~GIEW#}h3n{*iL51$ z7;30(XY6`2bsM&V`9Ajp8u?F&cTy6#l1R82iC7k*cwf=Db3NW&e@b<>CZ_+m-0+=z z%zn*wa4`J%-oy4ouA)8~0YH*7&ikv{Crj5d*lOl)W_Gv8u2nl;Mj9bFkOVURT<;K!umDP(P%f8#IUBA?WJxpn#J|f5hr{Be^!{uYLusG zZ8KK9H?5@zk`ZauV6x0qX^_F4)tWLEthJ3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L4%cgZL(6zCXbMP;s8-r}NKX83}oHw~j(OQ_z)(R~I5}#(zLHl^% z9bi^wy_sX-VcRWEV2h7z_X1ZgF)2TqkpS)ldDAxC!WAfJ&47bu9->dn8!v;NUuixo zn~`L$T6D&}RHY@4J*rO_piC)=6;-&i$h%Xs0DeafRV$Ph>Oo5i$LWvE-wV&gHCX89 ztTaX~08QBPKJ=ijToEwyMusJb0Nr#1rGL~h5nJVQmxNd-87lbKs>`d$M=j!Ug|)a+ z*VJRsuDDd~(mA=+XD=>>)UMcFd3b*ASR}4099x*8C+8Kle1?0017ld23Jd19pp%I5 zjh>)O@;KI%^)rV;ot71XO+!3FU5)X~v$b_3gcf3Wq4f7#_9fAIf?{hM9x4{RRmFR=gF?;qFPe^Q_PJ$d(=O7U~RrT+`{-*b5X q1phN(^#}anrwabx-|+8%-|xJYssbX?uNu^!*V4~upqBoxyZ-?0x(GJ_ literal 0 HcmV?d00001 diff --git a/bindings/java/src/org/hyperic/sigar/jmx/SigarCpuInfo.java b/bindings/java/src/org/hyperic/sigar/jmx/SigarCpuInfo.java index 7cac5321..de051937 100644 --- a/bindings/java/src/org/hyperic/sigar/jmx/SigarCpuInfo.java +++ b/bindings/java/src/org/hyperic/sigar/jmx/SigarCpuInfo.java @@ -89,14 +89,14 @@ public class SigarCpuInfo extends AbstractMBean { "sigar", Sigar.class.getName(), "The Sigar instance to use to fetch data from"); MBEAN_CONSTR_CPUINDEX = new MBeanConstructorInfo( - SigarCpu.class.getName(), + SigarCpuInfo.class.getName(), "Creates a new instance for the CPU index specified, " + "using a new Sigar instance to fetch the data. " + "Fails if the CPU index is out of range.", new MBeanParameterInfo[]{ MBEAN_PARAM_CPUINDEX}); MBEAN_CONSTR_CPUINDEX_SIGAR = new MBeanConstructorInfo( - SigarCpu.class.getName(), + SigarCpuInfo.class.getName(), "Creates a new instance for the CPU index specified, " + "using the Sigar instance specified to fetch the data. " + "Fails if the CPU index is out of range.", @@ -104,7 +104,7 @@ public class SigarCpuInfo extends AbstractMBean { MBEAN_PARAM_SIGAR, MBEAN_PARAM_CPUINDEX}); MBEAN_INFO = new MBeanInfo( - SigarCpu.class.getName(), + SigarCpuInfo.class.getName(), "Sigar CPU Info MBean, provides overall information for a " + "single CPU. This information only changes if, for example, " + "a CPU is reducing its clock frequency or shutting down " + diff --git a/bindings/java/src/org/hyperic/sigar/jmx/SigarCpuPerc.java b/bindings/java/src/org/hyperic/sigar/jmx/SigarCpuPerc.java index c63ba5e0..e3aec998 100644 --- a/bindings/java/src/org/hyperic/sigar/jmx/SigarCpuPerc.java +++ b/bindings/java/src/org/hyperic/sigar/jmx/SigarCpuPerc.java @@ -101,14 +101,14 @@ public class SigarCpuPerc extends AbstractMBean { "sigar", Sigar.class.getName(), "The Sigar instance to use to fetch data from"); MBEAN_CONSTR_CPUINDEX = new MBeanConstructorInfo( - SigarCpu.class.getName(), + SigarCpuPerc.class.getName(), "Creates a new instance for the CPU index specified, " + "using a new Sigar instance to fetch the data. " + "Fails if the CPU index is out of range.", new MBeanParameterInfo[]{ MBEAN_PARAM_CPUINDEX}); MBEAN_CONSTR_CPUINDEX_SIGAR = new MBeanConstructorInfo( - SigarCpu.class.getName(), + SigarCpuPerc.class.getName(), "Creates a new instance for the CPU index specified, " + "using the Sigar instance specified to fetch the data. " + "Fails if the CPU index is out of range.", @@ -116,7 +116,7 @@ public class SigarCpuPerc extends AbstractMBean { MBEAN_PARAM_SIGAR, MBEAN_PARAM_CPUINDEX}); MBEAN_INFO = new MBeanInfo( - SigarCpu.class.getName(), + SigarCpuPerc.class.getName(), "Sigar CPU MBean. Provides percentage data for a single " + "CPU, averaged over the timeframe between the last and " + "the current measurement point. Two measurement points " + diff --git a/bindings/java/src/org/hyperic/sigar/jmx/SigarMem.java b/bindings/java/src/org/hyperic/sigar/jmx/SigarMem.java index dcb24abf..13bc1604 100644 --- a/bindings/java/src/org/hyperic/sigar/jmx/SigarMem.java +++ b/bindings/java/src/org/hyperic/sigar/jmx/SigarMem.java @@ -88,13 +88,13 @@ public class SigarMem extends AbstractMBean { "sigar", Sigar.class.getName(), "The Sigar instance to use to fetch data from"); MBEAN_CONSTR_SIGAR = new MBeanConstructorInfo( - SigarCpu.class.getName(), + SigarMem.class.getName(), "Creates a new instance, using the Sigar instance " + "specified to fetch the data.", new MBeanParameterInfo[]{ MBEAN_PARAM_SIGAR}); MBEAN_INFO = new MBeanInfo( - SigarCpu.class.getName(), + SigarMem.class.getName(), "Sigar Memory MBean, provides raw data for the physical " + "memory installed on the system. Uses an internal cache " + "that invalidates within 500ms, allowing for bulk request " + diff --git a/bindings/java/src/org/hyperic/sigar/jmx/SigarRegistry.java b/bindings/java/src/org/hyperic/sigar/jmx/SigarRegistry.java index fb237bc7..11a14af9 100644 --- a/bindings/java/src/org/hyperic/sigar/jmx/SigarRegistry.java +++ b/bindings/java/src/org/hyperic/sigar/jmx/SigarRegistry.java @@ -174,30 +174,41 @@ public class SigarRegistry extends AbstractMBean { try { final int cpuCount = sigar.getCpuInfoList().length; for (int i = 0; i < cpuCount; i++) { + // add CPU bean SigarCpu nextCpu = new SigarCpu(sigarImpl, i); - SigarCpuPerc nextCpuPerc = new SigarCpuPerc(sigarImpl, i); - SigarCpuInfo nextCpuInfo = new SigarCpuInfo(sigarImpl, i); try { if (!mbeanServer.isRegistered(new ObjectName(nextCpu.getObjectName()))) nextRegistered = mbeanServer.registerMBean(nextCpu, null); } catch (Exception e) { // ignore } // add MBean to set of managed beans - managedBeans.add(nextRegistered.getObjectName()); + if (nextRegistered != null) + managedBeans.add(nextRegistered.getObjectName()); + nextRegistered = null; + + // add CPU percentage bean + SigarCpuPerc nextCpuPerc = new SigarCpuPerc(sigarImpl, i); try { if (!mbeanServer.isRegistered(new ObjectName(nextCpuPerc.getObjectName()))) nextRegistered = mbeanServer.registerMBean(nextCpuPerc, null); } catch (Exception e) { // ignore } // add MBean to set of managed beans - managedBeans.add(nextRegistered.getObjectName()); + if (nextRegistered != null) + managedBeans.add(nextRegistered.getObjectName()); + nextRegistered = null; + + // add CPU info bean + SigarCpuInfo nextCpuInfo = new SigarCpuInfo(sigarImpl, i); try { if (!mbeanServer.isRegistered(new ObjectName(nextCpuInfo.getObjectName()))) nextRegistered = mbeanServer.registerMBean(nextCpuInfo, null); } catch (Exception e) { // ignore } // add MBean to set of managed beans - managedBeans.add(nextRegistered.getObjectName()); + if (nextRegistered != null) + managedBeans.add(nextRegistered.getObjectName()); + nextRegistered = null; } } catch (SigarException e) { @@ -212,6 +223,7 @@ public class SigarRegistry extends AbstractMBean { ObjectInstance nextRegistered = null; + // add physical memory bean SigarMem mem = new SigarMem(sigarImpl); try { @@ -221,7 +233,23 @@ public class SigarRegistry extends AbstractMBean { } // add MBean to set of managed beans - managedBeans.add(nextRegistered.getObjectName()); + if (nextRegistered != null) + managedBeans.add(nextRegistered.getObjectName()); + nextRegistered = null; + + // add swap memory bean + SigarSwap swap = new SigarSwap(sigarImpl); + try { + if (!mbeanServer.isRegistered(new ObjectName(swap.getObjectName()))) + nextRegistered = mbeanServer.registerMBean(swap, null); + } catch (Exception e) { // ignore + nextRegistered = null; + } + + // add MBean to set of managed beans + if (nextRegistered != null) + managedBeans.add(nextRegistered.getObjectName()); + nextRegistered = null; } /** diff --git a/bindings/java/src/org/hyperic/sigar/jmx/SigarSwap.java b/bindings/java/src/org/hyperic/sigar/jmx/SigarSwap.java new file mode 100644 index 00000000..8ce05816 --- /dev/null +++ b/bindings/java/src/org/hyperic/sigar/jmx/SigarSwap.java @@ -0,0 +1,208 @@ +/* + * Copyright (C) [2004, 2005, 2006, 2007], Hyperic, Inc. + * This file is part of SIGAR. + * + * SIGAR is free software; you can redistribute it and/or modify + * it under the terms version 2 of the GNU General Public License as + * published by the Free Software Foundation. This program 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 for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + */ + +package org.hyperic.sigar.jmx; + +import javax.management.Attribute; +import javax.management.AttributeNotFoundException; +import javax.management.MBeanAttributeInfo; +import javax.management.MBeanConstructorInfo; +import javax.management.MBeanException; +import javax.management.MBeanInfo; +import javax.management.MBeanParameterInfo; +import javax.management.ReflectionException; + +import org.hyperic.sigar.Sigar; +import org.hyperic.sigar.SigarException; + +/** + * Sigar JMX MBean implementation for the Swap information + * package. Provides an OpenMBean conform implementation. + * + * @author Bjoern Martin + * @since 1.4 (2007-04) + */ +public class SigarSwap extends AbstractMBean { + + private static final String MBEAN_TYPE = "Swap"; + + private static final MBeanInfo MBEAN_INFO; + + private static final MBeanAttributeInfo MBEAN_ATTR_FREE; + + private static final MBeanAttributeInfo MBEAN_ATTR_TOTAL; + + private static final MBeanAttributeInfo MBEAN_ATTR_USED; + + private static final MBeanConstructorInfo MBEAN_CONSTR_SIGAR; + + private static MBeanParameterInfo MBEAN_PARAM_SIGAR; + + static { + MBEAN_ATTR_FREE = new MBeanAttributeInfo( + "Free", "long", + "The amount of free swap memory, in [bytes]", + true, false, false); + MBEAN_ATTR_TOTAL = new MBeanAttributeInfo( + "Total", "long", + "The total amount of swap memory, in [bytes]", + true, false, false); + MBEAN_ATTR_USED = new MBeanAttributeInfo( + "Used", "long", + "The amount of swap memory in use, in [bytes]", + true, false, false); + MBEAN_PARAM_SIGAR = new MBeanParameterInfo( + "sigar", Sigar.class.getName(), + "The Sigar instance to use to fetch data from"); + MBEAN_CONSTR_SIGAR = new MBeanConstructorInfo( + SigarSwap.class.getName(), + "Creates a new instance, using the Sigar instance " + + "specified to fetch the data.", + new MBeanParameterInfo[]{ + MBEAN_PARAM_SIGAR}); + MBEAN_INFO = new MBeanInfo( + SigarSwap.class.getName(), + "Sigar Swap MBean, provides raw data for the swap memory " + + "configured on the system. Uses an internal cache that " + + "invalidates within 5 seconds.", + new MBeanAttributeInfo[]{ + MBEAN_ATTR_FREE, + MBEAN_ATTR_TOTAL, + MBEAN_ATTR_USED}, + new MBeanConstructorInfo[]{ + MBEAN_CONSTR_SIGAR}, + null, null); + + } + + /** + * Object name this instance will give itself when being registered to an + * MBeanServer. + */ + private final String objectName; + + /** + * Creates a new instance, using the Sigar instance specified to fetch the + * data. + * + * @param sigar + * The Sigar instance to use to fetch data from + * + * @throws IllegalArgumentException + * If an unexpected Sigar error occurs + */ + public SigarSwap(Sigar sigar) throws IllegalArgumentException { + super(sigar, CACHED_5SEC); + + this.objectName = SigarInvokerJMX.DOMAIN_NAME + ":" + MBEAN_ATTR_TYPE + + "=Swap"; + } + + /** + * Object name this instance will give itself when being registered to an + * MBeanServer. + */ + public String getObjectName() { + return this.objectName; + } + + /** + * @return The amount of free swap memory, in [bytes] + */ + public long getFree() { + try { + return sigar.getSwap().getFree(); + } catch (SigarException e) { + throw unexpectedError(MBEAN_TYPE, e); + } + } + + /** + * @return The total amount of swap memory, in [bytes] + */ + public long getTotal() { + try { + return sigar.getSwap().getTotal(); + } catch (SigarException e) { + throw unexpectedError(MBEAN_TYPE, e); + } + } + + /** + * @return The amount of swap memory in use, in [bytes] + */ + public long getUsed() { + try { + return sigar.getSwap().getUsed(); + } catch (SigarException e) { + throw unexpectedError(MBEAN_TYPE, e); + } + } + + // ------- + // Implementation of the DynamicMBean interface + // ------- + + /* + * (non-Javadoc) + * + * @see javax.management.DynamicMBean#getAttribute(java.lang.String) + */ + public Object getAttribute(String attr) throws AttributeNotFoundException, + MBeanException, ReflectionException { + if (MBEAN_ATTR_FREE.getName().equals(attr)) { + return new Long(getFree()); + + } else if (MBEAN_ATTR_TOTAL.getName().equals(attr)) { + return new Long(getTotal()); + + } else if (MBEAN_ATTR_USED.getName().equals(attr)) { + return new Long(getUsed()); + + } else { + throw new AttributeNotFoundException(attr); + } + } + + /* + * (non-Javadoc) + * @see javax.management.DynamicMBean#setAttribute(javax.management.Attribute) + */ + public void setAttribute(Attribute attr) throws AttributeNotFoundException { + throw new AttributeNotFoundException(attr.getName()); + } + + /* + * (non-Javadoc) + * @see javax.management.DynamicMBean#invoke(java.lang.String, + * java.lang.Object[], java.lang.String[]) + */ + public Object invoke(String actionName, Object[] params, String[] signature) + throws ReflectionException { + throw new ReflectionException(new NoSuchMethodException(actionName), + actionName); + } + + /* + * (non-Javadoc) + * @see javax.management.DynamicMBean#getMBeanInfo() + */ + public MBeanInfo getMBeanInfo() { + return MBEAN_INFO; + } +}