在同一jvm中部署的多次战争中使用cassandra驱动程序时出现jmx错误 [英] jmx error while using cassandra driver in multiple wars deployed in same jvm

查看:151
本文介绍了在同一jvm中部署的多次战争中使用cassandra驱动程序时出现jmx错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一tomcat jvm中部署了app1.war和app2.war。这两个应用程序都有自己的上下文xml-app1.xml和app2.xml。
这两个应用程序都包含datastax驱动程序相关性以连接到Cassandra。当它们分别部署时,它们运行良好。但是,当两者都部署在同一jvm中时,我在日志中看到以下JMX异常:

I have app1.war and app2.war deployed in the same tomcat jvm. Both apps have their own context xmls - app1.xml and app2.xml. Both applications contain datastax driver dependancies to connect to Cassandra. They run well when they are deployed separately. But when both are deployed in the same jvm, I am seeing below JMX exceptions in logs:

[DEBUG] [TokenId=] [2015-07-29 20:54:35.177] [DefaultListableBeanFactory] - [Eagerly caching bean 'cluster' to allow for resolving potential circular references]
[DEBUG] [TokenId=] [2015-07-29 20:54:35.191] [DefaultListableBeanFactory] - [Invoking afterPropertiesSet() on bean with name 'cluster']
[DEBUG] [TokenId=] [2015-07-29 20:54:35.199] [SystemProperties] - [com.datastax.driver.NEW_NODE_DELAY_SECONDS is undefined, using default value 1]
[DEBUG] [TokenId=] [2015-07-29 20:54:35.199] [SystemProperties] - [com.datastax.driver.NON_BLOCKING_EXECUTOR_SIZE is undefined, using default value 16]
[DEBUG] [TokenId=] [2015-07-29 20:54:35.205] [SystemProperties] - [com.datastax.driver.NOTIF_LOCK_TIMEOUT_SECONDS is undefined, using default value 60]
[WARN ] [TokenId=] [2015-07-29 20:54:35.217] [FrameCompressor] - [Cannot find Snappy class, you should make sure the Snappy library is in the classpath if you intend to use it. Snappy compression
will not be available for the protocol.]
[WARN ] [TokenId=] [2015-07-29 20:54:35.219] [FrameCompressor] - [Cannot find LZ4 class, you should make sure the LZ4 library is in the classpath if you intend to use it. LZ4 compression will not
be available for the protocol.]
[DEBUG] [TokenId=] [2015-07-29 20:54:35.356] [Cluster] - [Starting new cluster with contact points [xxxxx1.com/10.63.162.182:9042, xxxx2.com/10.63.162.177:9042, xxxx3.com/10.63.162.183:9042]]
[DEBUG] [TokenId=] [2015-07-29 20:54:35.556] [JmxReporter] - [Unable to register gauge]
javax.management.InstanceAlreadyExistsException: cluster1-metrics:name=open-connections
        at com.sun.jmx.mbeanserver.Repository.addMBean(Unknown Source) ~[?:1.7.0_45]
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(Unknown Source) ~[?:1.7.0_45]
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(Unknown Source) ~[?:1.7.0_45]
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(Unknown Source) ~[?:1.7.0_45]
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(Unknown Source) ~[?:1.7.0_45]
        at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(Unknown Source) ~[?:1.7.0_45]
        at com.codahale.metrics.JmxReporter$JmxListener.onGaugeAdded(JmxReporter.java:494) [metrics-core-3.0.2.jar:3.0.2]
        at com.codahale.metrics.MetricRegistry.notifyListenerOfAddedMetric(MetricRegistry.java:344) [metrics-core-3.0.2.jar:3.0.2]
        at com.codahale.metrics.MetricRegistry.addListener(MetricRegistry.java:187) [metrics-core-3.0.2.jar:3.0.2]
        at com.codahale.metrics.JmxReporter.start(JmxReporter.java:697) [metrics-core-3.0.2.jar:3.0.2]
        at com.datastax.driver.core.Metrics.<init>(Metrics.java:77) [cassandra-driver-core-2.1.4.jar:?]
        at com.datastax.driver.core.Cluster$Manager.<init>(Cluster.java:1204) [cassandra-driver-core-2.1.4.jar:?]
        at com.datastax.driver.core.Cluster$Manager.<init>(Cluster.java:1144) [cassandra-driver-core-2.1.4.jar:?]
        at com.datastax.driver.core.Cluster.<init>(Cluster.java:121) [cassandra-driver-core-2.1.4.jar:?]
        at com.datastax.driver.core.Cluster.<init>(Cluster.java:108) [cassandra-driver-core-2.1.4.jar:?]
        at com.datastax.driver.core.Cluster.buildFrom(Cluster.java:177) [cassandra-driver-core-2.1.4.jar:?]
        at com.datastax.driver.core.Cluster$Builder.build(Cluster.java:1109) [cassandra-driver-core-2.1.4.jar:?]

该应用程序可以正常工作。我只是担心为什么我会看到此错误以及如何避免此错误。

The application works functionally. I am just concerned on why I am seeing this error and how to avoid this.

推荐答案

正如您所指出的,这不会除了未注册集群的度量标准MBean之一之外,还会引起其他问题。为了防止出现此消息/问题,您可以为您的集群实例指定唯一的名称,可能与您的应用程序本身的名称相关。

As you indicated, this won't cause any issues other than not registering one of the Cluster's metrics MBeans. To prevent this message/problem, you can give your Cluster instances unique names, maybe tied to the name of your application itself.

    Cluster cluster = Cluster.builder().withClusterName("myapplication")
            .build();

这将为您的mbean名称加上 myapplication-1前缀。

This will prefix your mbean name with 'myapplication-1'.

否则,您可以使用 withoutJMXReporting withoutMetrics 禁用指标报告。

Otherwise you can disable JMX metrics alltogether using withoutJMXReporting or withoutMetrics to disable metrics reporting.

这篇关于在同一jvm中部署的多次战争中使用cassandra驱动程序时出现jmx错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆