public class JmxMetricExporterSpi extends IgniteSpiAdapter implements MetricExporterSpi
MetricExporterSpi it exports metrics as JMX beans.
This implementation works by `pull` architecture which means that after the Ignite node start it should respond to
incoming user request.
Ignite ignite = Ignition.start(new IgniteConfiguration()
.setDataStorageConfiguration(new DataStorageConfiguration()
.setDefaultDataRegionConfiguration(
new DataRegionConfiguration()
.setMaxSize(12_000_000)))
.setIgniteInstanceName("jmxExampleInstanceName"));
String igniteInstanceName = ignite.name();
String metricGroup = "io";
// NOTE: The special characters of metric name must be escaped.
String metricName = "\"dataregion.default\"";
SB sb = new SB("org.apache:");
if (IgniteSystemProperties.getBoolean("IGNITE_MBEAN_APPEND_CLASS_LOADER_ID", true))
sb.a("clsLdr=").a(Integer.toHexString(Ignite.class.getClassLoader().hashCode())).a(',');
if (IgniteSystemProperties.getBoolean("IGNITE_MBEAN_APPEND_JVM_ID"))
sb.a("jvmId=").a(ManagementFactory.getRuntimeMXBean().getName()).a(',');
sb.a("igniteInstanceName=").a(igniteInstanceName).a(',')
.a("group=").a(metricGroup).a(',')
.a("name=").a(metricName);
DynamicMBean dataRegionMBean = MBeanServerInvocationHandler.newProxyInstance(
ignite.configuration().getMBeanServer(),
new ObjectName(sb.toString()),
DynamicMBean.class,
false);
Set listOfMetrics = Arrays.stream(dataRegionMBean.getMBeanInfo().getAttributes())
.map(MBeanFeatureInfo::getName)
.collect(toSet());
System.out.println("The list of available data region metrics: " + listOfMetrics);
System.out.println("The 'default' data region MaxSize: " + dataRegionMBean.getAttribute("MaxSize"));
ignite, igniteInstanceName, log| Constructor and Description |
|---|
JmxMetricExporterSpi() |
| Modifier and Type | Method and Description |
|---|---|
void |
setExportFilter(Predicate<ReadOnlyMetricRegistry> filter)
Sets export filter.
|
void |
setMetricRegistry(ReadOnlyMetricManager reg)
Sets metrics registry that SPI should export.
|
void |
spiStart(@Nullable String igniteInstanceName)
This method is called to start SPI.
|
void |
spiStop()
This method is called to stop SPI.
|
addTimeoutObject, assertParameter, checkConfigurationConsistency0, clientFailureDetectionTimeout, configInfo, createSpiAttributeName, failureDetectionTimeout, failureDetectionTimeoutEnabled, failureDetectionTimeoutEnabled, getConsistentAttributeNames, getExceptionRegistry, getLocalNode, getName, getNodeAttributes, getSpiContext, ignite, initFailureDetectionTimeout, injectables, injectResources, isNodeStopping, onBeforeStart, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextDestroyed0, onContextInitialized, onContextInitialized0, registerMBean, removeTimeoutObject, setName, started, startInfo, startStopwatch, stopInfo, unregisterMBeanclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitializedpublic void spiStart(@Nullable
@Nullable String igniteInstanceName)
throws IgniteSpiException
spiStart in interface IgniteSpiigniteInstanceName - Name of Ignite instance this SPI is being started for
(null for default Ignite instance).IgniteSpiException - Throws in case of any error during SPI start.public void spiStop()
throws IgniteSpiException
Note that this method can be called at any point including during recovery of failed start. It should make no assumptions on what state SPI will be in when this method is called.
spiStop in interface IgniteSpiIgniteSpiException - Thrown in case of any error during SPI stop.public void setMetricRegistry(ReadOnlyMetricManager reg)
IgniteSpi.spiStart(String).setMetricRegistry in interface MetricExporterSpireg - Metric registry.public void setExportFilter(Predicate<ReadOnlyMetricRegistry> filter)
filter shouldn't be exported.setExportFilter in interface MetricExporterSpifilter - Filter.RegexpMetricFilter
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023