Skip to content

Commit

Permalink
add federation and elastic data probes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiddlet2666 committed Mar 7, 2024
1 parent 95d068c commit c38f64c
Show file tree
Hide file tree
Showing 12 changed files with 964 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.cache.CacheMonitorPackage;
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.proxy.ProxyMonitorPackage;
import com.oracle.coherence.plugin.visualvm.tracer.service.ServiceMonitorPackage;

Expand Down Expand Up @@ -117,7 +119,9 @@ public TracerPackage<Application>[] getPackages(Application application)
new ClusterMonitorPackage(application),
new ProxyMonitorPackage(application),
new ServiceMonitorPackage(application),
new CacheMonitorPackage(application)
new CacheMonitorPackage(application),
new FederationMonitorPackage(application),
new ElasticDataMonitorPackage(application)
};
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
* 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.elasticdata;

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 elastic data related probes.
*
* @author tam 2024.03.07
*/
public class ElasticDataMonitorPackage
extends TracerPackage<Application> implements AbstractCoherenceMonitorProbe.MonitoredDataResolver {

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

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

@Override
public TracerProbeDescriptor[] getProbeDescriptors() {
m_ramournalMemoryProbeDescriptor = RamJournalMemoryProbe.createDescriptor(f_model != null);
m_flashjournalSpaceProbeDescriptor = FlashJournalSpaceProbe.createDescriptor(f_model != null);
m_ramjournalFilesProbeDescriptor = RamJournalFilesProbe.createDescriptor(f_model != null);
m_flashjournalFilesProbeDescriptor = FlashJournalFilesProbe.createDescriptor(f_model != null);

return new TracerProbeDescriptor[] {
m_ramournalMemoryProbeDescriptor,
m_flashjournalSpaceProbeDescriptor,
m_ramjournalFilesProbeDescriptor,
m_flashjournalFilesProbeDescriptor
};
}

@Override
public TracerProbe<Application> getProbe(TracerProbeDescriptor descriptor)
{
if (descriptor == m_ramournalMemoryProbeDescriptor)
{
if (m_ramjournalMemoryProbe == null)
{
m_ramjournalMemoryProbe = new RamJournalMemoryProbe(this);
}
return m_ramjournalMemoryProbe;
}
else if (descriptor == m_flashjournalSpaceProbeDescriptor)
{
if (m_flashjournalSpaceProbe == null)
{
m_flashjournalSpaceProbe = new FlashJournalSpaceProbe(this);
}
return m_flashjournalSpaceProbe;
}
else if (descriptor == m_flashjournalFilesProbeDescriptor)
{
if (m_flashjournalFilesProbe == null)
{
m_flashjournalFilesProbe = new FlashJournalFilesProbe(this);
}
return m_flashjournalFilesProbe;
}
else if (descriptor == m_ramjournalFilesProbeDescriptor)
{
if (m_ramjournalFilesProbe == null)
{
m_ramjournalFilesProbe = new RamJournalFilesProbe(this);
}
return m_ramjournalFilesProbe;
}
else
{
return null;
}
}

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

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

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

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 TracerProbeDescriptor m_ramournalMemoryProbeDescriptor;
private TracerProbeDescriptor m_flashjournalSpaceProbeDescriptor;
private TracerProbeDescriptor m_ramjournalFilesProbeDescriptor;
private TracerProbeDescriptor m_flashjournalFilesProbeDescriptor;

private AbstractCoherenceMonitorProbe m_ramjournalMemoryProbe;
private AbstractCoherenceMonitorProbe m_flashjournalSpaceProbe;
private AbstractCoherenceMonitorProbe m_ramjournalFilesProbe;
private AbstractCoherenceMonitorProbe m_flashjournalFilesProbe;

private final VisualVMModel f_model;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* 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.elasticdata;

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

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

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 flash journal files used.
*
* @author tam 2024.03.06
*/
public class FlashJournalFilesProbe
extends AbstractCoherenceMonitorProbe
{
// ----- constructors ---------------------------------------------------

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

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

@Override
public long[] getValues(VisualVMModel model)
{
long nRamJournalFileCount = getSingValueSum(model, VisualVMModel.DataType.FLASHJOURNAL, RamJournalData.FILE_COUNT, ZERO_VALUES1)[0];
long nRamJournaMaxFiles = getSingValueSum(model, VisualVMModel.DataType.FLASHJOURNAL, RamJournalData.MAX_FILES, ZERO_VALUES1)[0];
return new long[] {nRamJournalFileCount, nRamJournaMaxFiles};
}

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

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

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

private static final String LBL1 = "LBL_journal_files_used";
private static final String LBL2 = "LBL_max_journal_files";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* 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.elasticdata;

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

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

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 flash journal space committed and used.
*
* @author tam 2024.03.03]7
*/
public class FlashJournalSpaceProbe
extends AbstractCoherenceMonitorProbe
{
// ----- constructors ---------------------------------------------------

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

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

@Override
public long[] getValues(VisualVMModel model)
{
long nRamJournalCommitted = getSingValueSum(model, VisualVMModel.DataType.FLASHJOURNAL, RamJournalData.TOTAL_COMMITTED_BYTES, ZERO_VALUES1)[0];
long nRamJournalUsed = getSingValueSum(model, VisualVMModel.DataType.FLASHJOURNAL, RamJournalData.TOTAL_DATA_SIZE, ZERO_VALUES1)[0];
return new long[] {nRamJournalCommitted, nRamJournalUsed};
}

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

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

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

private static final String LBL1 = "GRPH_total_flashjournal_space";
private static final String LBL2 = "GRPH_used_flashjournal_space";
}
Loading

0 comments on commit c38f64c

Please sign in to comment.