You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2011/07/08 00:01:57 UTC
svn commit: r1144070 - in /incubator/jena/Experimental/TxTDB/trunk:
src-dev/tx/ src/main/java/com/hp/hpl/jena/tdb/base/objectfile/
src/main/java/com/hp/hpl/jena/tdb/transaction/
Author: andy
Date: Thu Jul 7 22:01:56 2011
New Revision: 1144070
URL: http://svn.apache.org/viewvc?rev=1144070&view=rev
Log: (empty)
Removed:
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileSink.java
Modified:
incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/DevTx.java
incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFile.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileLogger.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileMem.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileStorage.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileWrapper.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/Journal.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/ObjectFileTrans.java
incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/Transaction.java
Modified: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/DevTx.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/DevTx.java?rev=1144070&r1=1144069&r2=1144070&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/DevTx.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/DevTx.java Thu Jul 7 22:01:56 2011
@@ -3,8 +3,16 @@ package tx;
public class DevTx
{
// NodeTable journalling and recovery
- // Currently, NT wriiten in commit phase, before the journal commit entry.
- // Safe
+ // 1/ Currently, NT written in commit phase, before the journal commit entry.
+ // Safe but?
+ // nodes.dat-jrnl, prefixed.dat-jrnl
+ // 2/ Need to scan for whether commit written or not.
+ // 3/ general setup
+ // Replay ==> JournalCtl.
+ // warmReplay, coldReplay
+ // Dataset API
+ // DatasetGraphAPI - everything some kinds of transaction?
+ // Iterator tracking.
// DSG.add(Quad(tripleInQuad, triple)) does not affect default graph.
Modified: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java?rev=1144070&r1=1144069&r2=1144070&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java Thu Jul 7 22:01:56 2011
@@ -42,6 +42,8 @@ import com.hp.hpl.jena.tdb.sys.Names ;
import com.hp.hpl.jena.tdb.sys.SystemTDB ;
import com.hp.hpl.jena.tdb.transaction.DatasetGraphTxnTDB ;
import com.hp.hpl.jena.tdb.transaction.Journal ;
+import com.hp.hpl.jena.tdb.transaction.JournalEntry ;
+import com.hp.hpl.jena.tdb.transaction.JournalEntryType ;
import com.hp.hpl.jena.tdb.transaction.NodeTableTrans ;
import com.hp.hpl.jena.tdb.transaction.TransactionManager ;
import com.hp.hpl.jena.update.UpdateAction ;
@@ -83,24 +85,42 @@ public class TxMain
String journalFilename = dsg0.getLocation().absolute(Names.journalFile) ;
if ( FileOps.exists(journalFilename))
{
-
BufferChannel bc = new BufferChannelFile(journalFilename) ;
- if ( bc.size() != 0 )
+ System.out.println("Journal found") ;
+ query("Before", "SELECT (Count(*) AS ?c1) { ?s ?p ?o }", dsg0) ;
+ Journal j0 = new Journal(bc) ;
+
+ // Scan for commit.
+ boolean committed = false ;
+ for ( JournalEntry e : j0 )
+ {
+ if ( e.getType() == JournalEntryType.Commit )
+ committed = true ;
+ else
+ {
+ if ( committed )
+ {
+ Log.warn(Journal.class, "Extra journal entries") ;
+ break ;
+ }
+ }
+
+ }
+ j0.position(0) ;
+ if ( committed )
{
- System.out.println("Recovery !") ;
- query("Before", "SELECT (Count(*) AS ?c1) { ?s ?p ?o }", dsg0) ;
- Journal j0 = new Journal(bc) ;
-
+ System.out.println("Journal has transaction") ;
// NOTE
// The NodeTable Journal has already been done!
-
Replay.replay(j0, dsg0) ;
- System.out.println("after") ;
- query("After", "SELECT (Count(*) AS ?c1) { ?s ?p ?o }", dsg0) ;
- bc.close() ;
- FileOps.delete(journalFilename) ;
-
}
+ else
+ System.out.println("Journal has no cmmitted transaction") ;
+ j0.truncate(0) ;
+ System.out.println("after") ;
+ query("After", "SELECT (Count(*) AS ?c1) { ?s ?p ?o }", dsg0) ;
+ FileOps.delete(journalFilename) ;
+ exit(0) ;
}
dsg0.sync() ;
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFile.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFile.java?rev=1144070&r1=1144069&r2=1144070&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFile.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFile.java Thu Jul 7 22:01:56 2011
@@ -49,6 +49,10 @@ public interface ObjectFile extends Sync
*/
public void reposition(long id) ;
+ /**
+ */
+ public void truncate(long size) ;
+
/** All the bytebuffers - debugging aid */
public Iterator<Pair<Long, ByteBuffer>> all() ;
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileLogger.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileLogger.java?rev=1144070&r1=1144069&r2=1144070&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileLogger.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileLogger.java Thu Jul 7 22:01:56 2011
@@ -73,6 +73,13 @@ public class ObjectFileLogger implements
}
@Override
+ public void truncate(long size)
+ {
+ info("truncate("+size+")") ;
+ other.truncate(size) ;
+ }
+
+ @Override
public void sync()
{
info("sync") ;
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileMem.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileMem.java?rev=1144070&r1=1144069&r2=1144070&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileMem.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileMem.java Thu Jul 7 22:01:56 2011
@@ -124,6 +124,12 @@ public class ObjectFileMem implements Ob
}
@Override
+ public void truncate(long size)
+ {
+ reposition(size) ;
+ }
+
+ @Override
public Iterator<Pair<Long, ByteBuffer>> all()
{
int N = buffers.size() ;
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileStorage.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileStorage.java?rev=1144070&r1=1144069&r2=1144070&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileStorage.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileStorage.java Thu Jul 7 22:01:56 2011
@@ -205,6 +205,12 @@ public class ObjectFileStorage implement
}
@Override
+ public void truncate(long size)
+ {
+ reposition(size) ;
+ }
+
+ @Override
public ByteBuffer read(long loc)
{
if ( inAllocWrite )
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileWrapper.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileWrapper.java?rev=1144070&r1=1144069&r2=1144070&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileWrapper.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/objectfile/ObjectFileWrapper.java Thu Jul 7 22:01:56 2011
@@ -37,6 +37,9 @@ public class ObjectFileWrapper implement
public void reposition(long id) { other.reposition(id) ; }
@Override
+ public void truncate(long size) { other.truncate(size) ; }
+
+ @Override
public ByteBuffer read(long id) { return other.read(id) ; }
@Override
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/Journal.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/Journal.java?rev=1144070&r1=1144069&r2=1144070&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/Journal.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/Journal.java Thu Jul 7 22:01:56 2011
@@ -196,12 +196,9 @@ class Journal implements Iterable<Journa
@Override
public void close() { channel.close() ; }
- public void truncate() { truncate(0) ; }
+ public void truncate(long size) { channel.truncate(size) ; }
- private void truncate(long posn)
- {
- channel.truncate(posn) ;
- }
+ public void position(long posn) { channel.position(posn) ; }
}
/*
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java?rev=1144070&r1=1144069&r2=1144070&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/NodeTableTrans.java Thu Jul 7 22:01:56 2011
@@ -169,7 +169,7 @@ public class NodeTableTrans implements N
{
passthrough = true ;
//nodeIndex ;
- journal.reposition(0) ;
+ journal.truncate(0) ;
journal.close() ;
nodeTableJournal = null ;
}
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/ObjectFileTrans.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/ObjectFileTrans.java?rev=1144070&r1=1144069&r2=1144070&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/ObjectFileTrans.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/ObjectFileTrans.java Thu Jul 7 22:01:56 2011
@@ -110,6 +110,20 @@ public class ObjectFileTrans implements
other.reposition(0) ;
otherAllocOffset = base.length() ;
}
+
+ @Override
+ public void truncate(long id)
+ {
+ if ( passthrough ) { base.truncate(id) ; return ; }
+ if ( id > otherAllocOffset )
+ {
+ other.truncate(mapToOther(id)) ;
+ return ;
+ }
+ base.truncate(id) ;
+ other.truncate(0) ;
+ otherAllocOffset = base.length() ;
+ }
@Override
public Block allocWrite(int maxBytes)
Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/Transaction.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/Transaction.java?rev=1144070&r1=1144069&r2=1144070&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/Transaction.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/transaction/Transaction.java Thu Jul 7 22:01:56 2011
@@ -43,7 +43,6 @@ public class Transaction
for ( BlockMgrJournal x : blkMgrs )
x.commit(this) ;
-
for ( NodeTableTrans x : nodeTableTrans )
x.commit(this) ;
@@ -57,7 +56,7 @@ public class Transaction
if ( state != State.ACTIVE )
throw new TDBTransactionException("Transaction has already committed or aborted") ;
- journal.truncate() ;
+ journal.truncate(0) ;
// Clearup.
for ( BlockMgrJournal x : blkMgrs )