Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 06722200B5C for ; Thu, 28 Jul 2016 02:50:54 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 050EF160A93; Thu, 28 Jul 2016 00:50:54 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 50AEA160A90 for ; Thu, 28 Jul 2016 02:50:53 +0200 (CEST) Received: (qmail 74570 invoked by uid 500); 28 Jul 2016 00:50:52 -0000 Mailing-List: contact commits-help@asterixdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.apache.org Delivered-To: mailing list commits@asterixdb.apache.org Received: (qmail 74561 invoked by uid 99); 28 Jul 2016 00:50:52 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Jul 2016 00:50:52 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 51014E02A2; Thu, 28 Jul 2016 00:50:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mblow@apache.org To: commits@asterixdb.apache.org Message-Id: <3f709abfa1374dfbb416db180dadac8c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: asterixdb git commit: ASTERIXDB-1553: ClusterControllerService Dir/File Creation On-Demand Date: Thu, 28 Jul 2016 00:50:52 +0000 (UTC) archived-at: Thu, 28 Jul 2016 00:50:54 -0000 Repository: asterixdb Updated Branches: refs/heads/master 70908dfb4 -> 8a6b9ca51 ASTERIXDB-1553: ClusterControllerService Dir/File Creation On-Demand Change-Id: Ie2e65cf083b3eb2db3e716f2b34fb28fe01debca Reviewed-on: https://asterix-gerrit.ics.uci.edu/1029 Tested-by: Jenkins Reviewed-by: Till Westmann Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/8a6b9ca5 Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/8a6b9ca5 Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/8a6b9ca5 Branch: refs/heads/master Commit: 8a6b9ca51d17f2bf2aafe15a8448ce28977c415b Parents: 70908df Author: Michael Blow Authored: Wed Jul 27 19:40:33 2016 -0400 Committer: Michael Blow Committed: Wed Jul 27 17:50:29 2016 -0700 ---------------------------------------------------------------------- .../hyracks/control/common/logs/LogFile.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8a6b9ca5/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/logs/LogFile.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/logs/LogFile.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/logs/LogFile.java index 7eb0674..8f95c35 100644 --- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/logs/LogFile.java +++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/logs/LogFile.java @@ -27,6 +27,7 @@ import org.json.JSONObject; public class LogFile { private final File root; + private long openTime; private PrintWriter out; public LogFile(File root) { @@ -34,18 +35,23 @@ public class LogFile { } public void open() throws Exception { - root.mkdirs(); - out = new PrintWriter(new FileOutputStream(new File(root, String.valueOf(System.currentTimeMillis()) + ".log"), - true)); + openTime = System.currentTimeMillis(); } - public void log(JSONObject object) throws Exception { + public synchronized void log(JSONObject object) throws Exception { + if (out == null) { + root.mkdirs(); + out = new PrintWriter(new FileOutputStream(new File(root, openTime + ".log"), true)); + } out.println(object.toString(1)); out.flush(); } - public void close() { - out.flush(); - out.close(); + public synchronized void close() { + if (out != null) { + out.flush(); + out.close(); + out = null; + } } }