Skip to content

Commit fa573eb

Browse files
author
Tim Middleton
committed
Minor code updates
1 parent 7affdbb commit fa573eb

File tree

6 files changed

+45
-42
lines changed

6 files changed

+45
-42
lines changed

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/CoherenceApplicationType.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public CoherenceApplicationType(Application app, Jvm jvm, String sMainClass)
5555
this.f_description = sDescription
5656
+ " (" + sMainClass + ")"
5757
+ "\nCommand Line:" + jvm.getJvmArgs();
58-
this.iconPath = IMAGE_PATH;
58+
this.f_sIconPath = IMAGE_PATH;
5959
}
6060

6161
// ----- accessors ------------------------------------------------------
@@ -81,7 +81,7 @@ public String getDescription()
8181
@Override
8282
public Image getIcon()
8383
{
84-
return ImageUtilities.loadImage(iconPath, true);
84+
return ImageUtilities.loadImage(f_sIconPath, true);
8585
}
8686

8787
// ----- data members ----------------------------------------------------
@@ -99,16 +99,18 @@ public Image getIcon()
9999
/**
100100
* Icon path.
101101
*/
102-
private final String iconPath;
102+
private final String f_sIconPath;
103103

104104
/**
105105
* {@link Map} of possible classes to detect.
106106
*/
107-
static final Map<String, String> f_mapClasses = new HashMap<String, String>()
108-
{{
109-
put("com.tangosol.net.DefaultCacheServer", "Default Cache Server");
110-
put("com.tangosol.net.CacheFactory", "CacheFactory");
111-
put("com.tangosol.net.Coherence", "Coherence Bootstrap");
112-
put("com.tangosol.coherence.dslquery", "CohQL Client");
113-
}};
107+
static final Map<String, String> f_mapClasses = new HashMap<String, String>();
108+
109+
static
110+
{
111+
f_mapClasses.put("com.tangosol.net.DefaultCacheServer", "Default Cache Server");
112+
f_mapClasses.put("com.tangosol.net.CacheFactory", "CacheFactory");
113+
f_mapClasses.put("com.tangosol.net.Coherence", "Coherence Bootstrap");
114+
f_mapClasses.put("com.tangosol.coherence.dslquery", "CohQL Client");
115+
}
114116
}

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/CoherenceApplicationTypeFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@ public ApplicationType createApplicationTypeFor(Application app, Jvm jvm, String
7575
/**
7676
* Factory instance.
7777
*/
78-
private final static CoherenceApplicationTypeFactory INSTANCE = new CoherenceApplicationTypeFactory();
78+
private static final CoherenceApplicationTypeFactory INSTANCE = new CoherenceApplicationTypeFactory();
7979
}

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/CoherenceOptionsPanel.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public class CoherenceOptionsPanel
8989

9090
// ----- CoherenceOptionsPanel methods ---------------------------------
9191

92-
private final ChangeListener changeListener = new ChangeListener()
92+
private final transient ChangeListener f_changeListener = new ChangeListener()
9393
{
9494
public void stateChanged(ChangeEvent e)
9595
{
@@ -146,8 +146,8 @@ boolean valid()
146146
}
147147
catch (Exception e)
148148
{
149+
return false;
149150
}
150-
return false;
151151
}
152152

153153
/**
@@ -365,16 +365,16 @@ private void addHeader(int y, String sLabel)
365365
*/
366366
private void startTrackingChanges()
367367
{
368-
m_refreshTime.getModel().addChangeListener(changeListener);
369-
m_logQueryTimes.getModel().addChangeListener(changeListener);
370-
m_disableMBeanCheck.getModel().addChangeListener(changeListener);
371-
m_enableRestDebug.getModel().addChangeListener(changeListener);
372-
m_restRequestTimout.getModel().addChangeListener(changeListener);
373-
m_enableZoom.getModel().addChangeListener(changeListener);
374-
m_enablePersistenceList.getModel().addChangeListener(changeListener);
375-
m_enableClusterSnapshot.getModel().addChangeListener(changeListener);
376-
m_adminFunctionsEnabled.getModel().addChangeListener(changeListener);
377-
m_disableSSLCertValidation.getModel().addChangeListener(changeListener);
368+
m_refreshTime.getModel().addChangeListener(f_changeListener);
369+
m_logQueryTimes.getModel().addChangeListener(f_changeListener);
370+
m_disableMBeanCheck.getModel().addChangeListener(f_changeListener);
371+
m_enableRestDebug.getModel().addChangeListener(f_changeListener);
372+
m_restRequestTimout.getModel().addChangeListener(f_changeListener);
373+
m_enableZoom.getModel().addChangeListener(f_changeListener);
374+
m_enablePersistenceList.getModel().addChangeListener(f_changeListener);
375+
m_enableClusterSnapshot.getModel().addChangeListener(f_changeListener);
376+
m_adminFunctionsEnabled.getModel().addChangeListener(f_changeListener);
377+
m_disableSSLCertValidation.getModel().addChangeListener(f_changeListener);
378378
}
379379

380380
//----- inner classes ---------------------------------------------------
@@ -441,20 +441,20 @@ public String analyze(boolean fVerbose)
441441
long nLineId = lineId.incrementAndGet();
442442
mapLines.put(nLineId, s);
443443
return nLineId + " " +
444-
s.replaceAll("^.*thread=","")
445-
.replaceAll(", .*" + PARTITION_ID, "")
446-
.replaceAll(", .*" + PARTITION_SET, " ")
447-
.replaceAll(", " + OWNER, "")
448-
.replaceAll(", " + ACTION, "")
449-
.replaceAll(", " + UNAVAILABLE_TIME, "");
444+
s.replace("^.*thread=","")
445+
.replace(", .*" + PARTITION_ID, "")
446+
.replace(", .*" + PARTITION_SET, " ")
447+
.replace(", " + OWNER, "")
448+
.replace(", " + ACTION, "")
449+
.replace(", " + UNAVAILABLE_TIME, "");
450450
})
451451
.map(s -> s.split(" "))
452452
.filter(a -> a.length == 6)
453453
.map(a -> {
454454
// determine the service name from the thread as it is not always obvious
455-
String sServiceName = a[1].replaceAll("Dedicated.*$", "")
456-
.replaceAll("DistributedCache:", "")
457-
.replaceAll("FederatedCache:", "");
455+
String sServiceName = a[1].replace("Dedicated.*$", "")
456+
.replace("DistributedCache:", "")
457+
.replace("FederatedCache:", "");
458458

459459
// check for initial PartitionSet ASSIGN and allocate a partition id of -1 meaning all partitions
460460
String sPartitionId = a[2];
@@ -470,12 +470,12 @@ public String analyze(boolean fVerbose)
470470
Set<String> setServices = setMetrics.stream()
471471
.map(UnavailabilityMetrics::getServiceName)
472472
.collect(Collectors.toSet());
473-
if (setServices.size() == 0) {
473+
if (setServices.isEmpty()) {
474474
sb.append("No services found. This may not be a Coherence log file.");
475475
return sb.toString();
476476
}
477477

478-
sb.append(String.format("Total lines in file: %,d, total matching lines processed: %,d\n", listLines.size(), lineId.get()));
478+
sb.append(String.format("Total lines in file: %,d, total matching lines processed: %,d%n", listLines.size(), lineId.get()));
479479

480480
int nMaxLength = Math.max(setServices.stream().mapToInt(String::length).max().getAsInt(), 23);
481481
long nTotalMillis = setMetrics.stream().mapToLong(UnavailabilityMetrics::getMillis).sum();
@@ -546,11 +546,11 @@ public String analyze(boolean fVerbose)
546546
.forEach((e) ->
547547
{
548548
int nPartitionId = e.getKey();
549-
sb.append(String.format("- Partition: %d, total millis: %,d\n", nPartitionId,
549+
sb.append(String.format("- Partition: %d, total millis: %,d%n", nPartitionId,
550550
e.getValue()));
551551
setMetrics.stream()
552552
.filter(m->m.getServiceName().equals(s) && m.getPartitionId() == nPartitionId)
553-
.forEach(m->sb.append(String.format(" %s\n", mapLines.get(m.getLineId()))));
553+
.forEach(m->sb.append(String.format(" %s%n", mapLines.get(m.getLineId()))));
554554
});
555555

556556
sb.append("\nOutput by partition and event for ").append(s).append('\n');
@@ -565,10 +565,10 @@ public String analyze(boolean fVerbose)
565565
sb.append("- Partition ").append(p).append('\n');
566566
// retrieve the initial partition assign which has been marked with partition of -1
567567
setMetrics.stream().filter(m -> m.getServiceName().equals(s) && m.getPartitionId() == -1)
568-
.forEach(m -> sb.append(String.format(" %s\n", mapLines.get(m.getLineId()))));
568+
.forEach(m -> sb.append(String.format(" %s%n", mapLines.get(m.getLineId()))));
569569
setMetrics.stream()
570570
.filter(m -> m.getServiceName().equals(s) && m.getPartitionId() == p)
571-
.forEach(m -> sb.append(String.format(" %s\n", mapLines.get(m.getLineId()))));
571+
.forEach(m -> sb.append(String.format(" %s%n", mapLines.get(m.getLineId()))));
572572
});
573573
}
574574
});

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/VisualVMModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,8 @@ else if (sCoherenceVersion.startsWith("2"))
474474
nVersion = Integer.parseInt(sCoherenceVersion.replaceAll("\\.", ""));
475475
}
476476

477-
LOGGER.info("RAW Coherence version identified as " + m_sClusterVersion);
478-
LOGGER.info("Numeric Coherence version identified as " + nVersion);
477+
LOGGER.log(Level.INFO, "Raw Coherence version identified as {0}", m_sClusterVersion);
478+
LOGGER.log(Level.INFO,"Numeric Coherence version identified as {0}", String.format("%d", nVersion));
479479

480480
if (nVersion >= 121300)
481481
{

coherence-visualvm-plugin/src/main/java/com/oracle/coherence/plugin/visualvm/impl/CoherenceClusterConfigurator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ private static boolean isValid(String sClusterName, String sUrl)
119119
// Valid URL's are
120120
// Standard Coherence: http://host:management-port/management/coherence/cluster
121121
// Managed Coherence Servers: http://<admin-host>:<admin-port>/management/coherence/<version>/clusters
122-
if (!sender.isValidUrl() || !sUrl.contains("/management/coherence"))
122+
// No trailing slash should be present
123+
if (!sender.isValidUrl() || !sUrl.contains("/management/coherence") || sUrl.endsWith("/"))
123124
{
124125
DialogDisplayer.getDefault().notify(
125126
new NotifyDescriptor.Message(Localization.getLocalText("ERR_Invalid_URL", sUrl)));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public void updateGUI()
245245
f_txtClusterName.setText(entry.getValue().getColumn(ClusterData.CLUSTER_NAME).toString());
246246
f_txtRefreshDate.setText(new Date(f_model.getLastUpdate()).toString());
247247
f_txtVersion.setText(entry.getValue().getColumn(ClusterData.VERSION).toString().replaceFirst(" .*$", ""));
248-
f_txtClusterSize.setText(String.format("%d", entry.getValue().getColumn(ClusterData.CLUSTER_SIZE)));
248+
f_txtClusterSize.setText(String.format("%d", (Integer) entry.getValue().getColumn(ClusterData.CLUSTER_SIZE)));
249249
}
250250
}
251251

0 commit comments

Comments
 (0)