jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rve...@apache.org
Subject [26/52] [abbrv] jena git commit: JENA-895 : Do backup inside a read transaction.
Date Tue, 17 Mar 2015 11:21:38 GMT
JENA-895 : Do backup inside a read transaction.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/3ecbdba6
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/3ecbdba6
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/3ecbdba6

Branch: refs/heads/JENA-507
Commit: 3ecbdba6c11c1ae1ce197e937a3cefcf871e3a96
Parents: 5179485
Author: Andy Seaborne <andy@apache.org>
Authored: Sat Mar 7 16:32:28 2015 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Sat Mar 7 16:32:28 2015 +0000

----------------------------------------------------------------------
 .../java/org/apache/jena/fuseki/mgt/Backup.java | 25 ++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/3ecbdba6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/Backup.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/Backup.java
b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/Backup.java
index 66aa4c4..b0a94e1 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/Backup.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/Backup.java
@@ -31,7 +31,10 @@ import org.apache.jena.fuseki.server.FusekiServer ;
 import org.apache.jena.riot.Lang ;
 import org.apache.jena.riot.RDFDataMgr ;
 
+import com.hp.hpl.jena.query.ReadWrite ;
 import com.hp.hpl.jena.sparql.core.DatasetGraph ;
+import com.hp.hpl.jena.sparql.core.Transactional ;
+import com.hp.hpl.jena.sparql.core.TransactionalNull ;
 import com.hp.hpl.jena.sparql.util.Utils ;
 
 /** Perform a backup */ 
@@ -58,7 +61,26 @@ public class Backup
     // same dataset multiple times at the same time. 
     private static Set<DatasetGraph> activeBackups = new HashSet<>() ;
     
-    public static void backup(DatasetGraph dsg, String backupfile) {
+    /** Perform a backup.
+     *  A backup is a dump of the datset in comrpessed N-Quads, done inside a transaction.
+     */
+    public static void backup(Transactional transactional, DatasetGraph dsg, String backupfile)
{
+        if ( transactional == null )
+            transactional = new TransactionalNull() ;
+        transactional.begin(ReadWrite.READ);
+        try {
+            Backup.backup(dsg, backupfile) ;
+        }
+        finally {
+            transactional.end() ;
+        }
+    }
+    
+    /** Perform a backup.
+     * 
+     * @see #backup(Transactional, DatasetGraph, String)
+     */
+    private static void backup(DatasetGraph dsg, String backupfile) {
         if ( !backupfile.endsWith(".nq") )
             backupfile = backupfile + ".nq" ;
 
@@ -84,7 +106,6 @@ public class Backup
                 out = new FileOutputStream(backupfile) ;
                 out = new BufferedOutputStream(out) ;
             }
-
             RDFDataMgr.write(out, dsg, Lang.NQUADS) ;
             out.close() ;
             out = null ;


Mime
View raw message