java 8
Есть класс:
Код: Выделить всё
public class LoaderVerticle extends AbstractVerticle {
// some code..
@Override
public void start(Future startFuture) throws Exception {
super.start(startFuture);
this.client = Utils.createHttpClient(vertx, config());
vertx.eventBus().consumer(EVENT_LOAD, this::startLoad);
vertx.eventBus().consumer(EVENT_LOAD_ALL, this::loadAll);
vertx.eventBus().consumer(EVENT_CHUNK, this::loadChunk);
}
// some code..
}
Код: Выделить всё
private void loadAll(Message event) {
// some code..
HttpClientRequest request = client.getAbs(ctx.getUrl(), response -> {
// some code..
response.endHandler(dummy -> {
file.flush().close(evt -> {
if (evt.succeeded()) {
ctx.setChecksum(downloadPump.getChecksum());
ctx.setCompleted(FileUtils.getFileSize(ctx.getTmpFile()));
loadComplete(ctx);
} else {
loadError(String.format("Unable to close temporary download file (%s)", evt.cause()));
}
});
});
});
}
Код: Выделить всё
private void loadChunk(Message event) {
// some code..
client.getAbs(ctx.getUrl(), resp -> {
vertx.fileSystem().open(ctx.getTmpFile(), fileOpts, future -> {
if (future.succeeded()) {
AsyncFile file = future.result();
resp.bodyHandler(buff -> {
ctx.accept(buff.getBytes());
progressJob(ctx, buff.length());
file.write(buff).flush(futWrite -> {
if (futWrite.succeeded()) {
file.close(futClose -> {
if (futClose.succeeded()) {
if (ctx.getLoadedSize() < ctx.getTotalSize()) {
nextChunk(ctx.resetRetry());
} else {
// some code..
}
} else {
// some code..
}
});
} else {
// some code..
}
});
});
resp.exceptionHandler(e -> {
// some code..
});
resp.resume();
} else {
// some code..
}
});
});
}
02:10: 10.154 [vertx-blocked-thread-checker] WARN io.vertx.core.impl.BlockedThreadChecker — поток Thread[vert.x-internal-blocking-2,5,main] заблокирован на 60248 мс, ограничение по времени — 60000io.vertx.core.VertxException: поток заблокирован
в sun.nio.ch.FileDispatcherImpl.force0(собственный метод) ~[?:1.8.0_111]
в sun.nio.ch. FileDispatcherImpl.force(FileDispatcherImpl.java:76) ~[?:1.8.0_111]
at sun.nio.ch.SimpleAsynchronousFileChannelImpl.force(SimpleAsynchronousFileChannelImpl.java:162) ~[?:1.8.0_111]
at io.vertx.core.file.impl.AsyncFileImpl.lambda$doFlush$3(AsyncFileImpl.java:363) ~[s-app.jar:?]
at io.vertx.core.file.impl. AsyncFileImpl$$Lambda$256/1218269075.perform(Неизвестный источник) ~[?:?]
at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:275) ~[s-app .jar:?]
в io.vertx.core.impl.ContextImpl$$Lambda$59/1267985667.run(Неизвестный источник) ~[?:?]
в io.vertx.core.impl. TaskQueue.run(TaskQueue.java:76) ~[scheduler-app.jar:?]
at io.vertx.core.impl.TaskQueue$$Lambda$43/2067180044.run(Неизвестный источник) ~[?: ?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor. java:617) ~[?:1.8.0_111]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[s-app.jar:?]
at java.lang.Thread.run(Thread.java:745) ~[?:1.8.0_111]
и такое предупреждение повторяется снова и снова снова.
Помогает перезапуск приложения.
Локально я не могу воспроизвести проблему, поскольку она возникает непредсказуемо, примерно раз в один-три дня. Я подумывал об удалении промывки, но не уверен, решит ли это проблему. Если вы не можете определить причину проблемы, не могли бы вы предоставить мне информацию о том, как мне найти блок, вызывающий проблему, и что мне следует искать?
Подробнее здесь: https://stackoverflow.com/questions/783 ... is-blocked