[jboss-svn-commits] JBL Code SVN: r36967 - in labs/jbosstm/trunk: ArjunaJTS and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Apr 21 08:49:25 EDT 2011
Author: mmusgrov
Date: 2011-04-21 08:49:24 -0400 (Thu, 21 Apr 2011)
New Revision: 36967
Modified:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/stats/TxPerfGraph.form
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/stats/TxPerfGraph.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/stats/TxPerfPlugin.java
labs/jbosstm/trunk/ArjunaJTS/INSTALL
Log:
[JBTM-49] Add support for a jconsole plugin for graphing statistics
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/stats/TxPerfGraph.form
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/stats/TxPerfGraph.form 2011-04-21 10:51:40 UTC (rev 36966)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/stats/TxPerfGraph.form 2011-04-21 12:49:24 UTC (rev 36967)
@@ -219,42 +219,37 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" pref="23" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
+ <Component id="resetStatsBtn" alignment="0" pref="246" max="32767" attributes="1"/>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="pollIntervalBtn" pref="120" max="32767" attributes="1"/>
+ <EmptySpace type="unrelated" max="-2" attributes="0"/>
+ <Component id="pollIntervalSpinner" min="-2" pref="114" max="-2" attributes="0"/>
+ </Group>
<Group type="102" alignment="0" attributes="0">
- <EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
+ <EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="enableStatsCB" alignment="0" min="-2" max="-2" attributes="0"/>
- <Group type="102" alignment="1" attributes="0">
- <Group type="103" groupAlignment="1" attributes="0">
- <Component id="resetStatsBtn" alignment="0" pref="246" max="32767" attributes="1"/>
- <Group type="102" alignment="1" attributes="0">
- <Component id="pollIntervalBtn" pref="120" max="32767" attributes="1"/>
- <EmptySpace type="unrelated" max="-2" attributes="0"/>
- <Component id="pollIntervalSpinner" min="-2" pref="114" max="-2" attributes="0"/>
- </Group>
- </Group>
- <EmptySpace min="-2" pref="152" max="-2" attributes="0"/>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="sampleSizeBtn1" min="-2" max="-2" attributes="1"/>
+ <EmptySpace type="unrelated" max="-2" attributes="0"/>
+ <Component id="sampleSizeSpinner" min="-2" pref="114" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
- <Group type="102" alignment="0" attributes="0">
- <EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
- <Component id="sampleSizeBtn1" min="-2" max="-2" attributes="1"/>
- <EmptySpace type="unrelated" max="-2" attributes="0"/>
- <Component id="sampleSizeSpinner" min="-2" pref="114" max="-2" attributes="0"/>
- </Group>
</Group>
- <EmptySpace max="-2" attributes="0"/>
+ <EmptySpace min="-2" pref="149" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
- <EmptySpace min="-2" pref="35" max="-2" attributes="0"/>
+ <EmptySpace min="-2" pref="38" max="-2" attributes="0"/>
<Component id="enableStatsCB" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
+ <EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="sampleSizeBtn1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="sampleSizeSpinner" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -266,7 +261,7 @@
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="resetStatsBtn" min="-2" max="-2" attributes="0"/>
- <EmptySpace pref="73" max="32767" attributes="0"/>
+ <EmptySpace pref="47" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -296,6 +291,7 @@
</Component>
<Component class="javax.swing.JCheckBox" name="enableStatsCB">
<Properties>
+ <Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Enable Statistics"/>
<Property name="toolTipText" type="java.lang.String" value="Stop data collection by disabling the stats MBean in the target JVM"/>
</Properties>
@@ -321,7 +317,7 @@
</Container>
<Container class="org.jfree.beans.JLineChart" name="chart1">
<Properties>
- <Property name="xAxisLabel" type="java.lang.String" value="Time of Day"/>
+ <Property name="xAxisLabel" type="java.lang.String" value="Number of Poll Intervals"/>
<Property name="xAxisScale" type="org.jfree.beans.AxisScale" editor="org.jfree.beans.editors.AxisScaleEditor">
<SerializedValue value="-84,-19,0,5,115,114,0,25,111,114,103,46,106,102,114,101,101,46,98,101,97,110,115,46,65,120,105,115,83,99,97,108,101,110,85,102,59,126,70,-97,10,2,0,1,76,0,4,110,97,109,101,116,0,18,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,120,112,116,0,17,65,120,105,115,83,99,97,108,101,46,73,78,84,69,71,69,82"/>
</Property>
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/stats/TxPerfGraph.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/stats/TxPerfGraph.java 2011-04-21 10:51:40 UTC (rev 36966)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/stats/TxPerfGraph.java 2011-04-21 12:49:24 UTC (rev 36967)
@@ -22,8 +22,6 @@
import java.lang.reflect.InvocationTargetException;
import javax.swing.JMenuBar;
-import org.jfree.data.time.TimeSeries;
-import org.jfree.data.time.Second;
import com.arjuna.ats.arjuna.coordinator.TxStatsMBean;
import com.arjuna.ats.arjuna.common.CoordinatorEnvironmentBeanMBean;
import java.awt.BorderLayout;
@@ -32,9 +30,9 @@
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.MalformedURLException;
-import java.util.Calendar;
+import java.text.SimpleDateFormat;
-import java.util.Date;
+import java.util.TimeZone;
import javax.management.*;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
@@ -48,7 +46,8 @@
import javax.swing.SwingWorker;
import javax.swing.border.EmptyBorder;
import org.jfree.data.general.DefaultPieDataset;
-import org.jfree.data.time.TimeSeriesCollection;
+import org.jfree.data.xy.XYSeries;
+import org.jfree.data.xy.XYSeriesCollection;
public class TxPerfGraph extends javax.swing.JPanel { //JFrame {
private final static int NUMBER_OF_SAMPLES = 100;
@@ -87,16 +86,17 @@
NUMBER_OF_ABORTED_SERIES,
};
+ private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
+ private static SimpleDateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");
private MBeanServerConnection server;
private JFrame frame;
private TxStatsMBean txMBean;
private CoordinatorEnvironmentBeanMBean coordMBean;
- private TimeSeries[] _dataSeries = new TimeSeries[7];
- private TimeSeriesCollection _tsDS[] = new TimeSeriesCollection[7];
- private Second currPeriod;
- private Second tZero;
+ private XYSeries[] _dataSeries = new XYSeries[7];
+ private XYSeriesCollection _tsDS[] = new XYSeriesCollection[7];
+ private long counter = 0L;
private DefaultPieDataset pieDS;
// TimerTask timerTask;
// Timer timer = new Timer("TxPerf Sampling thread");
@@ -106,19 +106,27 @@
/** Creates new form TxPerfGraph */
public TxPerfGraph(JFrame frame) {
this.frame = frame;
- tZero = new Second(new Date());
+ timeFormatter.setTimeZone(GMT);
+
initComponents();
for (int count = 0; count < _dataSeries.length; count++) {
- _dataSeries[count] = new TimeSeries(SERIES_LABELS[count]);//, Second.class);
+ _dataSeries[count] = new XYSeries(SERIES_LABELS[count]);//, Second.class);
//_dataSeries[count].setMaximumItemCount(NUMBER_OF_SAMPLES);
- _tsDS[count] = new TimeSeriesCollection(_dataSeries[count]);
+ _tsDS[count] = new XYSeriesCollection(_dataSeries[count]);
}
chart1.setDataset(_tsDS[NUMBER_OF_TRANSACTIONS_SERIES]);
chart1.setTitle(SERIES_LABELS[NUMBER_OF_TRANSACTIONS_SERIES]);
chart1.setSubtitle("");
+ // DateAxis xAxis = new DateAxis("Time (hh:mm) Zulu", GMT);
+ // xAxis.setAutoRange(true);
+ // xAxis.setTickUnit(new DateTickUnit(DateTickUnit.MINUTE, 60, timeFormatter));
+ // xAxis.setVerticalTickLabels(true);
+ // xAxis.setDateFormatOverride(timeFormatter);
+
+
allTxnBtn.setSelected(true);
pieDS = new DefaultPieDataset();
@@ -143,8 +151,8 @@
sampleSizeSpinner.setVisible(false);
enableStatsCB.setSelected(false);
resetStatsBtn.setVisible(false);
- pollIntervalBtn.setVisible(false);
- sampleSizeBtn1.setVisible(false);
+ pollIntervalBtn.setVisible(false);
+ sampleSizeBtn1.setVisible(false);
taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
@@ -182,10 +190,7 @@
private void sample() {
try {
- int secs = Calendar.getInstance().get(Calendar.SECOND) - tZero.getSecond();
- Date d1 = new Date(secs);
- Date d2 = new Date();
- Second now = new Second(d2);
+ counter += 1;
long [] stats = new long[7];
@@ -198,28 +203,25 @@
stats[NUMBER_OF_TIMEDOUT_SERIES] = txMBean.getNumberOfTimedOutTransactions();
for (int i = 0; i < 7; i++) {
- _dataSeries[i].addOrUpdate(now, stats[i]);
+ _dataSeries[i].add(counter, stats[i]);
}
- if (currPeriod != null) {
- long [] pstats = new long[PIE_CHART_SERIES.length];
-
- int cindex = _dataSeries[0].getIndex(now);
+ if (counter > 1) {
+ int cindex = _dataSeries[0].indexOf(counter);
int slices = periodSelectSlider.getValue();
int lb = cindex < slices ? 0 : cindex - slices;
for (int i = 0; i < PIE_CHART_SERIES.length; i++) {
- TimeSeries ts = _dataSeries[PIE_CHART_SERIES[i]];
+ XYSeries ts = _dataSeries[PIE_CHART_SERIES[i]];
+ Number n1 = ts.getDataItem(cindex).getY();
+ Number n2 = ts.getDataItem(lb).getY();
- pieDS.setValue(PIE_CHART_LABELS[i], pstats[i] =
- ts.getValue(cindex).longValue() - ts.getValue(lb).longValue());
+ pieDS.setValue(PIE_CHART_LABELS[i], n1.longValue() - n2.longValue());
}
txnPieChart.setSubtitle("(during last " + // (cindex - lb + 1) * POLL_PERIOD / 1000 + " seconds) - " +
(cindex - lb + 1) + " poll intervals");
}
-
- currPeriod = now;
} catch (Exception e) {
System.err.println("MBean property failure: " + e);
}
@@ -395,6 +397,7 @@
}
});
+ enableStatsCB.setSelected(true);
enableStatsCB.setText("Enable Statistics");
enableStatsCB.setToolTipText("Stop data collection by disabling the stats MBean in the target JVM");
enableStatsCB.addActionListener(new java.awt.event.ActionListener() {
@@ -418,32 +421,29 @@
configTabLayout.setHorizontalGroup(
configTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(configTabLayout.createSequentialGroup()
+ .addGap(23, 23, 23)
.addGroup(configTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(resetStatsBtn, javax.swing.GroupLayout.DEFAULT_SIZE, 246, Short.MAX_VALUE)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, configTabLayout.createSequentialGroup()
+ .addComponent(pollIntervalBtn, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(pollIntervalSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(configTabLayout.createSequentialGroup()
- .addGap(20, 20, 20)
+ .addGap(2, 2, 2)
.addGroup(configTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(enableStatsCB)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, configTabLayout.createSequentialGroup()
- .addGroup(configTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(resetStatsBtn, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 246, Short.MAX_VALUE)
- .addGroup(configTabLayout.createSequentialGroup()
- .addComponent(pollIntervalBtn, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(pollIntervalSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGap(152, 152, 152))))
- .addGroup(configTabLayout.createSequentialGroup()
- .addGap(22, 22, 22)
- .addComponent(sampleSizeBtn1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(sampleSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap())
+ .addGroup(configTabLayout.createSequentialGroup()
+ .addComponent(sampleSizeBtn1)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(sampleSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)))))
+ .addGap(149, 149, 149))
);
configTabLayout.setVerticalGroup(
configTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(configTabLayout.createSequentialGroup()
- .addGap(35, 35, 35)
+ .addGap(38, 38, 38)
.addComponent(enableStatsCB)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGap(29, 29, 29)
.addGroup(configTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(sampleSizeBtn1)
.addComponent(sampleSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
@@ -453,12 +453,12 @@
.addComponent(pollIntervalSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(resetStatsBtn)
- .addContainerGap(73, Short.MAX_VALUE))
+ .addContainerGap(47, Short.MAX_VALUE))
);
chartsPane.addTab("Settings", configTab);
- chart1.setXAxisLabel("Time of Day");
+ chart1.setXAxisLabel("Number of Poll Intervals");
chart1.setXAxisScale(org.jfree.beans.AxisScale.INTEGER);
chart1.setYAxisLabel("Number of Txns");
chart1.setYAxisScale(org.jfree.beans.AxisScale.INTEGER);
@@ -542,6 +542,7 @@
);
add(jPanel1);
+ add(menuBar);
}// </editor-fold>//GEN-END:initComponents
private void btnActionPerformed(int series) {
@@ -657,14 +658,19 @@
/*
* SwingWorker for updating the TxPerf tab
*/
- public SwingWorker<TimeSeries[], Object> newSwingWorker() {
+ public SwingWorker<XYSeries[], Object> newSwingWorker() {
return new Worker();
}
- class Worker extends SwingWorker<TimeSeries[], Object> {
+ void dispose() {
+// if (coordMBean != null && disableStatsOnDispose.isSelected())
+// coordMBean.setEnableStatistics(false);
+ }
+ class Worker extends SwingWorker<XYSeries[], Object> {
+
@Override
- protected TimeSeries[] doInBackground() throws Exception {
+ protected XYSeries[] doInBackground() throws Exception {
sample();
return _dataSeries;
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/stats/TxPerfPlugin.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/stats/TxPerfPlugin.java 2011-04-21 10:51:40 UTC (rev 36966)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/stats/TxPerfPlugin.java 2011-04-21 12:49:24 UTC (rev 36967)
@@ -38,18 +38,24 @@
private Map<String, JPanel> tabs;
public TxPerfPlugin() {
+ // register itself as a listener
addContextPropertyChangeListener(this);
}
+ /*
+ * Returns a TxPerf tab to be added in JConsole.
+ */
public synchronized Map<String, JPanel> getTabs() {
if (tabs == null) {
+ graph = new TxPerfGraph(new JFrame("TxPerf"));
+
+ graph.setMBeanServerConnection(
+ getContext().getMBeanServerConnection());
+ // use LinkedHashMap if you want a predictable order
+ // of the tabs to be added in JConsole
tabs = new LinkedHashMap<String, JPanel>();
-
- graph = new TxPerfGraph(new JFrame("TxPerf"));
- graph.setMBeanServerConnection(getContext().getMBeanServerConnection());
tabs.put("TxPerf", graph);
}
-
return tabs;
}
@@ -63,12 +69,19 @@
// disconnected. Need to use the new MBeanServerConnection object
// created at reconnection time.
if (newState == ConnectionState.CONNECTED && graph != null) {
- graph.setMBeanServerConnection(getContext().getMBeanServerConnection());
+ graph.setMBeanServerConnection(
+ getContext().getMBeanServerConnection());
}
}
}
@Override
+ public void dispose() {
+ graph.dispose();
+ super.dispose();
+ }
+
+ @Override
public SwingWorker<?,?> newSwingWorker() {
return graph.newSwingWorker();
}
Modified: labs/jbosstm/trunk/ArjunaJTS/INSTALL
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/INSTALL 2011-04-21 10:51:40 UTC (rev 36966)
+++ labs/jbosstm/trunk/ArjunaJTS/INSTALL 2011-04-21 12:49:24 UTC (rev 36967)
@@ -216,10 +216,12 @@
to the admin console plugin directory ($JBOSS_HOME/common/deploy/admin-console.war/plugins).
There is also a transaction statistics graphing tool which can run standalone or inside a
-jconsole tab (jconsole, a tool for managing JVMs, is distributed with the reference JDK):
+jconsole tab (jconsole, a tool for managing JVMs, is distributed with the reference JDK).
+Various transaction statistics are graphed in real time with each graph updated during each
+poll interval (4 seconds unless the interval is overridden on the jconsole command line).
-The tool depends on the JFree graphing library. Download and upack orson from http://www.jfree.org/orson
-Set the env variable ORSON_HOME to the directory where you plan to unpack the downloaded zip.
+The tool depends on the JFree graphing library. Download and upack Orson from http://www.jfree.org/orson
+and set the env variable ORSON_HOME to the directory where you plan to unpack the downloaded zip.
If you intend to use the tool with jconsole you will also need to put the JDK tools and jconsole jars on
the classpath:
@@ -234,3 +236,5 @@
Usage with jconsole:
jconsole -J-Djava.class.path="$CLASSPATH" -pluginpath $TS_INSTALL_DIR/lib/jbossjts.jar
+
+The tool will automatically enable statistics gathering on startup. It is recommended that you disable statistics gathering prior to exit on the Settings tab in the GUI.
More information about the jboss-svn-commits
mailing list