[
https://issues.apache.org/jira/browse/IGNITE-12768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17061372#comment-17061372
]
Nikolay Izhikov commented on IGNITE-12768:
------------------------------------------
Hello [~NSAmelchev].
Can you, please, take a look at my changes.
> MetricRegistryMBean doesn't show histogram values in case when histogram name
> contains underscore character
> -----------------------------------------------------------------------------------------------------------
>
> Key: IGNITE-12768
> URL: https://issues.apache.org/jira/browse/IGNITE-12768
> Project: Ignite
> Issue Type: Bug
> Reporter: Andrey N. Gura
> Assignee: Nikolay Izhikov
> Priority: Major
> Labels: IEP-35
> Fix For: 2.8.1
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> {{MetricRegistryMBean}} doesn't show histogram values in case when histogram
> name contains underscore character.
> The problem in {{MetricRegistryMBean.searchHistogram()}} method which relies
> on first underscore character in the fully qualified metric name. This method
> also use relatively old and not effective API for string parsing (this API
> implementation is synchronized). It should be replaced by simple
> {{String.lastIndexOf()}} for example.
> Reproducer:
> {code:java}
> package org.apache.ignite.spi.metric.jmx;
> import org.apache.ignite.Ignite;
> import org.apache.ignite.IgniteException;
> import org.apache.ignite.configuration.IgniteConfiguration;
> import org.apache.ignite.internal.IgniteEx;
> import org.apache.ignite.internal.processors.metric.MetricRegistry;
> import org.apache.ignite.internal.util.typedef.internal.U;
> import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
> import org.junit.Test;
> import javax.management.*;
> import java.lang.management.ManagementFactory;
> public class MetricRegistryMBeanTest extends GridCommonAbstractTest {
> private static final String REGISTRY_NAME = "test_registry";
> private static final String VALID_HISTOGRAM_NAME = "testhist";
> private static final String INVALID_HISTOGRAM_NAME = "test_hist";
> @Override protected IgniteConfiguration getConfiguration(String
> igniteInstanceName) throws Exception {
> IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
> JmxMetricExporterSpi exporterSpi = new JmxMetricExporterSpi();
> cfg.setMetricExporterSpi(exporterSpi);
> return cfg;
> }
> @Test public void testBean() throws Exception {
> Ignite ignite = startGrid();
> MetricRegistry reg =
> ((IgniteEx)ignite).context().metric().registry(REGISTRY_NAME);
> reg.histogram(VALID_HISTOGRAM_NAME, new long[] {10, 100}, null);
> reg.histogram(INVALID_HISTOGRAM_NAME, new long[] {10, 100}, null);
> assertNotNull(mbean(ignite).getAttribute(VALID_HISTOGRAM_NAME + '_' +
> 10 + '_' + 100));
> assertEquals(0L, mbean(ignite).getAttribute(VALID_HISTOGRAM_NAME +
> '_' + 10 + '_' + 100));
> assertNotNull(mbean(ignite).getAttribute(INVALID_HISTOGRAM_NAME + '_'
> + 10 + '_' + 100));
> assertEquals(0L, mbean(ignite).getAttribute(INVALID_HISTOGRAM_NAME +
> '_' + 10 + '_' + 100));
> }
> private static DynamicMBean mbean(Ignite ignite) {
> try {
> ObjectName mbeanName = U.makeMBeanName(ignite.name(), null,
> REGISTRY_NAME);
> MBeanServer mbeanSrv = ManagementFactory.getPlatformMBeanServer();
> if (!mbeanSrv.isRegistered(mbeanName))
> fail("MBean is not registered: " +
> mbeanName.getCanonicalName());
> return MBeanServerInvocationHandler.newProxyInstance(mbeanSrv,
> mbeanName, DynamicMBean.class, false);
> } catch (MalformedObjectNameException e) {
> throw new IgniteException(e);
> }
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)