jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [23/65] [abbrv] jena git commit: JENA-1397: Rename java packages
Date Tue, 03 Oct 2017 19:34:09 GMT
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnId.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnId.java b/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnId.java
deleted file mode 100644
index e05f084..0000000
--- a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnId.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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 org.seaborne.dboe.transaction.txn;
-
-
-/**
- * {@code TxnId} is a identfier for a transaction.
- * A component in a transaction can use it as a unique key.
- * The {@code TxnId}
- * <ul>
- * <li>must be unique across a JVM run
- * <li>unique across JVm runs if used as a persistent name
- * <li>Must provide value equality semantics (two {@code TxnId} are {@code .equals}
- * if 
- * </ul>
- * <p>
- * It is preferrable that the TxnId is global unique over time and space.
- */
-public interface TxnId {
-//    public static TxnId create() { return TxnIdSimple.create() ; }
-//    
-//    public static TxnId create(byte[] bytes) {
-//        switch(bytes.length) {
-//            case 8:  return TxnIdSimple.create(bytes) ;
-//            case 16: return TxnIdUuid.create(bytes) ;
-//            default:
-//                throw new TransactionException("TxnId bytes unrecognized: length="+bytes.length) ;
-//        }
-//    }
-//    
-    // Reminder to implement.
-    @Override
-    public int hashCode() ;
-    @Override
-    public boolean equals(Object other) ;
-    
-    public String name() ;
-    public byte[] bytes() ;
-    /**  A long that is a subset, or all or, the bytes.
-     * This should be unique for the lifetime of the transaction and
-     * ideally unique per system instance. It is not a persistent record
-     * of a transaction, it is for a transaction identifier in running code.
-     * ("system" maybe larger than on e JVM).    
-     */
-    public long runtime() ;
-    
-}
-

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdFactory.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdFactory.java b/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdFactory.java
deleted file mode 100644
index 7c100e2..0000000
--- a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdFactory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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 org.seaborne.dboe.transaction.txn;
-
-import org.apache.commons.lang3.NotImplementedException ;
-
-/** Factory for some forms of {@link TxnId}.
- * This is ony some possible {@link TxnIdGenerator} 
- * 
- * @see TxnId
- */
-public class TxnIdFactory {
-    /** Generator for {@link TxnId}s for the counter based implemention. */
-    public static final TxnIdGenerator txnIdGenSimple = ()->TxnIdSimple.create() ;
-    /** Generator for {@link TxnId}s for the UUID based implemention. */
-    public static final TxnIdGenerator txnIdGenUuid   = ()->TxnIdUuid.create() ;
-    
-    /** Return the default, good enough for one JVM
-     * (usually the simple counter based implemention) 
-     */
-    public static TxnId create() {
-        return createSimple() ;
-    }
-    
-    /** Return a TxnId from the counter based implemention. */
-    public static TxnId createSimple() {
-        return txnIdGenSimple.generate() ; 
-    }
-    
-    /** Return a TxnId from the UUID based implemention. */
-    public static TxnId createUuid() {
-        return txnIdGenUuid.generate() ; 
-    }
-    
-    public static TxnId create(byte[] bytes) {
-        switch(bytes.length) {
-            case 8 : return TxnIdSimple.create(bytes) ;
-            case 16 :return TxnIdUuid.create(bytes) ;
-            default:
-                throw new NotImplementedException("Unrcognized bytes length: "+bytes.length) ;
-        }
-    }
-
-}
-

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdGenerator.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdGenerator.java b/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdGenerator.java
deleted file mode 100644
index 6095726..0000000
--- a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdGenerator.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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 org.seaborne.dboe.transaction.txn;
-
-
-/**
- * Generator of {@link TxnId}s. 
- * {@code TxnId} is a identfier for a transaction.
- * A component in a transaction can use it as a unique key.
- * The {@code TxnId}
- * <ul>
- * <li>must be unique across a JVM run
- * <li>unique across JVm runs if used as a persistent name
- * <li>Must provide value equality semantics (two {@code TxnId} are {@code .equals}
- * if 
- * </ul>
- * <p>
- * It is preferrable that the TxnId is global unique over time and space.
- */
-public interface TxnIdGenerator {
-    public TxnId generate() ;
-}
-

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdSimple.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdSimple.java b/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdSimple.java
deleted file mode 100644
index b4697e4..0000000
--- a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdSimple.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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 org.seaborne.dboe.transaction.txn;
-
-import java.util.concurrent.atomic.AtomicLong ;
-
-import org.apache.jena.atlas.lib.Bytes ;
-
-/**
- *  Simple TxnId, mainly for debugging.
- */
-public class TxnIdSimple implements TxnId {
-    private static AtomicLong counter = new AtomicLong(0) ;
-    
-    static TxnIdSimple create() {
-        return new TxnIdSimple(counter.incrementAndGet()) ; 
-    }
-
-    public static TxnIdSimple create(byte[] bytes) {
-        return new TxnIdSimple(Bytes.getLong(bytes)) ;
-    }
-
-    private final long x ;
-    
-    public TxnIdSimple(long x) { 
-        this.x = x ; 
-    }
-
-    @Override
-    public String name() {
-        return String.format("0x%04X",x) ;
-    }
-
-    @Override
-    public byte[] bytes() {
-        return Bytes.packLong(x) ;
-    }
-
-    @Override
-    public int hashCode() {
-        return Long.hashCode(x) ;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if ( this == obj )
-            return true ;
-        if ( obj == null )
-            return false ;
-        if ( getClass() != obj.getClass() )
-            return false ;
-        TxnIdSimple other = (TxnIdSimple)obj ;
-        if ( x != other.x )
-            return false ;
-        return true ;
-    }
-    
-    @Override
-    public String toString() {
-        return "txn:"+x ;
-    }
-
-    @Override
-    public long runtime() {
-        return x ;
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdUuid.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdUuid.java b/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdUuid.java
deleted file mode 100644
index 5360804..0000000
--- a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnIdUuid.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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 org.seaborne.dboe.transaction.txn;
-
-import java.util.UUID ;
-
-import org.apache.jena.atlas.lib.Bytes ;
-import org.seaborne.dboe.migrate.L ;
-
-import org.apache.jena.shared.uuid.JenaUUID ;
-
-/** {@link TxnId} based on a {@link UUID}. 
- */
-public class TxnIdUuid implements TxnId {
-    
-    static TxnIdUuid create() {
-        UUID id = JenaUUID.generate().asUUID() ; // UUID.randomUUID() ;
-        return new TxnIdUuid(id) ; 
-    }
-
-    public static TxnIdUuid create(byte[] bytes) {
-        long mostSignificantBits = Bytes.getLong(bytes, 0) ;
-        long leastSignificantBits = Bytes.getLong(bytes, 8) ;
-        return new TxnIdUuid(mostSignificantBits, leastSignificantBits) ; 
-    }
-
-    private long mostSignificantBits ;
-    private long leastSignificantBits ;
-    private byte[] bytes = null ;
-    private String name = null ;
-    
-    /*package*/ TxnIdUuid(UUID id) { 
-        mostSignificantBits = id.getMostSignificantBits() ;
-        leastSignificantBits = id.getLeastSignificantBits() ;
-    }
-
-    /*package*/ TxnIdUuid(long mostSig, long leastSig) { 
-        mostSignificantBits = mostSig ;
-        leastSignificantBits = leastSig ;
-    }
-
-    @Override
-    public String name() {
-        if ( name == null )
-            name = L.uuidToString(mostSignificantBits, leastSignificantBits) ;
-        return name ;
-    }
-
-    @Override
-    public byte[] bytes() {
-        if ( bytes == null )
-            bytes = L.uuidAsBytes(mostSignificantBits, leastSignificantBits) ;
-        return bytes ;
-    }
-
-    @Override
-    public long runtime() {
-        // In type 1, the mostSignificantBits have the timestamp in it.
-        return mostSignificantBits ;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31 ;
-        int result = 1 ;
-        result = prime * result + (int)(leastSignificantBits ^ (leastSignificantBits >>> 32)) ;
-        result = prime * result + (int)(mostSignificantBits ^ (mostSignificantBits >>> 32)) ;
-        return result ;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if ( this == obj )
-            return true ;
-        if ( obj == null )
-            return false ;
-        if ( getClass() != obj.getClass() )
-            return false ;
-        TxnIdUuid other = (TxnIdUuid)obj ;
-        if ( leastSignificantBits != other.leastSignificantBits )
-            return false ;
-        if ( mostSignificantBits != other.mostSignificantBits )
-            return false ;
-        return true ;
-    }
-
-    @Override
-    public String toString() {
-        //return name() ;
-        return String.format("[%04X]", mostSignificantBits&0xFFFF) ;
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnState.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnState.java b/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnState.java
deleted file mode 100644
index d012614..0000000
--- a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/TxnState.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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 org.seaborne.dboe.transaction.txn;
-
-/** The states of the transaction lifecycle */ 
-public enum TxnState { INACTIVE, ACTIVE, DETACHED, PREPARE, COMMIT, COMMITTED, ABORTED, END_COMMITTED, END_ABORTED }

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/Journal.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/Journal.java b/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/Journal.java
deleted file mode 100644
index 145c72b..0000000
--- a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/Journal.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * 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 org.seaborne.dboe.transaction.txn.journal;
-
-import static org.seaborne.dboe.sys.Sys.SizeOfInt ;
-
-import java.nio.ByteBuffer ;
-import java.util.Iterator ;
-import java.util.zip.Adler32 ;
-
-import org.apache.jena.atlas.iterator.IteratorSlotted ;
-import org.apache.jena.atlas.lib.ByteBufferLib ;
-import org.apache.jena.atlas.lib.Closeable ;
-import org.apache.jena.atlas.lib.FileOps ;
-import org.apache.jena.atlas.lib.Sync ;
-import org.seaborne.dboe.base.file.BufferChannel ;
-import org.seaborne.dboe.base.file.BufferChannelFile ;
-import org.seaborne.dboe.base.file.BufferChannelMem ;
-import org.seaborne.dboe.base.file.Location ;
-import org.seaborne.dboe.sys.Names ;
-import org.seaborne.dboe.transaction.txn.ComponentId ;
-import org.seaborne.dboe.transaction.txn.PrepareState ;
-import org.seaborne.dboe.transaction.txn.TransactionException ;
-import org.slf4j.Logger ;
-import org.slf4j.LoggerFactory ;
-
-/** A transaction journal.
-* The journal is append-only for writes, with truncation of the file
-* every so often. It is read during recovery.
-* The size of entries depends on per-component redo/undo records;
-* the control records like COMMIT are quite small.
-* Entries have a CRC to ensure that part-entries are not acted on.
-*/
-
-public final
-class Journal implements Sync, Closeable
-{
-    private static final boolean LOGGING = false ;
-    private static Logger log = LoggerFactory.getLogger(Journal.class) ;
-    
-    private static boolean logging() {
-        return LOGGING && log.isInfoEnabled() ;
-    }
-    
-    private static void log(String fmt, Object...args) {
-        if ( ! logging() )
-            return ;
-        log.info(String.format(fmt, args));
-    }
-    
-    private BufferChannel channel ;
-    private long position ;
-    
-    // Header: fixed, inc CRC
-    //   length of data             4 bytes
-    //   CRC of whole entry.        4 bytes
-    //   entry type                 4 bytes (1 byte and 3 alignment)
-    //   component                  16 bytes (fixed??)
-    // Data area : variable
-    //   Bytes
-    
-    private static final int posnLength     = 0 ;
-    private static final int posnCRC        = posnLength + SizeOfInt ;
-    private static final int posnEntry      = posnCRC    + SizeOfInt ;
-    private static final int posnComponent  = posnEntry  + SizeOfInt ;
-    // Start of the component data area.
-    private static final int posnData       = posnComponent  + ComponentId.SIZE ;
-    
-    // Currently, the header is fixed size so this is the size.
-    private static int HeaderLen            = posnData-posnLength ;
-    
-    private ByteBuffer header    = ByteBuffer.allocate(HeaderLen) ;
-    
-    public static boolean exists(Location location) {
-        if ( location.isMem() )
-            return false ;
-        return FileOps.exists(journalFilename(location)) ;
-    }
-
-    public static Journal create(Location location) {
-        BufferChannel chan ;
-        String channelName = journalFilename(location) ;
-        if ( location.isMem() )
-            chan = BufferChannelMem.create(channelName) ;
-        else
-            chan = BufferChannelFile.create(channelName) ;
-        return create(chan) ;
-    }
-
-    public static Journal create(BufferChannel chan) {
-        return new Journal(chan) ;
-    }
-
-    private static String journalFilename(Location location) {
-        return location.absolute(Names.journalFile) ;
-    }
-
-    private Journal(BufferChannel channel) {
-        this.channel = channel ;
-        position = 0 ;
-    }
-
-    // synchronized : excessive?
-    // Given the calling context, we know it's thread safe.
-    
-    synchronized public long writeJournal(JournalEntry entry) {
-        long posn = write(entry.getType(), entry.getComponentId(), entry.getByteBuffer()) ;
-
-        if ( entry.getPosition() < 0 ) {
-            entry.setPosition(posn) ;
-            entry.setEndPosition(position) ;
-        }
-        return posn ;
-    }
-
-//    /** Write an entry and return its location in the journal */
-//    synchronized public void write(List<PrepareState> prepareStates) {
-//        prepareStates.forEach(this::write) ;
-//    }
-
-    public long write(PrepareState prepareState) {
-        return write(JournalEntryType.REDO, prepareState.getComponent(), prepareState.getData()) ;
-    }
-    
-    /** Write an entry and return it's location in the journal */
-    synchronized public long write(JournalEntryType type, ComponentId componentId, ByteBuffer buffer) {
-        // Check buffer set right.
-        if ( LOGGING ) {
-            log("write@%-3d >> %s %s %s", position, type.name(),
-                componentId == null ? "<null>" : componentId.label(),
-                buffer == null ? "<null>" : ByteBufferLib.details(buffer)) ;
-        }
-
-        long posn = position ;
-        int len = -1 ;
-        int bufferLimit = -1 ;
-        int bufferPosition = -1 ;
-        if ( buffer != null ) {
-            bufferLimit = buffer.limit() ;
-            bufferPosition = buffer.position() ;
-            buffer.rewind() ;
-            len = buffer.remaining() ;
-        }
-
-        // Header: (length/4, crc/4, entry/4, component/16)
-
-        header.clear() ;
-        header.putInt(len) ;
-        header.putInt(0) ; // Set CRC to zero
-        header.putInt(type.id) ;
-        header.put(componentId.getBytes()) ;
-        header.flip() ;
-        // Need to put CRC in before writing.
-
-        Adler32 adler = new Adler32() ;
-        adler.update(header.array()) ;
-
-        if ( len > 0 ) {
-            adler.update(buffer) ;
-            buffer.rewind() ;
-        }
-
-        int crc = (int)adler.getValue() ;
-        header.putInt(posnCRC, crc) ;
-        if ( LOGGING )
-            log("write@    -- crc = %s", Integer.toHexString(crc) ) ;
-        channel.write(header) ;
-        if ( len > 0 ) {
-            channel.write(buffer) ;
-            buffer.position(bufferPosition) ;
-            buffer.limit(bufferLimit) ;
-        }
-        position += HeaderLen + len ;
-        if ( LOGGING )
-            log("write@%-3d << %s", position, componentId.label()) ;
-        
-        if ( len > 0 ) {
-            buffer.position(bufferPosition) ;
-            buffer.limit(bufferLimit) ;
-        }
-        
-        return posn ;
-    }
-
-    synchronized public JournalEntry readJournal(long id) {
-        return _readJournal(id) ;
-    }
-
-    private JournalEntry _readJournal(long id) {
-        long x = channel.position() ;
-        if ( x != id )
-            channel.position(id) ;
-        JournalEntry entry = _read() ;
-        long x2 = channel.position() ;
-        entry.setPosition(id) ;
-        entry.setEndPosition(x2) ;
-        if ( x != id )
-            channel.position(x) ;
-        return entry ;
-    }
-
-    // read one entry at the channel position.
-    // Move position to end of read.
-    private JournalEntry _read() {
-        if ( LOGGING ) {
-            log("read@%-3d >>", channel.position()) ;   
-        }
-        
-        header.clear() ;
-        int lenRead = channel.read(header) ;
-        if ( lenRead == -1 ) {
-            // probably broken file.
-            throw new TransactionException("Read off the end of a journal file") ;
-            // return null ;
-        }
-        if ( lenRead != header.capacity() )
-            throw new TransactionException("Partial read of journal file") ;
-            
-        header.rewind() ;
-        // Header: (length/4, crc/4, entry/4, component/16)
-        int len = header.getInt() ;
-        int checksum = header.getInt() ;
-        header.putInt(posnCRC, 0) ;
-        int entryType = header.getInt() ;
-        byte[] bytes = new byte[ComponentId.SIZE] ;
-        header.get(bytes) ;
-        ComponentId component = ComponentId.create(null, bytes) ;
-
-        Adler32 adler = new Adler32() ;
-        adler.update(header.array()) ;
-
-        ByteBuffer bb = null ;
-        if ( len > 0 ) {
-            bb = ByteBuffer.allocate(len) ;
-            lenRead = channel.read(bb) ;
-            if ( lenRead != len )
-                throw new TransactionException("Failed to read the journal entry data: wanted " + len + " bytes, got " + lenRead) ;
-            bb.rewind() ;
-            adler.update(bb) ;
-            bb.rewind() ;
-        }
-
-        int crc = (int)adler.getValue() ;
-        if ( checksum != crc )
-            throw new TransactionException("Checksum error reading from the Journal. "+Integer.toHexString(checksum)+" / "+Integer.toHexString(crc)) ;
-
-        JournalEntryType type = JournalEntryType.type(entryType) ;
-        JournalEntry entry = new JournalEntry(type, component, bb) ;
-        if ( LOGGING )
-            log("read@%-3d >> %s", channel.position(), entry) ;   
-        return entry ;
-    }
-
-    /**
-     * Iterator of entries from current point in Journal, going forward. Must be
-     * JournalEntry aligned at start.
-     */
-    private class IteratorEntries extends IteratorSlotted<JournalEntry> {
-        JournalEntry slot = null ;
-        final long   endPoint ;
-        long         iterPosn ;
-
-        public IteratorEntries(long startPosition) {
-            iterPosn = startPosition ;
-            endPoint = channel.size() ;
-        }
-
-        @Override
-        protected JournalEntry moveToNext() {
-            // synchronized necessary? Outer policy is single thread?
-            synchronized (Journal.this) {
-                if ( iterPosn >= endPoint )
-                    return null ;
-                JournalEntry e = _readJournal(iterPosn) ;
-                iterPosn = e.getEndPosition() ;
-                return e ;
-            }
-        }
-
-        @Override
-        protected boolean hasMore() {
-            return iterPosn < endPoint ;
-        }
-    }
-
-    public Iterator<JournalEntry> entries() {
-        return new IteratorEntries(0) ;
-    }
-
-    synchronized public Iterator<JournalEntry> entries(long startPosition) {
-        return new IteratorEntries(startPosition) ;
-    }
-
-    @Override
-    public void sync()  { channel.sync() ; }
-
-    @Override
-    public void close() { channel.close() ; }
-
-    public long size()  { return channel.size() ; }
-    
-    public boolean isEmpty()  { return channel.size() == 0 ; }
-
-    public void truncate(long size) { channel.truncate(size) ; }
-    
-    public void reset() { 
-        truncate(0) ;
-        sync() ;
-    }
-    
-//    public void append()    { position(size()) ; }
-    
-     public long position() { return channel.position() ; }  
-    
-//    public void position(long posn) { channel.position(posn) ; }
-    
-    public String getFilename() { return channel.getFilename() ; }
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalControl.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalControl.java b/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalControl.java
deleted file mode 100644
index b036082..0000000
--- a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalControl.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * 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 org.seaborne.dboe.transaction.txn.journal;
-
-import java.util.Iterator ;
-
-import org.seaborne.dboe.base.file.BufferChannelFile ;
-import org.slf4j.Logger ;
-import org.slf4j.LoggerFactory ;
-
-
-public class JournalControl
-{
-    private static Logger log = LoggerFactory.getLogger(JournalControl.class) ;
-
-    // In TransactionCoordinator
-//    // Interface
-//    public static void recovery(TransactionCoordinator txnCoord)
-//    {
-//        txnCoord.getJournal() ;
-//        
-//    }
-//    
-//    public static void replay(Transaction transaction)
-//    {}
-    
-    /** 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 = Journal.create(chan) ;
-        JournalControl.print(journal) ;
-        chan.close() ;
-    }
-    
-    public static void print(Journal journal) {
-        System.out.println("Size: "+journal.size()) ;
-        Iterator<JournalEntry> iter = journal.entries() ; 
-        
-        for (  ; iter.hasNext() ; )
-        {
-            JournalEntry e = iter.next() ;
-            //System.out.println("Posn: "+journal.position()+" : ("+(journal.size()-journal.position())+")") ;
-            System.out.println(JournalEntry.format(e)) ;
-        }
-    }
-
-//    /** Recover a base storage DatasetGraph */
-//    public static void recovery(Location location)
-//    {
-//        if ( location.isMem() )
-//            return ;
-//        
-//        // Do we need to recover?
-//        Journal journal = findJournal(location) ;
-//        if ( journal == null || journal.isEmpty() )
-//            return ;
-//        
-//        for ( FileRef fileRef : dsg.getConfig().nodeTables.keySet() )
-//            recoverNodeDat(dsg, fileRef) ;
-//        recoverFromJournal(dsg.getConfig(), journal) ;
-//        
-//        journal.close() ;
-//        // Recovery complete.  Tidy up.  Node journal files have already been handled.
-//        if ( journal.getFilename() != null )
-//        {
-//            if ( FileOps.exists(journal.getFilename()) )
-//                FileOps.delete(journal.getFilename()) ;
-//        }
-//    }
-//    
-//    private static Journal findJournal(Location location)
-//    {
-//        String journalFilename = location.absolute(Names.journalFile) ;
-//        File f = new File(journalFilename) ;
-//        //if ( FileOps.exists(journalFilename)
-//        
-//        if ( f.exists() && f.isFile() && f.length() > 0 )
-//            return Journal.create(location) ;
-//        else
-//            return null ;
-//    }
-//
-//    /** Recovery from a journal.
-//     *  Find if there is a commit record; if so, replay the journal to that point.
-//     *  Try to see if there is another commit record ...
-//     *  Return true if a recovery was attempted; return false if we decided no work needed.
-//     */
-//    public static boolean recoverFromJournal(StorageConfig sConf, Journal jrnl)
-//    {
-//        if ( jrnl.isEmpty() )
-//            return false ;
-//
-//        long posn = 0 ;
-//        for ( ;; )
-//        {
-//            // Any errors indicate a partially written journal.
-//            // A commit was not written properly in the prepare phase.
-//            // e.g. JVM died half-way though writing the prepare phase data.
-//            // The valid journal ends at this point. Exit loop and clean up.  
-//
-//            long x ;
-//            try { x = scanForCommit(jrnl, posn) ; }
-//            catch (TDBException ex) { x = -1 ; }
-//            
-//            if ( x == -1 ) break ;
-//            recoverSegment(jrnl, posn, x, sConf) ;
-//            posn = x ;
-//        }
-//
-//        // We have replayed the journals - clean up.
-//        jrnl.truncate(0) ;
-//        jrnl.sync() ;
-//        syncAll(sConf) ;
-//        return true ;
-//    }
-//
-//    /** Scan to a commit entry, starting at a given position in the journal.
-//     * Return address of entry after commit if found, else -1.
-//     */
-//    private static long scanForCommit(Journal jrnl, long startPosn)
-//    {
-//        Iterator<JournalEntry> iter = jrnl.entries(startPosn) ;
-//        try {
-//            for ( ; iter.hasNext() ; )
-//            {
-//                JournalEntry e = iter.next() ;
-//                if ( e.getType() == JournalEntryType.Commit )
-//                    return e.getEndPosition() ;
-//            }
-//            return -1 ;
-//        } finally { Iter.close(iter) ; }
-//    }
-//    
-//    /** Recover one transaction from the start position given.
-//     *  Scan to see if theer is a commit; if found, play the
-//     *  journal from the start point to the commit.
-//     *  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, StorageConfig sConf)
-//    {
-//        Iterator<JournalEntry> iter = jrnl.entries(startPosn) ;
-//        iter = jrnl.entries(startPosn) ;
-//        try {
-//            for ( ; iter.hasNext() ; )
-//            {
-//                JournalEntry e = iter.next() ;
-//                if ( e.getType() == JournalEntryType.Commit )
-//                {
-//                    if ( e.getEndPosition() != endPosn )
-//                        log.warn(format("Inconsistent: end at %d; expected %d", e.getEndPosition(), endPosn)) ;
-//                    return ;
-//                }
-//                replay(e, sConf) ;
-//            }
-//        } finally { Iter.close(iter) ; }
-//    }
-//    
-//    /** 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 full recovery that works from the master journal.
-//     */
-//    private static void recoverNodeDat(DatasetGraphTDB dsg, FileRef fileRef)
-//    {
-//        // See DatasetBuilderTxn - same name generation code.
-//        // [TxTDB:TODO]
-//        
-//        RecordFactory recordFactory = new RecordFactory(SystemTDB.LenNodeHash, SystemTDB.SizeOfNodeId) ;
-//        NodeTable baseNodeTable = dsg.getConfig().nodeTables.get(fileRef) ;
-//        String objFilename = fileRef.getFilename()+"-"+Names.extJournal ;
-//        objFilename = dsg.getLocation().absolute(objFilename) ;
-//        File jrnlFile = new File(objFilename) ;
-//        if ( jrnlFile.exists() && jrnlFile.length() > 0 )
-//        {
-//            syslog.info("Recovering node data: "+fileRef.getFilename()) ;
-//            ObjectFile dataJrnl = FileFactory.createObjectFileDisk(objFilename) ;
-//            NodeTableTrans ntt = new NodeTableTrans(null, objFilename, baseNodeTable, new IndexMap(recordFactory), dataJrnl) ;
-//            ntt.append() ;
-//            ntt.close() ;
-//            dataJrnl.close() ;
-//            baseNodeTable.sync() ;
-//        }
-//        if ( jrnlFile.exists() )
-//            FileOps.delete(objFilename) ;
-//    }
-//    
-//    public static void replay(Transaction transaction)
-//    {
-//        if ( syslog.isDebugEnabled())
-//            syslog.debug("Replay "+transaction.getLabel()) ;
-//        Journal journal = transaction.getJournal() ;
-//        DatasetGraphTDB dsg = transaction.getBaseDataset() ;
-//        // Currently, we (crudely) replay the whole journal.
-//        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) ;
-//        try {
-//            Iterator<JournalEntry> iter = journal.entries() ; 
-//
-//            for (  ; iter.hasNext() ; )
-//            {
-//                JournalEntry e = iter.next() ;
-//                replay(e, sConf) ;
-//
-//                // There is no point sync here.  
-//                // No writes via the DSG have been done. 
-//                // so all internal flags "syncNeeded" are false.
-//                //dsg.sync() ;
-//            }
-//        } 
-//        catch (RuntimeException ex)
-//        { 
-//            // Bad news travels fast.
-//            syslog.error("Exception during journal replay", ex) ;
-//            throw ex ;
-//        }
-//        
-//        Collection<BlockMgr> x = sConf.blockMgrs.values() ;
-//        for ( BlockMgr blkMgr : x )
-//            blkMgr.syncForce() ;
-//        // Must do a hard sync before this.
-//        journal.truncate(0) ;
-//    }
-//
-//    /** return true for "go on" */
-//    private static boolean replay(JournalEntry e, StorageConfig sConf)
-//    {
-//        switch (e.getType())
-//        {
-//            case Block:
-//            {
-//                BlockMgr blkMgr = sConf.blockMgrs.get(e.getFileRef()) ;
-//                Block blk = e.getBlock() ;
-//                log.debug("Replay: {} {}",e.getFileRef(), blk) ;
-//                blk.setModified(true) ;
-//                blkMgr.overwrite(blk) ; 
-//                return true ;
-//            }   
-//            case Buffer:
-//            {
-//                BufferChannel chan = sConf.bufferChannels.get(e.getFileRef()) ;
-//                ByteBuffer bb = e.getByteBuffer() ;
-//                log.debug("Replay: {} {}",e.getFileRef(), bb) ;
-//                chan.write(bb, 0) ; // YUK!
-//                return true ;
-//            }
-//                
-//            case Commit:
-//                return false ;
-//            case Abort:
-//            case Object:
-//            case Checkpoint:
-//                errlog.warn("Unexpected block type: "+e.getType()) ;
-//        }
-//        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 ;
-//    }
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalEntry.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalEntry.java b/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalEntry.java
deleted file mode 100644
index fdefb0a..0000000
--- a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalEntry.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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 org.seaborne.dboe.transaction.txn.journal;
-
-import java.nio.ByteBuffer ;
-
-import org.apache.jena.atlas.lib.ByteBufferLib ;
-import org.apache.jena.atlas.lib.Bytes ;
-import org.seaborne.dboe.transaction.txn.ComponentId ;
-import org.seaborne.dboe.transaction.txn.ComponentIds ;
-
-public class JournalEntry
-{
-//    static public final JournalEntry Redo       = new JournalEntry(JournalEntryType.REDO) ;
-//    static public final JournalEntry Undo       = new JournalEntry(JournalEntryType.UNDO) ;
-
-    
-    // Zero payload JournalEntry - create once.
-    static public final JournalEntry COMMIT     = new JournalEntry(JournalEntryType.COMMIT, ComponentIds.idSystem) ;
-    static public final JournalEntry ABORT      = new JournalEntry(JournalEntryType.ABORT, ComponentIds.idSystem) ;
-    
-    private long position = -1 ;                // Location in the Journal (if known).
-    private long endPosition = -1 ;             // End location in the Journal: offset of next entry start.
-
-    private final JournalEntryType type ;
-    private final ComponentId componentId ;
-    private final ByteBuffer data ;
-    
-    private JournalEntry(JournalEntryType type, ComponentId id) {
-        this(type, id, null) ;
-    }
-    
-    public JournalEntry(JournalEntryType type, ComponentId componentId, ByteBuffer bytes) {
-        this.type = type ;
-        this.componentId = componentId ;
-        this.data = bytes ;
-    }
-
-    void setPosition(long posn)             { position = posn ; }
-    void setEndPosition(long endPosn)       { endPosition = endPosn ; }
-
-    public long getPosition()               { return position ; }
-    long getEndPosition()                   { return endPosition ; }
-    
-    public JournalEntryType getType()       { return type ; }
-    public ComponentId getComponentId()     { return componentId ; }
-    public ByteBuffer getByteBuffer()       { return data ; }
-    
-    @Override
-    public String toString()
-    {
-        return "JournalEntry: "+type+" "+componentId ;
-    }
-    
-    static public String format(JournalEntry entry)
-    {
-        StringBuilder sbuff = new StringBuilder() ;
-        
-        sbuff.append("Entry: ") ;
-        sbuff.append("  "+entry.type) ;
-        if ( entry.componentId != null ) {
-            String label = entry.componentId.label() ;
-            if ( label != null )
-                sbuff.append(label) ;
-            sbuff.append(" [..") ;
-            int z = Bytes.getInt(entry.componentId.getBytes(), entry.componentId.getBytes().length-4) ;
-            sbuff.append(Integer.toHexString(z)) ;
-            sbuff.append("]") ;
-        }
-        if ( entry.data != null )
-            sbuff.append("  "+ByteBufferLib.details(entry.data)) ;
-        return sbuff.toString() ;
-    }
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalEntryType.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalEntryType.java b/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalEntryType.java
deleted file mode 100644
index d68bf23..0000000
--- a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalEntryType.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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 org.seaborne.dboe.transaction.txn.journal;
-
-import org.apache.jena.atlas.lib.InternalErrorException ;
-import org.apache.jena.atlas.logging.Log ;
-
-/** 
- * Types of Journal entry.
- * This set is quite general and so not all cases may be used in practice.
- * <p>
- * The id must be stable across new versions on the code as it ends up
- * in the journal on-disk so we are explicit about id even though there is
- * {@link Enum#ordinal} 
- */
-public enum JournalEntryType 
-{ 
-    /*
-     * REDO, UNDO -- Actions (UNDO unused)
-     * COMMIT, ABORT -- Transaction action (ABORT unused)
-     * CHECKPOINT -- data written to the journal as a safe spill file (unused)
-     */
-    REDO(1), UNDO(2), COMMIT(3), ABORT(4) 
-    /*, CHECKPOINT(6)*/
-    ;
-
-    final int id ;
-    JournalEntryType(int x) { id = x ; }
-    int getId() { return id ; }
-    static public JournalEntryType type(int x)
-    {
-        if      ( x == REDO.id )            return REDO ;
-        else if ( x == UNDO.id )            return UNDO ;
-        else if ( x == COMMIT.id )          return COMMIT ;
-        else if ( x == ABORT.id )           return ABORT ;
-        //else if ( x == CHECKPOINT.id )      return CHECKPOINT ;
-        else {
-            Log.error(JournalEntryType.class, "Unknown type: "+x) ;
-            throw new InternalErrorException("Unknown type: "+x) ;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/package-info.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/package-info.java b/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/package-info.java
deleted file mode 100644
index e6ce746..0000000
--- a/jena-db/jena-dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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 org.seaborne.dboe.transaction.txn;
-

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/AbstractTestTxn.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/AbstractTestTxn.java b/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/AbstractTestTxn.java
new file mode 100644
index 0000000..fb1bbc5
--- /dev/null
+++ b/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/AbstractTestTxn.java
@@ -0,0 +1,64 @@
+/*
+ * 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 org.apache.jena.dboe.transaction;
+
+import static org.junit.Assert.assertEquals ;
+
+import java.util.Arrays ;
+import java.util.List ;
+
+import org.apache.jena.dboe.base.file.Location;
+import org.apache.jena.dboe.transaction.TransInteger;
+import org.apache.jena.dboe.transaction.TransMonitor;
+import org.apache.jena.dboe.transaction.Transactional;
+import org.apache.jena.dboe.transaction.txn.*;
+import org.apache.jena.dboe.transaction.txn.journal.Journal;
+import org.junit.After ;
+import org.junit.Before ;
+
+public abstract class AbstractTestTxn {
+    protected TransactionCoordinator txnMgr ;
+    protected TransInteger counter1 = new TransInteger(0) ; 
+    protected TransInteger counter2 = new TransInteger(0) ;
+    protected TransMonitor monitor  = new TransMonitor(ComponentId.allocLocal()) ;
+    protected Transactional unit ;
+    
+    @Before public void setup() {
+        Journal jrnl = Journal.create(Location.mem()) ;
+        List<TransactionalComponent> cg = Arrays.asList
+            (counter1, new TransactionalComponentWrapper(counter2), monitor) ;
+        txnMgr = new TransactionCoordinator(jrnl, cg) ;
+        unit = new TransactionalBase(txnMgr) ;
+        txnMgr.start() ;
+    }
+    
+    @After public void clearup() {
+        txnMgr.shutdown(); 
+    }
+    
+    protected void checkClear() {
+        assertEquals(0, txnMgr.countActive()) ;
+        assertEquals(0, txnMgr.countBegin()-txnMgr.countFinished()) ;
+        assertEquals(0, txnMgr.countActiveReaders()) ;
+        assertEquals(0, txnMgr.countActiveWriter()) ;
+        
+
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TS_Transactions.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TS_Transactions.java b/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TS_Transactions.java
new file mode 100644
index 0000000..9e30e67
--- /dev/null
+++ b/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TS_Transactions.java
@@ -0,0 +1,44 @@
+/*
+ * 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 org.apache.jena.dboe.transaction;
+
+import org.junit.runner.RunWith ;
+import org.junit.runners.Suite ;
+import org.junit.runners.Suite.SuiteClasses ;
+
+@RunWith(Suite.class)
+@SuiteClasses( {
+    TestTxnId.class
+    , TestJournal.class
+    , TestStateMgrData.class
+    , TestTransactionLifecycle.class
+    , TestTransactionLifecycle2.class
+    , TestTransactionCoordinator.class
+    , TestTransactionCoordinatorControl.class
+    , TestTxnLib.class
+    , TestTxnLib2.class
+    , TestThreadingTransactions.class
+    , TestTxnSwitching.class
+    
+    
+})
+public class TS_Transactions {
+
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestJournal.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestJournal.java b/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestJournal.java
new file mode 100644
index 0000000..5f63a57
--- /dev/null
+++ b/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestJournal.java
@@ -0,0 +1,150 @@
+/*
+ * 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 org.apache.jena.dboe.transaction;
+
+import static org.junit.Assert.assertEquals ;
+import static org.junit.Assert.assertFalse ;
+import static org.junit.Assert.assertNotEquals ;
+import static org.junit.Assert.assertNotNull ;
+import static org.junit.Assert.assertTrue ;
+import static org.junit.Assert.fail ;
+
+import java.nio.ByteBuffer ;
+import java.util.Arrays ;
+import java.util.Iterator ;
+import java.util.List ;
+
+import org.apache.jena.atlas.lib.ByteBufferLib ;
+import org.apache.jena.dboe.base.file.Location;
+import org.apache.jena.dboe.transaction.txn.ComponentId;
+import org.apache.jena.dboe.transaction.txn.ComponentIds;
+import org.apache.jena.dboe.transaction.txn.journal.Journal;
+import org.apache.jena.dboe.transaction.txn.journal.JournalEntry;
+import org.apache.jena.dboe.transaction.txn.journal.JournalEntryType;
+import org.junit.Test ;
+
+/** Journal tests spearate from the transaction coordinator */  
+public class TestJournal {
+    // For testing recovery, we need something to recover!
+    // See tests in TestRecovery in dboe-trans-data 
+    
+    @Test public void journal_01() {
+        Journal jrnl = Journal.create(Location.mem()) ;
+        assertNotNull(jrnl) ;
+        assertTrue(jrnl.isEmpty()) ;
+    }
+    
+    @Test public void journal_02() {
+        Journal jrnl = Journal.create(Location.mem()) ;
+        assertNotNull(jrnl) ;
+        JournalEntry e = JournalEntry.COMMIT ;
+        jrnl.writeJournal(e) ;
+        assertFalse(jrnl.isEmpty()) ;
+        assertNotEquals(0, jrnl.position()) ;
+    }
+
+    @Test public void journal_03() {
+        Journal jrnl = Journal.create(Location.mem()) ;
+        assertNotNull(jrnl) ;
+        jrnl.writeJournal(JournalEntry.COMMIT) ;
+        assertNotEquals(0, jrnl.position()) ;
+        JournalEntry e = jrnl.readJournal(0) ;
+        check(JournalEntry.COMMIT, e) ;
+        assertEquals(ComponentIds.idSystem, e.getComponentId());
+        assertEquals(JournalEntryType.COMMIT, e.getType());
+        check(JournalEntry.COMMIT, e) ;
+    }
+
+    @Test public void journal_04() {
+        Journal jrnl = Journal.create(Location.mem()) ;
+        jrnl.writeJournal(JournalEntry.COMMIT) ;
+        jrnl.writeJournal(JournalEntry.ABORT) ;
+        jrnl.writeJournal(JournalEntry.ABORT) ;
+        jrnl.writeJournal(JournalEntry.COMMIT) ;
+        assertFalse(jrnl.isEmpty()) ;
+        
+        Iterator<JournalEntry> iter = jrnl.entries(0) ;
+        
+        List<JournalEntry> expected = Arrays.asList(JournalEntry.COMMIT,
+                                                    JournalEntry.ABORT,
+                                                    JournalEntry.ABORT,
+                                                    JournalEntry.COMMIT) ;
+    }
+
+    @Test public void journal_05() {
+        Journal jrnl = Journal.create(Location.mem()) ;
+        jrnl.writeJournal(JournalEntry.COMMIT) ;
+        jrnl.writeJournal(JournalEntry.ABORT) ;
+        long x = jrnl.writeJournal(JournalEntry.COMMIT) ;
+        jrnl.writeJournal(JournalEntry.COMMIT) ;
+        assertFalse(jrnl.isEmpty()) ;
+        
+        Iterator<JournalEntry> iter = jrnl.entries(x) ;
+        
+        List<JournalEntry> expected = Arrays.asList(JournalEntry.COMMIT,
+                                                    JournalEntry.COMMIT) ;
+    }
+    
+    @Test public void journal_06() {
+        ByteBuffer bb = ByteBuffer.allocateDirect(100) ;
+        ByteBufferLib.fill(bb, (byte)0XA5);
+        Journal jrnl = Journal.create(Location.mem()) ;
+        JournalEntry e = new JournalEntry(JournalEntryType.REDO, ComponentId.allocLocal(), bb) ;
+        jrnl.writeJournal(e) ;
+        jrnl.sync() ;
+        JournalEntry e2 = jrnl.readJournal(0) ;
+        check(e, e2);
+    }
+
+    @Test public void journal_07() {
+        ByteBuffer bb = ByteBuffer.allocateDirect(100) ;
+        ByteBufferLib.fill(bb, (byte)0XA5);
+        Journal jrnl = Journal.create(Location.mem()) ;
+        JournalEntry e = new JournalEntry(JournalEntryType.REDO, ComponentId.allocLocal(), bb) ;
+        
+        jrnl.writeJournal(JournalEntry.COMMIT) ;
+        long locn = jrnl.position() ;
+        jrnl.writeJournal(e) ;
+        
+        assertNotEquals(0, locn);
+        jrnl.sync() ;
+        JournalEntry e2 = jrnl.readJournal(locn) ;
+        check(e, e2);
+    }
+    
+    private void check(List<JournalEntry> expected, Iterator<JournalEntry> iter) {
+        Iterator<JournalEntry> iter2 = expected.iterator() ;
+        for(;;) {
+            if ( ! iter.hasNext() || ! iter2.hasNext() )
+                break ;
+            check(iter2.next(), iter.next()) ;
+        }
+        if ( iter.hasNext() )
+            fail("Journal iterator longer") ;
+        if ( iter2.hasNext() )
+            fail("Expected iterator longer") ;
+    }
+
+    private void check(JournalEntry expected, JournalEntry actual) {
+        assertEquals(expected.getType(), actual.getType()) ;
+        assertEquals(expected.getComponentId(), actual.getComponentId()) ; 
+        assertEquals(expected.getByteBuffer(), actual.getByteBuffer()) ;  
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestStateMgrData.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestStateMgrData.java b/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestStateMgrData.java
new file mode 100644
index 0000000..9349684
--- /dev/null
+++ b/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestStateMgrData.java
@@ -0,0 +1,76 @@
+/*
+ * 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 org.apache.jena.dboe.transaction;
+import static org.junit.Assert.* ;
+
+import java.nio.ByteBuffer ;
+
+import org.apache.jena.dboe.base.file.BufferChannel;
+import org.apache.jena.dboe.base.file.FileFactory;
+import org.apache.jena.dboe.transaction.txn.StateMgrDataIdx;
+import org.junit.Test ;
+
+public class TestStateMgrData {
+    
+    @Test public void state_data_01() {
+        BufferChannel x = FileFactory.createBufferChannelMem() ;
+        long[] data = {2,3} ; 
+        StateMgrDataIdx sm = new StateMgrDataIdx(x, data) ;
+        assertEquals(data.length, sm.getData().length) ;
+        assertEquals(2L, sm.get(0)) ;
+        assertEquals(3L, sm.get(1)) ;
+        // Test initial state written
+        ByteBuffer bb = ByteBuffer.allocate(2*Long.BYTES) ;
+        x.read(bb, 0) ;
+        assertEquals(2L, bb.getLong(0)) ;
+        assertEquals(3L, bb.getLong(Long.BYTES)) ; 
+    }
+    
+    @Test public void state_data_02() {
+        BufferChannel x = FileFactory.createBufferChannelMem() ;
+        long[] data = {2,3} ; 
+        StateMgrDataIdx sm = new StateMgrDataIdx(x, data) ;
+        sm.writeState(); 
+        sm.set(1, 99L);
+        sm.writeState();
+        ByteBuffer bb = ByteBuffer.allocate(2*Long.BYTES) ;
+        x.read(bb, 0) ;
+        assertEquals(99L, bb.getLong(Long.BYTES)) ; 
+    }
+
+    @Test public void state_data_03() {
+        BufferChannel x = FileFactory.createBufferChannelMem() ;
+        {
+            ByteBuffer bb = ByteBuffer.allocate(Long.BYTES) ;
+            bb.putLong(0, -8888) ;
+            bb.rewind();
+            x.write(bb) ;
+            bb.putLong(0, -1234) ;
+            bb.rewind();
+            x.write(bb) ;
+            x.sync(); 
+        }
+        long[] data = {2,3} ; 
+        StateMgrDataIdx sm = new StateMgrDataIdx(x, data) ;
+        assertEquals(-8888L, sm.get(0)) ;
+        assertEquals(-1234L, sm.get(1)) ;
+    }
+    
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestThreadingTransactions.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestThreadingTransactions.java b/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestThreadingTransactions.java
new file mode 100644
index 0000000..de464c0
--- /dev/null
+++ b/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestThreadingTransactions.java
@@ -0,0 +1,122 @@
+/*
+ * 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 org.apache.jena.dboe.transaction;
+
+import java.util.concurrent.Semaphore ;
+
+import org.apache.jena.dboe.base.file.Location;
+import org.apache.jena.dboe.jenax.Txn;
+import org.apache.jena.dboe.transaction.ThreadTxn;
+import org.apache.jena.dboe.transaction.txn.TransactionCoordinator;
+import org.apache.jena.query.ReadWrite ;
+import org.junit.After ;
+import org.junit.Assert ;
+import org.junit.Before ;
+import org.junit.Test ;
+
+public class TestThreadingTransactions {
+    static final long InitValue = 3 ;
+    private TransactionalInteger transInt ; 
+    
+    @Before public void init() {
+        TransactionCoordinator coord = new TransactionCoordinator(Location.mem()) ;
+        transInt = new TransactionalInteger(coord, InitValue) ;
+        coord.start();
+    }
+
+    @After public void after() {
+        transInt.getTxnMgr().shutdown();
+    }
+
+    // Read synchronously in a transaction.
+    void readTxn(String label, TransactionalInteger trans, long expected) {
+        Txn.executeRead(trans, () -> {
+            read(label, trans, expected) ;
+        }) ;
+    }
+
+    void read(String label, TransactionalInteger trans, long expected) {
+        long x = trans.get() ;
+        Assert.assertEquals(label, expected, x); 
+    }
+
+    ThreadTxn threadRead(String label, TransactionalInteger trans, long expectedValue) {
+        return ThreadTxn.threadTxnRead(trans, ()->{
+            read(label, trans, expectedValue) ;
+        }) ;
+    }
+    
+    @Test public void threadTrans_01() {
+        transInt.begin(ReadWrite.READ) ;
+        read("[01]", transInt, InitValue) ;
+        transInt.end();
+    }
+    
+    @Test public void threadTrans_02() {
+        transInt.begin(ReadWrite.READ) ;
+        threadRead("[02]", transInt, InitValue).run() ;
+        transInt.end();
+    }
+
+    @Test public void threadTrans_03() {
+        Semaphore semaBefore = new Semaphore(0, true) ;
+        Semaphore semaAfter  = new Semaphore(0, true) ;
+        ThreadTxn async1 = threadRead("[03/1]", transInt, InitValue);
+        ThreadTxn async2 = threadRead("[03/2]", transInt, InitValue);
+        
+        transInt.begin(ReadWrite.WRITE) ;
+        read("[03/3]", transInt, InitValue) ;
+        transInt.inc(); 
+        read("[03/4]", transInt, InitValue+1) ;
+        
+        async1.run() ;
+       
+        threadRead("[03/5]", transInt, InitValue) ;
+        
+        transInt.commit();
+        transInt.end();
+        async2.run();
+        readTxn("[03/6]", transInt, InitValue+1) ;
+    }
+    
+    @Test public void threadTrans_04() {
+        Semaphore semaBefore1 = new Semaphore(0, true) ;
+        Semaphore semaBefore2 = new Semaphore(0, true) ;
+        Semaphore semaAfter  = new Semaphore(0, true) ;
+        
+        ThreadTxn async1 = threadRead("[04/1]", transInt, InitValue);
+        ThreadTxn async2 = threadRead("[04/2]", transInt, InitValue);
+        ThreadTxn async3 = threadRead("[04/3]", transInt, InitValue);
+        
+        Txn.executeWrite(transInt, transInt::inc);
+
+        ThreadTxn async4 = threadRead("[04/3]", transInt, InitValue+1);
+        async1.run() ;
+
+        Txn.executeWrite(transInt, transInt::inc);  // ++
+        async2.run() ;
+        async4.run() ;
+
+        Txn.executeWrite(transInt, transInt::inc);  // ++
+        async3.run() ;
+        
+        readTxn("[04/4]", transInt, InitValue+3) ;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestTransactionCoordinator.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestTransactionCoordinator.java b/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestTransactionCoordinator.java
new file mode 100644
index 0000000..9b6ad3a
--- /dev/null
+++ b/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestTransactionCoordinator.java
@@ -0,0 +1,178 @@
+/*
+ * 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 org.apache.jena.dboe.transaction;
+
+import static org.junit.Assert.assertEquals ;
+
+import org.apache.jena.query.ReadWrite ;
+import org.junit.Test ;
+
+public class TestTransactionCoordinator extends AbstractTestTxn {
+    @Test public void txn_coord_read_1() {
+        assertEquals(0, txnMgr.countActive()) ;
+        assertEquals(0, txnMgr.countFinished()) ;
+        assertEquals(0, txnMgr.countBegin()) ;
+        assertEquals(0, txnMgr.countBeginRead()) ;
+        assertEquals(0, txnMgr.countBeginWrite()) ;
+        assertEquals(0, txnMgr.countActiveReaders()) ;
+        assertEquals(0, txnMgr.countActiveWriter()) ;
+
+        unit.begin(ReadWrite.READ);
+
+        assertEquals(1, txnMgr.countActive()) ;
+        assertEquals(0, txnMgr.countFinished()) ;
+        assertEquals(1, txnMgr.countBegin()) ;
+        assertEquals(1, txnMgr.countBeginRead()) ;
+        assertEquals(0, txnMgr.countBeginWrite()) ;
+        
+        assertEquals(1, txnMgr.countActiveReaders()) ;
+        assertEquals(0, txnMgr.countActiveWriter()) ;
+
+        unit.end() ;
+
+        assertEquals(0, txnMgr.countActive()) ;
+        assertEquals(1, txnMgr.countBeginRead()) ;
+        assertEquals(0, txnMgr.countBeginWrite()) ;
+        assertEquals(1, txnMgr.countFinished()) ;
+        assertEquals(1, txnMgr.countBegin()) ;
+        assertEquals(0, txnMgr.countActiveReaders()) ;
+        assertEquals(0, txnMgr.countActiveWriter()) ;
+    }
+    
+    @Test public void txn_coord_read_2() {
+        assertEquals(0, txnMgr.countActive()) ;
+        assertEquals(0, txnMgr.countFinished()) ;
+        assertEquals(0, txnMgr.countBegin()) ;
+        assertEquals(0, txnMgr.countBeginRead()) ;
+        assertEquals(0, txnMgr.countBeginWrite()) ;
+
+        unit.begin(ReadWrite.READ);
+
+        assertEquals(1, txnMgr.countActive()) ;
+        assertEquals(0, txnMgr.countFinished()) ;
+        assertEquals(1, txnMgr.countBegin()) ;
+        assertEquals(1, txnMgr.countBeginRead()) ;
+        assertEquals(0, txnMgr.countBeginWrite()) ;
+
+        unit.commit() ;
+        
+        assertEquals(0, txnMgr.countActive()) ;
+        assertEquals(1, txnMgr.countBeginRead()) ;
+        assertEquals(0, txnMgr.countBeginWrite()) ;
+        assertEquals(1, txnMgr.countFinished()) ;
+        assertEquals(1, txnMgr.countBegin()) ;
+
+        unit.end() ;
+
+        assertEquals(0, txnMgr.countActive()) ;
+        assertEquals(1, txnMgr.countBeginRead()) ;
+        assertEquals(0, txnMgr.countBeginWrite()) ;
+        assertEquals(1, txnMgr.countFinished()) ;
+        assertEquals(1, txnMgr.countBegin()) ;
+    }
+
+    @Test public void txn_coord_write_1() {
+        assertEquals(0, txnMgr.countActive()) ;
+        assertEquals(0, txnMgr.countFinished()) ;
+        assertEquals(0, txnMgr.countBegin()) ;
+        assertEquals(0, txnMgr.countBeginRead()) ;
+        assertEquals(0, txnMgr.countBeginWrite()) ;
+
+        assertEquals(0, txnMgr.countActiveReaders()) ;
+        assertEquals(0, txnMgr.countActiveWriter()) ;
+
+        
+        unit.begin(ReadWrite.WRITE);
+        
+        assertEquals(1, txnMgr.countActive()) ;
+        assertEquals(0, txnMgr.countFinished()) ;
+        assertEquals(1, txnMgr.countBegin()) ;
+        assertEquals(0, txnMgr.countBeginRead()) ;
+        assertEquals(1, txnMgr.countBeginWrite()) ;
+        
+        assertEquals(0, txnMgr.countActiveReaders()) ;
+        assertEquals(1, txnMgr.countActiveWriter()) ;
+
+        unit.commit() ;
+
+        assertEquals(0, txnMgr.countActive()) ;
+        assertEquals(1, txnMgr.countFinished()) ;
+        assertEquals(1, txnMgr.countBegin()) ;
+        assertEquals(0, txnMgr.countBeginRead()) ;
+        assertEquals(1, txnMgr.countBeginWrite()) ;
+
+        assertEquals(0, txnMgr.countActiveReaders()) ;
+        assertEquals(0, txnMgr.countActiveWriter()) ;
+
+        unit.end() ;
+
+        assertEquals(0, txnMgr.countActive()) ;
+        assertEquals(1, txnMgr.countFinished()) ;
+        assertEquals(1, txnMgr.countBegin()) ;
+        assertEquals(0, txnMgr.countBeginRead()) ;
+        assertEquals(1, txnMgr.countBeginWrite()) ;
+
+        assertEquals(0, txnMgr.countActiveReaders()) ;
+        assertEquals(0, txnMgr.countActiveWriter()) ;
+    }
+
+    @Test public void txn_coord_write_2() {
+        assertEquals(0, txnMgr.countActive()) ;
+        assertEquals(0, txnMgr.countFinished()) ;
+        assertEquals(0, txnMgr.countBegin()) ;
+        assertEquals(0, txnMgr.countBeginRead()) ;
+        assertEquals(0, txnMgr.countBeginWrite()) ;
+        assertEquals(0, txnMgr.countActiveReaders()) ;
+        assertEquals(0, txnMgr.countActiveWriter()) ;
+        
+        unit.begin(ReadWrite.WRITE);
+        
+        assertEquals(1, txnMgr.countActive()) ;
+        assertEquals(0, txnMgr.countFinished()) ;
+        assertEquals(1, txnMgr.countBegin()) ;
+        assertEquals(0, txnMgr.countBeginRead()) ;
+        assertEquals(1, txnMgr.countBeginWrite()) ;
+        
+        assertEquals(0, txnMgr.countActiveReaders()) ;
+        assertEquals(1, txnMgr.countActiveWriter()) ;
+        
+        unit.abort() ;
+
+        assertEquals(0, txnMgr.countActive()) ;
+        assertEquals(1, txnMgr.countFinished()) ;
+        assertEquals(1, txnMgr.countBegin()) ;
+        assertEquals(0, txnMgr.countBeginRead()) ;
+        assertEquals(1, txnMgr.countBeginWrite()) ;
+        
+        assertEquals(0, txnMgr.countActiveReaders()) ;
+        assertEquals(0, txnMgr.countActiveWriter()) ;
+        
+        unit.end() ;
+
+        assertEquals(0, txnMgr.countActive()) ;
+        assertEquals(1, txnMgr.countFinished()) ;
+        assertEquals(1, txnMgr.countBegin()) ;
+        assertEquals(0, txnMgr.countBeginRead()) ;
+        assertEquals(1, txnMgr.countBeginWrite()) ;
+
+        assertEquals(0, txnMgr.countActiveReaders()) ;
+        assertEquals(0, txnMgr.countActiveWriter()) ;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestTransactionCoordinatorControl.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestTransactionCoordinatorControl.java b/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestTransactionCoordinatorControl.java
new file mode 100644
index 0000000..c8915a8
--- /dev/null
+++ b/jena-db/jena-dboe-transaction/src/test/java/org/apache/jena/dboe/transaction/TestTransactionCoordinatorControl.java
@@ -0,0 +1,144 @@
+/*
+ * 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 org.apache.jena.dboe.transaction;
+
+import static org.junit.Assert.assertEquals ;
+import static org.junit.Assert.assertFalse ;
+import static org.junit.Assert.assertNotNull ;
+import static org.junit.Assert.assertNull ;
+import static org.junit.Assert.assertTrue ;
+
+import java.util.concurrent.Semaphore ;
+import java.util.concurrent.atomic.AtomicInteger ;
+
+import org.apache.jena.dboe.base.file.Location;
+import org.apache.jena.dboe.jenax.Txn;
+import org.apache.jena.dboe.migrate.L;
+import org.apache.jena.dboe.transaction.ThreadTxn;
+import org.apache.jena.dboe.transaction.Transactional;
+import org.apache.jena.dboe.transaction.txn.Transaction;
+import org.apache.jena.dboe.transaction.txn.TransactionCoordinator;
+import org.apache.jena.dboe.transaction.txn.TransactionException;
+import org.apache.jena.dboe.transaction.txn.TransactionalBase;
+import org.apache.jena.query.ReadWrite ;
+import org.junit.After ;
+import org.junit.Before ;
+import org.junit.Test ;
+
+public class TestTransactionCoordinatorControl {
+    // The problem with these tests is the need for Lib.sleep as a way to ensure
+    // async threads run if they can.  And we are sometimes testing for "they can't".
+    
+    static final long InitValue = 3 ;
+    private TransactionCoordinator txnMgr ;
+    protected Transactional unit ;
+    
+    @Before public void init() {
+        txnMgr = new TransactionCoordinator(Location.mem()) ;
+        unit = new TransactionalBase(txnMgr) ;
+        txnMgr.start();
+    }
+
+    @After public void after() {
+        txnMgr.shutdown();
+    }
+    
+    
+    @Test public void txn_coord_disable_writers_1() {
+        AtomicInteger counter1 = new AtomicInteger(0) ;
+        AtomicInteger counter2 = new AtomicInteger(0) ;
+
+        txnMgr.blockWriters();
+        ThreadTxn threadTxn1 = ThreadTxn.threadTxnRead(unit, ()->counter1.incrementAndGet()) ;
+        threadTxn1.run() ;
+        assertEquals(1, counter1.get()) ;
+    }
+
+    @Test public void txn_coord_disable_writers_2() {
+        txnMgr.blockWriters();
+        Transaction txn = L.syncCallThread(()->txnMgr.begin(ReadWrite.WRITE, false)) ;
+        assertNull(txn) ;
+        txnMgr.enableWriters();
+        Transaction txn1 = L.syncCallThread(()->txnMgr.begin(ReadWrite.WRITE, false)) ;
+        assertNotNull(txn1) ;
+    }
+    
+    @Test public void txn_coord_disable_writers_3() {
+        txnMgr.blockWriters();
+        Transaction txn = L.syncCallThread(()->txnMgr.begin(ReadWrite.READ, false)) ;
+        assertNotNull(txn) ;
+        txnMgr.enableWriters();
+        Transaction txn1 = L.syncCallThread(()->txnMgr.begin(ReadWrite.WRITE, false)) ;
+        assertNotNull(txn1) ;
+        Transaction txn2 = L.syncCallThread(()->txnMgr.begin(ReadWrite.READ, false)) ;
+        assertNotNull(txn2) ;
+    }
+    
+    @Test(expected=TransactionException.class)
+    public void txn_coord_disable_writers_4() {
+        txnMgr.blockWriters();
+        txnMgr.enableWriters();
+        txnMgr.enableWriters();
+    }
+
+    @Test
+    public void txn_coord_disable_writers_() {
+        txnMgr.blockWriters();
+        boolean b = txnMgr.tryBlockWriters() ;
+        assertFalse(b) ;
+        txnMgr.enableWriters();
+    }
+    
+    @Test public void txn_coord_exclusive_1() {
+        txnMgr.startExclusiveMode();
+        L.syncOtherThread(()->{
+            Transaction txn1 = txnMgr.begin(ReadWrite.WRITE, false) ;
+            assertNull(txn1) ;
+            Transaction txn2 = txnMgr.begin(ReadWrite.READ, false) ;
+            assertNull(txn2) ;
+        }) ;
+        
+        txnMgr.finishExclusiveMode();
+        L.syncOtherThread(()->{
+            Transaction txn1 = txnMgr.begin(ReadWrite.WRITE, false) ;
+            assertNotNull(txn1) ;
+            Transaction txn2 = txnMgr.begin(ReadWrite.READ, false) ;
+            assertNotNull(txn2) ;
+        }) ;
+    }
+    
+    @Test public void txn_coord_exclusive_2() {
+        AtomicInteger counter1 = new AtomicInteger(0) ;
+        Semaphore finalSema = new Semaphore(0) ;
+        ThreadTxn ttxn = ThreadTxn.threadTxnWrite(unit, ()->{
+            counter1.incrementAndGet() ;
+        }) ;
+        boolean b = txnMgr.tryExclusiveMode(false);
+        assertFalse(b) ;
+        assertEquals(0, counter1.get()) ;
+        ttxn.run(); // Now run thread
+        assertEquals(1, counter1.get()) ;
+        Txn.executeWrite(unit, ()->{});
+        b = txnMgr.tryExclusiveMode(false);
+        assertTrue(b) ;
+    }
+    
+    
+}
+


Mime
View raw message