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 2012/08/25 15:32:26 UTC
svn commit: r1377294 - in /jena/trunk/jena-tdb/src:
main/java/com/hp/hpl/jena/tdb/ main/java/com/hp/hpl/jena/tdb/base/file/
main/java/com/hp/hpl/jena/tdb/setup/ main/java/com/hp/hpl/jena/tdb/store/
main/java/com/hp/hpl/jena/tdb/sys/ main/java/com/hp/hp...
Author: andy
Date: Sat Aug 25 13:32:25 2012
New Revision: 1377294
URL: http://svn.apache.org/viewvc?rev=1377294&view=rev
Log:
StoreConfig -> StorageConfig to reflect it's true role.
RefactorJournal to be clear when a dataset is needed and when just a StorageConfig is needed.
Expose operations to allow creating BufferChannelFile without going through the system cache/tracker.
Dump operation for a journal file.
Added:
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/StorageConfig.java
- copied, changed from r1372890, jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/StoreConfig.java
Removed:
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/StoreConfig.java
Modified:
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/BufferChannelFile.java
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/FileBase.java
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/FileFactory.java
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/Journal.java
jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/JournalControl.java
jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/base/file/TestChannelFile.java
jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/base/objectfile/TestObjectFileDisk.java
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java?rev=1377294&r1=1377293&r2=1377294&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java Sat Aug 25 13:32:25 2012
@@ -151,7 +151,7 @@ public class StoreConnection
/** Flush the journal regardless - use with great case - do not use when transactions may be active. */
public void forceRecoverFromJournal()
{
- JournalControl.recoverFromJournal(getBaseDataset(), transactionManager.getJournal()) ;
+ JournalControl.recoverFromJournal(getBaseDataset().getConfig(), transactionManager.getJournal()) ;
}
/** Highly risky! */
@@ -231,7 +231,7 @@ public class StoreConnection
if (sConn == null)
{
sConn = new StoreConnection(dsg) ;
- boolean actionTaken = JournalControl.recoverFromJournal(dsg, sConn.transactionManager.getJournal()) ;
+ boolean actionTaken = JournalControl.recoverFromJournal(dsg.getConfig(), sConn.transactionManager.getJournal()) ;
if ( actionTaken )
{
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/BufferChannelFile.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/BufferChannelFile.java?rev=1377294&r1=1377293&r2=1377294&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/BufferChannelFile.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/BufferChannelFile.java Sat Aug 25 13:32:25 2012
@@ -18,8 +18,11 @@
package com.hp.hpl.jena.tdb.base.file;
+import java.io.FileNotFoundException ;
import java.io.IOException ;
+import java.io.RandomAccessFile ;
import java.nio.ByteBuffer ;
+import java.nio.channels.FileChannel ;
import org.openjena.atlas.io.IO ;
import org.openjena.atlas.lib.FileOps ;
@@ -28,12 +31,41 @@ import org.openjena.atlas.lib.FileOps ;
public class BufferChannelFile implements BufferChannel
{
private FileBase file ;
+
+ /** Create a BufferChannelFile */
+ public static BufferChannelFile create(String filename)
+ {
+ FileBase base = FileBase.create(filename) ;
+ return new BufferChannelFile(base) ;
+ }
+
+ /** Create a BufferChannelFile with unmangaged file resources - use with care */
+ public static BufferChannelFile createUnmanaged(String filename, String mode)
+ {
+ try
+ {
+ @SuppressWarnings("resource")
+ RandomAccessFile out = new RandomAccessFile(filename, mode) ;
+ FileChannel channel = out.getChannel() ;
+ FileBase base = FileBase.createUnmanged(filename, channel) ;
+ return new BufferChannelFile(base) ;
+ } catch (FileNotFoundException e)
+ {
+ IO.exception(e) ;
+ return null ;
+ }
+ }
- public BufferChannelFile(String filename)
+ private BufferChannelFile(FileBase filebase)
{
- file = FileBase.create(filename) ;
+ file = filebase ;
}
+ private BufferChannelFile(String filename)
+ {
+ file = FileBase.create(filename) ;
+ }
+
@Override
public BufferChannel duplicate()
{
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/FileBase.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/FileBase.java?rev=1377294&r1=1377293&r2=1377294&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/FileBase.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/FileBase.java Sat Aug 25 13:32:25 2012
@@ -38,6 +38,10 @@ public final class FileBase implements S
private static long counter = 0 ;
private final long id ;
+ /** Create an FileBase withotu managed resources Use with case. */
+ static FileBase createUnmanged(String filename, FileChannel channel) { return new FileBase(filename, channel) ; }
+
+ /** Create a Filebase with managed resources */
static FileBase create(String filename) { return new FileBase(filename) ; }
static FileBase create(String filename, String mode) { return new FileBase(filename, mode) ; }
@@ -57,6 +61,14 @@ public final class FileBase implements S
channel = ChannelManager.acquire(filename, mode) ;
}
+ private /*public*/ FileBase(String filename, FileChannel channel)
+ {
+ DebugThis = false ;
+ id = -1 ;
+ this.filename = filename ;
+ this.channel = channel ;
+ }
+
public final FileChannel channel() { return channel ; }
public long size()
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/FileFactory.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/FileFactory.java?rev=1377294&r1=1377293&r2=1377294&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/FileFactory.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/base/file/FileFactory.java Sat Aug 25 13:32:25 2012
@@ -32,7 +32,7 @@ public class FileFactory
public static ObjectFile createObjectFileDisk(String filename)
{
- BufferChannel file = new BufferChannelFile(filename) ;
+ BufferChannel file = BufferChannelFile.create(filename) ;
return new ObjectFileStorage(file) ;
}
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java?rev=1377294&r1=1377293&r2=1377294&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/DatasetBuilderStd.java Sat Aug 25 13:32:25 2012
@@ -170,8 +170,8 @@ public class DatasetBuilderStd implement
ReorderTransformation transform = (_transform==null) ? chooseReorderTransformation(location) : _transform ;
- StoreConfig storeConfig = new StoreConfig(location, params, blockMgrs, bufferChannels, nodeTables, transform) ;
- DatasetGraphTDB dsg = new DatasetGraphTDB(tripleTable, quadTable, prefixes, transform, storeConfig) ;
+ StorageConfig storageConfig = new StorageConfig(location, params, blockMgrs, bufferChannels, nodeTables) ;
+ DatasetGraphTDB dsg = new DatasetGraphTDB(tripleTable, quadTable, prefixes, transform, storageConfig) ;
return dsg ;
}
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java?rev=1377294&r1=1377293&r2=1377294&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/DatasetGraphTDB.java Sat Aug 25 13:32:25 2012
@@ -62,14 +62,14 @@ public class DatasetGraphTDB extends Dat
private QuadTable quadTable ;
private DatasetPrefixesTDB prefixes ;
private final ReorderTransformation transform ;
- private final StoreConfig config ;
+ private final StorageConfig config ;
private GraphTDB effectiveDefaultGraph ;
private boolean closed = false ;
private boolean readOnly = false ;
public DatasetGraphTDB(TripleTable tripleTable, QuadTable quadTable, DatasetPrefixesTDB prefixes,
- ReorderTransformation transform, StoreConfig config)
+ ReorderTransformation transform, StorageConfig config)
{
this.tripleTable = tripleTable ;
this.quadTable = quadTable ;
@@ -220,7 +220,7 @@ public class DatasetGraphTDB extends Dat
public GraphTDB getEffectiveDefaultGraph() { return effectiveDefaultGraph ; }
- public StoreConfig getConfig() { return config ; }
+ public StorageConfig getConfig() { return config ; }
// public String getConfigValue(String key)
// {
Copied: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/StorageConfig.java (from r1372890, jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/StoreConfig.java)
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/StorageConfig.java?p2=jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/StorageConfig.java&p1=jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/StoreConfig.java&r1=1372890&r2=1377294&rev=1377294&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/StoreConfig.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/StorageConfig.java Sat Aug 25 13:32:25 2012
@@ -20,7 +20,6 @@ package com.hp.hpl.jena.tdb.store;
import java.util.Map ;
-import com.hp.hpl.jena.sparql.engine.optimizer.reorder.ReorderTransformation ;
import com.hp.hpl.jena.tdb.base.block.BlockMgr ;
import com.hp.hpl.jena.tdb.base.file.BufferChannel ;
import com.hp.hpl.jena.tdb.base.file.Location ;
@@ -28,27 +27,24 @@ import com.hp.hpl.jena.tdb.nodetable.Nod
import com.hp.hpl.jena.tdb.setup.SystemParams ;
import com.hp.hpl.jena.tdb.sys.FileRef ;
-public class StoreConfig
+public class StorageConfig
{
public final SystemParams params ;
public final Map<FileRef, BlockMgr> blockMgrs ;
public final Map<FileRef, BufferChannel> bufferChannels ;
public final Map<FileRef, NodeTable> nodeTables ;
public final Location location ;
- public final ReorderTransformation reorder ;
- public StoreConfig(Location location, SystemParams params,
+ public StorageConfig(Location location, SystemParams params,
Map<FileRef, BlockMgr> blockMgrs,
Map<FileRef, BufferChannel> bufferChannels,
- Map<FileRef, NodeTable> nodeTables,
- ReorderTransformation reorder)
+ Map<FileRef, NodeTable> nodeTables)
{
this.location = location ;
this.params = params ;
this.blockMgrs = blockMgrs ;
this.bufferChannels = bufferChannels ;
this.nodeTables = nodeTables ;
- this.reorder = reorder ;
}
}
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java?rev=1377294&r1=1377293&r2=1377294&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/SystemTDB.java Sat Aug 25 13:32:25 2012
@@ -47,7 +47,7 @@ public class SystemTDB
/** TDB System log - use for general messages (a few) and warnings.
* Generally, do not log events unless you want every user to see them every time.
- * TDB is an embedded database - libraries and embedded systsm shoudl be seen and not heard.
+ * TDB is an embedded database - libraries and embedded systems should be seen and not heard.
* @see #errlog
*/
// This was added quite late in TDB so need to check it's used appropriately - check for Log.*
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/Journal.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/Journal.java?rev=1377294&r1=1377293&r2=1377294&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/Journal.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/Journal.java Sat Aug 25 13:32:25 2012
@@ -83,19 +83,13 @@ class Journal implements Sync, Closeable
if ( location.isMem() )
chan = BufferChannelMem.create() ;
else
- chan = new BufferChannelFile(journalFilename(location)) ;
+ chan = BufferChannelFile.create(journalFilename(location)) ;
return new Journal(chan) ;
}
private static String journalFilename(Location location) { return location.absolute(Names.journalFile) ; }
- private Journal(String filename)
- {
- this(new BufferChannelFile(filename)) ;
-
- }
-
- /*testing*/Journal(BufferChannel channel)
+ public /*testing*/ Journal(BufferChannel channel)
{
this.channel = channel ;
position = 0 ;
Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/JournalControl.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/JournalControl.java?rev=1377294&r1=1377293&r2=1377294&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/JournalControl.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/JournalControl.java Sat Aug 25 13:32:25 2012
@@ -26,17 +26,16 @@ import java.io.File ;
import java.nio.ByteBuffer ;
import java.util.Collection ;
import java.util.Iterator ;
-import java.util.Map ;
import org.openjena.atlas.iterator.Iter ;
import org.openjena.atlas.lib.FileOps ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
-import com.hp.hpl.jena.shared.Lock ;
import com.hp.hpl.jena.tdb.base.block.Block ;
import com.hp.hpl.jena.tdb.base.block.BlockMgr ;
import com.hp.hpl.jena.tdb.base.file.BufferChannel ;
+import com.hp.hpl.jena.tdb.base.file.BufferChannelFile ;
import com.hp.hpl.jena.tdb.base.file.FileFactory ;
import com.hp.hpl.jena.tdb.base.file.Location ;
import com.hp.hpl.jena.tdb.base.objectfile.ObjectFile ;
@@ -44,6 +43,7 @@ import com.hp.hpl.jena.tdb.base.record.R
import com.hp.hpl.jena.tdb.index.IndexMap ;
import com.hp.hpl.jena.tdb.nodetable.NodeTable ;
import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
+import com.hp.hpl.jena.tdb.store.StorageConfig ;
import com.hp.hpl.jena.tdb.sys.FileRef ;
import com.hp.hpl.jena.tdb.sys.Names ;
import com.hp.hpl.jena.tdb.sys.SystemTDB ;
@@ -52,6 +52,15 @@ public class JournalControl
{
private static Logger log = LoggerFactory.getLogger(JournalControl.class) ;
+ /** Dump a journal - debug support function - opens the journal specially - inconsistent views possible */
+ public static void print(String filename)
+ {
+ BufferChannelFile chan = BufferChannelFile.createUnmanaged(filename, "r") ;
+ Journal journal = new Journal(chan) ;
+ JournalControl.print(journal) ;
+ chan.close() ;
+ }
+
public static void print(Journal journal)
{
System.out.println("Size: "+journal.size()) ;
@@ -60,8 +69,8 @@ public class JournalControl
for ( ; iter.hasNext() ; )
{
JournalEntry e = iter.next() ;
- System.out.println(JournalEntry.format(e)) ;
System.out.println("Posn: "+journal.position()+" : ("+(journal.size()-journal.position())+")") ;
+ System.out.println(JournalEntry.format(e)) ;
}
}
@@ -78,7 +87,8 @@ public class JournalControl
for ( FileRef fileRef : dsg.getConfig().nodeTables.keySet() )
recoverNodeDat(dsg, fileRef) ;
- recoverFromJournal(dsg, journal) ;
+ recoverFromJournal(dsg.getConfig(), journal) ;
+
journal.close() ;
// Recovery complete. Tidy up. Node journal files have already been handled.
if ( journal.getFilename() != null )
@@ -101,14 +111,12 @@ public class JournalControl
return null ;
}
- // New recovery - scan to commit, enact, scan, ....
-
/** Recovery from a journal.
- * Find if there is a commit record; if so, reply the journal to that point.
+ * Find if there is a commit record; if so, replay the journal to that point.
* Try to see if there is another commit record ...
- * Retirn true if a recovery was attempted; return false if we decided no work needed.
+ * Return true if a recovery was attempted; return false if we decided no work needed.
*/
- public static boolean recoverFromJournal(DatasetGraphTDB dsg, Journal jrnl )
+ public static boolean recoverFromJournal(StorageConfig sConf, Journal jrnl)
{
if ( jrnl.isEmpty() )
return false ;
@@ -118,13 +126,14 @@ public class JournalControl
{
long x = scanForCommit(jrnl, posn) ;
if ( x == -1 ) break ;
- recoverSegment(jrnl, posn, x, dsg) ;
+ recoverSegment(jrnl, posn, x, sConf) ;
posn = x ;
}
// We have replayed the journals - clean up.
jrnl.truncate(0) ;
- dsg.sync() ;
+ jrnl.sync() ;
+ syncAll(sConf) ;
return true ;
}
@@ -152,7 +161,7 @@ public class JournalControl
* Return true is a commit was found.
* Leave journal positioned just after commit or at end if none found.
*/
- private static void recoverSegment(Journal jrnl, long startPosn, long endPosn, DatasetGraphTDB dsg)
+ private static void recoverSegment(Journal jrnl, long startPosn, long endPosn, StorageConfig sConf)
{
Iterator<JournalEntry> iter = jrnl.entries(startPosn) ;
iter = jrnl.entries(startPosn) ;
@@ -166,56 +175,14 @@ public class JournalControl
log.warn(format("Inconsistent: end at %d; expected %d", e.getEndPosition(), endPosn)) ;
return ;
}
- replay(e, dsg) ;
+ replay(e, sConf) ;
}
} finally { Iter.close(iter) ; }
}
-// /** Recovery from the system journal.
-// * Find is there is a commit record; if so, reply the journal.
-// */
-// private static void recoverSystemJournal_0(DatasetGraphTDB dsg)
-// {
-// Location loc = dsg.getLocation() ;
-// String journalFilename = loc.absolute(Names.journalFile) ;
-// File f = new File(journalFilename) ;
-// //if ( FileOps.exists(journalFilename)
-// if ( f.exists() && f.isFile() && f.length() > 0 )
-// {
-// Journal jrnl = Journal.create(loc) ;
-// // Scan for commit.
-// boolean committed = false ;
-// for ( JournalEntry e : jrnl )
-// {
-// if ( e.getType() == JournalEntryType.Commit )
-// committed = true ;
-// else
-// {
-// if ( committed )
-// {
-// errlog.warn("Extra journal entries ("+loc+")") ;
-// break ;
-// }
-// }
-// }
-// if ( committed )
-// {
-// syslog.info("Recovering committed transaction") ;
-// // The NodeTable Journal has already been done!
-// JournalControl.replay(jrnl, dsg) ;
-// }
-// jrnl.truncate(0) ;
-// jrnl.close();
-// dsg.sync() ;
-// }
-//
-// if ( f.exists() )
-// FileOps.delete(journalFilename) ;
-// }
-
/** Recover a node data file (".dat").
* Node data files are append-only so recovering, then not using the data is safe.
- * Node data file is a precursor for ful lrecovery that works from the master journal.
+ * Node data file is a precursor for full recovery that works from the master journal.
*/
private static void recoverNodeDat(DatasetGraphTDB dsg, FileRef fileRef)
{
@@ -245,23 +212,29 @@ public class JournalControl
{
Journal journal = transaction.getJournal() ;
DatasetGraphTDB dsg = transaction.getBaseDataset() ;
- replay(journal, dsg) ;
+ replay(journal, dsg.getConfig()) ;
}
+ /** Replay a journal onto a dataset */
public static void replay(Journal journal, DatasetGraphTDB dsg)
{
+ replay(journal, dsg.getConfig()) ;
+ }
+
+ /** Replay a journal onto a store configuration (the file resources) */
+ private static void replay(Journal journal, StorageConfig sConf)
+ {
if ( journal.size() == 0 )
return ;
journal.position(0) ;
- dsg.getLock().enterCriticalSection(Lock.WRITE) ;
try {
Iterator<JournalEntry> iter = journal.entries() ;
for ( ; iter.hasNext() ; )
{
JournalEntry e = iter.next() ;
- replay(e, dsg) ;
+ replay(e, sConf) ;
// There is no point sync here.
// No writes via the DSG have been done.
@@ -275,9 +248,8 @@ public class JournalControl
syslog.error("Exception during journal replay", ex) ;
throw ex ;
}
- finally { dsg.getLock().leaveCriticalSection() ; }
- Collection<BlockMgr> x = dsg.getConfig().blockMgrs.values() ;
+ Collection<BlockMgr> x = sConf.blockMgrs.values() ;
for ( BlockMgr blkMgr : x )
blkMgr.syncForce() ;
// Must do a hard sync before this.
@@ -285,10 +257,8 @@ public class JournalControl
}
/** return true for "go on" */
- private static boolean replay(JournalEntry e, DatasetGraphTDB dsg)
+ private static boolean replay(JournalEntry e, StorageConfig sConf)
{
- Map<FileRef, BlockMgr> mgrs = dsg.getConfig().blockMgrs ;
-
switch (e.getType())
{
case Block:
@@ -298,7 +268,7 @@ public class JournalControl
// Direct: blkMgr.write(e.getBlock()) would work.
// Mapped: need to copy over the bytes.
- BlockMgr blkMgr = mgrs.get(e.getFileRef()) ;
+ BlockMgr blkMgr = sConf.blockMgrs.get(e.getFileRef()) ;
Block blk = e.getBlock() ;
log.debug("Replay: {} {}",e.getFileRef(), blk) ;
blk.setModified(true) ;
@@ -307,7 +277,7 @@ public class JournalControl
}
case Buffer:
{
- BufferChannel chan = dsg.getConfig().bufferChannels.get(e.getFileRef()) ;
+ BufferChannel chan = sConf.bufferChannels.get(e.getFileRef()) ;
ByteBuffer bb = e.getByteBuffer() ;
log.debug("Replay: {} {}",e.getFileRef(), bb) ;
chan.write(bb, 0) ; // YUK!
@@ -323,4 +293,15 @@ public class JournalControl
}
return false ;
}
+
+ private static void syncAll(StorageConfig sConf)
+ {
+ Collection<BlockMgr> x = sConf.blockMgrs.values() ;
+ for ( BlockMgr blkMgr : x )
+ blkMgr.syncForce() ;
+ Collection<BufferChannel> y = sConf.bufferChannels.values() ;
+ for ( BufferChannel bChan : y )
+ bChan.sync() ;
+ //sConf.nodeTables ;
+ }
}
Modified: jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/base/file/TestChannelFile.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/base/file/TestChannelFile.java?rev=1377294&r1=1377293&r2=1377294&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/base/file/TestChannelFile.java (original)
+++ jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/base/file/TestChannelFile.java Sat Aug 25 13:32:25 2012
@@ -35,6 +35,6 @@ public class TestChannelFile extends Abs
protected BufferChannel open()
{
FileOps.deleteSilent(filename) ;
- return new BufferChannelFile(filename) ;
+ return BufferChannelFile.create(filename) ;
}
}
Modified: jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/base/objectfile/TestObjectFileDisk.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/base/objectfile/TestObjectFileDisk.java?rev=1377294&r1=1377293&r2=1377294&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/base/objectfile/TestObjectFileDisk.java (original)
+++ jena/trunk/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/base/objectfile/TestObjectFileDisk.java Sat Aug 25 13:32:25 2012
@@ -35,7 +35,7 @@ public class TestObjectFileDisk extends
protected ObjectFile make()
{
FileOps.deleteSilent(filename) ;
- BufferChannel chan = new BufferChannelFile(filename) ;
+ BufferChannel chan = BufferChannelFile.create(filename) ;
// No buffering.
return new ObjectFileStorage(chan, -1) ;
}