Skip to content

Commit

Permalink
Persistence probes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiddlet2666 committed Mar 7, 2024
1 parent c91bd1c commit 0b4dd6a
Show file tree
Hide file tree
Showing 13 changed files with 427 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.oracle.coherence.plugin.visualvm.tracer.cluster.ClusterMonitorPackage;
import com.oracle.coherence.plugin.visualvm.tracer.elasticdata.ElasticDataMonitorPackage;
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.ServiceMonitorPackage;

Expand Down Expand Up @@ -121,7 +122,8 @@ public TracerPackage<Application>[] getPackages(Application application)
new ServiceMonitorPackage(application),
new CacheMonitorPackage(application),
new FederationMonitorPackage(application),
new ElasticDataMonitorPackage(application)
new ElasticDataMonitorPackage(application),
new PersistenceMonitorPackage(application)
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ 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
Expand All @@ -144,6 +145,37 @@ protected long[] getSingValueSum(VisualVMModel model, VisualVMModel.DataType dat
return new long[] {nSum};
}

/**
* Returns the max 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[] getSingValueMax(VisualVMModel model, VisualVMModel.DataType dataType, int nColumn, long[] aDefault)
{
List<Map.Entry<Object, Data>> data = model.getData(dataType);
long nMax = 0L;
long nValue = 0L;

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

if (nValue > nMax)
{
nMax = nValue;
}
}
}

return new long[] {nMax};
}

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

private final MonitoredDataResolver f_resolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public VisualVMModel getMonitoredData()

private static final String NAME = Localization.getLocalText("LBL_cache_probe");
private static final String DESCR = Localization.getLocalText("LBL_cache_probe_description");
private static final int POSITION = 510;
private static final int POSITION = 20510;

private TracerProbeDescriptor m_memorySizeProbeDescriptor;
private TracerProbeDescriptor m_SizeProbeDescriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public VisualVMModel getMonitoredData()

private static final String NAME = Localization.getLocalText("LBL_cluster_probe");
private static final String DESCR = Localization.getLocalText("LBL_cluster_probe_description");
private static final int POSITION = 500;
private static final int POSITION = 20500;

private TracerProbeDescriptor m_heapProbeDescriptor;
private TracerProbeDescriptor m_clusterSizeProbeDescriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public VisualVMModel getMonitoredData()

private static final String NAME = Localization.getLocalText("LBL_elasticdata_probe");
private static final String DESCR = Localization.getLocalText("LBL_elasticdata_probe_description");
private static final int POSITION = 570;
private static final int POSITION = 20570;

private TracerProbeDescriptor m_ramournalMemoryProbeDescriptor;
private TracerProbeDescriptor m_flashjournalSpaceProbeDescriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public VisualVMModel getMonitoredData()

private static final String NAME = Localization.getLocalText("LBL_federation_probe");
private static final String DESCR = Localization.getLocalText("LBL_federation_probe_description");
private static final int POSITION = 550;
private static final int POSITION = 20550;

private TracerProbeDescriptor m_bytesSentPerSecondProbeDescriptor;
private TracerProbeDescriptor m_msgsSentPerSecondProbeDescriptor;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* 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.persistence;

import com.oracle.coherence.plugin.visualvm.Localization;
import com.oracle.coherence.plugin.visualvm.VisualVMModel;
import com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheData;
import com.oracle.coherence.plugin.visualvm.tablemodel.model.PersistenceData;
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;

import static com.oracle.coherence.plugin.visualvm.helper.GraphHelper.MB;

/**
* Tracer probe to return the total active space used across all persistence services.
*
* @author tam 2024.03.07
*/
public class ActiveSpaceProbe
extends AbstractCoherenceMonitorProbe
{
// ----- constructors ---------------------------------------------------

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

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

@Override
public long[] getValues(VisualVMModel model)
{
long[] anValue = getSingValueSum(model, VisualVMModel.DataType.PERSISTENCE, PersistenceData.TOTAL_ACTIVE_SPACE_USED_MB, ZERO_VALUES1);
anValue[0] = anValue[0] * MB;
return anValue;
}

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

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

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

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

import static com.oracle.coherence.plugin.visualvm.helper.GraphHelper.MB;

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

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

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 backup space used across all persistence services.
*
* @author tam 2024.03.07
*/
public class BackupSpaceProbe
extends AbstractCoherenceMonitorProbe
{
// ----- constructors ---------------------------------------------------

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

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

@Override
public long[] getValues(VisualVMModel model)
{
long[] anValue = getSingValueSum(model, VisualVMModel.DataType.PERSISTENCE, PersistenceData.TOTAL_BACKUP_SPACE_USED_MB, ZERO_VALUES1);
anValue[0] = anValue[0] * MB;
return anValue;
}

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

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

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

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


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

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

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

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

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

/**
* Tracer probe to return the maximum latency of all persistence services.
*
* @author tam 2024.03.07
*/
public class MaximumLatencyProbe
extends AbstractCoherenceMonitorProbe
{
// ----- constructors ---------------------------------------------------

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

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

@Override
public long[] getValues(VisualVMModel model)
{
return getSingValueMax(model, VisualVMModel.DataType.PERSISTENCE, PersistenceData.MAX_LATENCY, ZERO_VALUES1);
}

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

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

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

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

0 comments on commit 0b4dd6a

Please sign in to comment.