gpt4 book ai didi

livy - 使用 Apache Livy 的 Java 应用程序

转载 作者:行者123 更新时间:2023-12-02 04:27:40 27 4
gpt4 key购买 nike

我决定使用 Apache Livy 为 Apache Spark 构建一个 Web 服务(应用程序)。
根据 Livy 配置默认值,Livy 服务器已启动并在 localhost 端口 8998 上运行。
我的测试程序是 Apache Livy 文档中的示例应用程序:https://livy.incubator.apache.org/docs/latest/programmatic-api.html

通过 创建 LivyClient 时LivyClientBuilder 类(class),

 client = new LivyClientBuilder().setURI(new 
URI("http","user:info","localhost",8998,"","",""))
.build();

我得到“任何注册的客户端工厂都不支持 URI”异常:
Exception in thread "main" java.lang.IllegalArgumentException: URI 'http://%5Bredacted%5D@localhost:8998?#' is not supported by any registered client factories.
at org.apache.livy.LivyClientBuilder.build(LivyClientBuilder.java:155)
at Client.<init>(Client.java:17)
at Client.main(Client.java:25)

我发现客户端实例在 中保持为空LivyClientBuilder 类(class)。
client = factory.createClient(uri, this.config);

factory 是 的一个实例LivyClientFactory 界面。
唯一实现该接口(interface)的类是 RSCClientFactory .
RSCClientFactory 我们有这段代码:
if (!"rsc".equals(uri.getScheme())) {
return null;
}

我试过“rsc”而不是“http”,这是错误:
    2018-09-15 11:32:55 ERROR RSCClient:340 - RPC error.
java.util.concurrent.ExecutionException: javax.security.sasl.SaslException: Client closed before SASL negotiation finished.
javax.security.sasl.SaslException: Client closed before SASL negotiation finished.
at io.netty.util.concurrent.AbstractFuture.get(AbstractFuture.java:41)
at org.apache.livy.rsc.rpc.Rpc$SaslClientHandler.dispose(Rpc.java:419)
at org.apache.livy.rsc.JobHandleImpl.get(JobHandleImpl.java:60)
at org.apache.livy.rsc.rpc.SaslHandler.channelInactive(SaslHandler.java:92)
at Client.main(Client.java:39)

Apache Livy 在 http://localhost:8998 上运行然后我认为我们需要将我们的 jar 文件提交到这个地址,但我不明白那里的“rsc”。

如果有人指导我解决这些问题,我将不胜感激。

最佳答案

您只需要将 URL 作为字符串传递:

LivyClient client = new LivyClientBuilder()
.setURI(new URI("http://localhost:8998"))
.build();

之后,您可以添加 *.jar 文件:
client.addJar("file://...yourPathToJarHere.../*.jar");

或者
client.uploadJar(new File("...."));

这取决于您的集群配置。您可以在此处找到完整的 java API 描述: https://livy.incubator.apache.org/docs/latest/api/java/index.html

关于livy - 使用 Apache Livy 的 Java 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52342747/

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