Lines 33-38
import java.awt.event.ItemListener;
Link Here
|
33 |
import java.io.IOException; |
33 |
import java.io.IOException; |
34 |
import java.util.Collections; |
34 |
import java.util.Collections; |
35 |
import java.util.HashMap; |
35 |
import java.util.HashMap; |
|
|
36 |
import java.util.Iterator; |
36 |
import java.util.List; |
37 |
import java.util.List; |
37 |
import java.util.Map; |
38 |
import java.util.Map; |
38 |
|
39 |
|
Lines 46-51
import javax.swing.JScrollPane;
Link Here
|
46 |
import javax.swing.JSplitPane; |
47 |
import javax.swing.JSplitPane; |
47 |
import javax.swing.JTabbedPane; |
48 |
import javax.swing.JTabbedPane; |
48 |
import javax.swing.JTree; |
49 |
import javax.swing.JTree; |
|
|
50 |
import javax.swing.Timer; |
49 |
import javax.swing.border.Border; |
51 |
import javax.swing.border.Border; |
50 |
import javax.swing.event.TreeSelectionEvent; |
52 |
import javax.swing.event.TreeSelectionEvent; |
51 |
import javax.swing.event.TreeSelectionListener; |
53 |
import javax.swing.event.TreeSelectionListener; |
Lines 55-60
import javax.swing.tree.DefaultTreeModel;
Link Here
|
55 |
import javax.swing.tree.TreePath; |
57 |
import javax.swing.tree.TreePath; |
56 |
import javax.swing.tree.TreeSelectionModel; |
58 |
import javax.swing.tree.TreeSelectionModel; |
57 |
|
59 |
|
|
|
60 |
import org.apache.commons.collections.buffer.BoundedFifoBuffer; |
58 |
import org.apache.commons.lang3.StringUtils; |
61 |
import org.apache.commons.lang3.StringUtils; |
59 |
import org.apache.jmeter.JMeter; |
62 |
import org.apache.jmeter.JMeter; |
60 |
import org.apache.jmeter.assertions.AssertionResult; |
63 |
import org.apache.jmeter.assertions.AssertionResult; |
Lines 63-70
import org.apache.jmeter.samplers.Clearable;
Link Here
|
63 |
import org.apache.jmeter.samplers.SampleResult; |
66 |
import org.apache.jmeter.samplers.SampleResult; |
64 |
import org.apache.jmeter.util.JMeterUtils; |
67 |
import org.apache.jmeter.util.JMeterUtils; |
65 |
import org.apache.jmeter.visualizers.gui.AbstractVisualizer; |
68 |
import org.apache.jmeter.visualizers.gui.AbstractVisualizer; |
66 |
import org.apache.jorphan.logging.LoggingManager; |
69 |
import org.slf4j.Logger; |
67 |
import org.apache.log.Logger; |
70 |
import org.slf4j.LoggerFactory; |
68 |
|
71 |
|
69 |
/** |
72 |
/** |
70 |
* Base for ViewResults |
73 |
* Base for ViewResults |
Lines 75-81
implements ActionListener, TreeSelectionListener, Clearable, ItemListener {
Link Here
|
75 |
|
78 |
|
76 |
private static final long serialVersionUID = 7338676747296593842L; |
79 |
private static final long serialVersionUID = 7338676747296593842L; |
77 |
|
80 |
|
78 |
private static final Logger log = LoggingManager.getLoggerForClass(); |
81 |
private static final Logger log = LoggerFactory.getLogger(ViewResultsFullVisualizer.class); |
79 |
|
82 |
|
80 |
public static final Color SERVER_ERROR_COLOR = Color.red; |
83 |
public static final Color SERVER_ERROR_COLOR = Color.red; |
81 |
|
84 |
|
Lines 124-165
implements ActionListener, TreeSelectionListener, Clearable, ItemListener {
Link Here
|
124 |
private static final String VIEWERS_ORDER = |
127 |
private static final String VIEWERS_ORDER = |
125 |
JMeterUtils.getPropDefault("view.results.tree.renderers_order", ""); // $NON-NLS-1$ //$NON-NLS-2$ |
128 |
JMeterUtils.getPropDefault("view.results.tree.renderers_order", ""); // $NON-NLS-1$ //$NON-NLS-2$ |
126 |
|
129 |
|
|
|
130 |
private static final int UPDATE_PERIOD = JMeterUtils.getPropDefault("view.results.tree.update_period", 500); |
131 |
|
127 |
private ResultRenderer resultsRender = null; |
132 |
private ResultRenderer resultsRender = null; |
128 |
|
133 |
|
129 |
private TreeSelectionEvent lastSelectionEvent; |
134 |
private TreeSelectionEvent lastSelectionEvent; |
130 |
|
135 |
|
131 |
private JCheckBox autoScrollCB; |
136 |
private JCheckBox autoScrollCB; |
132 |
|
137 |
|
|
|
138 |
private BoundedFifoBuffer buffer = new BoundedFifoBuffer(JMeterUtils.getPropDefault("view.results.tree.max_results", 100)); |
139 |
|
140 |
private boolean dataChanged; |
141 |
|
133 |
/** |
142 |
/** |
134 |
* Constructor |
143 |
* Constructor |
135 |
*/ |
144 |
*/ |
136 |
public ViewResultsFullVisualizer() { |
145 |
public ViewResultsFullVisualizer() { |
137 |
super(); |
146 |
super(); |
138 |
init(); |
147 |
init(); |
|
|
148 |
new Timer(UPDATE_PERIOD, e -> { |
149 |
updateGui(); |
150 |
}).start(); |
139 |
} |
151 |
} |
140 |
|
152 |
|
141 |
/** {@inheritDoc} */ |
153 |
/** {@inheritDoc} */ |
142 |
@Override |
154 |
@Override |
143 |
public void add(final SampleResult sample) { |
155 |
public void add(final SampleResult sample) { |
144 |
JMeterUtils.runSafe(false, ()-> updateGui(sample)); |
156 |
synchronized (buffer) { |
|
|
157 |
if (buffer.isFull()) { |
158 |
buffer.remove(); |
159 |
} |
160 |
buffer.add(sample); |
161 |
dataChanged = true; |
162 |
} |
145 |
} |
163 |
} |
146 |
|
164 |
|
147 |
/** |
165 |
/** |
148 |
* Update the visualizer with new data. |
166 |
* Update the visualizer with new data. |
149 |
*/ |
167 |
*/ |
150 |
private synchronized void updateGui(SampleResult res) { |
168 |
private void updateGui() { |
151 |
// Add sample |
169 |
synchronized (buffer) { |
152 |
DefaultMutableTreeNode currNode = new SearchableTreeNode(res, treeModel); |
170 |
if (!dataChanged) { |
153 |
treeModel.insertNodeInto(currNode, root, root.getChildCount()); |
171 |
return; |
154 |
addSubResults(currNode, res); |
172 |
} |
155 |
// Add any assertion that failed as children of the sample node |
173 |
root.removeAllChildren(); |
156 |
AssertionResult[] assertionResults = res.getAssertionResults(); |
174 |
@SuppressWarnings("unchecked") |
157 |
int assertionIndex = currNode.getChildCount(); |
175 |
Iterator<SampleResult> samplers = buffer.iterator(); |
158 |
for (AssertionResult assertionResult : assertionResults) { |
176 |
while (samplers.hasNext()) { |
159 |
if (assertionResult.isFailure() || assertionResult.isError()) { |
177 |
SampleResult res = (SampleResult) samplers.next(); |
160 |
DefaultMutableTreeNode assertionNode = new SearchableTreeNode(assertionResult, treeModel); |
178 |
// Add sample |
161 |
treeModel.insertNodeInto(assertionNode, currNode, assertionIndex++); |
179 |
DefaultMutableTreeNode currNode = new SearchableTreeNode(res, treeModel); |
|
|
180 |
treeModel.insertNodeInto(currNode, root, root.getChildCount()); |
181 |
addSubResults(currNode, res); |
182 |
// Add any assertion that failed as children of the sample node |
183 |
AssertionResult[] assertionResults = res.getAssertionResults(); |
184 |
int assertionIndex = currNode.getChildCount(); |
185 |
for (AssertionResult assertionResult : assertionResults) { |
186 |
if (assertionResult.isFailure() || assertionResult.isError()) { |
187 |
DefaultMutableTreeNode assertionNode = new SearchableTreeNode(assertionResult, treeModel); |
188 |
treeModel.insertNodeInto(assertionNode, currNode, assertionIndex++); |
189 |
} |
190 |
} |
162 |
} |
191 |
} |
|
|
192 |
treeModel.nodeStructureChanged(root); |
193 |
dataChanged = false; |
163 |
} |
194 |
} |
164 |
|
195 |
|
165 |
if (root.getChildCount() == 1) { |
196 |
if (root.getChildCount() == 1) { |
Lines 198-208
implements ActionListener, TreeSelectionListener, Clearable, ItemListener {
Link Here
|
198 |
|
229 |
|
199 |
/** {@inheritDoc} */ |
230 |
/** {@inheritDoc} */ |
200 |
@Override |
231 |
@Override |
201 |
public synchronized void clearData() { |
232 |
public void clearData() { |
202 |
while (root.getChildCount() > 0) { |
233 |
synchronized (buffer) { |
203 |
// the child to be removed will always be 0 'cos as the nodes are |
234 |
buffer.clear(); |
204 |
// removed the nth node will become (n-1)th |
235 |
dataChanged = true; |
205 |
treeModel.removeNodeFromParent((DefaultMutableTreeNode) root.getChildAt(0)); |
|
|
206 |
} |
236 |
} |
207 |
resultsRender.clearData(); |
237 |
resultsRender.clearData(); |
208 |
} |
238 |
} |
209 |
- |
|
|