Commit 82dacdba authored by ncampbell's avatar ncampbell

Reorganized the Accumulators into their own package

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/branches/pampero@2856 b35dd754-fafc-0310-a699-88a17e54d16e
parent bfb9da80
...@@ -22,6 +22,7 @@ import javax.management.ReflectionException; ...@@ -22,6 +22,7 @@ import javax.management.ReflectionException;
import org.jivesoftware.messenger.container.Plugin; import org.jivesoftware.messenger.container.Plugin;
import org.jivesoftware.messenger.container.PluginManager; import org.jivesoftware.messenger.container.PluginManager;
import org.jivesoftware.messenger.plugin.meter.accumulator.Accumulator;
import org.jrobin.core.RrdDbPool; import org.jrobin.core.RrdDbPool;
import org.jrobin.core.RrdException; import org.jrobin.core.RrdException;
......
...@@ -37,6 +37,8 @@ import javax.management.relation.RelationServiceMBean; ...@@ -37,6 +37,8 @@ import javax.management.relation.RelationServiceMBean;
import javax.management.relation.RoleInfo; import javax.management.relation.RoleInfo;
import org.apache.commons.jxpath.JXPathIntrospector; import org.apache.commons.jxpath.JXPathIntrospector;
import org.jivesoftware.messenger.plugin.meter.accumulator.Accumulator;
import org.jivesoftware.messenger.plugin.meter.accumulator.AccumulatorManager;
import org.jrobin.annotations.Arc; import org.jrobin.annotations.Arc;
import org.jrobin.annotations.Ds; import org.jrobin.annotations.Ds;
import org.jrobin.annotations.Rrd; import org.jrobin.annotations.Rrd;
...@@ -66,6 +68,9 @@ public class RrdManager { ...@@ -66,6 +68,9 @@ public class RrdManager {
return Collections.unmodifiableMap(stores); return Collections.unmodifiableMap(stores);
} }
/** The overrides. */
private final List<Accumulator> overrides = new ArrayList<Accumulator>();
/** The stores. */ /** The stores. */
private static Map<String, RrdManager> stores = new HashMap<String, RrdManager>(); private static Map<String, RrdManager> stores = new HashMap<String, RrdManager>();
...@@ -109,13 +114,14 @@ public class RrdManager { ...@@ -109,13 +114,14 @@ public class RrdManager {
is = this.getClass().getClassLoader().getResourceAsStream("typeoverrides.config"); is = this.getClass().getClassLoader().getResourceAsStream("typeoverrides.config");
} }
try { try {
new Properties().load(is); Properties p = new Properties();
p.load(is);
Enumeration names = new Properties().propertyNames(); Enumeration names = p.propertyNames();
for(; names.hasMoreElements(); ) { for(; names.hasMoreElements(); ) {
String name = (String)names.nextElement(); String name = (String)names.nextElement();
try { try {
AccumulatorManager.registerOverride(new ObjectName(name), Class.forName(new Properties().getProperty(name))); AccumulatorManager.registerOverride(new ObjectName(name), Class.forName(p.getProperty(name)));
} catch (Exception e) { } catch (Exception e) {
logger.log(Level.WARNING, "Unable to register override: {0}", e.getLocalizedMessage()); logger.log(Level.WARNING, "Unable to register override: {0}", e.getLocalizedMessage());
} }
...@@ -128,6 +134,13 @@ public class RrdManager { ...@@ -128,6 +134,13 @@ public class RrdManager {
/**
* @return overrides A list of overrides
*/
public List<Accumulator> getGraphableObjectNames() {
return this.overrides;
}
/** /**
* @throws MalformedObjectNameException * @throws MalformedObjectNameException
......
/** /**
* *
*/ */
package org.jivesoftware.messenger.plugin.meter; package org.jivesoftware.messenger.plugin.meter.accumulator;
import java.io.IOException; import java.io.IOException;
import java.util.Date; import java.util.Date;
...@@ -12,6 +12,7 @@ import java.util.logging.Logger; ...@@ -12,6 +12,7 @@ import java.util.logging.Logger;
import javax.management.ObjectName; import javax.management.ObjectName;
import org.jivesoftware.messenger.plugin.meter.UnableToAllocateAccumulator;
import org.jrobin.annotations.Arc; import org.jrobin.annotations.Arc;
import org.jrobin.annotations.Ds; import org.jrobin.annotations.Ds;
import org.jrobin.annotations.Rrd; import org.jrobin.annotations.Rrd;
...@@ -25,7 +26,7 @@ import org.jrobin.core.Sample; ...@@ -25,7 +26,7 @@ import org.jrobin.core.Sample;
* @author Noah Campbell * @author Noah Campbell
* @version 1.0 * @version 1.0
*/ */
public class Accumulator implements Runnable { public class Accumulator implements AccumulatorMBean, Runnable {
/** The logger. */ /** The logger. */
...@@ -56,6 +57,9 @@ public class Accumulator implements Runnable { ...@@ -56,6 +57,9 @@ public class Accumulator implements Runnable {
/** The lastTimestamp. */ /** The lastTimestamp. */
private long lastTimestamp = Long.MIN_VALUE; private long lastTimestamp = Long.MIN_VALUE;
/** The count. */
private long count = 0;
/** /**
* @see java.lang.Runnable#run() * @see java.lang.Runnable#run()
*/ */
...@@ -94,6 +98,7 @@ public class Accumulator implements Runnable { ...@@ -94,6 +98,7 @@ public class Accumulator implements Runnable {
} }
s.update(); s.update();
lastTimestamp = timestamp; lastTimestamp = timestamp;
count++;
} catch (IOException e) { } catch (IOException e) {
logger.log(Level.WARNING, "accumulator.ioexception", e); logger.log(Level.WARNING, "accumulator.ioexception", e);
...@@ -119,4 +124,24 @@ public class Accumulator implements Runnable { ...@@ -119,4 +124,24 @@ public class Accumulator implements Runnable {
} }
/**
* @see org.jivesoftware.messenger.plugin.meter.accumulator.AccumulatorMBean#getPath()
*/
public String getPath() {
return this.getPath();
}
/**
* @see org.jivesoftware.messenger.plugin.meter.accumulator.AccumulatorMBean#getSourceMBean()
*/
public ObjectName getSourceMBean() {
return this.objectName;
}
/**
* @see org.jivesoftware.messenger.plugin.meter.accumulator.AccumulatorMBean#getTotalReads()
*/
public long getTotalReads() {
return count;
}
} }
/** /**
* *
*/ */
package org.jivesoftware.messenger.plugin.meter; package org.jivesoftware.messenger.plugin.meter.accumulator;
/** /**
* @author Noah Campbell * @author Noah Campbell
......
/** /**
* *
*/ */
package org.jivesoftware.messenger.plugin.meter; package org.jivesoftware.messenger.plugin.meter.accumulator;
import java.util.Map; import java.util.Map;
......
/**
*
*/
package org.jivesoftware.messenger.plugin.meter.accumulator;
import javax.management.ObjectName;
/**
* @author Noah Campbell
* @version 1.0
*/
public interface AccumulatorMBean {
String getPath();
ObjectName getSourceMBean();
long getTotalReads();
}
/** /**
* *
*/ */
package org.jivesoftware.messenger.plugin.meter; package org.jivesoftware.messenger.plugin.meter.accumulator;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationHandler;
...@@ -20,6 +20,7 @@ import javax.management.ObjectName; ...@@ -20,6 +20,7 @@ import javax.management.ObjectName;
import org.apache.commons.jxpath.CompiledExpression; import org.apache.commons.jxpath.CompiledExpression;
import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.JXPathContext;
import org.apache.commons.jxpath.JXPathException; import org.apache.commons.jxpath.JXPathException;
import org.jivesoftware.messenger.plugin.meter.UnableToAllocateAccumulator;
import org.jrobin.annotations.Ds; import org.jrobin.annotations.Ds;
import org.jrobin.annotations.Rrd; import org.jrobin.annotations.Rrd;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment