我们使用java REST客户端将jar上传到Flink 1.5.0服务器时收到错误响应{"errors":["内部服务器错误:null"]}。相同的代码在 Flink 1.4.2 中正常工作。事实上,我们可以看到 jar 是从 Flink GUI 上传的。但错误的状态打破了逻辑。有什么建议吗?
HttpPost uploadFile = new HttpPost(flinkJobManagerUrl + "/jars/upload");
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addBinaryBody(
"jarfile",
new FileInputStream(f),
ContentType.create("application/x-java-archive"),
f.getName()
);
HttpEntity multipart = builder.build();
uploadFile.setEntity(multipart);
CloseableHttpResponse response = restClient.execute(uploadFile);
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
====
=========================JM 日志中的错误:
018-06-01 16:05:46,514 WARN org.apache.flink.runtime.dispatcher.DispatcherRestEndpoint - 未处理的异常 org.apache.flink.shaded.netty4.io.netty.handler.codec.http.multipart.HttpPostRequestDecoder$EndOfDataDecoderException at org.apache.flink.shaded.netty4.io.netty.handler.codec.http.multipart.HttpPostMultipartRequestDecoder.hasNext(HttpPostMultipartRequestDecoder.java:366) at org.apache.flink.shaded.netty4.io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.hasNext(HttpPostRequestDecoder.java:241)at org.apache.flink.runtime.rest.FileUploadHandler.channelRead0(FileUploadHandler.java:92) at org.apache.flink.runtime.rest.FileUploadHandler.channelRead0(FileUploadHandler.java:51) at org.apache.flink.shaded.netty4.io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) at org.apache.flink.shaded.netty4.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339) at org.apache.flink.shaded.netty4.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324) at org.apache.flink.shaded.netty4.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:242) at org.apache.flink.shaded.netty4.io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:147) at org.apache.flink.shaded.netty4.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)at org.apache.flink.shaded.netty4.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324) at org.apache.flink.shaded.netty4.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:847) at org.apache.flink.shaded.netty4.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) at org.apache.flink.shaded.netty4.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) at org.apache.flink.shaded.netty4.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) at org.apache.flink.shaded.netty4.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) at org.apache.flink.shaded.netty4.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) at org.apache.flink.shaded.netty4.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)at org.apache.flink.shaded.netty4.io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) at java.lang.Thread.run(Thread.java:748)
但是过了一会儿,您将看到从GUI上传的jar。但是当运行它时,它会给出另一个异常:
2018-06-01 16:10:06,752 错误 org.apache.flink.runtime.webmonitor.handlers.JarRunHandler - REST 处理程序中发生异常。 org.apache.flink.runtime.rest.handler.RestHandlerException:预期只有一个值 [--KAFKA_IN a_O@192.168.56.120:9092, 192.168.56.121:9092, 192.168.56.122:9092/a_O_124 --ZK_SESSION_TIMEOUT 60000 --ZK_KEEP_CONN_ALIVE 1]。 at org.apache.flink.runtime.rest.handler.util.HandlerRequestUtils.getQueryParameter(HandlerRequestUtils.java:56) at org.apache.flink.runtime.rest.handler.util.HandlerRequestUtils.getQueryParameter(HandlerRequestUtils.java:44) at org.apache.flink.runtime.webmonitor.handlers.JarRunHandler.handleRequest(JarRunHandler.java:102)at org.apache.flink.runtime.webmonitor.handlers.JarRunHandler.handleRequest(JarRunHandler.java:68) at org.apache.flink.runtime.rest.handler.AbstractRestHandler.respondToRequest(AbstractRestHandler.java:77) at org.apache.flink.runtime.rest.AbstractHandler.respondAsLeader(AbstractHandler.java:168) at org.apache.flink.runtime.rest.handler.RedirectHandler.lambda$null$0(RedirectHandler.java:139) at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:760) at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:736) at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:442) at org.apache.flink.shaded.netty4.io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:357) at org.apache.flink.shaded.netty4.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)at org.apache.flink.shaded.netty4.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111) at org.apache.flink.shaded.netty4.io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) at java.lang.Thread.run(Thread.java:748)
第一个异常是由于FileUploadHandler中的一个错误;它不能正确处理EmptyLastHttpContent消息。请参阅 https://issues.apache.org/jira/browse/FLINK-9500。
第二个例外是由于程序参数中有空格引起的,从 1.5 开始不再支持。
关于第二个例外,您可以将带有逗号的程序Args放入post请求正文中,例如
{
"programArgs":"--test=a,b"
}