jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1230512 - in /incubator/jena/Jena2/TDB/trunk/src/main/java: com/hp/hpl/jena/tdb/TDBBackup.java tdb/tdbbackup.java
Date Thu, 12 Jan 2012 13:13:29 GMT
Author: andy
Date: Thu Jan 12 13:13:28 2012
New Revision: 1230512

URL: http://svn.apache.org/viewvc?rev=1230512&view=rev
Log:
Back facility (start of ...)

Added:
    incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/TDBBackup.java
    incubator/jena/Jena2/TDB/trunk/src/main/java/tdb/tdbbackup.java

Added: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/TDBBackup.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/TDBBackup.java?rev=1230512&view=auto
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/TDBBackup.java (added)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/TDBBackup.java Thu Jan
12 13:13:28 2012
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.tdb;
+
+import java.io.BufferedOutputStream ;
+import java.io.FileNotFoundException ;
+import java.io.FileOutputStream ;
+import java.io.IOException ;
+import java.io.OutputStream ;
+
+import org.openjena.atlas.io.IO ;
+import org.openjena.atlas.logging.Log ;
+import org.openjena.riot.out.NQuadsWriter ;
+
+import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.query.ReadWrite ;
+import com.hp.hpl.jena.tdb.base.file.Location ;
+
+/**
+ * Backup a database.
+ */
+
+public class TDBBackup
+{
+    public static void backup(Location location, String backupfile)
+    {
+        try
+        {
+            OutputStream out = new FileOutputStream(backupfile) ;
+            out = new BufferedOutputStream(out) ;
+            backup(location, out) ;
+            out.close() ;
+        } 
+        catch (FileNotFoundException e)
+        {
+            Log.warn(TDBBackup.class, "File not found: "+backupfile) ;
+            throw new TDBException("File not found: "+backupfile) ;
+        } 
+        catch (IOException e)
+        { IO.exception(e) ; }
+        
+    }
+    
+    public static void backup(Location location, OutputStream backupfile)
+    {
+        Dataset ds = TDBFactory.createDataset(location) ;
+        StoreConnection sConn = StoreConnection.make(location) ;
+        DatasetGraphTxn dsg = sConn.begin(ReadWrite.READ, "backup") ;
+        NQuadsWriter.write(backupfile, dsg) ;
+        dsg.end();
+        // Someway to decrement in StoreConnection
+    }
+    
+}
+

Added: incubator/jena/Jena2/TDB/trunk/src/main/java/tdb/tdbbackup.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/tdb/tdbbackup.java?rev=1230512&view=auto
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/tdb/tdbbackup.java (added)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/tdb/tdbbackup.java Thu Jan 12 13:13:28 2012
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tdb;
+
+import org.openjena.atlas.logging.Log ;
+import tdb.cmdline.CmdTDB ;
+
+import com.hp.hpl.jena.tdb.TDBBackup ;
+
+public class tdbbackup extends CmdTDB
+{
+
+    static public void main(String... argv)
+    { 
+        Log.setLog4j() ;
+        new tdbdump(argv).mainRun() ;
+    }
+
+    protected tdbbackup(String[] argv)
+    {
+        super(argv) ;
+    }
+    
+    @Override
+    protected String getSummary()
+    {
+        return getCommandName()+" : Write N-Quads to stdout" ;
+    }
+
+    @Override
+    protected void exec()
+    {
+        TDBBackup.backup(getLocation(), System.out) ;
+    }
+}
+



Mime
View raw message