我有一个 Oozie 协调器,每小时运行一个工作流。工作流由两个顺序操作组成:一个 shell 操作和一个 Java 操作。当我运行协调器时,shell 操作似乎成功执行,但是,当需要执行 Java 操作时,Hue 中的作业浏览器总是显示:
There was a problem communicating with the server: Job application_<java-action-id> has expired.
这似乎指向views.py 和api.py。当我查看服务器日志时:
[23/Nov/2015 02:25:22 -0800] middleware INFO Processing exception: Job application_1448245438537_0010 has expired.: Traceback (most recent call last):
File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/transaction.py", line 371, in inner
return func(*args, **kwargs)
File "/usr/lib/hue/apps/jobbrowser/src/jobbrowser/views.py", line 67, in decorate
raise PopupException(_('Job %s has expired.') % jobid, detail=_('Cannot be found on the History Server.'))
PopupException: Job application_1448245438537_0010 has expired.
Java 操作由两部分组成:REST API 调用和将解析结果写入 HDFS(通过 Hadoop 客户端库)。尽管 Java 操作作业在 Job Browser 上到期/失败,但写入 HDFS 是成功的。这是编写部分 Java 代码的 HDFS 的片段。
FileSystem hdfs = FileSystem.get(new URI(hdfsUriPath), conf);
OutputStream os = hdfs.create(file);
BufferedWriter br = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
...
br.write(toWriteToHDFS);
br.flush();
br.close();
hdfs.close();
当我作为独立运行工作流时,我在 Java 操作部分有 50-50 的成功和到期机会,但在协调器上,所有 Java 操作都将到期。
YARN 日志显示了这一点:
Job commit failed: java.io.IOException: Filesystem closed
at org.apache.hadoop.hdfs.DFSClient.checkOpen(DFSClient.java:794)
at org.apache.hadoop.hdfs.DFSClient.create(DFSClient.java:1645)
at org.apache.hadoop.hdfs.DFSClient.create(DFSClient.java:1587)
at org.apache.hadoop.hdfs.DistributedFileSystem$6.doCall(DistributedFileSystem.java:397)
at org.apache.hadoop.hdfs.DistributedFileSystem$6.doCall(DistributedFileSystem.java:393)
at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)
at org.apache.hadoop.hdfs.DistributedFileSystem.create(DistributedFileSystem.java:393)
at org.apache.hadoop.hdfs.DistributedFileSystem.create(DistributedFileSystem.java:337)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:908)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:889)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:786)
at org.apache.hadoop.mapreduce.v2.app.commit.CommitterEventHandler$EventProcessor.touchz(CommitterEventHandler.java:265)
at org.apache.hadoop.mapreduce.v2.app.commit.CommitterEventHandler$EventProcessor.handleJobCommit(CommitterEventHandler.java:271)
at org.apache.hadoop.mapreduce.v2.app.commit.CommitterEventHandler$EventProcessor.run(CommitterEventHandler.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
所以看起来在我的Java代码结束时关闭文件系统有问题(我应该保持文件系统打开吗?)。
我正在使用 Cloudera Quickstart CDH 5.4.0 和 Oozie 4.1.0