[jboss-cvs] jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/collector ...
Takuro Okada
t2-okada at nri.co.jp
Fri Nov 10 04:12:25 EST 2006
User: tokada
Date: 06/11/10 04:12:25
Modified: java/src/expansion/org/jboss/profiler/exp/agent/collector
Tag: JBossProfiler_Expansion MetricCollector.java
ScaleMetricCollector.java
ThreadMetricCollector.java
TimeScaleMetricCollector.java
StackMetricCollector.java
Added: java/src/expansion/org/jboss/profiler/exp/agent/collector
Tag: JBossProfiler_Expansion CollectorConfig.java
Log:
Added some functions for collector setting.
Revision Changes Path
No revision
No revision
1.1.2.3 +6 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/collector/Attic/MetricCollector.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MetricCollector.java
===================================================================
RCS file: /cvsroot/jboss/jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/collector/Attic/MetricCollector.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -b -r1.1.2.2 -r1.1.2.3
--- MetricCollector.java 31 Oct 2006 11:25:48 -0000 1.1.2.2
+++ MetricCollector.java 10 Nov 2006 09:12:25 -0000 1.1.2.3
@@ -76,4 +76,10 @@
*/
void setMetricsMap(MetricsMap metricsMap);
+ /**
+ * Sets the config information
+ * @param config - config object
+ */
+ void setCollectorConfig(CollectorConfig config);
+
}
1.1.2.3 +4 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/collector/Attic/ScaleMetricCollector.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ScaleMetricCollector.java
===================================================================
RCS file: /cvsroot/jboss/jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/collector/Attic/ScaleMetricCollector.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -b -r1.1.2.2 -r1.1.2.3
--- ScaleMetricCollector.java 31 Oct 2006 11:25:48 -0000 1.1.2.2
+++ ScaleMetricCollector.java 10 Nov 2006 09:12:25 -0000 1.1.2.3
@@ -79,6 +79,10 @@
this.metricsMap = metricsMap;
}
+ public void setCollectorConfig(CollectorConfig config) {
+ // Does not use a config.
+ }
+
public void run() {
Map<MetricName, Metric> mmap = null;
if(metricsMap.containsKey(category)) {
1.1.2.3 +18 -15 jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/collector/Attic/ThreadMetricCollector.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ThreadMetricCollector.java
===================================================================
RCS file: /cvsroot/jboss/jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/collector/Attic/ThreadMetricCollector.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -b -r1.1.2.2 -r1.1.2.3
--- ThreadMetricCollector.java 31 Oct 2006 11:25:48 -0000 1.1.2.2
+++ ThreadMetricCollector.java 10 Nov 2006 09:12:25 -0000 1.1.2.3
@@ -54,16 +54,7 @@
private MetricsMap metricsMap = null;
- // TODO Remove a external file.
- private static Map<String, String> IMPLEMENTATION_MAP = new HashMap<String, String>();
- static {
- IMPLEMENTATION_MAP.put("org.jboss.resource.adapter.jdbc.WrapperDataSource", "java.sql.DataSource");
- IMPLEMENTATION_MAP.put("org.jboss.resource.adapter.jdbc.WrappedConnection", "java.sql.Connection");
- IMPLEMENTATION_MAP.put("org.jboss.resource.adapter.jdbc.WrappedStatement", "java.sql.Statement");
- IMPLEMENTATION_MAP.put("org.jboss.resource.adapter.jdbc.WrappedPreparedStatement", "java.sql.PreparedStatement");
- IMPLEMENTATION_MAP.put("org.jboss.resource.adapter.jdbc.WrappedCallableStatement", "java.sql.CallableStatement");
- IMPLEMENTATION_MAP.put("org.jboss.resource.adapter.jdbc.WrappedResultSet", "java.sql.ResultSet");
- }
+ private CollectorConfig config = null;
public ThreadMetricCollector(String category, String operationName, long timestamp, Object... args) {
this.category = category;
@@ -104,6 +95,10 @@
this.metricsMap = metricsMap;
}
+ public void setCollectorConfig(CollectorConfig config) {
+ this.config = config;
+ }
+
@Override
public String toString() {
StringBuilder expression = new StringBuilder();
@@ -173,7 +168,7 @@
break;
}
}else {
- String interfaceName = IMPLEMENTATION_MAP.get(stackTrace[i].getClassName());
+ String interfaceName = config.getJdbcImplementationMap().get(stackTrace[i].getClassName());
if(interfaceName==null) continue;
if(operationName.contains(stackTrace[i].getMethodName())) {
index = i;
@@ -189,9 +184,11 @@
if(className.contains("$")) continue;
else if(methodName.contains("$")) continue;
// Ignores JBoss Profiler classes.
- else if(className.contains("org.jboss.profiler.exp.agent.interceptor")) continue;
+ else if(className.startsWith("org.jboss.profiler.exp.agent.interceptor")) continue;
+ // Ignores Java API classes
+ else if(className.startsWith("java") || className.startsWith("sun")) continue;
// Retrieve servlet class.
- else if(methodName.equals("doGet") || methodName.equals("doPost")) {
+ else if(methodName.equals("doGet") || methodName.equals("doPost") || methodName.equals("service")) {
for(int j=i+1; j<stackTrace.length; j++) {
String c = stackTrace[j].getClassName();
if(className.equals(c)) continue;
@@ -206,10 +203,16 @@
}
break;
}else {
+ // Ignores framework classes.
+ boolean ignore = false;
+ for(String expression : config.getFrameworkExpressionSet()) {
+ if(className.contains(expression)) ignore = true;
+ }
+ if(ignore) continue;
+ }
result = className+"."+methodName;
break;
}
- }
return result;
}
1.1.2.3 +4 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/collector/Attic/TimeScaleMetricCollector.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TimeScaleMetricCollector.java
===================================================================
RCS file: /cvsroot/jboss/jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/collector/Attic/TimeScaleMetricCollector.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -b -r1.1.2.2 -r1.1.2.3
--- TimeScaleMetricCollector.java 31 Oct 2006 11:25:48 -0000 1.1.2.2
+++ TimeScaleMetricCollector.java 10 Nov 2006 09:12:25 -0000 1.1.2.3
@@ -80,6 +80,10 @@
this.metricsMap = metricsMap;
}
+ public void setCollectorConfig(CollectorConfig config) {
+ // Does not use a config.
+ }
+
public void run() {
Map<MetricName, Metric> mmap = null;
if(metricsMap.containsKey(category)) {
1.1.2.3 +4 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/collector/Attic/StackMetricCollector.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: StackMetricCollector.java
===================================================================
RCS file: /cvsroot/jboss/jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/collector/Attic/StackMetricCollector.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -b -r1.1.2.2 -r1.1.2.3
--- StackMetricCollector.java 31 Oct 2006 11:25:48 -0000 1.1.2.2
+++ StackMetricCollector.java 10 Nov 2006 09:12:25 -0000 1.1.2.3
@@ -83,6 +83,10 @@
this.metricsMap = metricsMap;
}
+ public void setCollectorConfig(CollectorConfig config) {
+ // Does not use a config.
+ }
+
private String[] cutoffMethodNames(String[] source, String operationName) {
List<String> result = new ArrayList<String>();
for(int i=0; i<source.length; i++) {
No revision
No revision
1.1.2.1 +85 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/exp/agent/collector/Attic/CollectorConfig.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CollectorConfig.java
===================================================================
RCS file: CollectorConfig.java
diff -N CollectorConfig.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CollectorConfig.java 10 Nov 2006 09:12:25 -0000 1.1.2.1
@@ -0,0 +1,85 @@
+package org.jboss.profiler.exp.agent.collector;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Set;
+
+import javolution.util.FastMap;
+import javolution.util.FastSet;
+import javolution.xml.stream.XMLInputFactory;
+import javolution.xml.stream.XMLStreamConstants;
+import javolution.xml.stream.XMLStreamException;
+import javolution.xml.stream.XMLStreamReader;
+
+import org.apache.log4j.Logger;
+
+public class CollectorConfig {
+
+ private static Logger logger = Logger.getLogger(CollectorConfig.class);
+
+ private Map<String, String> jdbcImplementationMap = new FastMap<String, String>();
+ private Set<String> frameworkExpressionSet = new FastSet<String>();
+
+ /**
+ * Loads the configuration file specified and fills properties.
+ * @param filePath
+ */
+ public CollectorConfig(String filePath) throws XMLStreamException, IOException {
+ try {
+ load(filePath);
+ } catch (Exception e) {
+ logger.error("failed to load collector-config file.");
+ }
+ }
+
+ /**
+ * Gets names of implementation classes mapped JDBC interfaces.
+ * @return map object (implementation : interface)
+ */
+ public Map<String, String> getJdbcImplementationMap() {
+ return jdbcImplementationMap;
+ }
+
+ /**
+ * Get expressions of framework objects
+ * @return set object
+ */
+ public Set<String> getFrameworkExpressionSet() {
+ return frameworkExpressionSet;
+ }
+
+ private void load(String filePath) throws XMLStreamException, IOException {
+ InputStream is = null;
+ XMLStreamReader reader = null;
+ try {
+ is = this.getClass().getResourceAsStream(filePath);
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+ reader = factory.createXMLStreamReader(is);
+ String state = "";
+ while(reader.getEventType() != XMLStreamConstants.END_DOCUMENT) {
+ switch(reader.next()) {
+ case XMLStreamConstants.START_ELEMENT:
+ if(reader.getLocalName().equals("jdbc")) state = "jdbc";
+ else if(reader.getLocalName().equals("framework")) state = "framework";
+ else if(state.equals("jdbc") && reader.getLocalName().equals("impl-mapping")) {
+ String key = reader.getAttributeValue(null, "impl").toString();
+ String value = reader.getAttributeValue(null, "interface").toString();
+ jdbcImplementationMap.put(key, value);
+ }
+ if(state.equals("framework") && reader.getLocalName().equals("expression")) {
+ if(reader.hasNext()) {
+ reader.next();
+ if(reader.hasText()) {
+ frameworkExpressionSet.add(reader.getText().toString());
+ }
+ }
+ }
+ }
+ }
+ } finally {
+ if(is!=null) is.close();
+ if(reader!=null) reader.close();
+ }
+ }
+}
More information about the jboss-cvs-commits
mailing list