[jboss-cvs] jboss-profiler/java/src/expansion/org/jboss/profiler/agent/collector/model ...
Takuro Okada
t2-okada at nri.co.jp
Wed Apr 11 07:13:09 EDT 2007
User: tokada
Date: 07/04/11 07:13:09
Added: java/src/expansion/org/jboss/profiler/agent/collector/model
Tag: JBossProfiler_Expansion MetricsMap.java
Metric.java TimeScaleMetric.java ThreadMetric.java
StackMetric.java MetricName.java ScaleMetric.java
Log:
Moved to another directory
Revision Changes Path
No revision
No revision
1.1.2.1 +85 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/agent/collector/model/Attic/MetricsMap.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MetricsMap.java
===================================================================
RCS file: MetricsMap.java
diff -N MetricsMap.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MetricsMap.java 11 Apr 2007 11:13:09 -0000 1.1.2.1
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.agent.collector.model;
+
+import java.util.Map;
+
+import javolution.util.FastMap;
+
+/**
+ * The map object of the entity object(instance of Metric).
+ *
+ * <p>The following structure are created. </p>
+ * <p>
+ * <table border="1">
+ * <tr>
+ * <td colspan="4">Map</td>
+ * </tr>
+ * <tr>
+ * <td rowspan="3" valign="top">category : String</td>
+ * <td colspan="3">Map</td>
+ * </tr>
+ * <tr>
+ * <td rowspan="2" valign="top">operation name : String</td>
+ * <td colspan="3">Map</td>
+ * </tr>
+ * <tr>
+ * <td>MetricName</td>
+ * <td>Metric</td>
+ * </tr>
+ * </table>
+ * </p>
+ *
+ * @see org.jboss.profiler.production.metrics.MetricName
+ * @author Takuro Okada (Nomura Research Institute, Ltd.)
+ * Copyright 2006 Nomura Research Institute, Ltd. All Rights Reserved.
+ * Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2006.
+ * Result of Open Source Software Development Activities of Information-technology Promotion Agency, Japan.
+ */
+public class MetricsMap extends FastMap<String, Map<String, Map<MetricName, Metric>>> {
+
+ public void merge(MetricsMap map) {
+
+ for(Map.Entry<String, Map<String, Map<MetricName, Metric>>> cEntry : map.entrySet()) {
+ if(this.containsKey(cEntry.getKey())) {
+ Map<String, Map<MetricName, Metric>> oMap = this.get(cEntry.getKey());
+ for(Map.Entry<String, Map<MetricName, Metric>> oEntry : cEntry.getValue().entrySet()) {
+ if(oMap.containsKey(cEntry.getKey())) {
+ Map<MetricName, Metric> mMap = oMap.get(oEntry.getKey());
+ for(Map.Entry<MetricName, Metric> mEntry : oEntry.getValue().entrySet()) {
+ if(mMap.containsKey(mEntry.getKey())) {
+ mMap.get(mEntry.getKey()).merge(mEntry.getValue());
+ }else {
+ mMap.put(mEntry.getKey(), mEntry.getValue());
+ }
+ }
+ }else {
+ oMap.put(oEntry.getKey(), oEntry.getValue());
+ }
+ }
+ }else {
+ this.put(cEntry.getKey(), cEntry.getValue());
+ }
+ }
+ }
+}
1.1.2.1 +68 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/agent/collector/model/Attic/Metric.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Metric.java
===================================================================
RCS file: Metric.java
diff -N Metric.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Metric.java 11 Apr 2007 11:13:09 -0000 1.1.2.1
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.agent.collector.model;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * The entity object for metric value.
+ *
+ * @author Takuro Okada (Nomura Research Institute, Ltd.)
+ * Copyright 2006 Nomura Research Institute, Ltd. All Rights Reserved.
+ * Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2006.
+ * Result of Open Source Software Development Activities of Information-technology Promotion Agency, Japan.
+ */
+public interface Metric<T> extends Cloneable, Serializable {
+
+ /**
+ * Updates current value.
+ * @param value - the value to update
+ * @param args - optional value
+ */
+ void update(T value, Object... args);
+
+ /**
+ * Resets current value.
+ */
+ void reset();
+
+ /**
+ * Merges the metric data
+ * @param metric
+ */
+ void merge(Metric metric);
+
+ /**
+ * Converts to properties expression.
+ * @return properties expression (Map / List of Map)
+ */
+ Object toProperties();
+
+ /**
+ * Converts to metric value.
+ * @param properties - properties expression
+ */
+ void fromProperties(Map<String, String> properties);
+
+}
\ No newline at end of file
1.1.2.1 +96 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/agent/collector/model/Attic/TimeScaleMetric.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TimeScaleMetric.java
===================================================================
RCS file: TimeScaleMetric.java
diff -N TimeScaleMetric.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TimeScaleMetric.java 11 Apr 2007 11:13:09 -0000 1.1.2.1
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.agent.collector.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * @author Takuro Okada (Nomura Research Institute, Ltd.)
+ * Copyright 2006 Nomura Research Institute, Ltd. All Rights Reserved.
+ * Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2006.
+ * Result of Open Source Software Development Activities of Information-technology Promotion Agency, Japan.
+ */
+public class TimeScaleMetric implements Metric<Long> {
+
+ private List<Entry> entries = new ArrayList<Entry>();
+
+ /**
+ * Updates current value.
+ * @param value - the value to update
+ * @param args - [0]:timestamp
+ */
+ public void update(Long value, Object... args) {
+ entries.add(new Entry((Long)args[0], value));
+ }
+
+ public void reset() {
+ entries = new ArrayList<Entry>();
+ }
+
+ public List<Entry> getEntries() {
+// Collections.sort(entries);
+ return entries;
+ }
+
+ public Object toProperties() {
+ // TODO implement
+ return null;
+ }
+
+ public void fromProperties(Map<String, String> properties) {
+ // TODO implement
+ }
+
+ public void merge(Metric metric) {
+ // TODO implement
+ }
+
+ public class Entry implements Serializable, Comparable<Entry> {
+ private long timestamp = 0L;
+ private long value = 0L;
+
+ public Entry(long timestamp, long value) {
+ this.timestamp = timestamp;
+ this.value = value;
+ }
+
+ public int compareTo(Entry entry) {
+ if(this.timestamp>entry.timestamp) return 1;
+ else if(this.timestamp<entry.timestamp) return -1;
+ return 0;
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public long getValue() {
+ return value;
+ }
+ }
+
+}
1.1.2.1 +151 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/agent/collector/model/Attic/ThreadMetric.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ThreadMetric.java
===================================================================
RCS file: ThreadMetric.java
diff -N ThreadMetric.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ThreadMetric.java 11 Apr 2007 11:13:09 -0000 1.1.2.1
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.agent.collector.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * @author Takuro Okada (Nomura Research Institute, Ltd.)
+ * Copyright 2006 Nomura Research Institute, Ltd. All Rights Reserved.
+ * Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2006.
+ * Result of Open Source Software Development Activities of Information-technology Promotion Agency, Japan.
+ */
+public class ThreadMetric implements Metric<Long> {
+
+ private List<Entry> entries = new ArrayList<Entry>();
+
+ /**
+ * Updates current value.
+ * @param value - the value to update
+ * @param args - [0]:method name, [1]:timestamp, [2]:caller, [3]addition
+ */
+ public void update(Long value, Object... args) {
+ entries.add(new Entry((String)args[0], (Long)args[1], value, args[2], args[3]));
+ }
+
+ public void reset() {
+ entries = new ArrayList<Entry>();
+ }
+
+ public List<Entry> getEntries() {
+ // Permutes entries in reverse order of called.
+ Collections.reverse(entries);
+ // Permutes entries in order of timestamp.
+ Collections.sort(entries, new TimestampComparator());
+ return entries;
+ }
+
+ public void merge(Metric metric) {
+ ThreadMetric target = (ThreadMetric)metric;
+ List<Entry> entries = target.getEntries();
+ if(entries.size()>0) {
+ this.entries.addAll(entries);
+ }
+ }
+
+ public Object toProperties() {
+ List<Map> mapList = new ArrayList<Map>(entries.size());
+ for(Entry entry : this.entries) {
+ Map<String, String> expression = new HashMap<String, String>();
+ expression.put("methodName", entry.getMethodName());
+ expression.put("timestamp", String.valueOf(entry.getTimestamp()));
+ expression.put("value", String.valueOf(entry.getValue()));
+ expression.put("caller", String.valueOf(entry.getCaller()));
+ expression.put("addition", String.valueOf(entry.getAddition()));
+ mapList.add(expression);
+ }
+ return mapList;
+ }
+
+ public void fromProperties(Map<String, String> properties) {
+ if(properties.containsKey("methodName") &&
+ properties.containsKey("timestamp") &&
+ properties.containsKey("value") &&
+ properties.containsKey("caller") &&
+ properties.containsKey("addition")) {
+ reset();
+ Entry entry = new Entry(properties.get("methodName"),
+ Long.valueOf(properties.get("timestamp")),
+ Long.valueOf(properties.get("value")),
+ properties.get("caller"),
+ properties.get("addition"));
+ entries.add(entry);
+ }
+ }
+
+ public class Entry implements Serializable, Comparable<Entry> {
+ private String methodName = null;
+ private long timestamp = 0L;
+ private long value = 0L;
+ private Object caller = null;
+ private Object addition = null;
+
+ public Entry(String methodName, long timestamp, long value, Object caller, Object addition) {
+ this.methodName = methodName;
+ this.timestamp = timestamp;
+ this.value = value;
+ this.addition = addition;
+ this.caller = caller;
+ }
+
+ public int compareTo(Entry entry) {
+ if(this.timestamp>entry.timestamp) return 1;
+ else if(this.timestamp<entry.timestamp) return -1;
+ return 0;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public long getValue() {
+ return value;
+ }
+
+ public Object getCaller() {
+ return caller;
+ }
+
+ public Object getAddition() {
+ return addition;
+ }
+ }
+
+ private class TimestampComparator implements Comparator<Entry>, Serializable {
+ public int compare(Entry o1, Entry o2) {
+ return Long.valueOf(o1.getTimestamp()).compareTo(Long.valueOf(o2.getTimestamp()));
+ }
+ }
+
+}
1.1.2.1 +73 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/agent/collector/model/Attic/StackMetric.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: StackMetric.java
===================================================================
RCS file: StackMetric.java
diff -N StackMetric.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ StackMetric.java 11 Apr 2007 11:13:09 -0000 1.1.2.1
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.agent.collector.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * @author Takuro Okada (Nomura Research Institute, Ltd.)
+ * Copyright 2006 Nomura Research Institute, Ltd. All Rights Reserved.
+ * Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2006.
+ * Result of Open Source Software Development Activities of Information-technology Promotion Agency, Japan.
+ */
+public class StackMetric implements Metric<String[]> {
+
+ List<String[]> stacks = new ArrayList<String[]>();
+
+ public void reset() {
+ stacks = new ArrayList<String[]>();
+ }
+
+ public void update(String[] value, Object... args) {
+ for(String[] stack : stacks) {
+ if(Arrays.equals(stack, value)) return;
+ }
+ stacks.add(value);
+ }
+
+ public List<String[]> getStacks() {
+ return stacks;
+ }
+
+ public void setStacks(List<String[]> stacks) {
+ this.stacks = stacks;
+ }
+
+ public Object toProperties() {
+ // TODO implement
+ return null;
+ }
+
+ public void fromProperties(Map<String, String> properties) {
+ // TODO implement
+ }
+
+ public void merge(Metric metric) {
+ // TODO implement
+ }
+
+}
1.1.2.1 +69 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/agent/collector/model/Attic/MetricName.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MetricName.java
===================================================================
RCS file: MetricName.java
diff -N MetricName.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MetricName.java 11 Apr 2007 11:13:09 -0000 1.1.2.1
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.agent.collector.model;
+
+/**
+ * Name given to Metric.
+ *
+ * @see org.jboss.profiler.production.metrics.MetricName
+ * @author Takuro Okada (Nomura Research Institute, Ltd.)
+ * Copyright 2006 Nomura Research Institute, Ltd. All Rights Reserved.
+ * Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2006.
+ * Result of Open Source Software Development Activities of Information-technology Promotion Agency, Japan.
+ */
+public enum MetricName {
+
+ CPU_TIME("Elapsed CPU Time"),
+ USER_CPU_TIME("Elapsed CPU Time (User)"),
+ REAL_TIME("Elapsed Time"),
+
+ WAIT_COUNT("Wait Count"),
+ WAIT_TIME("Wait Time"),
+ BLOCK_COUNT("Block Count"),
+ BLOCK_TIME("BlockTime"),
+
+ MEMORY_USED("Memory Usage"),
+
+ STACK_TRACE("Stack Trace"),
+
+ CPU_TIME_PASSAGE("Elapsed CPU Time"),
+ USER_CPU_TIME_PASSAGE("Elapsed CPU Time (User)"),
+ REAL_TIME_PASSAGE("Elapsed Time"),
+
+ CPU_TIME_PASSAGE_DETAIL("Elapsed CPU Time"),
+ USER_CPU_TIME_PASSAGE_DETAIL("Elapsed CPU Time (User)"),
+ REAL_TIME_PASSAGE_DETAIL("Elapsed Time");
+
+ private String expression = null;
+
+ private MetricName(String expression) {
+ this.expression = expression;
+ }
+
+ /**
+ * Returns a string representation.
+ */
+ public String toString() {
+ return this.expression;
+ }
+}
\ No newline at end of file
1.1.2.1 +150 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/agent/collector/model/Attic/ScaleMetric.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ScaleMetric.java
===================================================================
RCS file: ScaleMetric.java
diff -N ScaleMetric.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ScaleMetric.java 11 Apr 2007 11:13:09 -0000 1.1.2.1
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.agent.collector.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * @see org.jboss.profiler.production.service.OperationMetric
+ * @author Takuro Okada (Nomura Research Institute, Ltd.)
+ * Copyright 2006 Nomura Research Institute, Ltd. All Rights Reserved.
+ * Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2006.
+ * Result of Open Source Software Development Activities of Information-technology Promotion Agency, Japan.
+ */
+public class ScaleMetric implements Metric<Long> {
+
+ private long high = 0L;
+ private long low = 0L;
+ private long average = 0L;
+
+ private long last = 0L;
+
+ private long total = 0L;
+ private long count = 0L;
+
+ public void update(Long elapsed, Object... args) {
+ count++;
+ last = elapsed;
+ if(elapsed > high) {
+ high = elapsed;
+ }
+ if(elapsed < low || count==1) {
+ low = elapsed;
+ }
+ total = total + elapsed;
+ average = total / count;
+ }
+
+ public void reset() {
+ high = 0L;
+ low = 0L;
+ average = 0L;
+ last = 0L;
+ total = 0L;
+ count = 0L;
+ }
+
+ public void merge(Metric metric) {
+ ScaleMetric target = (ScaleMetric)metric;
+ count += target.getCount();
+ if(count==0) return;
+ long high = target.getHigh();
+ if(high > this.high) {
+ this.high = high;
+ }
+ long low = target.getLow();
+ if(low < this.low || this.count==1) {
+ this.low = low;
+ }
+ total += target.getTotal();
+ average = total / count;
+ }
+
+ @Override
+ public Metric clone() {
+ ScaleMetric clone = new ScaleMetric();
+ clone.high = this.high;
+ clone.low = this.low;
+ clone.average = this.average;
+ clone.last = this.last;
+ clone.total = this.total;
+ clone.count = this.count;
+ return clone;
+ }
+
+ public Object toProperties() {
+ Map<String, String> expression = new HashMap<String, String>();
+ expression.put("high", String.valueOf(this.high));
+ expression.put("low", String.valueOf(this.low));
+ expression.put("average", String.valueOf(this.average));
+ expression.put("last", String.valueOf(this.last));
+ expression.put("total", String.valueOf(this.total));
+ expression.put("count", String.valueOf(this.count));
+ return expression;
+ }
+
+ public void fromProperties(Map<String, String> properties) {
+ if(properties.containsKey("high") &&
+ properties.containsKey("low") &&
+ properties.containsKey("average") &&
+ properties.containsKey("last") &&
+ properties.containsKey("total") &&
+ properties.containsKey("count")) {
+ reset();
+ this.high = Long.valueOf(properties.get("high"));
+ this.low = Long.valueOf(properties.get("low"));
+ this.average = Long.valueOf(properties.get("average"));
+ this.last = Long.valueOf(properties.get("last"));
+ this.total = Long.valueOf(properties.get("total"));
+ this.count = Long.valueOf(properties.get("count"));
+ }
+
+ }
+
+ public long getAverage() {
+ return average;
+ }
+
+ public long getHigh() {
+ return high;
+ }
+
+ public long getLow() {
+ return low;
+ }
+
+ public long getLast() {
+ return last;
+ }
+
+ public long getCount() {
+ return count;
+ }
+
+ public long getTotal() {
+ return total;
+ }
+
+}
More information about the jboss-cvs-commits
mailing list