Skip to content

Commit

Permalink
Add option to display partition stats
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiddlet2666 committed Feb 26, 2024
1 parent 5e5f889 commit 7ededd6
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 20 deletions.
2 changes: 1 addition & 1 deletion coherence-visualvm-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<parent>
<groupId>com.oracle.coherence.plugin.visualvm</groupId>
<artifactId>coherence-visualvm-main</artifactId>
<version>1.6.3-SNAPSHOT</version>
<version>1.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2024 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -294,6 +294,26 @@ public void invokeStorageManagerOperation(String sService, String sCacheName, St
sendPostRequest(urlBuilder);
}

@Override
public String invokeReportPartitionsStatsOperation(String sService, String sCacheName)
throws Exception
{
URLBuilder urlBuilder = getBasePath()
.addPathSegment(SERVICES)
.addPathSegment(encodeServiceName(sService))
.addPathSegment("storage")
.addPathSegment(encodeServiceName(sCacheName))
.addPathSegment(PART_STATS);

JsonNode rootNode = getResponseJson(sendGetRequest(urlBuilder));
if (rootNode != null)
{
return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(rootNode.get(PART_STATS));
}

return "";
}

@Override
public Set<ObjectName> getAllJournalMembers(String sJournalType)
throws Exception
Expand Down Expand Up @@ -2054,6 +2074,7 @@ private void initSSL()
private static final String CACHE = "Cache";
private static final String DOMAIN_PART = "domainPartition";
private static final String DESCRIPTION = "description";
public static final String PART_STATS = "reportPartitionStats";

/**
* A trust manager that will trust all certificates. Only used when the preference to ignore SSL certs is chosen.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2024 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -46,6 +46,7 @@
import javax.management.NotificationListener;
import javax.management.ObjectName;

import static com.oracle.coherence.plugin.visualvm.helper.HttpRequestSender.PART_STATS;
import static com.oracle.coherence.plugin.visualvm.panel.CoherenceTopicPanel.NOTIFY_POPULATED;

/**
Expand Down Expand Up @@ -125,6 +126,19 @@ public void invokeStorageManagerOperation(String sService, String sCacheName, St
invoke(new ObjectName(sFQN), sOperation, new Object[]{}, new String[]{});
}

@Override
public String invokeReportPartitionsStatsOperation(String sService, String sCacheName)
throws Exception
{
ObjectName objectName = new ObjectName("Coherence:type=StorageManager,service=" + sService + ",cache=" + sCacheName + ",*");

Set<ObjectName> setResult = getCompleteObjectName(objectName);
String sFQN = getFirstResult(setResult);

return (String) invoke(new ObjectName(sFQN), PART_STATS, new Object[]{"json"}, new String[]{String.class.getName()});
}


@Override
public Set<ObjectName> getAllJournalMembers(String sJournalType)
throws Exception
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2024 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -102,6 +102,17 @@ Set<ObjectName> getAllCacheMembers()
void invokeStorageManagerOperation(String sService, String sCacheName, String sOperation)
throws Exception;

/**
* Invoke the reportPartitionStats Storage Manager operation.
*
* @param sService the name of the service
* @param sCacheName the name of the cache
*
* @throws Exception in case of errors
*/
String invokeReportPartitionsStatsOperation(String sService, String sCacheName)
throws Exception;

/**
* Return the list of all journal member ObjectNames in the cluster.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ public CoherenceCachePanel(VisualVMModel model)
setTablePadding(f_tableStorage);
f_tableStorage.setMenuOptions(new MenuOption[] {
new ShowDetailMenuOption(model, f_tableStorage, SELECTED_STORAGE),
new ShowIndexInfoMenuOption(model, m_requestSender, f_tableStorage)
new ShowIndexInfoMenuOption(model, m_requestSender, f_tableStorage),
new ShowPartitionStatsMenuOption(model, m_requestSender, f_tableStorage)
});

// Create the scroll pane and add the table to it.
Expand Down Expand Up @@ -531,7 +532,7 @@ protected class ShowIndexInfoMenuOption
// ----- constructors -----------------------------------------------

/**
* Create a new menu option for displaying heat map.
* Create a new menu option for displaying index information.
*
* @param model the {@link VisualVMModel} to get collected data from
* @param requestSender the {@link MBeanServerConnection} to perform additional queries
Expand Down Expand Up @@ -673,6 +674,65 @@ public void actionPerformed(ActionEvent e)
private final String f_sMenuItem;
}

/**
* Right-click option to show index information.
*/
protected class ShowPartitionStatsMenuOption
extends AbstractMenuOption
{

// ----- constructors -----------------------------------------------

/**
* Create a new menu option for displaying partition stats information.
*
* @param model the {@link VisualVMModel} to get collected data from
* @param requestSender the {@link MBeanServerConnection} to perform additional queries
* @param jtable the {@link ExportableJTable} that this applies to
*/
public ShowPartitionStatsMenuOption(VisualVMModel model, RequestSender requestSender,
ExportableJTable jtable)
{
super(model, requestSender, jtable);
f_sMenuItem = getLocalizedText("LBL_cache_partition_stats");
}

// ----- AbstractMenuOption methods ---------------------------------

@Override
public String getMenuItem()
{
return f_sMenuItem;
}

@Override
public void actionPerformed(ActionEvent e)
{
String sResult = "unknown";
Pair<String, String> selectedCache = f_model.getSelectedCache();

try
{
sResult = m_requestSender.invokeReportPartitionsStatsOperation(selectedCache.getX(), selectedCache.getY());
showMessageDialog(Localization.getLocalText("LBL_cache_partition_stats"),
sResult, JOptionPane.INFORMATION_MESSAGE);
}
catch (Exception ee)
{
showMessageDialog(Localization.getLocalText("LBL_error"),
ee.getMessage(), JOptionPane.ERROR_MESSAGE);
}

}

// ----- data members ------------------------------------------------

/**
* Menu option description.
*/
private final String f_sMenuItem;
}

/**
* Menu option to invoke clear or truncate against a cache. Only available in most recent versions of Coherence.
*/
Expand Down Expand Up @@ -848,7 +908,7 @@ public synchronized void updateData()
while (iter.hasNext())
{
Pair<Pair<String, String>, Long> entryHeatMap = iter.next();
if (entryHeatMap.getY().longValue() <= cache.getY().longValue())
if (entryHeatMap.getY() <= cache.getY())
{
// add new value at the current position
f_listValues.add(nLocation, cache);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ LBL_title_size_heat_map=Cache Size Heat Map for All Caches
LBL_title_memory_heat_map=Primary Memory Heat Map for All Caches
LBL_no_caches=No caches are defined or all caches have zero size. Unable to create Heat Map.
LBL_no_data=You have selected a new row, please wait for the data to be refreshed and try viewing the heat map again.
LBL_index_info=Index information
LBL_index_info=Index Information
LBL_cache_partition_stats=Cache Partition Stats
LBL_truncate=Truncate Cache
LBL_clear=Clear Cache
LBL_confirm_cache_operation=WARNING: This operation will remove the cache contents.\nAre you sure you want to perform operation {0} against cache {1}?
Expand Down
4 changes: 2 additions & 2 deletions coherence-visualvm-tests/coherence-visualvm-tests-ce/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2020, 2024 Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,7 +33,7 @@
<parent>
<groupId>com.oracle.coherence.plugin.visualvm</groupId>
<artifactId>coherence-visualvm-tests</artifactId>
<version>1.6.3-SNAPSHOT</version>
<version>1.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2020, 2024 Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,7 +33,7 @@
<parent>
<groupId>com.oracle.coherence.plugin.visualvm</groupId>
<artifactId>coherence-visualvm-tests</artifactId>
<version>1.6.3-SNAPSHOT</version>
<version>1.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2020, 2024 Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -34,7 +34,7 @@
<parent>
<groupId>com.oracle.coherence.plugin.visualvm</groupId>
<artifactId>coherence-visualvm-tests</artifactId>
<version>1.6.3-SNAPSHOT</version>
<version>1.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2020, 2024 Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,7 +33,7 @@
<parent>
<groupId>com.oracle.coherence.plugin.visualvm</groupId>
<artifactId>coherence-visualvm-tests</artifactId>
<version>1.6.3-SNAPSHOT</version>
<version>1.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions coherence-visualvm-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2020, 2024 Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,7 +33,7 @@
<parent>
<groupId>com.oracle.coherence.plugin.visualvm</groupId>
<artifactId>coherence-visualvm-main</artifactId>
<version>1.6.3-SNAPSHOT</version>
<version>1.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2020, 2023 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2020, 2024 Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -34,7 +34,7 @@
<groupId>com.oracle.coherence.plugin.visualvm</groupId>
<artifactId>coherence-visualvm-main</artifactId>
<packaging>pom</packaging>
<version>1.6.3-SNAPSHOT</version>
<version>1.7.0-SNAPSHOT</version>
<name>Coherence VisualVM Plugin Parent</name>

<description>
Expand Down

0 comments on commit 7ededd6

Please sign in to comment.