[jira] [Commented] (IGNITE-12768) MetricRegistryMBean doesn't show histogram values in case when histogram name contains underscore character
[ https://issues.apache.org/jira/browse/IGNITE-12768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17062659#comment-17062659 ] Andrey N. Gura commented on IGNITE-12768: - [~nizhikov] [~NSAmelchev] Code could be simpler and shorter if you just change metric name format from "name__" to "name._". It looks logically and last dot in the name always split name and bounds. > 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: 40m > 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)
[jira] [Commented] (IGNITE-12768) MetricRegistryMBean doesn't show histogram values in case when histogram name contains underscore character
[ https://issues.apache.org/jira/browse/IGNITE-12768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17061620#comment-17061620 ] Nikolay Izhikov commented on IGNITE-12768: -- Merged to master. Cherry-picked to 2.8.1 > 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: 40m > 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)
[jira] [Commented] (IGNITE-12768) MetricRegistryMBean doesn't show histogram values in case when histogram name contains underscore character
[ https://issues.apache.org/jira/browse/IGNITE-12768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17061599#comment-17061599 ] Ignite TC Bot commented on IGNITE-12768: {panel:title=Branch: [pull/7542/head] Base: [master] : No blockers found!|borderStyle=dashed|borderColor=#ccc|titleBGColor=#D6F7C1}{panel} [TeamCity *-- Run :: All* Results|https://ci.ignite.apache.org/viewLog.html?buildId=5135360buildTypeId=IgniteTests24Java8_RunAll] > 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: 0.5h > 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)
[jira] [Commented] (IGNITE-12768) MetricRegistryMBean doesn't show histogram values in case when histogram name contains underscore character
[ https://issues.apache.org/jira/browse/IGNITE-12768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17061526#comment-17061526 ] Amelchev Nikita commented on IGNITE-12768: -- [~nizhikov], Hi, LGTM. > 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: 0.5h > 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)
[jira] [Commented] (IGNITE-12768) MetricRegistryMBean doesn't show histogram values in case when histogram name contains underscore character
[ https://issues.apache.org/jira/browse/IGNITE-12768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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)