Skip to content

Commit b102618

Browse files
author
Tim Middleton
committed
Various fixes after QA testing
1 parent 9e33ba2 commit b102618

File tree

6 files changed

+186
-26
lines changed

6 files changed

+186
-26
lines changed

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/panel/CoherenceCachePanel.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,7 @@ public void actionPerformed (ActionEvent e)
583583
}
584584
else
585585
{
586-
JOptionPane.showMessageDialog(null,
587-
getLocalizedText("LBL_no_caches"));
586+
JOptionPane.showMessageDialog(null, getLocalizedText("LBL_no_data"));
588587
}
589588
}
590589

@@ -595,7 +594,7 @@ public void actionPerformed (ActionEvent e)
595594
public synchronized void updateData()
596595
{
597596
// build a linked list with a Pair<X,Y> where X = cache name (which is Pair<String, String>) and
598-
// Y is the count of size of memory
597+
// Y is the count of size or memory
599598
f_listValues.clear();
600599
m_cTotal = 0L;
601600

@@ -665,7 +664,7 @@ public HeatMapJPanel()
665664
{
666665
super();
667666
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
668-
int nWidth = (int) (screenSize.getWidth() * 0.75);
667+
int nWidth = (int) (screenSize.getWidth() * 0.5);
669668
int nHeight = (int) (screenSize.getHeight() * 0.5);
670669
AbstractMenuOption.setResizable(this);
671670

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/panel/CoherenceMemberPanel.java

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -410,41 +410,34 @@ public void actionPerformed(ActionEvent e)
410410

411411
Timer timer = new Timer(nDelay * 1000, null);
412412

413+
// generate the first thread dump and then run the timer for subsequent thread dumps
414+
generateThreadDump(sb, 1, nCount, nNode, status);
415+
413416
timer.addActionListener(new ActionListener()
414417
{
415418
public void actionPerformed(ActionEvent e)
416419
{
417420
m_nCounter++;
418-
status[0] = StatusDisplayer.getDefault().setStatusText(getLocalText("LBL_thread_dump_progress",
419-
Integer.toString(m_nCounter), Integer.toString(nCount),
420-
String.format("%3.1f", (m_nCounter * 1f / nCount) * 100.0f )), 5);
421-
422-
String sNodeState = null;
423421
try
424422
{
425-
sNodeState = m_requestSender.getNodeState(nNode);
423+
generateThreadDump(sb, m_nCounter, nCount, nNode, status);
426424
}
427425
catch (Exception exception)
428426
{
429427
sb.append(exception.getMessage());
430428
timer.stop();
431429
}
432-
sb.append("*** START THREAD DUMP ").append(m_nCounter).append(" - ")
433-
.append(new Date(System.currentTimeMillis()))
434-
.append("\n")
435-
.append(sNodeState)
436-
.append("\n*** END THREAD DUMP ").append(m_nCounter).append("\n");
437430

438431
if (m_nCounter == nCount)
439432
{
440433
timer.stop();
441434
status[0] = StatusDisplayer.getDefault().setStatusText(getLocalText("LBL_thread_dump_completed"),5);
442435
status[0].clear(5000);
443-
showMessageDialog(getLocalizedText("LBL_state_for_node") + " " + nNode, sb.toString(), JOptionPane.INFORMATION_MESSAGE);
436+
showThreadDumpResult(nNode, sb.toString());
444437
}
445438
}
446439

447-
private int m_nCounter = 0;
440+
private int m_nCounter = 1;
448441
});
449442

450443
timer.setRepeats(true);
@@ -453,8 +446,7 @@ public void actionPerformed(ActionEvent e)
453446
}
454447
else
455448
{
456-
showMessageDialog(getLocalizedText("LBL_state_for_node") + " " + nNodeId,
457-
m_requestSender.getNodeState(nNodeId), JOptionPane.INFORMATION_MESSAGE);
449+
showThreadDumpResult(nNodeId, generateHeader(nNodeId) + " " + m_requestSender.getNodeState(nNodeId));
458450
}
459451
}
460452
catch (Exception ee)
@@ -463,6 +455,45 @@ public void actionPerformed(ActionEvent e)
463455
}
464456
}
465457
}
458+
459+
// ------ helpers -----------------------------------------------
460+
461+
/**
462+
* Display the thread dump result.
463+
*
464+
* @param nNode node id
465+
* @param sThreadDump the result
466+
*/
467+
private void showThreadDumpResult(int nNode, String sThreadDump)
468+
{
469+
showMessageDialog(getLocalizedText("LBL_state_for_node") + " " + nNode,
470+
sThreadDump, JOptionPane.INFORMATION_MESSAGE, 500, 400, true);
471+
}
472+
}
473+
474+
/**
475+
* Generate a thread dump and save the output in the {@link StringBuilder}.
476+
*
477+
* @param sb {@link StringBuilder} to save output in
478+
* @param nCounter current counter of thread dumps
479+
* @param nMax max number of thread dumps
480+
* @param status {@link StatusDisplayer.Message} to display messages
481+
*
482+
* @throws Exception if any errors
483+
*/
484+
private void generateThreadDump(StringBuilder sb, int nCounter, int nMax, int nNode, StatusDisplayer.Message[] status)
485+
throws Exception
486+
{
487+
String sNodeState = m_requestSender.getNodeState(nNode);
488+
status[0] = StatusDisplayer.getDefault().setStatusText(getLocalText("LBL_thread_dump_progress",
489+
Integer.toString(nCounter), Integer.toString(nMax),
490+
String.format("%3.1f", (nCounter * 1f / nMax) * 100.0f )), 5);
491+
492+
sb.append("*** START THREAD DUMP ").append(nCounter).append(" - ")
493+
.append(new Date(System.currentTimeMillis()))
494+
.append("\n")
495+
.append(sNodeState)
496+
.append("\n*** END THREAD DUMP ").append(nCounter).append("\n");
466497
}
467498

468499
/**

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/panel/CoherencePersistencePanel.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@
8484

8585
import org.graalvm.visualvm.charts.SimpleXYChartSupport;
8686

87-
import static com.oracle.coherence.plugin.visualvm.VisualVMModel.PROP_PERSISTENCE_LIST_ENABLED;
88-
8987

9088
/**
9189
* An implementation of an {@link AbstractCoherencePanel} to view summarized

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/panel/util/AbstractMenuOption.java

Lines changed: 126 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,35 @@
2929
import com.oracle.coherence.plugin.visualvm.helper.RequestSender;
3030
import com.oracle.coherence.plugin.visualvm.VisualVMModel;
3131

32+
import java.awt.BorderLayout;
3233
import java.awt.Dialog;
34+
import java.awt.Toolkit;
3335
import java.awt.Window;
3436
import java.awt.Dimension;
3537

38+
import java.awt.datatransfer.StringSelection;
3639
import java.awt.event.HierarchyEvent;
3740
import java.awt.event.HierarchyListener;
41+
import java.io.File;
42+
import java.io.FileOutputStream;
43+
import java.io.IOException;
44+
import java.io.PrintStream;
45+
import java.util.logging.Level;
3846

47+
import javax.swing.JButton;
3948
import javax.swing.JComponent;
49+
import javax.swing.JFileChooser;
50+
import javax.swing.JLabel;
4051
import javax.swing.JOptionPane;
52+
import javax.swing.JPanel;
4153
import javax.swing.JScrollPane;
4254
import javax.swing.JTextArea;
4355
import javax.swing.SwingUtilities;
56+
import javax.swing.filechooser.FileNameExtensionFilter;
57+
import javax.swing.table.AbstractTableModel;
58+
import javax.swing.table.TableColumnModel;
59+
60+
import static com.oracle.coherence.plugin.visualvm.Localization.getLocalText;
4461

4562
/**
4663
* Abstract implementation of a {@link MenuOption} providing default functionality.
@@ -89,10 +106,13 @@ protected void showMessageDialog(String sTitle, String sMessage, int nDialogType
89106
* @param nDialogType the type of dialog, e.g. JOptionPane.INFORMATION_MESSAGE
90107
* @param nLength the length of the dialog window
91108
* @param nWidth the width of the dialog window
109+
* @param fCopySave true if copy and save buttons should be displayed
92110
*/
93-
protected void showMessageDialog(String sTitle, String sMessage, int nDialogType, int nLength, int nWidth)
111+
protected void showMessageDialog(String sTitle, String sMessage, int nDialogType, int nLength, int nWidth, boolean fCopySave)
94112
{
95113
JTextArea txtArea = new JTextArea(sMessage);
114+
final JPanel panel = new JPanel();
115+
panel.setLayout(new BorderLayout());
96116
final JScrollPane pneMessage = new JScrollPane(txtArea);
97117

98118
txtArea.setEditable(false);
@@ -101,8 +121,111 @@ protected void showMessageDialog(String sTitle, String sMessage, int nDialogType
101121
pneMessage.setPreferredSize(new Dimension(nLength, nWidth));
102122

103123
setResizable(pneMessage);
124+
panel.add(pneMessage, BorderLayout.CENTER);
125+
126+
if (fCopySave)
127+
{
128+
JButton btnCopy = new JButton();
129+
JButton btnSaveAs = new JButton();
130+
btnCopy.setText(getLocalText("LBL_copy_to_clipboard"));
131+
btnSaveAs.setText(getLocalText("LBL_save_data_as"));
132+
133+
btnCopy.addActionListener((a) ->
134+
{
135+
Toolkit.getDefaultToolkit()
136+
.getSystemClipboard()
137+
.setContents(new StringSelection(sMessage), null);
138+
JOptionPane.showMessageDialog(panel, getLocalText("LBL_copied"), getLocalText("LBL_result"), JOptionPane.INFORMATION_MESSAGE);
139+
});
140+
141+
btnSaveAs.addActionListener((a) ->
142+
{
143+
JFileChooser fileChooser = new ExportableJTable.CheckExistsFileChooser();
144+
fileChooser.setFileFilter(new FileNameExtensionFilter("*.*", "txt", "log"));
145+
146+
int result = fileChooser.showSaveDialog(btnSaveAs);
147+
148+
if (result == JFileChooser.APPROVE_OPTION)
149+
{
150+
File selectedFile = fileChooser.getSelectedFile();
151+
if (saveContentsToFile(selectedFile, sMessage))
152+
{
153+
JOptionPane.showMessageDialog(panel,
154+
getLocalText("LBL_data_saved",selectedFile.getAbsolutePath()),
155+
getLocalText("LBL_result"), JOptionPane.INFORMATION_MESSAGE);
156+
}
157+
}
158+
});
159+
160+
JPanel flowLayout = new JPanel();
161+
flowLayout.add(getFiller());
162+
flowLayout.add(btnCopy);
163+
flowLayout.add(getFiller());
164+
flowLayout.add(btnSaveAs);
165+
flowLayout.add(getFiller());
166+
panel.add(flowLayout, BorderLayout.SOUTH);
167+
}
168+
169+
JOptionPane.showMessageDialog(null, panel, sTitle, nDialogType);
170+
}
171+
172+
/**
173+
* Returns a filler {@link JLabel}.
174+
*
175+
* @return a filler {@link JLabel}
176+
*/
177+
private JLabel getFiller()
178+
{
179+
JLabel label = new JLabel();
180+
label.setText(" ");
181+
return label;
182+
}
183+
184+
/**
185+
* Save contents to a file.
186+
*
187+
* @param file the {@link File} to save to
188+
*
189+
* @return true if the file was saved
190+
*/
191+
private boolean saveContentsToFile(File file, String sContents)
192+
{
193+
PrintStream fileWriter = null;
194+
195+
try
196+
{
197+
fileWriter = new PrintStream(new FileOutputStream(file));
198+
fileWriter.write(sContents.getBytes());
199+
}
200+
catch (IOException ioe)
201+
{
202+
JOptionPane.showMessageDialog(null, getLocalText("LBL_unable_to_save", file.getAbsolutePath(), ioe.getMessage()),
203+
getLocalText("LBL_result"), JOptionPane.ERROR_MESSAGE);
204+
return false;
205+
}
206+
finally
207+
{
208+
if (fileWriter != null)
209+
{
210+
fileWriter.close();
211+
}
212+
}
213+
return true;
214+
}
104215

105-
JOptionPane.showMessageDialog(null, pneMessage, sTitle, nDialogType);
216+
217+
/**
218+
* Show a message dialog with a scrollable text area for the message.
219+
*
220+
* @param sTitle the title of the dialog box
221+
* @param sMessage the message to display
222+
* @param nDialogType the type of dialog, e.g. JOptionPane.INFORMATION_MESSAGE
223+
* @param nLength the length of the dialog window
224+
* @param nWidth the width of the dialog window
225+
*/
226+
protected void showMessageDialog(String sTitle, String sMessage, int nDialogType, int nLength, int nWidth)
227+
{
228+
showMessageDialog(sTitle, sMessage, nDialogType, nLength, nWidth,false);
106229
}
107230

108231
// ----- helpers --------------------------------------------------------
@@ -215,5 +338,5 @@ public void setMenuLabel(String sMenuLabel)
215338
/**
216339
* The menu label for the right click option.
217340
*/
218-
protected String m_sMenuLabel = Localization.getLocalText("LBL_show_details");
341+
protected String m_sMenuLabel = getLocalText("LBL_show_details");
219342
}

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/tablemodel/model/ServiceData.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ public SortedMap<Object, Data> getAggregatedDataFromHttpQuerying(VisualVMModel
303303
{
304304
// is another type such as proxy/http
305305
data.setColumn(ServiceData.STORAGE_MEMBERS, 0);
306+
data.setColumn(ServiceData.PARTITIONS_ENDANGERED, 0);
307+
data.setColumn(ServiceData.PARTITIONS_VULNERABLE, 0);
308+
data.setColumn(ServiceData.PARTITIONS_UNBALANCED, 0);
309+
data.setColumn(ServiceData.PARTITIONS_PENDING, 0);
310+
data.setColumn(ServiceData.PARTITION_COUNT, 0);
306311
}
307312

308313
// check if the service is federation

coherence-visualvm-plugin/src/main/resources/com/oracle/coherence/plugin/visualvm/Bundle.properties

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ LBL_refresh_date=Refresh Date
6464
LBL_cluster_statusha=Cluster StatusHA
6565
BTN_admin=Cluster Heap Dump
6666
TTIP_admin=Generate a heap dump across all members.
67-
LBL_heap_dump_completed=Please check the coherence logs files for location of the heap dumps.
67+
LBL_heap_dump_completed=Please check the Coherence log files for locations of the generated heap dumps.
6868
LBL_heap_dump_failed=Heap dump failed: {0}.
69-
LBL_heap_dump_question=WARNING: This operation will have a performance impact on your running Cluster. \nAre you sure you want to instruct the cluster to perform a head dump across all members?
69+
LBL_heap_dump_question=WARNING: This operation will have a performance impact on your running cluster\nand may write large amounts of data to your heap dump location, usually temp directory. \nAre you sure you want to instruct the cluster to perform a head dump across all members?
7070
LBL_heap_dump_confirm=Please confirm heap dump
7171

7272
# CoherenceCachePanel (spaces before are for label spacing)
@@ -84,6 +84,7 @@ LBL_memory_heat_map=Show Memory Heat Map
8484
LBL_title_size_heat_map=Cache Size Heat Map for All Caches
8585
LBL_title_memory_heat_map=Primary Memory Heat Map for All Caches
8686
LBL_no_caches=No caches are defined or all caches have zero size. Unable to create Heat Map.
87+
LBL_no_data=You have selected a new row, please wait for the data to be refreshed and try viewing the heat map again.
8788

8889
# CoherenceTopicPanel
8990
LBL_total_topics=Total Topics
@@ -112,6 +113,9 @@ LBL_wait=Duration: {0} seconds
112113
LBL_thread_dump_confirmation=Please follow the progress in the status bar at the bottom left of VisualVM.
113114
LBL_thread_dump_progress=Generated thread dump {0} of {1} ({2}% complete)
114115
LBL_thread_dump_completed=Completed.
116+
LBL_copy_to_clipboard=Copy contents to Clipboard
117+
LBL_copied=Data has been copied to the Clipboard.
118+
LBL_data_saved=Thread Dump has been saved to {0}.
115119

116120
# CoherencePersistencePanel
117121
LBL_total_active_space=Total Active Persistence Space Used (MB)

0 commit comments

Comments
 (0)