Answer the question
In order to leave comments, you need to log in
How to solve java.lang.NoSuchMethodError issue?
Hello.
Wrote node_exporter for prometheus
class listing
import io.prometheus.client.Counter;
import io.prometheus.client.Gauge;
import io.prometheus.client.Histogram;
import io.prometheus.client.Summary;
import io.prometheus.client.vertx.MetricsHandler;
import io.vertx.core.Vertx;
import io.vertx.ext.web.Router;
import java.util.Timer;
import java.util.TimerTask;
//import io.prometheus.client.vertx.MetricsHandler;
public class Test {
static final Gauge g = Gauge.build().name("gauge").help("blah").register();
static final Counter c = Counter.build().name("counter").help("meh").register();
static final Summary s = Summary.build().name("summary").help("meh").register();
static final Histogram h = Histogram.build().name("histogram").help("meh").register();
static final Gauge l = Gauge.build().name("labels").help("blah").labelNames("l").register();
public static void main1(String[] args) throws Exception {
}
public static void main(String[] args) {
final Timer time = new Timer();
final Vertx vertx = Vertx.vertx();
final Router router = Router.router(vertx);
router.route("/metrics").handler(new MetricsHandler());
vertx.createHttpServer().requestHandler(router::accept).listen(8001);
time.schedule(new TimerTask() {
int i = 0;
@Override
public void run() { //ПЕРЕЗАГРУЖАЕМ МЕТОД RUN В КОТОРОМ ДЕЛАЕТЕ ТО ЧТО ВАМ НАДО
// g.set(1);
// c.inc(2);
// s.observe(3);
// h.observe(4);
// l.labels("port").inc(10010);
// l.labels("number").inc(12345);
if(i>=21){
System.out.println("Timer is over");
vertx.close();
time.cancel();
return;
}
l.labels("foo").inc(Math.random()*3 );
System.out.println("4 second ago");
i = i + 1;
}
}, 4000, 4000); //(4000 - ПОДОЖДАТЬ ПЕРЕД НАЧАЛОМ В МИЛИСЕК, ПОВТОРЯТСЯ 4 СЕКУНДЫ (1 СЕК = 1000 МИЛИСЕК))
}
}
plugins {
id 'java'
}
group 'PrometheusNodeExporters'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile('org.apache.hive:hive-jdbc:2.0.0')
compile group: 'com.esotericsoftware.yamlbeans', name: 'yamlbeans', version: '1.06'
compile group: 'io.prometheus', name: 'simpleclient', version: '0.5.0'
compile group: 'io.prometheus', name: 'simpleclient_hotspot', version: '0.5.0'
compile group: 'io.prometheus', name: 'simpleclient_httpserver', version: '0.5.0'
compile group: 'io.prometheus', name: 'simpleclient_vertx', version: '0.5.0'
// https://mvnrepository.com/artifact/io.vertx/vertx-core
compile group: 'io.vertx', name: 'vertx-core', version: '3.5.0'
// https://mvnrepository.com/artifact/io.vertx/vertx-web
compile group: 'io.vertx', name: 'vertx-web', version: '3.0.0'
// compile group: 'io.vertx', name: 'vertx-core', version: '3.6.0.CR1'
// compile group: 'io.vertx', name: 'vertx-web', version: '3.6.0.CR1'
// compile group: 'io.vertx', name: 'vertx-ext', version: '34'
}
task Hive(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': 'ru.prometheus.nodeexporters.Hive'
}
exclude("META-INF/*.LIST","META-INF/*.SF","META-INF/*.DSA","META-INF/*.RSA")
baseName = project.name + '-Hive'
from {
configurations.runtime.collect {
it.isDirectory() ? it : zipTree(it)
}
}
with jar
}
task Test(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': 'ru.prometheus.nodeexporters.Test'
}
exclude("META-INF/*.LIST","META-INF/*.SF","META-INF/*.DSA","META-INF/*.RSA")
baseName = project.name + '-Test'
from {
configurations.runtime.collect {
it.isDirectory() ? it : zipTree(it)
}
}
with jar
}
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
20:42:20.021 [main] DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
20:42:20.023 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetectionLevel: simple
20:42:20.048 [main] DEBUG i.n.c.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 8
20:42:20.053 [main] DEBUG i.n.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
20:42:20.054 [main] DEBUG i.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
20:42:20.054 [main] DEBUG i.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
20:42:20.054 [main] DEBUG i.n.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: true
20:42:20.060 [main] DEBUG i.n.util.internal.PlatformDependent - UID: 1000
20:42:20.060 [main] DEBUG i.n.util.internal.PlatformDependent - Java version: 8
20:42:20.060 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.noUnsafe: false
20:42:20.060 [main] DEBUG i.n.util.internal.PlatformDependent - sun.misc.Unsafe: available
20:42:20.060 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.noJavassist: false
20:42:20.061 [main] DEBUG i.n.util.internal.PlatformDependent - Javassist: unavailable
20:42:20.061 [main] DEBUG i.n.util.internal.PlatformDependent - You don't have Javassist in your class path or you don't have enough permission to load dynamically generated classes. Please check the configuration for better performance.
20:42:20.061 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.tmpdir: /tmp (java.io.tmpdir)
20:42:20.061 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
20:42:20.061 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
20:42:20.072 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
20:42:20.072 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
20:42:20.104 [main] DEBUG i.n.r.d.DefaultDnsServerAddressStreamProvider - Default DNS servers: [/127.0.0.53:53] (sun.net.dns.ResolverConfiguration)
20:42:20.107 [main] DEBUG io.netty.util.NetUtil - Loopback interface: lo (lo, 0:0:0:0:0:0:0:1%lo)
20:42:20.107 [main] DEBUG io.netty.util.NetUtil - /proc/sys/net/core/somaxconn: 128
20:42:20.297 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 4
20:42:20.297 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 4
20:42:20.297 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192
20:42:20.297 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 11
20:42:20.297 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 16777216
20:42:20.297 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.tinyCacheSize: 512
20:42:20.297 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256
20:42:20.297 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64
20:42:20.297 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
20:42:20.297 [main] DEBUG i.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192
ноя 19, 2018 8:42:20 PM io.vertx.core.http.impl.HttpServerImpl
SEVERE: java.lang.NoSuchMethodError: io.netty.util.NetUtil.isIpV4StackPreferred()Z
4 second ago
4 second ago
4 second ago
4 second ago
Answer the question
In order to leave comments, you need to log in
An exception NoSuchMethodError
is always a sign of library version incompatibility.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question