Skip to content

Commit

Permalink
Add service and proxy probes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiddlet2666 committed Mar 6, 2024
1 parent 09bdd87 commit df81533
Show file tree
Hide file tree
Showing 11 changed files with 776 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

import com.oracle.coherence.plugin.visualvm.tracer.cluster.ClusterMonitorPackage;

import com.oracle.coherence.plugin.visualvm.tracer.proxy.ProxyMonitorPackage;
import com.oracle.coherence.plugin.visualvm.tracer.service.ServiceMonitorPackage;
import org.graalvm.visualvm.application.Application;
import org.graalvm.visualvm.modules.tracer.TracerPackage;
import org.graalvm.visualvm.modules.tracer.TracerPackageProvider;
Expand Down Expand Up @@ -108,7 +110,12 @@ private static class TracerPackageProviderImpl

public TracerPackage<Application>[] getPackages(Application application)
{
return new ClusterMonitorPackage[] {new ClusterMonitorPackage(application)};
return new TracerPackage[]
{
new ClusterMonitorPackage(application),
new ProxyMonitorPackage(application),
new ServiceMonitorPackage(application)
};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,30 @@ protected long[] getSingValue(VisualVMModel model, VisualVMModel.DataType dataTy

return new long[] {getValueAsLong(data.get(0).getValue().getColumn(nColumn))};
}
/**
* Returns the sum of a single value from all entries for a datatype.
* @param model the {@link VisualVMModel} to use
* @param dataType the {@link VisualVMModel.DataType} to query
* @param nColumn the column to extract
* @param aDefault default value
*
* @return the tracer result
*/
protected long[] getSingValueSum(VisualVMModel model, VisualVMModel.DataType dataType, int nColumn, long[] aDefault)
{
List<Map.Entry<Object, Data>> data = model.getData(dataType);
long nSum = 0L;

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

return new long[] {nSum};
}

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2007, 2018, 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.proxy;

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

import com.oracle.coherence.plugin.visualvm.tablemodel.model.ProxyData;

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

import org.graalvm.visualvm.modules.tracer.ItemValueFormatter;
import org.graalvm.visualvm.modules.tracer.ProbeItemDescriptor;
import org.graalvm.visualvm.modules.tracer.TracerProbeDescriptor;

/**
* Tracer probe to return the total number of proxy server connections.
*
* @author tam 2024.03.03
*/
public class ProxyConnectionCountProbe
extends AbstractCoherenceMonitorProbe
{
// ----- constructors ---------------------------------------------------

public ProxyConnectionCountProbe(MonitoredDataResolver resolver)
{
super(1, createItemDescriptors(), resolver);
}

// ---- TracerProbe methods ---------------------------------------------

@Override
public long[] getValues(VisualVMModel model)
{
return getSingValueSum(model, VisualVMModel.DataType.PROXY, ProxyData.CONNECTION_COUNT, ZERO_VALUES1);
}

public static TracerProbeDescriptor createDescriptor(boolean available)
{
return new TracerProbeDescriptor(Localization.getLocalText(LBL),
Localization.getLocalText("LBL_proxy_desc"), ICON, 5, available);
}

private static ProbeItemDescriptor[] createItemDescriptors()
{
return new ProbeItemDescriptor[]
{
ProbeItemDescriptor.continuousLineFillItem(Localization.getLocalText(LBL),
getMonitorsString(LBL), ItemValueFormatter.DEFAULT_DECIMAL,
1d, 0, 1),
};
}

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

private static final String LBL = "GRPH_total_connections";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* 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.proxy;

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 Proxy related probes.
*
* @author tam 2024.03.04
*/
public class ProxyMonitorPackage
extends TracerPackage<Application> implements AbstractCoherenceMonitorProbe.MonitoredDataResolver {

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

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

@Override
public TracerProbeDescriptor[] getProbeDescriptors() {
m_proxyConnectionsProbeDescriptor = ProxyConnectionCountProbe.createDescriptor(f_model != null);
m_proxyOutgoingMsgProbeDescriptor = ProxyOutgoingMsgBacklogProbe.createDescriptor(f_model != null);

return new TracerProbeDescriptor[] {
m_proxyConnectionsProbeDescriptor,
m_proxyOutgoingMsgProbeDescriptor
};
}

@Override
public TracerProbe<Application> getProbe(TracerProbeDescriptor descriptor)
{
if (descriptor == m_proxyConnectionsProbeDescriptor)
{
if (m_proxyConnectionsProbe == null)
{
m_proxyConnectionsProbe = new ProxyConnectionCountProbe(this);
}
return m_proxyConnectionsProbe;
}
else if (descriptor == m_proxyOutgoingMsgProbeDescriptor)
{
if (m_proxyOutgoingMsgBacklogProbe == null)
{
m_proxyOutgoingMsgBacklogProbe = new ProxyOutgoingMsgBacklogProbe(this);
}
return m_proxyOutgoingMsgBacklogProbe;
}
else
{
return null;
}
}

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

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

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

private static final String NAME = Localization.getLocalText("LBL_proxy_probe");
private static final String DESCR = Localization.getLocalText("LBL_proxy_probe_description");
private static final int POSITION = 520;

private TracerProbeDescriptor m_proxyConnectionsProbeDescriptor;
private TracerProbeDescriptor m_proxyOutgoingMsgProbeDescriptor;

private AbstractCoherenceMonitorProbe m_proxyConnectionsProbe;
private AbstractCoherenceMonitorProbe m_proxyOutgoingMsgBacklogProbe;

private final VisualVMModel f_model;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2007, 2018, 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.proxy;

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

import com.oracle.coherence.plugin.visualvm.tablemodel.model.ProxyData;

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

import org.graalvm.visualvm.modules.tracer.ItemValueFormatter;
import org.graalvm.visualvm.modules.tracer.ProbeItemDescriptor;
import org.graalvm.visualvm.modules.tracer.TracerProbeDescriptor;

/**
* Tracer probe to return the total number of outgoing message backlog for all proxy servers.
*
* @author tam 2024.03.03
*/
public class ProxyOutgoingMsgBacklogProbe
extends AbstractCoherenceMonitorProbe
{
// ----- constructors ---------------------------------------------------

public ProxyOutgoingMsgBacklogProbe(MonitoredDataResolver resolver)
{
super(1, createItemDescriptors(), resolver);
}

// ---- TracerProbe methods ---------------------------------------------

@Override
public long[] getValues(VisualVMModel model)
{
return getSingValueSum(model, VisualVMModel.DataType.PROXY, ProxyData.OUTGOING_MSG_BACKLOG, ZERO_VALUES1);
}

public static TracerProbeDescriptor createDescriptor(boolean available)
{
return new TracerProbeDescriptor(Localization.getLocalText(LBL),
Localization.getLocalText("LBL_proxy_outgoing_desc"), ICON, 5, available);
}

private static ProbeItemDescriptor[] createItemDescriptors()
{
return new ProbeItemDescriptor[]
{
ProbeItemDescriptor.continuousLineFillItem(Localization.getLocalText(LBL),
getMonitorsString(LBL), ItemValueFormatter.DEFAULT_DECIMAL,
1d, 0, 1),
};
}

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

private static final String LBL = "LBL_outgoing_msg_backlog";
}
Loading

0 comments on commit df81533

Please sign in to comment.