jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1241043 - in /incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/apache/jena/fuseki: FusekiCmd.java mgt/ActionBackup.java
Date Mon, 06 Feb 2012 15:33:33 GMT
Author: andy
Date: Mon Feb  6 15:33:32 2012
New Revision: 1241043

URL: http://svn.apache.org/viewvc?rev=1241043&view=rev
Log:
Better backup process

Modified:
    incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
    incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java

Modified: incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/apache/jena/fuseki/FusekiCmd.java?rev=1241043&r1=1241042&r2=1241043&view=diff
==============================================================================
--- incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
(original)
+++ incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
Mon Feb  6 15:33:32 2012
@@ -356,6 +356,7 @@ public class FusekiCmd extends CmdARQ
         
         if ( mgtPort > 0 )
         {
+            Fuseki.configLog.info("Management services on port "+mgtPort) ;
             mgtServer = ManagementServer.createManagementServer(mgtPort) ;
             try { mgtServer.start() ; }
             catch (java.net.BindException ex)

Modified: incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java?rev=1241043&r1=1241042&r2=1241043&view=diff
==============================================================================
--- incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java
(original)
+++ incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java
Mon Feb  6 15:33:32 2012
@@ -29,6 +29,7 @@ import java.io.PrintWriter ;
 import java.util.concurrent.Callable ;
 import java.util.concurrent.ExecutorService ;
 import java.util.concurrent.Executors ;
+import java.util.zip.GZIPOutputStream ;
 
 import javax.servlet.http.HttpServletRequest ;
 import javax.servlet.http.HttpServletResponse ;
@@ -40,6 +41,7 @@ import org.apache.jena.fuseki.server.Dat
 import org.apache.jena.fuseki.servlets.HttpAction ;
 import org.apache.jena.fuseki.servlets.ServletBase ;
 import org.openjena.atlas.io.IO ;
+import org.openjena.atlas.lib.FileOps ;
 import org.openjena.atlas.logging.Log ;
 import org.openjena.riot.out.NQuadsWriter ;
 
@@ -82,21 +84,26 @@ public class ActionBackup extends Servle
         scheduleBackup(action, dataset) ;
     }
 
-    private void scheduleBackup(final HttpAction action, final String dataset)
+    static final String BackupArea = "backups" ;  
+    
+    private void scheduleBackup(final HttpAction action, String dataset)
     {
+        final String ds = dataset.startsWith("/")? dataset : "/"+dataset ;
+        
         String timestamp = Utils.nowAsString("yyyy-MM-dd_HH-mm-ss") ;
-        final String filename = "backups" + dataset + "_" + timestamp ;
+        final String filename = BackupArea + dataset + "_" + timestamp ;
+        FileOps.ensureDir(BackupArea) ;
         
         try {
             final Callable<Boolean> task = new Callable<Boolean>() {
                 @Override
                 public Boolean call() throws Exception
                 {
-                    log.info(format("[%d] Start backup %s to '%s'", action.id, dataset, filename))
;
+                    log.info(format("[%d] Start backup %s to '%s'", action.id, ds, filename))
;
                     action.beginRead() ;
                     try {
                         backup(action.getActiveDSG(), filename) ;
-                        log.info(format("[%d] Finish backup %s to '%s'", action.id, dataset,
filename)) ;
+                        log.info(format("[%d] Finish backup %s to '%s'", action.id, ds, filename))
;
                     }
                     catch ( RuntimeException ex )
                     {
@@ -152,8 +159,22 @@ public class ActionBackup extends Servle
     {
         try
         {
-            OutputStream out = new FileOutputStream(backupfile) ;
-            out = new BufferedOutputStream(out) ;
+            OutputStream out ;
+            if ( false )
+            {
+                // This seems to achive about the same as "gzip -6"
+                // It's not too expensive in elapsed time but it's not zero cost.
+                // GZip, large buffer.
+                out = new FileOutputStream(backupfile+".gz") ;
+                out = new GZIPOutputStream(out, 8*1024) ;
+                out = new BufferedOutputStream(out) ;
+            }
+            else
+            {
+                out = new FileOutputStream(backupfile) ;
+                out = new BufferedOutputStream(out) ;
+            }
+            
             NQuadsWriter.write(out, dsg) ;
             out.close() ;
         } 



Mime
View raw message