Skip to content

Commit

Permalink
Finalize tracer probes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiddlet2666 committed Mar 12, 2024
1 parent 05c951b commit b1da84b
Show file tree
Hide file tree
Showing 21 changed files with 821 additions and 50 deletions.
39 changes: 1 addition & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,44 +206,7 @@ From the VisualVM website
When you connect to a cluster via JMX, you will see the `Tracer` tab as shown below:
   ![Coherence VisualVM Probes](assets/probes.png)
Each of the probes areas can be expanded to reveal the individual probes. You can select the probes and then
click `Start` to display the information.
The supported Coherence probes are:
*Cluster Overview*
    ![Cluster Overview](assets/probes-cluster-overview.png)
*Services*
    ![Cluster Overview](assets/probes-services.png)
*Caches*
    ![Caches](assets/probes-caches.png)
*Proxy Servers*
    ![Proxy Servers](assets/probes-proxies.png)
*Persistence*
    ![Persistence](assets/probes-persistence.png)
*Federation*
    ![Federation](assets/probes-federation.png)
*Elastic Data*
    ![elastic Data](assets/probes-elastic-data.png)
> Note: In the initial release of this integration, only summary information can to be plotted. We may include
> additional functionality in future releases to allow for specific services or caches to be monitored.
> There are no timelines for these releases. If you would like specific information included, please raise an issue.
TBC.
## <a id="build"></a> Building the Plugin
Expand Down
Binary file removed assets/probes-caches.png
Binary file not shown.
Binary file removed assets/probes-cluster-overview.png
Binary file not shown.
Binary file removed assets/probes-elastic-data.png
Binary file not shown.
Binary file removed assets/probes-federation.png
Binary file not shown.
Binary file removed assets/probes-persistence.png
Binary file not shown.
Binary file removed assets/probes-proxies.png
Binary file not shown.
Binary file removed assets/probes-services.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.oracle.coherence.plugin.visualvm.tracer.federation.FederationMonitorPackage;
import com.oracle.coherence.plugin.visualvm.tracer.persistence.PersistenceMonitorPackage;
import com.oracle.coherence.plugin.visualvm.tracer.proxy.ProxyMonitorPackage;
import com.oracle.coherence.plugin.visualvm.tracer.service.SelectedServiceMonitorPackage;
import com.oracle.coherence.plugin.visualvm.tracer.service.ServiceMonitorPackage;

import org.graalvm.visualvm.application.Application;
Expand Down Expand Up @@ -120,6 +121,7 @@ public TracerPackage<Application>[] getPackages(Application application)
new ClusterMonitorPackage(application),
new ProxyMonitorPackage(application),
new ServiceMonitorPackage(application),
new SelectedServiceMonitorPackage(application),
new CacheMonitorPackage(application),
new FederationMonitorPackage(application),
new ElasticDataMonitorPackage(application),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,10 @@ public void updateData()
// only include task averages where there is a thread count
if (cThread > 0)
{
// update values for taks average duration
// update values for task average duration
cTotalTaskAverage++;

cAverage = (Float) entry.getValue().getColumn(ServiceMemberData.TASK_AVERAGE_DURATION);

nTotalTaskAverage += cAverage;

if (cAverage > nMaxTaskAverage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.oracle.coherence.plugin.visualvm.Localization;
import com.oracle.coherence.plugin.visualvm.VisualVMModel;
import com.oracle.coherence.plugin.visualvm.tablemodel.model.Data;
import com.oracle.coherence.plugin.visualvm.tablemodel.model.ServiceMemberData;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import org.graalvm.visualvm.application.Application;
Expand Down Expand Up @@ -176,6 +177,98 @@ protected long[] getSingValueMax(VisualVMModel model, VisualVMModel.DataType dat
return new long[] {nMax};
}

/**
* Returns the total and idle threads for the selected service.
* @param model the {@link VisualVMModel} to use
*
* @return the tracer result
* 0: Integer - total thread count
* 1: Integer - total idle threads
*/
protected Object[] getSelectedServiceThreadValues(VisualVMModel model)
{
List<Map.Entry<Object, Data>> data = model.getData(VisualVMModel.DataType.SERVICE_DETAIL);
int nTotalThreadCount = 0;
int nTotalIdleThreads = 0;

if (data != null && !data.isEmpty())
{
for (Map.Entry<Object, Data> entry : data)
{
nTotalThreadCount += (Integer) entry.getValue().getColumn(ServiceMemberData.THREAD_COUNT);
nTotalIdleThreads += (Integer) entry.getValue().getColumn(ServiceMemberData.THREAD_IDLE_COUNT);
}
}

return new Object[] {nTotalThreadCount, nTotalIdleThreads};
}

/**
* Returns the max and average value for a selected service.
*
* @param model the {@link VisualVMModel} to use
* @param nColumn the column to extract
*
* @return the tracer result (multiplied byt 1000)
* 0: Long - Max
* 1: Long - Average
*/
protected Long[] getSelectedServiceMaxAndAverage(VisualVMModel model, int nColumn)
{
List<Map.Entry<Object, Data>> data = model.getData(VisualVMModel.DataType.SERVICE_DETAIL);

long nTotal = 0L;
long nMax = 0L;
long nCount = 0L;
long nCurrent = 0L;

if (data != null && !data.isEmpty())
{
for (Map.Entry<Object, Data> entry : data)
{
nCurrent = (long) ((Float) entry.getValue().getColumn(nColumn) * 1000L);
if (nCurrent <= 0)
{
// exclude negative values
continue;
}
nCount++;
nTotal += nCurrent;
if (nCurrent > nMax)
{
nMax = nCurrent;
}
}
}

return nCount == 0L ? new Long[] {0L,0L} : new Long[] {nMax, nTotal / nCount};
}

/**
* Returns the mtotal value for a selected service.
*
* @param model the {@link VisualVMModel} to use
* @param nColumn the column to extract
*
* @return the tracer result
*/
protected long getSelectedServiceTotalInteger(VisualVMModel model, int nColumn)
{
List<Map.Entry<Object, Data>> data = model.getData(VisualVMModel.DataType.SERVICE_DETAIL);

int nTotal = 0;

if (data != null && !data.isEmpty())
{
for (Map.Entry<Object, Data> entry : data)
{
nTotal += (Integer) entry.getValue().getColumn(nColumn);
}
}

return nTotal;
}

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

private final MonitoredDataResolver f_resolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class ClusterSizeProbe

public ClusterSizeProbe(MonitoredDataResolver resolver)
{
super(12, createItemDescriptors(), resolver);
super(2, createItemDescriptors(), resolver);
}

// ---- TracerProbe methods ---------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/*
* Copyright (c) 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package com.oracle.coherence.plugin.visualvm.tracer.service;

import static com.oracle.coherence.plugin.visualvm.tracer.AbstractCoherenceMonitorProbe.ICON;

import com.oracle.coherence.plugin.visualvm.Localization;
import com.oracle.coherence.plugin.visualvm.VisualVMModel;
import com.oracle.coherence.plugin.visualvm.VisualVMView;

import com.oracle.coherence.plugin.visualvm.tracer.AbstractCoherenceMonitorProbe;

import org.graalvm.visualvm.application.Application;

import org.graalvm.visualvm.modules.tracer.TracerPackage;
import org.graalvm.visualvm.modules.tracer.TracerProbe;
import org.graalvm.visualvm.modules.tracer.TracerProbeDescriptor;


/**
* A {@link TracerPackage} to show service related probes for the currently selected service.
*
* @author tam 2024.03.12
*/
public class SelectedServiceMonitorPackage
extends TracerPackage<Application> implements AbstractCoherenceMonitorProbe.MonitoredDataResolver {

public SelectedServiceMonitorPackage(Application application)
{
super(NAME, DESCR, ICON, POSITION);
this.f_model = VisualVMView.getModelForApplication(application);
}

// ---- TracerPackage methods -------------------------------------------

@Override
public TracerProbeDescriptor[] getProbeDescriptors() {
m_threadCountProbeDescriptor = SelectedServiceThreadCountProbe.createDescriptor(f_model != null);
m_threadUtilProbeDescriptor = SelectedServiceThreadUtilizationProbe.createDescriptor(f_model != null);
m_taskAverageProbeDescriptor = SelectedServiceTaskAverageProbe.createDescriptor(f_model != null);
m_requestAverageProbeDescriptor = SelectedServiceRequestAverageProbe.createDescriptor(f_model != null);
m_taskBacklogProbeDescriptor = SelectedServiceTaskBackLogProbe.createDescriptor(f_model != null);
m_partitionsProbeDescriptor = SelectedServicePartitionsProbe.createDescriptor(f_model != null);

return new TracerProbeDescriptor[] {
m_threadCountProbeDescriptor,
m_threadUtilProbeDescriptor,
m_taskAverageProbeDescriptor,
m_requestAverageProbeDescriptor,
m_taskBacklogProbeDescriptor,
m_partitionsProbeDescriptor
};
}

@Override
public TracerProbe<Application> getProbe(TracerProbeDescriptor descriptor)
{
if (descriptor == m_threadCountProbeDescriptor)
{
if (m_threadCountProbe == null)
{
m_threadCountProbe = new SelectedServiceThreadCountProbe(this);
}
return m_threadCountProbe;
}
else if (descriptor == m_threadUtilProbeDescriptor)
{
if (m_threadUtilProbe == null)
{
m_threadUtilProbe = new SelectedServiceThreadUtilizationProbe(this);
}
return m_threadUtilProbe;
}
else if (descriptor == m_taskAverageProbeDescriptor)
{
if (m_taskAverageProbe == null)
{
m_taskAverageProbe = new SelectedServiceTaskAverageProbe(this);
}
return m_taskAverageProbe;
}
else if (descriptor == m_requestAverageProbeDescriptor)
{
if (m_requestAverageProbe == null)
{
m_requestAverageProbe = new SelectedServiceRequestAverageProbe(this);
}
return m_requestAverageProbe;
}
else if (descriptor == m_taskBacklogProbeDescriptor)
{
if (m_taskBacklogProbe == null)
{
m_taskBacklogProbe = new SelectedServiceTaskBackLogProbe(this);
}
return m_taskBacklogProbe;
}
else if (descriptor == m_partitionsProbeDescriptor)
{
if (m_partitionsProbe == null)
{
m_partitionsProbe = new SelectedServicePartitionsProbe(this);
}
return m_partitionsProbe;
}
else
{
return null;
}
}

// ---- AbstractCoherenceMonitorProbe.MonitoredDataResolver interface ---

@Override
public VisualVMModel getMonitoredData()
{
return f_model;
}

// ----- constants ------------------------------------------------------

private static final String NAME = Localization.getLocalText("LBL_selected_service_probe");
private static final String DESCR = Localization.getLocalText("LBL_selected_service_probe_description");
private static final int POSITION = 20506;

private TracerProbeDescriptor m_threadCountProbeDescriptor;
private TracerProbeDescriptor m_threadUtilProbeDescriptor;
private TracerProbeDescriptor m_taskAverageProbeDescriptor;
private TracerProbeDescriptor m_requestAverageProbeDescriptor;
private TracerProbeDescriptor m_taskBacklogProbeDescriptor;
private TracerProbeDescriptor m_partitionsProbeDescriptor;

private AbstractCoherenceMonitorProbe m_threadCountProbe;
private AbstractCoherenceMonitorProbe m_threadUtilProbe;
private AbstractCoherenceMonitorProbe m_taskAverageProbe;
private AbstractCoherenceMonitorProbe m_requestAverageProbe;
private AbstractCoherenceMonitorProbe m_taskBacklogProbe;
private AbstractCoherenceMonitorProbe m_partitionsProbe;

private final VisualVMModel f_model;
}
Loading

0 comments on commit b1da84b

Please sign in to comment.