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 2017/09/28 16:05:50 UTC
[038/100] [abbrv] [partial] jena git commit: JENA-1397: Rename
modules and set versions
http://git-wip-us.apache.org/repos/asf/jena/blob/1dabea3a/jena-db/dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalEntry.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalEntry.java b/jena-db/dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalEntry.java
deleted file mode 100644
index fdefb0a..0000000
--- a/jena-db/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/1dabea3a/jena-db/dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalEntryType.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalEntryType.java b/jena-db/dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/journal/JournalEntryType.java
deleted file mode 100644
index d68bf23..0000000
--- a/jena-db/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/1dabea3a/jena-db/dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/package-info.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/package-info.java b/jena-db/dboe-transaction/src/main/java/org/seaborne/dboe/transaction/txn/package-info.java
deleted file mode 100644
index e6ce746..0000000
--- a/jena-db/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/1dabea3a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/AbstractTestTxn.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/AbstractTestTxn.java b/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/AbstractTestTxn.java
deleted file mode 100644
index 31e7713..0000000
--- a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/AbstractTestTxn.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;
-
-import static org.junit.Assert.assertEquals ;
-
-import java.util.Arrays ;
-import java.util.List ;
-
-import org.junit.After ;
-import org.junit.Before ;
-import org.seaborne.dboe.base.file.Location ;
-import org.seaborne.dboe.transaction.TransInteger ;
-import org.seaborne.dboe.transaction.TransMonitor ;
-import org.seaborne.dboe.transaction.Transactional ;
-import org.seaborne.dboe.transaction.txn.* ;
-import org.seaborne.dboe.transaction.txn.journal.Journal ;
-
-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/1dabea3a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TS_Transactions.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TS_Transactions.java b/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TS_Transactions.java
deleted file mode 100644
index 8c9a919..0000000
--- a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TS_Transactions.java
+++ /dev/null
@@ -1,44 +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;
-
-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/1dabea3a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestJournal.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestJournal.java b/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestJournal.java
deleted file mode 100644
index a00efb4..0000000
--- a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestJournal.java
+++ /dev/null
@@ -1,150 +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;
-
-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.junit.Test ;
-import org.seaborne.dboe.base.file.Location ;
-import org.seaborne.dboe.transaction.txn.ComponentId ;
-import org.seaborne.dboe.transaction.txn.ComponentIds ;
-import org.seaborne.dboe.transaction.txn.journal.Journal ;
-import org.seaborne.dboe.transaction.txn.journal.JournalEntry ;
-import org.seaborne.dboe.transaction.txn.journal.JournalEntryType ;
-
-/** 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/1dabea3a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestStateMgrData.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestStateMgrData.java b/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestStateMgrData.java
deleted file mode 100644
index d2e43c7..0000000
--- a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestStateMgrData.java
+++ /dev/null
@@ -1,76 +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;
-import static org.junit.Assert.* ;
-
-import java.nio.ByteBuffer ;
-
-import org.junit.Test ;
-import org.seaborne.dboe.base.file.BufferChannel ;
-import org.seaborne.dboe.base.file.FileFactory ;
-import org.seaborne.dboe.transaction.txn.StateMgrDataIdx ;
-
-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/1dabea3a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestThreadingTransactions.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestThreadingTransactions.java b/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestThreadingTransactions.java
deleted file mode 100644
index 2805359..0000000
--- a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestThreadingTransactions.java
+++ /dev/null
@@ -1,121 +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;
-
-import java.util.concurrent.Semaphore ;
-
-import org.apache.jena.query.ReadWrite ;
-import org.junit.After ;
-import org.junit.Assert ;
-import org.junit.Before ;
-import org.junit.Test ;
-import org.seaborne.dboe.base.file.Location ;
-import org.seaborne.dboe.jenax.Txn ;
-import org.seaborne.dboe.transaction.txn.TransactionCoordinator ;
-
-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/1dabea3a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionCoordinator.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionCoordinator.java b/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionCoordinator.java
deleted file mode 100644
index 008660f..0000000
--- a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionCoordinator.java
+++ /dev/null
@@ -1,178 +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;
-
-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/1dabea3a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionCoordinatorControl.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionCoordinatorControl.java b/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionCoordinatorControl.java
deleted file mode 100644
index b87d7a7..0000000
--- a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionCoordinatorControl.java
+++ /dev/null
@@ -1,142 +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;
-
-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.query.ReadWrite ;
-import org.junit.After ;
-import org.junit.Before ;
-import org.junit.Test ;
-import org.seaborne.dboe.base.file.Location ;
-import org.seaborne.dboe.jenax.Txn ;
-import org.seaborne.dboe.migrate.L ;
-import org.seaborne.dboe.transaction.txn.Transaction ;
-import org.seaborne.dboe.transaction.txn.TransactionCoordinator ;
-import org.seaborne.dboe.transaction.txn.TransactionException ;
-import org.seaborne.dboe.transaction.txn.TransactionalBase ;
-
-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) ;
- }
-
-
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1dabea3a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionLifecycle.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionLifecycle.java b/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionLifecycle.java
deleted file mode 100644
index a77a000..0000000
--- a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionLifecycle.java
+++ /dev/null
@@ -1,262 +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;
-
-import static org.junit.Assert.fail ;
-import org.junit.Test ;
-import org.seaborne.dboe.transaction.txn.TransactionException ;
-
-import org.apache.jena.query.ReadWrite ;
-
-/**
- * Tests of transaction lifecycle in one JVM.
- * Journal independent.
- * Not testing recovery or writing to the journal.
- */
-public class TestTransactionLifecycle extends AbstractTestTxn {
- @Test public void txn_read_end() {
- unit.begin(ReadWrite.READ);
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_read_end_end() {
- unit.begin(ReadWrite.READ);
- unit.end() ;
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_read_abort() {
- unit.begin(ReadWrite.READ);
- unit.abort() ;
- checkClear() ;
- }
-
- @Test public void txn_read_commit() {
- unit.begin(ReadWrite.READ);
- unit.commit() ;
- checkClear() ;
- }
-
- @Test public void txn_read_abort_end() {
- unit.begin(ReadWrite.READ);
- unit.abort() ;
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_read_commit_end() {
- unit.begin(ReadWrite.READ);
- unit.commit() ;
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_read_commit_abort() {
- unit.begin(ReadWrite.READ);
- unit.commit() ;
- try { unit.abort() ; fail() ; }
- catch (TransactionException ex) { /* Expected : can continue */ }
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_read_commit_commit() {
- unit.begin(ReadWrite.READ);
- unit.commit() ;
- try { unit.commit() ; fail() ; }
- catch (TransactionException ex) { /* Expected : can continue */ }
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_read_abort_commit() {
- unit.begin(ReadWrite.READ);
- unit.abort() ;
- try { unit.commit() ; fail() ; }
- catch (TransactionException ex) { /* Expected : can continue */ }
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_read_abort_abort() {
- unit.begin(ReadWrite.READ);
- unit.abort() ;
- try { unit.abort() ; fail() ; }
- catch (TransactionException ex) { /* Expected : can continue */ }
- unit.end() ;
- checkClear() ;
- }
-
- @Test(expected=TransactionException.class)
- public void txn_begin_read_begin_read() {
- unit.begin(ReadWrite.READ);
- unit.begin(ReadWrite.READ);
- }
-
- @Test(expected=TransactionException.class)
- public void txn_begin_read_begin_write() {
- unit.begin(ReadWrite.READ);
- unit.begin(ReadWrite.WRITE);
- }
-
- @Test(expected=TransactionException.class)
- public void txn_begin_write_begin_read() {
- unit.begin(ReadWrite.WRITE);
- unit.begin(ReadWrite.READ);
- }
-
- @Test(expected=TransactionException.class)
- public void txn_begin_write_begin_write() {
- unit.begin(ReadWrite.WRITE);
- unit.begin(ReadWrite.WRITE);
- }
-
- @Test(expected=TransactionException.class)
- public void txn_write_begin_end() {
- unit.begin(ReadWrite.WRITE);
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_write_abort() {
- unit.begin(ReadWrite.WRITE);
- unit.abort() ;
- checkClear() ;
- }
-
- @Test public void txn_write_commit() {
- unit.begin(ReadWrite.WRITE);
- unit.commit() ;
- checkClear() ;
- }
-
- @Test public void txn_write_abort_end() {
- unit.begin(ReadWrite.WRITE);
- unit.abort() ;
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_write_abort_end_end() {
- unit.begin(ReadWrite.WRITE);
- unit.abort() ;
- unit.end() ;
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_write_commit_end() {
- unit.begin(ReadWrite.WRITE);
- unit.commit() ;
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_write_commit_end_end() {
- unit.begin(ReadWrite.WRITE);
- unit.commit() ;
- unit.end() ;
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_write_commit_abort() {
- // commit-abort
- unit.begin(ReadWrite.WRITE);
- unit.commit() ;
- try { unit.abort() ; fail() ; }
- catch (TransactionException ex) { /* Expected : can continue */ }
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_write_commit_commit() {
- // commit-commit
- unit.begin(ReadWrite.WRITE);
- unit.commit() ;
- try { unit.commit() ; fail() ; }
- catch (TransactionException ex) { /* Expected : can continue */ }
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_write_abort_commit() {
- // abort-commit
- unit.begin(ReadWrite.WRITE);
- unit.abort() ;
- try { unit.commit() ; fail() ; }
- catch (TransactionException ex) { /* Expected : can continue */ }
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_write_abort_abort() {
- // abort-abort
- unit.begin(ReadWrite.WRITE);
- unit.abort() ;
- try { unit.abort() ; fail() ; }
- catch (TransactionException ex) { /* Expected : can continue */ }
- unit.end() ;
- checkClear() ;
- }
-
- private void read() {
- unit.begin(ReadWrite.READ);
- unit.end() ;
- checkClear() ;
- }
-
- private void write() {
- unit.begin(ReadWrite.WRITE);
- unit.commit() ;
- unit.end() ;
- checkClear() ;
- }
-
- @Test public void txn_read_read() {
- read() ;
- read() ;
- }
-
- @Test public void txn_write_read() {
- write() ;
- read() ;
- }
-
- @Test public void txn_read_write() {
- read() ;
- write() ;
- }
-
- @Test public void txn_write_write() {
- write() ;
- write() ;
- }
-
- @Test public void txn_www() {
- write() ;
- write() ;
- write() ;
- checkClear();
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1dabea3a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionLifecycle2.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionLifecycle2.java b/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionLifecycle2.java
deleted file mode 100644
index 72b732b..0000000
--- a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTransactionLifecycle2.java
+++ /dev/null
@@ -1,299 +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;
-
-import static org.junit.Assert.* ;
-
-import java.util.concurrent.atomic.AtomicReference ;
-
-import org.apache.jena.query.ReadWrite ;
-import org.junit.After ;
-import org.junit.Before ;
-import org.junit.Test ;
-import org.seaborne.dboe.base.file.Location ;
-import org.seaborne.dboe.migrate.L ;
-import org.seaborne.dboe.transaction.txn.Transaction ;
-import org.seaborne.dboe.transaction.txn.TransactionCoordinator ;
-import org.seaborne.dboe.transaction.txn.TransactionException ;
-import org.seaborne.dboe.transaction.txn.journal.Journal ;
-
-/**
- * Details tests of the transaction lifecycle in one JVM
- * including tests beyond the TransactionalComponentLifecycle
- *
- * Journal independent.
- */
-public class TestTransactionLifecycle2 {
- // org.junit.rules.ExternalResource ?
- protected TransactionCoordinator txnMgr ;
-// protected TransInteger counter1 = new TransInteger(0) ;
-// protected TransInteger counter2 = new TransInteger(0) ;
-// protected TransMonitor monitor = new TransMonitor() ;
-
- @Before public void setup() {
- Journal jrnl = Journal.create(Location.mem()) ;
- txnMgr = new TransactionCoordinator(jrnl) ;
- txnMgr.start() ;
- }
-
- @After public void clearup() {
- txnMgr.shutdown();
- }
-
- protected void checkClear() {
- assertEquals(0, txnMgr.countActive()) ;
- assertEquals(0, txnMgr.countBegin()-txnMgr.countFinished()) ;
- }
-
- @Test public void txn_direct_01() {
- Transaction txn1 = txnMgr.begin(ReadWrite.READ) ;
- txn1.end();
- checkClear() ;
- }
-
- @Test(expected=TransactionException.class)
- public void txn_direct_02() {
- Transaction txn1 = txnMgr.begin(ReadWrite.WRITE) ;
- txn1.end();
- checkClear() ;
- }
-
- @Test
- public void txn_direct_03() {
- Transaction txn1 = txnMgr.begin(ReadWrite.WRITE) ;
- txn1.commit() ;
- txn1.end() ;
- checkClear() ;
- }
-
- @Test
- public void txn_direct_04() {
- Transaction txn1 = txnMgr.begin(ReadWrite.WRITE) ;
- // This tests the TransactionCoordinator
- // but the TransactiolComponentLifecycle doesn't support multiple
- // transactions per thread (use of ThreadLocals).
- // To do that, the transaction object would be needed in all
- // component API calls. Doable but intrusive.
- Transaction txn2 = txnMgr.begin(ReadWrite.READ) ;
- txn1.commit() ;
- txn2.end() ;
- txn1.end() ;
- checkClear() ;
- }
-
- @Test
- public void txn_direct_05() {
- Transaction txn1 = txnMgr.begin(ReadWrite.WRITE) ;
- txn1.prepare() ;
- txn1.commit() ;
- txn1.end() ;
- checkClear() ;
- }
-
- @Test
- public void txn_direct_06() {
- Transaction txn1 = txnMgr.begin(ReadWrite.WRITE) ;
- // txn1.prepare() ; Optional.
- txn1.commit() ;
- txn1.end() ;
- checkClear() ;
- }
-
- @Test
- public void txn_overlap_WW() {
- Transaction txn1 = txnMgr.begin(ReadWrite.WRITE, false) ;
- assertNotNull(txn1) ;
-
- Transaction txn2 = txnMgr.begin(ReadWrite.WRITE, false) ;
- assertNull(txn2) ; // Otherwise blocking.
-
- txn1.commit();
- txn1.end() ;
- checkClear() ;
- }
-
- @Test
- public void txn_overlap_WR() {
- Transaction txn1 = txnMgr.begin(ReadWrite.WRITE, false) ;
- assertNotNull(txn1) ;
-
- Transaction txn2 = txnMgr.begin(ReadWrite.READ, false) ;
- assertNotNull(txn2) ;
-
- txn1.commit();
- txn1.end() ;
- txn2.end();
- checkClear() ;
- }
-
- @Test
- public void txn_overlap_RW() {
- Transaction txn1 = txnMgr.begin(ReadWrite.READ, false) ;
- assertNotNull(txn1) ;
-
- Transaction txn2 = txnMgr.begin(ReadWrite.WRITE, false) ;
- assertNotNull(txn2) ;
- txn1.commit();
- txn1.end() ;
- txn2.abort();
- txn2.end();
- checkClear() ;
- }
-
- @Test
- public void txn_overlap_RR() {
- Transaction txn1 = txnMgr.begin(ReadWrite.READ, false) ;
- assertNotNull(txn1) ;
-
- Transaction txn2 = txnMgr.begin(ReadWrite.READ, false) ;
- assertNotNull(txn2) ;
-
- txn1.commit();
- txn1.end() ;
- txn2.end();
- checkClear() ;
- }
-
- @Test
- public void txn_promote_1() {
- Transaction txn1 = txnMgr.begin(ReadWrite.READ) ;
- assertNotNull(txn1) ;
- boolean b = txn1.promote() ;
- assertTrue(b) ;
- assertEquals(ReadWrite.WRITE, txn1.getMode()) ;
- txn1.commit() ;
- txn1.end() ;
- checkClear() ;
- }
-
- @Test
- public void txn_promote_2() {
- Transaction txn1 = txnMgr.begin(ReadWrite.WRITE) ;
- boolean b = txn1.promote() ;
- assertTrue(b) ;
- b = txn1.promote() ;
- assertTrue(b) ;
- txn1.abort() ;
- txn1.end() ;
- checkClear() ;
- }
-
- @Test(expected=TransactionException.class)
- public void txn_promote_3() {
- Transaction txn1 = txnMgr.begin(ReadWrite.READ) ;
- boolean b = txn1.promote() ;
- assertTrue(b) ;
- b = txn1.promote() ;
- assertTrue(b) ;
- // Exception - now a writer
- txn1.end() ;
- checkClear() ;
- }
-
- //Not a @Test
- public void txn_promote_deadlock() {
- Transaction txn1 = txnMgr.begin(ReadWrite.READ) ;
- Transaction txn2 = txnMgr.begin(ReadWrite.WRITE) ;
- // Deadlock.
- // Promotion waits for the writer to decide whether it is commiting or not.
- // This can't be done on one thread.
- boolean b = txn1.promote() ;
- assertFalse(b) ;
- txn1.end() ;
- txn2.commit();
- txn2.end() ;
- checkClear() ;
- }
-
- @Test
- public void txn_promote_thread_writer_1() {
- Transaction txn1 = txnMgr.begin(ReadWrite.READ) ;
- L.syncOtherThread(()->{
- Transaction txn2 = txnMgr.begin(ReadWrite.WRITE) ;
- txn2.commit();
- txn2.end() ;
- }) ;
-
- boolean b = txn1.promote() ;
- assertFalse(b) ;
- txn1.end() ;
- checkClear() ;
- }
-
- @Test
- public void txn_promote_thread_writer_2() {
- Transaction txn1 = txnMgr.begin(ReadWrite.READ) ;
- L.syncOtherThread(()->{
- Transaction txn2 = txnMgr.begin(ReadWrite.WRITE) ;
- txn2.abort();
- txn2.end() ;
- }) ;
-
- boolean b = txn1.promote() ;
- assertTrue(b) ;
- // Now a writer.
- txn1.commit();
- txn1.end() ;
- checkClear() ;
- }
-
- @Test
- public void txn_promote_thread_writer_3() {
- Transaction txn1 = txnMgr.begin(ReadWrite.READ) ;
- boolean b = txn1.promote() ;
- assertTrue(b) ;
- AtomicReference<Transaction> ref = new AtomicReference<>(txn1) ;
- L.syncOtherThread(()->{
- // Should fail.
- Transaction txn2 = txnMgr.begin(ReadWrite.WRITE, false) ;
- ref.set(txn2);
- }) ;
- assertNull(ref.get()) ;
- txn1.abort() ;
- txn1.end() ;
- }
-
- @Test
- public void txn_promote_thread_writer_4() {
- Transaction txn1 = txnMgr.begin(ReadWrite.READ) ;
- boolean b = txn1.promote() ;
- assertTrue(b) ;
- AtomicReference<Transaction> ref = new AtomicReference<>(txn1) ;
- L.syncOtherThread(()->{
- // Should fail.
- Transaction txn2 = txnMgr.begin(ReadWrite.WRITE, false) ;
- ref.set(txn2);
- }) ;
- assertNull(ref.get()) ;
- txn1.abort() ;
- txn1.end() ;
-
- L.syncOtherThread(()->{
- // Should suceed
- Transaction txn2 = txnMgr.begin(ReadWrite.WRITE, false) ;
- ref.set(txn2);
- txn2.abort() ;
- txn2.end() ;
- }) ;
- assertNotNull(ref.get()) ;
- checkClear() ;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1dabea3a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnId.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnId.java b/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnId.java
deleted file mode 100644
index 6c2a85f..0000000
--- a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnId.java
+++ /dev/null
@@ -1,53 +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;
-
-import static org.junit.Assert.assertEquals ;
-import static org.junit.Assert.assertNotEquals ;
-import static org.junit.Assert.assertNotNull ;
-import static org.junit.Assert.assertNotSame ;
-
-import org.junit.Test ;
-import org.seaborne.dboe.transaction.txn.TxnId ;
-import org.seaborne.dboe.transaction.txn.TxnIdFactory ;
-import org.seaborne.dboe.transaction.txn.TxnIdSimple ;
-
-public class TestTxnId {
- @Test public void txnId_1() {
- TxnId id1 = TxnIdFactory.createSimple() ;
- assertNotNull(id1) ;
- }
-
- @Test public void txnId_2() {
- TxnId id1 = TxnIdFactory.createSimple() ;
- TxnId id2 = TxnIdFactory.createSimple() ;
- assertNotSame(id1, id2) ;
- assertNotEquals(id1, id2) ;
- }
-
- @Test public void txnId_3() {
- TxnId id1 = TxnIdFactory.createSimple() ;
- TxnId id2 = TxnIdSimple.create(id1.bytes()) ;
- assertNotSame(id1, id2) ;
- assertEquals(id1, id2) ;
- assertEquals(id1.name(), id2.name()) ;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1dabea3a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnLib.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnLib.java b/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnLib.java
deleted file mode 100644
index 36537fe..0000000
--- a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnLib.java
+++ /dev/null
@@ -1,198 +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;
-
-import static org.junit.Assert.assertEquals ;
-import static org.junit.Assert.assertNotEquals ;
-import static org.junit.Assert.fail ;
-
-import org.apache.jena.query.ReadWrite ;
-import org.junit.Test ;
-import org.seaborne.dboe.jenax.Txn ;
-
-public class TestTxnLib extends AbstractTestTxn {
-
- @Test public void libTxn_1() {
- long v1 = counter1.value() ;
- long v2 = counter2.value() ;
- assertEquals(0, v1) ;
- assertEquals(0, v2) ;
-
- Txn.executeRead(unit, () -> {
- assertEquals(0, counter1.get()) ;
- assertEquals(0, counter2.get()) ;
- }) ;
- }
-
- @Test public void libTxn_2() {
- assertEquals(0, counter1.value()) ;
-
- Txn.executeWrite(unit, () -> {
- counter1.inc() ;
- assertEquals("In W, value()", 0, counter1.value()) ;
- assertEquals("In W, get()",1, counter1.get()) ;
- }) ;
-
- assertEquals("Direct value()", 1, counter1.value()) ;
- assertEquals("Direct get()", 1, counter1.get()) ;
-
- Txn.executeRead(unit, () -> {
- assertEquals("In R, value()", 1, counter1.get()) ;
- assertEquals("In R, get()", 1, counter1.value()) ;
- }) ;
- }
-
- @Test public void libTxn_3() {
- Txn.executeRead(unit, () -> {
- assertEquals("In R, value()", 0, counter2.get()) ;
- assertEquals("In R, get()", 0, counter2.value()) ;
- }) ;
-
- Txn.executeWrite(unit, () -> {
- counter2.inc() ;
- assertEquals("In W, value()", 0, counter2.value()) ;
- assertEquals("In W, get()",1, counter2.get()) ;
- }) ;
-
- assertEquals("Direct value()", 1, counter2.value()) ;
- assertEquals("Direct get()", 1, counter2.get()) ;
-
- Txn.executeRead(unit, () -> {
- assertEquals("In R, value()", 1, counter2.get()) ;
- assertEquals("In R, get()", 1, counter2.value()) ;
- }) ;
- }
-
- @Test public void libTxn_4() {
- long v1 = counter1.value() ;
- long v2 = counter2.value() ;
- assertEquals(0, v1) ;
- assertEquals(0, v2) ;
-
- //Txn.execWrite(unit, () -> {
-
- unit.begin(ReadWrite.WRITE);
- counter1.inc() ;
- counter2.inc() ;
- assertEquals("Counter out of step", counter1.get(), counter2.get());
- assertNotEquals("Counter 1 can see wrong state", counter1.get(), counter1.value() ) ;
- assertNotEquals("Counter 2 can see wrong state", counter2.get(), counter2.value() ) ;
- counter2.inc() ;
- assertNotEquals("Counter 1 and 2 should differ", counter1.get(), counter2.get() ) ;
- unit.commit() ;
- unit.end() ;
- //}) ;
- assertEquals("Component 1 inconsistent", 1, counter1.value()) ;
- assertEquals("Component 2 inconsistent", 2, counter2.value()) ;
-
- Txn.executeRead(unit, () -> {
- assertEquals("Component 1 inconsistent (R)", 1, counter1.get()) ;
- assertEquals("Component 2 inconsistent (R)", 2, counter2.get()) ;
- }) ;
- }
-
- @Test public void libTxn_5() {
- long x =
- Txn.calculateRead(unit, () -> {
- assertEquals("In R, value()", 0, counter2.get()) ;
- assertEquals("In R, get()", 0, counter2.value()) ;
- return counter2.get() ;
- }) ;
- assertEquals("Outside R", 0, x) ;
- }
-
- @Test public void libTxn_6() {
- long x =
- Txn.calculateWrite(unit, () -> {
- counter2.inc() ;
- assertEquals("In W, value()", 0, counter2.value()) ;
- assertEquals("In W, get()",1, counter2.get()) ;
- return counter2.get() ;
- }) ;
- assertEquals("Outside W",1, x) ;
- }
-
- @Test public void libTxn_7() {
- long x1 =
- Txn.calculateWrite(unit, () -> {
- counter2.inc() ;
- counter2.inc() ;
- return counter2.get() ;
- }) ;
- long x2 = Txn.calculateRead(unit, () -> {
- return counter2.get() ;
- }) ;
- assertEquals("After W and R",x1 , x2) ;
- }
-
- // Tests for thread transactions.
-
- @Test public void libTxnThread_1() {
- ThreadTxn t = ThreadTxn.threadTxnRead(unit, ()->{}) ;
- t.run();
- }
-
- @Test public void libTxnThread_2() {
- ThreadTxn t = ThreadTxn.threadTxnWrite(unit, ()-> fail("")) ;
- }
-
- @Test(expected=AssertionError.class)
- public void libTxnThread_3() {
- ThreadTxn t = ThreadTxn.threadTxnWrite(unit, ()-> fail("")) ;
- t.run() ;
- }
-
- @Test public void libTxnThread_10() {
- long x1 = counter1.get() ;
- ThreadTxn t = ThreadTxn.threadTxnWrite(unit, ()->{ counter1.inc() ;}) ;
- long x2 = counter1.get() ;
- assertEquals("x2", x1, x2) ;
- t.run() ;
- long x3 = counter1.get() ;
- assertEquals("x3", x1+1, x3) ;
- }
-
- @Test public void libTxnThread_11() {
- long x1 = counter1.get() ;
- Txn.executeWrite(unit, ()->{
- counter1.inc();
- // Read the "before" state
- ThreadTxn t = ThreadTxn.threadTxnRead(unit, ()->{ long z1 = counter1.get() ; assertEquals("Thread read", x1, z1) ; }) ;
- counter1.inc();
- t.run();
- }) ;
- long x2 = counter1.get() ;
- assertEquals("after", x1+2, x2) ;
- }
-
- @Test public void libTxnThread_12() {
- long x1 = counter1.get() ;
- ThreadTxn t = ThreadTxn.threadTxnRead(unit, () -> {
- long z1 = counter1.get() ;
- assertEquals("Thread", x1, z1) ;
- }) ;
- Txn.executeWrite(unit, ()->counter1.inc()) ;
- t.run() ;
- long x2 = counter1.get() ;
- assertEquals("after", x1+1, x2) ;
- }
-
-}
-
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jena/blob/1dabea3a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnLib2.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnLib2.java b/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnLib2.java
deleted file mode 100644
index 44e76e8..0000000
--- a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnLib2.java
+++ /dev/null
@@ -1,66 +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;
-
-import org.apache.jena.atlas.lib.Pair ;
-import org.junit.After ;
-import org.junit.Assert ;
-import org.junit.Before ;
-import org.junit.Test ;
-import org.seaborne.dboe.base.file.Location ;
-import org.seaborne.dboe.jenax.Txn ;
-import org.seaborne.dboe.transaction.txn.TransactionCoordinator ;
-
-/** Unusual ways to do things.
- * Rather than a TransactionalComponent,
- * TransactionalInteger
- */
-public class TestTxnLib2 extends Assert {
- // With setup/teardown / not from AbstractTestTxn
- private final long InitValue = 7 ;
- TransactionalInteger integer ;
-
- @Before public void setup() {
- TransactionCoordinator coord = new TransactionCoordinator(Location.mem()) ;
- integer = new TransactionalInteger(coord, InitValue) ;
- coord.start() ;
- }
-
- @After public void clearup() {
- integer.shutdown();
- }
-
- @Test public void libTxn_10() {
- Txn.executeWrite(integer, integer::inc) ;
- long x = Txn.calculateRead(integer, integer::get) ;
- assertEquals(InitValue+1, x) ;
- }
-
- @Test public void libTxn_11() {
- Pair<Long, Long> p = Txn.calculateWrite(integer, () -> {
- integer.inc() ;
- return Pair.create(integer.value(), integer.get()) ;
- }) ;
- assertEquals(InitValue, p.getLeft().longValue()) ;
- assertEquals(InitValue+1, p.getRight().longValue()) ;
- assertEquals(InitValue+1, integer.get()) ;
- assertEquals(InitValue+1, integer.value()) ;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1dabea3a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnSwitching.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnSwitching.java b/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnSwitching.java
deleted file mode 100644
index 7f7b128..0000000
--- a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TestTxnSwitching.java
+++ /dev/null
@@ -1,193 +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;
-
-import static org.junit.Assert.assertEquals ;
-import static org.junit.Assert.fail ;
-
-import org.apache.jena.query.ReadWrite ;
-import org.junit.After ;
-import org.junit.Before ;
-import org.junit.Test ;
-import org.seaborne.dboe.base.file.Location ;
-import org.seaborne.dboe.jenax.Txn ;
-import org.seaborne.dboe.transaction.txn.* ;
-import org.seaborne.dboe.transaction.txn.journal.Journal ;
-
-/** Tests of changing the thread state ... carefully */
-public class TestTxnSwitching {
- TransInteger integer = new TransInteger(100) ;
- Journal jrnl = Journal.create(Location.mem()) ;
-
- //Transactional transactional = TransactionalFactory.create(jrnl, integer) ;
- TransactionalBase transactional ;
- TransactionCoordinator txnMgr = new TransactionCoordinator(jrnl) ;
- {
- txnMgr.add(integer) ;
- transactional = new TransactionalBase(txnMgr) ;
- txnMgr.start() ;
- }
-
-
- @Before public void setup() {
- }
-
- @After public void clearup() {
- }
-
- @Test public void txnSwitch_01() {
- long z = integer.value() ;
- transactional.begin(ReadWrite.WRITE);
- integer.inc();
-
- assertEquals(integer.value()+1, integer.get()) ;
- assertEquals(z+1, integer.get()) ;
-
- TransactionCoordinatorState txnState = transactional.detach() ;
-
- assertEquals(integer.value(), integer.get()) ;
- assertEquals(z, integer.get()) ;
-
- transactional.attach(txnState);
-
- assertEquals(integer.value()+1, integer.get()) ;
- assertEquals(z+1, integer.get()) ;
-
- transactional.commit() ;
- transactional.end() ;
- assertEquals(z+1, integer.get()) ;
- assertEquals(z+1, integer.value()) ;
- }
-
- @Test public void txnSwitch_02() {
- long z = integer.value() ;
- Txn.executeWrite(transactional, ()->integer.inc());
- assertEquals(z+1, integer.value()) ;
-
-
- //Transaction txn = txnMgr.begin(ReadWrite.WRITE) ;
- transactional.begin(ReadWrite.WRITE);
- integer.inc();
- assertEquals(z+2, integer.get()) ;
- TransactionCoordinatorState txnState = transactional.detach() ;
- // Can't transactional read.
- try { integer.read() ; fail() ; } catch (TransactionException ex) {}
-
- long z1 = Txn.calculateRead(transactional, ()->integer.get()) ;
- assertEquals(z+1, z1) ;
- transactional.attach(txnState) ;
- integer.inc();
- assertEquals(z+3, integer.get()) ;
-
- ThreadTxn threadTxn = ThreadTxn.threadTxnRead(transactional, ()->assertEquals(z+1, integer.get())) ;
- threadTxn.run() ;
-
- transactional.commit() ;
- transactional.end() ;
- }
-
- // As 02 but with Transaction txn = txnMgr.begin(ReadWrite.WRITE) ;
- // and txn calls and integer calls. Not transactional calls but txnMgr calls.
-
- @Test public void txnSwitch_03() {
- long z = integer.value() ;
- Txn.executeWrite(transactional, ()->integer.inc());
- assertEquals(z+1, integer.value()) ;
-
- Transaction txn = txnMgr.begin(ReadWrite.WRITE) ;
- integer.inc();
- assertEquals(z+2, integer.get()) ;
- TransactionCoordinatorState txnState = txnMgr.detach(txn) ;
-
- Transaction txnRead = txnMgr.begin(ReadWrite.READ) ;
- assertEquals(z+1, integer.get()) ;
- txnRead.end() ;
-
- try { integer.read() ; fail() ; } catch (TransactionException ex) {}
-
- txnMgr.attach(txnState);
-
- integer.inc();
- assertEquals(z+3, integer.get()) ;
-
- ThreadTxn.threadTxnRead(transactional, ()->assertEquals(z+1, integer.get())).run();
- txn.commit();
- txn.end() ;
- }
-
- // Switch between read and write all on one thread.
- @Test public void txnSwitch_04() {
- long z = integer.value() ;
-
- transactional.begin(ReadWrite.READ);
- TransactionCoordinatorState txnStateR1 = transactional.detach() ;
-
- ThreadTxn t1 = ThreadTxn.threadTxnRead(transactional, ()->assertEquals(z, integer.get() )) ;
- ThreadTxn t2 = ThreadTxn.threadTxnRead(transactional, ()->assertEquals(z, integer.get() )) ;
-
- transactional.begin(ReadWrite.WRITE);
- integer.inc();
-
- TransactionCoordinatorState txnStateW1 = transactional.detach() ;
-
- // Currently, thread has no transaction.
- long z1 = Txn.calculateRead(transactional, ()->integer.get() );
- assertEquals(z, z1) ;
-
- // Back to writer.
- transactional.attach(txnStateW1) ;
- integer.inc();
- TransactionCoordinatorState txnStateW2 = transactional.detach() ;
-
- try { integer.read() ; fail() ; } catch (TransactionException ex) {}
- // To reader.
- transactional.attach(txnStateR1) ;
- assertEquals(z1, integer.read()) ;
- t1.run() ;
-
- // And the writer again.
- TransactionCoordinatorState txnStateR2 = transactional.detach() ;
- transactional.attach(txnStateW2) ;
- integer.inc();
- transactional.commit();
- transactional.end() ;
-
- t2.run() ;
- transactional.attach(txnStateR2) ;
- assertEquals(z1, integer.read()) ;
- transactional.end() ;
- }
-
- // Some error cases.
- @Test(expected=TransactionException.class)
- public void txnSwitch_10() {
- transactional.begin(ReadWrite.READ);
- TransactionCoordinatorState txnState = transactional.detach() ;
- transactional.attach(txnState);
- transactional.attach(txnState);
- }
- @Test(expected=TransactionException.class)
- public void txnSwitch_11() {
- transactional.begin(ReadWrite.READ);
- TransactionCoordinatorState txnState1 = transactional.detach() ;
- TransactionCoordinatorState txnState2 = transactional.detach() ;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1dabea3a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TransactionalInteger.java
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TransactionalInteger.java b/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TransactionalInteger.java
deleted file mode 100644
index 64f521a..0000000
--- a/jena-db/dboe-transaction/src/test/java/org/seaborne/dboe/transaction/TransactionalInteger.java
+++ /dev/null
@@ -1,60 +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;
-
-import org.seaborne.dboe.transaction.txn.TransactionCoordinator ;
-import org.seaborne.dboe.transaction.txn.TransactionalBase ;
-
-/**
- * A Transactional (unit of begin/commit) of a single integer component.
- * Testing support. Use {@link TransInteger} for application code.
- * @see TransInteger
- */
-public class TransactionalInteger extends TransactionalBase {
- final private TransInteger integer ;
-
- public TransactionalInteger(TransactionCoordinator coord, long v) {
- super(coord) ;
- integer = new TransInteger(v) ;
- coord.add(integer) ;
- }
-
- public void inc() {
- integer.inc() ;
- }
-
- /** Return the current value.
- * If inside a transaction, return the tarnsaction view of the value.
- * If not in a transaction return the state value (effectively
- * a fast read transaction).
- */
- public long get() {
- return integer.get() ;
- }
-
- public void set(long v) {
- integer.set(v) ;
- }
-
- /** Return the currently commited value */
- public long value() {
- return integer.value() ;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1dabea3a/jena-db/dboe-transaction/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/jena-db/dboe-transaction/src/test/resources/log4j.properties b/jena-db/dboe-transaction/src/test/resources/log4j.properties
deleted file mode 100644
index d6b299a..0000000
--- a/jena-db/dboe-transaction/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-log4j.rootLogger=INFO, stdlog
-
-log4j.appender.stdlog=org.apache.log4j.ConsoleAppender
-## log4j.appender.stdlog.target=System.err
-log4j.appender.stdlog.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdlog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %-20c{1} :: %m%n
http://git-wip-us.apache.org/repos/asf/jena/blob/1dabea3a/jena-db/fuseki-tdb2/pom.xml
----------------------------------------------------------------------
diff --git a/jena-db/fuseki-tdb2/pom.xml b/jena-db/fuseki-tdb2/pom.xml
deleted file mode 100644
index 1f13c1a..0000000
--- a/jena-db/fuseki-tdb2/pom.xml
+++ /dev/null
@@ -1,130 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- 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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <name>Mantis (${project.artifactId})</name>
- <artifactId>fuseki-tdb2-server</artifactId>
-
- <parent>
- <groupId>org.seaborne.mantis</groupId>
- <artifactId>mantis</artifactId>
- <version>0.3.1-SNAPSHOT</version>
- </parent>
-
- <packaging>jar</packaging>
- <description>Apache Jena Fuseki combined with Mantis/TDB2</description>
-
- <dependencies>
-
- <dependency>
- <groupId>org.seaborne.mantis</groupId>
- <artifactId>tdb2</artifactId>
- <version>0.3.1-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.jena</groupId>
- <artifactId>jena-fuseki-core</artifactId>
- <version>${ver.fuseki}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.jena</groupId>
- <artifactId>jena-cmds</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <scope>runtime</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>2.4.3</version>
- <configuration>
- <shadedArtifactAttached>false</shadedArtifactAttached>
- <transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <!--<mainClass>org.apache.jena.fuseki.cmd.FusekiCmd</mainClass>-->
- <mainClass>org.seaborne.fuseki.cmd.FusekiTDB2Cmd</mainClass>
- </transformer>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
- <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
- <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
- <addHeader>false</addHeader>
- </transformer>
- </transformers>
- <filters>
- <filter>
- <artifact>*:*</artifact>
- <excludes>
- <!-- Some jars are signed but shading breaks that.
- Don't include signing files.
- -->
- <exclude>META-INF/*.SF</exclude>
- <exclude>META-INF/*.DSA</exclude>
- <exclude>META-INF/*.RSA</exclude>
- </excludes>
- </filter>
- </filters>
- </configuration>
- <executions>
- <execution>
- <phase>package</phase>
- <!--<phase /><!- - Switch off -->
- <goals>
- <goal>shade</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
-
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/jena/blob/1dabea3a/jena-db/fuseki-tdb2/src/main/java/org/seaborne/fuseki/cmd/FusekiTDB2Cmd.java
----------------------------------------------------------------------
diff --git a/jena-db/fuseki-tdb2/src/main/java/org/seaborne/fuseki/cmd/FusekiTDB2Cmd.java b/jena-db/fuseki-tdb2/src/main/java/org/seaborne/fuseki/cmd/FusekiTDB2Cmd.java
deleted file mode 100644
index 25e1314..0000000
--- a/jena-db/fuseki-tdb2/src/main/java/org/seaborne/fuseki/cmd/FusekiTDB2Cmd.java
+++ /dev/null
@@ -1,33 +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.fuseki.cmd;
-
-import org.apache.jena.fuseki.Fuseki;
-import org.apache.jena.fuseki.FusekiLogging;
-import org.apache.jena.fuseki.cmd.FusekiCmd;
-
-public class FusekiTDB2Cmd {
-
- public static void main(String... args) {
- FusekiLogging.setLogging() ;
- Fuseki.serverLog.info("Fuseki-TDB2 integration");
- FusekiCmd.main(args);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/1dabea3a/jena-db/jena-dboe-base/.gitignore
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/.gitignore b/jena-db/jena-dboe-base/.gitignore
new file mode 100644
index 0000000..b49c563
--- /dev/null
+++ b/jena-db/jena-dboe-base/.gitignore
@@ -0,0 +1,4 @@
+/target/
+/target/
+/target/
+/target/