asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mb...@apache.org
Subject asterixdb git commit: ASTERIXDB-1553: ClusterControllerService Dir/File Creation On-Demand
Date Thu, 28 Jul 2016 00:50:52 GMT
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 <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>


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 <mblow@apache.org>
Authored: Wed Jul 27 19:40:33 2016 -0400
Committer: Michael Blow <mblow@apache.org>
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;
+        }
     }
 }


Mime
View raw message