无法通过livy客户端将jar上传到livy会话

时间:2016-10-06 12:04:31

标签: java cloudera

代码:

LivyClient client = null;
try
{
  String livyUrl = "http://dummy16814.zycus.net:8998";
  client = new LivyClientBuilder().setURI(new URI(livyUrl)).build();

  String piJar = "E:\\livy_old.jar";
  System.err.printf("Uploading %s to the Spark context...\n", piJar);
  client.uploadJar(new File(piJar)).get();

  int samples = 10;
  System.err.printf("Running PiJob with %d samples...\n", samples);

  double pi = client.submit(new PiJob()).get();
  System.out.println("Pi is roughly: " + pi);
}
finally
{
  client.stop(true);
}

上传jar时获得以下异常

  

将E:\ livy_old.jar上传到Spark上下文...线程中的异常   “main”java.util.concurrent.ExecutionException:java.io.IOException:   错误请求:“要求失败:本地路径   /root/.livy-sessions/61a5e39c-d199-4bb8-967b-960b4e3e9ee3/livy_old.jar   无法添加到用户会话。“在   java.util.concurrent.FutureTask.report(FutureTask.java:122)at   java.util.concurrent.FutureTask.get(FutureTask.java:192)at   com.zycus.spark.PiJob.main(PiJob.java:64)引起:   java.io.IOException:错误请求:“要求失败:本地路径   /root/.livy-sessions/61a5e39c-d199-4bb8-967b-960b4e3e9ee3/livy_old.jar   无法添加到用户会话。“在   com.cloudera.livy.client.http.LivyConnection.sendRequest(LivyConnection.java:197)     在   com.cloudera.livy.client.http.LivyConnection.post(LivyConnection.java:162)     在   com.cloudera.livy.client.http.HttpClient $ 2.call(HttpClient.java:155)     在   com.cloudera.livy.client.http.HttpClient $ 2.call(HttpClient.java:152)     在java.util.concurrent.FutureTask.run(FutureTask.java:266)at   java.util.concurrent.ScheduledThreadPoolExecutor中的$ ScheduledFutureTask.access $ 201(ScheduledThreadPoolExecutor.java:180)     在   java.util.concurrent.ScheduledThreadPoolExecutor中的$ ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)     在   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)     在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:617)     在java.lang.Thread.run(Thread.java:745)

3 个答案:

答案 0 :(得分:3)

默认情况下,Livy不允许将本地文件附加到用户会话:https://groups.google.com/a/cloudera.org/forum/#!topic/livy-user/mm-XEhANDHU 我通过在livy-server-0.3.0 / conf / livy.conf中指定本地路径解决了这个问题:

livy.file.local-dir-whitelist = / root / .livy-sessions /

这应该在他们的文档中提到

答案 1 :(得分:1)

在我的情况下将spark.master yarn-cluster添加到spark配置文件spark-defaults.conf

在群集中的所有节点上添加此条目。

答案 2 :(得分:0)

如果在本地运行,则必须修改livy.conf中的两个属性。

  

livy.spark.master =本地,

     

livy.file.local-dir-whitelist = [/ path / tothe / file]

更改了这两个参数后,我能够使它工作