From c5f87b1ded9b6b7b996a6e189c34bddd6f53ad16 Mon Sep 17 00:00:00 2001 From: Yeonsu Han Date: Mon, 21 Sep 2015 18:56:17 +0900 Subject: [PATCH] TAJO-1807: Not display "Finished Queries" in query.jsp --- .../tajo/util/history/HistoryWriter.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tajo-core/src/main/java/org/apache/tajo/util/history/HistoryWriter.java b/tajo-core/src/main/java/org/apache/tajo/util/history/HistoryWriter.java index 5fca7a747e..7864cb8494 100644 --- a/tajo-core/src/main/java/org/apache/tajo/util/history/HistoryWriter.java +++ b/tajo-core/src/main/java/org/apache/tajo/util/history/HistoryWriter.java @@ -404,6 +404,11 @@ private WriterHolder writeQuerySummary(QueryInfo queryInfo) throws Exception { try { querySummaryWriter.out.writeInt(jsonBytes.length); querySummaryWriter.out.write(jsonBytes); + //If object storage, close the output stream in order to create a readable object. + if(isObjectStorage(querySummaryWriter.path.toUri().getScheme())){ + IOUtils.cleanup(LOG, querySummaryWriter); + querySummaryWriter.out = null; + } } catch (IOException ie) { IOUtils.cleanup(LOG, querySummaryWriter); querySummaryWriter.out = null; @@ -484,6 +489,19 @@ private FSDataOutputStream createTaskHistoryFile(String taskStartTime, WriterHol writerHolder.path = path; return fs.create(path, false, 4096, taskReplication, fs.getDefaultBlockSize(path)); } + + /* + * Discern object storage. + * - gs:google cloud storage + * - s3: AWS object storage + */ + private boolean isObjectStorage(String scheme) { + if(scheme.indexOf("gs") != -1 || scheme.indexOf("s3") != -1 ){ + return true; + } else { + return false; + } + } } public static Path getQueryTaskHistoryPath(FileSystem fs, Path parent,