ScyllaDB 是否支持最新版本的指标?

Does ScyllaDB Support Latest Version of Metrics?

当我第一次启动 ScyllaDB 时:

Cluster cluster = Cluster.builder().addContactPoints("xx.xxx.xx.xxx").build();
Session session = cluster.connect("my_scylladb_cluster");

System.out.println(session.isClosed());

我收到以下错误:

===== Using optimized driver!!! =====
Exception in thread "main" java.lang.NoClassDefFoundError: com/codahale/metrics/JmxReporter
    at com.datastax.driver.core.Metrics.<init>(Metrics.java:156)
    at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1773)
    at com.datastax.driver.core.Cluster.init(Cluster.java:228)
    at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:401)
    at com.datastax.driver.core.Cluster.connect(Cluster.java:352)
    at scylladbX.ScyllaDBXMain.main(ScyllaDBMain.java:12)
Caused by: java.lang.ClassNotFoundException: com.codahale.metrics.JmxReporter
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 6 more

在我的 Maven POM 文件中,我使用的是最新版本的 Metrics:

    <dependency>
        <groupId>io.dropwizard.metrics</groupId>
        <artifactId>metrics-core</artifactId>
        <version>4.2.9</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/io.dropwizard.metrics/metrics-graphite -->
    <dependency>
        <groupId>io.dropwizard.metrics</groupId>
        <artifactId>metrics-graphite</artifactId>
        <version>4.2.9</version>
    </dependency>

我注意到如果我降级到更早的 Metrics 版本,问题就会消失:

    <!-- https://mvnrepository.com/artifact/com.codahale.metrics/metrics-core -->
    <dependency>
        <groupId>com.codahale.metrics</groupId>
        <artifactId>metrics-core</artifactId>
        <version>3.0.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.codahale.metrics/metrics-graphite -->
    <dependency>
        <groupId>com.codahale.metrics</groupId>
        <artifactId>metrics-graphite</artifactId>
        <version>3.0.0</version>
    </dependency>

ScyllaDB不支持最新版本的Metrics吗?支持的最新版本是什么?

谢谢

DataStax Java 驱动程序文档 here 有一个部分与您看到的问题有关:

While the driver depends on Metrics 3.2.x, it also works with Metrics 4, with some caveats. In Metrics 4, JMX reporting was moved to a separate module, metrics-jmx. Because of this you are likely to encounter the following exception at runtime when initializing a Cluster:

Exception in thread "main" java.lang.NoClassDefFoundError: com/codahale/metrics/JmxReporter
   at com.datastax.driver.core.Metrics.<init>(Metrics.java:103)
   at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1402)
   at com.datastax.driver.core.Cluster.init(Cluster.java:159)
   at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:330)
   at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:305)
   at com.datastax.durationtest.core.DurationTest.createSessions(DurationTest.java:360)
       ....
Caused by: java.lang.ClassNotFoundException: com.codahale.metrics.JmxReporter
   at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
   at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
   at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
   ... 8 more

该文档还提供了在这种情况下该怎么做的建议。

无论如何,此问题与 Scylla(您要连接的后端服务器)无关 - 只是您使用的 Java 客户端(“驱动程序”)的问题。