gpt4 book ai didi

spring-mvc - 在同一 jvm 中部署的多个 war 中使用 cassandra 驱动程序时出现 jmx 错误

转载 作者:行者123 更新时间:2023-11-28 21:50:39 24 4
gpt4 key购买 nike

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

[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:?]

应用程序正常运行。我只是关心为什么会看到此错误以及如何避免此错误。

最佳答案

正如您所指出的,除了不注册集群的指标 MBean 之一外,这不会导致任何问题。为防止出现此消息/问题,您可以为您的集群实例指定唯一的名称,可能与您的应用程序本身的名称相关联。

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

这将为您的 mbean 名称添加前缀“myapplication-1”。

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

关于spring-mvc - 在同一 jvm 中部署的多个 war 中使用 cassandra 驱动程序时出现 jmx 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31711469/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com