[jboss-cvs] jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent ...
Takuro Okada
t2-okada at nri.co.jp
Mon Feb 19 05:52:03 EST 2007
User: tokada
Date: 07/02/19 05:52:03
Modified: java/src/expansion/org/jboss/profiler/exp/agent Tag:
JBossProfiler_Expansion
DefaultProfilerServiceMBean.java
DefaultProfilerService.java
Log:
Removed an interface for collector config.
Revision Changes Path
No revision
No revision
1.1.2.6 +36 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/Attic/DefaultProfilerServiceMBean.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DefaultProfilerServiceMBean.java
===================================================================
RCS file: /cvsroot/jboss/jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/Attic/DefaultProfilerServiceMBean.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -b -r1.1.2.5 -r1.1.2.6
--- DefaultProfilerServiceMBean.java 22 Dec 2006 08:38:49 -0000 1.1.2.5
+++ DefaultProfilerServiceMBean.java 19 Feb 2007 10:52:03 -0000 1.1.2.6
@@ -61,18 +61,54 @@
void setPersistorName(String persistorName);
/**
+ * Gets the persistor class name.
+ * @return persistor class name
+ */
+ String getPersistorName();
+
+ /**
* Sets whether the metric data is stored.
* @param storable - whether the metric data is stored
*/
void setStorable(boolean storable);
/**
+ * Gets whether the metric data is stored.
+ * @return whether the metric data is stored
+ */
+ boolean isStorable();
+
+ /**
* Sets a period to persist metrics data.
* @param persistentPeriod - a period (minutes)
*/
void setPersistentPeriod(long persistentPeriod);
/**
+ * Gets a period to persist metrics data.
+ * @return a period (minutes)
+ */
+ long getPersistentPeriod();
+
+ /**
+ * Sets the path of persistent directory.
+ * @param persistentPath the path of persistent directory
+ */
+ void setPersistentPath(String persistentPath);
+
+ /**
+ * Gets the path of persistent directory.
+ * @return the path of persistent directory
+ */
+ String getPersistentPath();
+
+ /**
+ * Gets the size of the metrics data.
+ * @return the size of the metrics data
+ */
+ int getMetricsSize();
+
+ /**
* Gets a snapshot of current metrics data.
* @return metrics data
*/
1.1.2.7 +64 -26 jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/Attic/DefaultProfilerService.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DefaultProfilerService.java
===================================================================
RCS file: /cvsroot/jboss/jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/Attic/DefaultProfilerService.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -b -r1.1.2.6 -r1.1.2.7
--- DefaultProfilerService.java 15 Feb 2007 08:29:02 -0000 1.1.2.6
+++ DefaultProfilerService.java 19 Feb 2007 10:52:03 -0000 1.1.2.7
@@ -22,15 +22,18 @@
package org.jboss.profiler.exp.agent;
+import java.io.File;
import java.util.Date;
+import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.log4j.Logger;
-import org.jboss.profiler.exp.agent.collector.CollectorConfig;
+import org.jboss.profiler.exp.adaptor.ServiceManager;
import org.jboss.profiler.exp.agent.collector.MetricCollector;
+import org.jboss.profiler.exp.agent.collector.model.Metric;
import org.jboss.profiler.exp.agent.collector.model.MetricName;
import org.jboss.profiler.exp.agent.collector.model.MetricsMap;
import org.jboss.profiler.exp.agent.persistor.MetricsPersistor;
@@ -56,40 +59,43 @@
/*
* collector executor
*/
- private ExecutorService collectorExecutor = null;
+ private ExecutorService collectorExecutor;
/*
* persistor
*/
- private String persistorName = null;
- private MetricsPersistor metricsPersistor = null;
- private Timer persistentTimer = null;
+ private String persistorName;
+ private MetricsPersistor metricsPersistor;
+ private Timer persistentTimer;
private long persistentPeriod = 1*60*60*1000;
/*
* parameters
*/
private boolean storable = false;
-
- /*
- * collector config
- */
- private CollectorConfig collectorConfig = null;
+ private String persistentPath;
public void start() throws Exception {
//The executor gives priority to adding a new thread.
collectorExecutor = Executors.newCachedThreadPool();
+ if(storable) {
try {
metricsPersistor = (MetricsPersistor)Class.forName(persistorName).newInstance();
} catch (Exception e) {
logger.error("Persistor name is illegal.");
}
+ if(persistentPath==null) {
+ // JBoss AS only
+ File file = (File)ServiceManager.getAttributeLocal("jboss.system:type=ServerConfig", "ServerLogDir");
+ persistentPath = file.getPath() + File.separator + "jboss-profiler"+ File.separator;
+ }
+ metricsPersistor.setPersistentPath(persistentPath);
+
persistentTimer = new Timer("Persistent Timer", true);
persistentTimer.scheduleAtFixedRate(new PersistentTask(), 10000, persistentPeriod);
-
- collectorConfig = new CollectorConfig("/collector-config.xml");
+ }
logger.info("started");
}
@@ -103,14 +109,15 @@
}
public void stop() throws Exception {
+ if(storable) {
persistentTimer.cancel();
+ }
collectorExecutor.shutdown();
logger.info("stoped");
}
public void submitMetric(MetricCollector collector) {
collector.setMetricsMap(metricsMap);
- collector.setCollectorConfig(collectorConfig);
if(collectorExecutor == null) return;
try {
synchronized(metricsMap) {
@@ -129,10 +136,45 @@
this.persistentPeriod = persistentPeriod * 60 * 1000;
}
+ public void setStorable(boolean storable) {
+ this.storable = storable;
+ }
+
+ public void setPersistentPath(String persistentPath) {
+ this.persistentPath = persistentPath;
+ }
+
+ public String getPersistentPath() {
+ return persistentPath;
+ }
+
+ public long getPersistentPeriod() {
+ return persistentPeriod;
+ }
+
+ public String getPersistorName() {
+ return persistorName;
+ }
+
+ public boolean isStorable() {
+ return storable;
+ }
+
+ public int getMetricsSize() {
+ int result = 0;
+ for(Map<String, Map<MetricName, Metric>> ov : metricsMap.values()) {
+ for(Map<MetricName, Metric> mv : ov.values()) {
+ result += mv.size();
+ }
+ }
+ return result;
+ }
+
private void saveMetrics() {
if(!storable || metricsMap.size()==0) return;
metricsPersistor.store(copyMetrics());
resetMetrics();
+ logger.info("saved current metrics data.");
}
public void resetMetrics() {
@@ -177,10 +219,6 @@
return result;
}
- public void setStorable(boolean storable) {
- this.storable = storable;
- }
-
private class PersistentTask extends TimerTask {
@Override
More information about the jboss-cvs-commits
mailing list