jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [03/34] jena git commit: Remove journaling package due to changes in DSG upstream.
Date Sat, 06 Feb 2016 15:50:52 GMT
Remove journaling package due to changes in DSG upstream.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/06b0aa85
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/06b0aa85
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/06b0aa85

Branch: refs/heads/master
Commit: 06b0aa85dcf745a62a40bdd044605cbc0fa8dff0
Parents: eb58acb
Author: Andy Seaborne <andy@apache.org>
Authored: Wed Feb 3 15:44:41 2016 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Wed Feb 3 15:44:41 2016 +0000

----------------------------------------------------------------------
 .../core/journaling/DatasetGraphWithRecord.java | 247 -----------------
 .../journaling/ListBackedOperationRecord.java   |  73 -----
 .../jena/sparql/core/journaling/Operation.java  |  59 -----
 .../sparql/core/journaling/QuadOperation.java   | 133 ----------
 .../journaling/ReversibleOperationRecord.java   |  55 ----
 .../sparql/core/journaling/package-info.java    |  19 --
 .../sparql/core/journaling/TS_Journaling.java   |  27 --
 .../journaling/TestDatasetGraphWithRecord.java  | 265 -------------------
 .../TestListBackedOperationRecord.java          | 124 ---------
 .../core/journaling/TestQuadOperation.java      |  92 -------
 10 files changed, 1094 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/06b0aa85/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/DatasetGraphWithRecord.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/DatasetGraphWithRecord.java
b/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/DatasetGraphWithRecord.java
deleted file mode 100644
index 8dc67a3..0000000
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/DatasetGraphWithRecord.java
+++ /dev/null
@@ -1,247 +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.apache.jena.sparql.core.journaling;
-
-import static org.apache.jena.ext.com.google.common.collect.Lists.newArrayList;
-import static org.apache.jena.graph.Node.ANY;
-import static org.apache.jena.query.ReadWrite.WRITE;
-import static org.apache.jena.sparql.graph.GraphFactory.createGraphMem;
-
-import java.util.ArrayList;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.function.Consumer;
-
-import org.apache.jena.graph.Graph;
-import org.apache.jena.graph.Node;
-import org.apache.jena.query.ReadWrite;
-import org.apache.jena.sparql.JenaTransactionException;
-import org.apache.jena.sparql.core.DatasetGraph;
-import org.apache.jena.sparql.core.DatasetGraphWithLock;
-import org.apache.jena.sparql.core.Quad;
-import org.apache.jena.sparql.core.journaling.QuadOperation.QuadAddition;
-import org.apache.jena.sparql.core.journaling.QuadOperation.QuadDeletion;
-
-/**
- * A {@link DatasetGraph} implementation with two key affordances. First, this class keeps
a record of operations
- * conducted against it. This enables the implementation of {@link #abort()}, by reversing
that record and running it
- * backwards. Second, this class has "copy-on-add" semantics for {@link #addGraph(Node, Graph)}.
This means that the
- * transactional semantics of a given {@link Graph} are discarded on add and replaced with
those of this class, so that
- * transactional semantics are uniform and therefore useful.
- *
- * This class supports MRSW locking. It can only be used with an underlying DatasetGraph
implementation that provides
- * MRSW or weaker locking. If the provided locking is weaker, then this class will only be
able to support that level of
- * locking. Because there is only one record of operations in use in this class at any time,
using this class with an
- * underlying implementation that supports stronger-than-MRSW semantics will have unpredictable
results.
- */
-public class DatasetGraphWithRecord extends DatasetGraphWithLock {
-
-    /**
-     * A record of operations for use in rewinding transactions.
-     */
-    private ReversibleOperationRecord<QuadOperation<?, ?>> record = new ListBackedOperationRecord<>(new
ArrayList<>());
-
-    /**
-     * Mutex permitting only one writer at a time to mutate the operation record.
-     */
-    private final Lock recordLock = new ReentrantLock(true);
-
-    /**
-     * Indicates whether we should be recording operations. True iff we are in a WRITE-transaction
and not aborting.
-     */
-    private boolean recording = false;
-
-    private boolean isRecording() {
-        return recording;
-    }
-
-    private void startRecording() {
-        // enforce the single-writer constraint
-        recordLock.lock();
-        recording = true;
-    }
-
-    private void stopRecording() {
-        recording = false;
-    }
-
-    /**
-     * @param dsg the DatasetGraph that will back this one
-     */
-    public DatasetGraphWithRecord(final DatasetGraph dsg) {
-        super(dsg);
-    }
-
-    /**
-     * @param dsg the DatasetGraph that will back this one
-     * @param record the operation record to use with this DatasetGraph
-     */
-    public DatasetGraphWithRecord(final DatasetGraph dsg, final ReversibleOperationRecord<QuadOperation<?,
?>> record) {
-        super(dsg);
-        this.record = record;
-    }
-
-    /**
-     * Guards a mutation to the state of this dataset.
-     *
-     * @param data the data with which to mutate this dataset
-     * @param mutator the kind of change to make
-     */
-    private <T> void mutate(final T data, final Consumer<T> mutator) {
-        if (allowedToWrite()) mutator.accept(data);
-        else throw new JenaTransactionException("Tried to write in a non-WRITE transaction!");
-    }
-
-    @Override
-    public void add(final Quad quad) {
-        mutate(quad, _add);
-    }
-
-    @Override
-    public void delete(final Quad quad) {
-        mutate(quad, _delete);
-    }
-
-    @Override
-    public void addGraph(final Node graphName, final Graph graph) {
-        mutate(graph, _addGraph(graphName));
-    }
-
-    @Override
-    public void removeGraph(final Node graphName) {
-        mutate(graphName, _removeGraph);
-    }
-
-    /**
-     * A mutator that adds a graph to this dataset.
-     */
-    private Consumer<Graph> _addGraph(final Node name) {
-        return g -> {
-            super.addGraph(name, createGraphMem());
-            g.find(ANY, ANY, ANY).forEachRemaining(t -> add(new Quad(name, t)));
-        };
-    }
-
-    /**
-     * A mutator that removes a graph from this dataset.
-     */
-    private final Consumer<Node> _removeGraph = graphName -> {
-        // delete all triples in this graph in the backing store
-        deleteAny(graphName, ANY, ANY, ANY);
-        // remove the graph itself
-        super.removeGraph(graphName);
-    };
-
-    /**
-     * A mutator that adds a quad to this dataset.
-     */
-    private final Consumer<Quad> _add = quad -> {
-        if (!contains(quad)) {
-            super.add(quad);
-            if (isRecording()) record.accept(new QuadAddition(quad));
-        }
-    };
-
-    /**
-     * A mutator that deletes a quad from this dataset.
-     */
-    private final Consumer<Quad> _delete = quad -> {
-        if (contains(quad)) {
-            super.delete(quad);
-            if (isRecording()) record.accept(new QuadDeletion(quad));
-        }
-    };
-
-    /**
-     * @return true iff we are outside a transaction or inside a WRITE transaction
-     */
-    private boolean allowedToWrite() {
-        return !isInTransaction() || isInTransaction() && isTransactionType(WRITE);
-    }
-
-    @Override
-    public void add(final Node g, final Node s, final Node p, final Node o) {
-        add(new Quad(g, s, p, o));
-    }
-
-    @Override
-    public void delete(final Node g, final Node s, final Node p, final Node o) {
-        delete(new Quad(g, s, p, o));
-    }
-
-    @Override
-    public void deleteAny(final Node g, final Node s, final Node p, final Node o) {
-        newArrayList(find(g, s, p, o)).forEach(this::delete);
-    }
-
-    @Override
-    public void clear() {
-        deleteAny(ANY, ANY, ANY, ANY);
-        super.clear();
-    }
-
-    @Override
-    protected boolean abortImplemented() {
-        return true;
-    }
-
-    @Override
-    protected void _begin(final ReadWrite readWrite) {
-        super._begin(readWrite);
-        if (readWrite.equals(WRITE)) startRecording();
-    }
-
-    @Override
-    protected void _commit() {
-        stopRecording();
-        record.clear();
-        recordLock.unlock();
-        super._commit();
-    }
-
-    @Override
-    protected void _abort() {
-        _end();
-    }
-
-    @Override
-    protected void _end() {
-        if (isRecording()) {
-            try {
-                // stop recording operations from this thread
-                stopRecording();
-                // and unwind the record
-                record.reverse().consume(op -> op.inverse().actOn(this));
-            } finally {
-                recordLock.unlock();
-            }
-        }
-        super._end();
-    }
-
-    @Override
-    public void close() {
-        if (isRecording()) {
-            stopRecording();
-            record.clear();
-            recordLock.unlock();
-        }
-        super.close();
-    }
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/06b0aa85/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/ListBackedOperationRecord.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/ListBackedOperationRecord.java
b/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/ListBackedOperationRecord.java
deleted file mode 100644
index 81ccdbd..0000000
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/ListBackedOperationRecord.java
+++ /dev/null
@@ -1,73 +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.apache.jena.sparql.core.journaling;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.function.Consumer;
-
-import org.apache.jena.ext.com.google.common.collect.Lists;
-import org.apache.jena.sparql.core.journaling.Operation.InvertibleOperation;
-
-/**
- * A {@link ReversibleOperationRecord} using a {@link List} to record operations.
- *
- * @param <OpType> the type of {@link Operation} contained in this record
- */
-public class ListBackedOperationRecord<OpType extends InvertibleOperation<?, ?, ?,
?>>
-implements ReversibleOperationRecord<OpType> {
-
-    /**
-     * A {@link List} into which we will record operations. The iterator of this list _must_
implement {@link Iterator#remove()}
-     * for {@link #consume(Consumer)} to operate correctly!
-     */
-    private final List<OpType> operations;
-
-    /**
-     * @param ops a list into which we will record operations. The iterator of this list
_must_ implement
-     *        {@link Iterator#remove()} for {@link #consume(Consumer)} to operate correctly!
-     */
-    public ListBackedOperationRecord(final List<OpType> ops) {
-        operations = ops;
-    }
-
-    @Override
-    public void accept(final OpType op) {
-        operations.add(op);
-    }
-
-    @Override
-    public ListBackedOperationRecord<OpType> reverse() {
-        return new ListBackedOperationRecord<>(Lists.reverse(operations));
-    }
-
-    @Override
-    public void consume(final Consumer<OpType> consumer) {
-        final Iterator<OpType> i = operations.iterator();
-        while (i.hasNext()) {
-            consumer.accept(i.next());
-            i.remove();
-        }
-    }
-
-    @Override
-    public void clear() {
-        operations.clear();
-    }
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/06b0aa85/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/Operation.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/Operation.java
b/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/Operation.java
deleted file mode 100644
index 5d232ab..0000000
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/Operation.java
+++ /dev/null
@@ -1,59 +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.apache.jena.sparql.core.journaling;
-
-/**
- * An encapsulation of some operation against a service of type <code>Upon</code>
around a datum of type
- * <code>DataType</code>.
- *
- * @param <DataType> the type of data encapsulated
- * @param <ServiceType> the type of service upon which this operation acts
- */
-public interface Operation<DataType, ServiceType> {
-
-    /**
-     * @return the data encapsulated in this operation
-     */
-    DataType data();
-
-    /**
-     * Execute this operation against a given service
-     *
-     * @param service the service against which to execute
-     */
-    void actOn(ServiceType service);
-
-    /**
-     * An invertible {@link Operation}.
-     *
-     * @param <DataType> the type of data encapsulated
-     * @param <ServiceType> the type of service upon which this operation acts
-     * @param <SelfType> this type
-     * @param <InverseType> the type of the inverse operation
-     */
-    public static interface InvertibleOperation<DataType, ServiceType, SelfType extends
InvertibleOperation<DataType, ServiceType, SelfType, InverseType>, InverseType extends
InvertibleOperation<DataType, ServiceType, InverseType, SelfType>>
-    extends Operation<DataType, ServiceType> {
-        /**
-         * Creates an inverse operation for this data.
-         *
-         * @return the inverse of this operation on the same data and against the same type
of service.
-         */
-        InverseType inverse();
-    }
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/06b0aa85/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/QuadOperation.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/QuadOperation.java
b/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/QuadOperation.java
deleted file mode 100644
index 29a5eaf..0000000
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/QuadOperation.java
+++ /dev/null
@@ -1,133 +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.apache.jena.sparql.core.journaling;
-
-import static java.util.Objects.hash;
-
-import org.apache.jena.sparql.core.DatasetGraph;
-import org.apache.jena.sparql.core.Quad;
-import org.apache.jena.sparql.core.journaling.Operation.InvertibleOperation;
-
-/**
- * An {@link Operation} sending a {@link Quad} against a {@link DatasetGraph}.
- *
- * @param <SelfType> the selftype of this operation
- * @param <InverseType> the type of this operation's inverse
- *
- */
-public abstract class QuadOperation<SelfType extends QuadOperation<SelfType, InverseType>,
InverseType extends QuadOperation<InverseType, SelfType>>
-implements InvertibleOperation<Quad, DatasetGraph, SelfType, InverseType> {
-
-    protected final Quad quad;
-
-    /**
-     * @param q the quad that is being operated with
-     */
-    public QuadOperation(final Quad q) {
-        this.quad = q;
-    }
-
-    /**
-     * The addition of a {@link Quad} to a {@link DatasetGraph}
-     */
-    public static class QuadAddition extends QuadOperation<QuadAddition, QuadDeletion>
{
-
-        /**
-         * @param q the quad that is being operated with
-         */
-        public QuadAddition(final Quad q) {
-            super(q);
-        }
-
-        @Override
-        public Quad data() {
-            return quad;
-        }
-
-        @Override
-        public QuadDeletion inverse() {
-            return new QuadDeletion(data());
-        }
-
-        @Override
-        public void actOn(final DatasetGraph dsg) {
-            dsg.add(data());
-        }
-
-        @Override
-        public String toString() {
-            return "ADD " + super.toString();
-        }
-
-        @Override
-        public int hashCode() {
-            return hash(data());
-        }
-
-        @Override
-        public boolean equals(final Object other) {
-            if (other instanceof QuadAddition) return data().equals(((QuadAddition) other).data());
-            return false;
-        }
-    }
-
-    /**
-     * The deletion of a {@link Quad} from a {@link DatasetGraph}
-     */
-    public static class QuadDeletion extends QuadOperation<QuadDeletion, QuadAddition>
{
-
-        /**
-         * @param q the quad that is being operated with
-         */
-        public QuadDeletion(final Quad q) {
-            super(q);
-        }
-
-        @Override
-        public Quad data() {
-            return quad;
-        }
-
-        @Override
-        public QuadAddition inverse() {
-            return new QuadAddition(data());
-        }
-
-        @Override
-        public void actOn(final DatasetGraph dsg) {
-            dsg.delete(data());
-        }
-
-        @Override
-        public String toString() {
-            return "DELETE " + super.toString();
-        }
-
-        @Override
-        public int hashCode() {
-            return hash(data());
-        }
-
-        @Override
-        public boolean equals(final Object other) {
-            if (other instanceof QuadDeletion) return data().equals(((QuadDeletion) other).data());
-            return false;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/06b0aa85/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/ReversibleOperationRecord.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/ReversibleOperationRecord.java
b/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/ReversibleOperationRecord.java
deleted file mode 100644
index 3cbf37d..0000000
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/ReversibleOperationRecord.java
+++ /dev/null
@@ -1,55 +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.apache.jena.sparql.core.journaling;
-
-import java.util.function.Consumer;
-
-/**
- * A reversible record of a series of operations.
- *
- * @param <OpType> the type of operation recorded
- */
-public interface ReversibleOperationRecord<OpType extends Operation<?, ?>> extends
Consumer<OpType> {
-
-    /**
-     * For each {@link Operation} in this record from the least-recently added to the most-recently
added, use
-     * <code>consumer::accept</code> on that operation and then discard that
operation from the record.
-     *
-     * @param consumer the consumer to use in consuming this record
-     */
-    void consume(Consumer<OpType> consumer);
-
-    /**
-     * Clear this record.
-     */
-    default void clear() {
-        consume(op -> {}); // /dev/null
-    }
-
-    /**
-     * Produces a time-reversed version of this record. If a record is compact (i.e. every
operation in it caused a
-     * definite change in the state of the service against which it was run) and this record
is run against a service,
-     * and then its reverse is run against a service with each operation inverted, no change
should result in the state
-     * of that service. This method may not produce an independent object: in other words,
it may not be possible to use
-     * {@link #reverse()} on the result of this method to recover the original.
-     *
-     * @return the reverse of this record
-     */
-    ReversibleOperationRecord<OpType> reverse();
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/06b0aa85/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/package-info.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/package-info.java
b/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/package-info.java
deleted file mode 100644
index 2f66381..0000000
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/journaling/package-info.java
+++ /dev/null
@@ -1,19 +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.apache.jena.sparql.core.journaling;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jena/blob/06b0aa85/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TS_Journaling.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TS_Journaling.java
b/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TS_Journaling.java
deleted file mode 100644
index 9741a39..0000000
--- a/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TS_Journaling.java
+++ /dev/null
@@ -1,27 +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.apache.jena.sparql.core.journaling;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@RunWith(Suite.class)
-@SuiteClasses({ TestQuadOperation.class, TestListBackedOperationRecord.class, TestDatasetGraphWithRecord.class
})
-public class TS_Journaling {}

http://git-wip-us.apache.org/repos/asf/jena/blob/06b0aa85/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TestDatasetGraphWithRecord.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TestDatasetGraphWithRecord.java
b/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TestDatasetGraphWithRecord.java
deleted file mode 100644
index 61fea7f..0000000
--- a/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TestDatasetGraphWithRecord.java
+++ /dev/null
@@ -1,265 +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.apache.jena.sparql.core.journaling;
-
-import static org.apache.jena.graph.Node.ANY;
-import static org.apache.jena.graph.NodeFactory.createURI;
-import static org.apache.jena.query.ReadWrite.READ;
-import static org.apache.jena.query.ReadWrite.WRITE;
-import static org.apache.jena.sparql.graph.GraphFactory.createGraphMem;
-import static org.apache.jena.sparql.sse.SSE.parseTriple;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.jena.graph.Graph;
-import org.apache.jena.graph.Node;
-import org.apache.jena.query.Dataset;
-import org.apache.jena.query.DatasetFactory;
-import org.apache.jena.sparql.JenaTransactionException;
-import org.apache.jena.sparql.core.* ;
-import org.apache.jena.sparql.core.journaling.QuadOperation.QuadDeletion;
-import org.apache.jena.sparql.core.journaling.TestDatasetGraphWithRecord.TestDatasetGraphWithRecordAsDSG;
-import org.apache.jena.sparql.core.journaling.TestDatasetGraphWithRecord.TestDatasetGraphWithRecordConcurrency;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@RunWith(Suite.class)
-@SuiteClasses({ TestDatasetGraphWithRecordAsDSG.class, TestDatasetGraphWithRecordConcurrency.class
})
-public class TestDatasetGraphWithRecord {
-
-	public static class TestDatasetGraphWithRecordAsDSG extends AbstractDatasetGraphTests {
-		private static final Node graphName = createURI("some-graph");
-		private static final Quad q1 = new Quad(graphName, parseTriple("(<subject1> <predicate>
<object1>)"));
-		private static final Quad q2 = new Quad(graphName, parseTriple("(<subject1> <predicate>
<object2>)"));
-		private static final Quad q3 = new Quad(graphName, parseTriple("(<subject2> <predicate>
<object2>)"));
-
-		@Override
-		protected DatasetGraph emptyDataset() {
-			return new DatasetGraphWithRecord(DatasetGraphFactory.create());
-		}
-
-		/**
-		 * Adding a graph via {@link DatasetGraphWithRecord#addGraph(Node, org.apache.jena.graph.Graph)}
should copy the
-		 * tuples from that graph, instead of creating a reference to that graph.
-		 */
-		@Test
-		public void testAddGraphCopiesTuples() {
-			final Graph graph = createGraphMem();
-			graph.add(q1.asTriple());
-			graph.add(q2.asTriple());
-
-			final Dataset dataset = DatasetFactory.wrap(emptyDataset());
-			final DatasetGraph dsg = dataset.asDatasetGraph();
-
-			dataset.begin(WRITE);
-			try {
-				dsg.addGraph(graphName, graph);
-				dataset.commit();
-			} finally {
-				dataset.end();
-			}
-
-			assertTrue(dsg.contains(q1));
-			assertTrue(dsg.contains(q2));
-			// we add a new triple to our original graph
-			graph.add(q3.asTriple());
-			// which should not show up in the dataset, because of our "copy-on-addGraph" semantics
-			assertFalse(dsg.contains(ANY, q3.getSubject(), q3.getPredicate(), q3.getObject()));
-			dataset.close();
-		}
-
-		/**
-		 * {@link Transactional#abort()} is properly supported.
-		 */
-		@Test
-		public void testSimpleAbort() {
-			final Dataset dataset = DatasetFactory.wrap(emptyDataset());
-			final DatasetGraph dsg = dataset.asDatasetGraph();
-
-			dataset.begin(WRITE);
-			try {
-				dsg.addGraph(graphName, createGraphMem());
-				dsg.add(q1);
-				dataset.commit();
-			} finally {
-				dataset.end();
-			}
-			try {
-				dataset.begin(WRITE);
-				dsg.add(q2);
-				dsg.add(q3);
-				dsg.delete(q3);
-				dsg.add(q3);
-				dataset.abort();
-			} finally {
-				dataset.end();
-			}
-			assertTrue(dsg.contains(q1));
-			assertFalse(dsg.contains(q2));
-			assertFalse(dsg.contains(q3));
-			dataset.close();
-		}
-
-		/**
-		 * Neither adding an already-present quad nor removing an absent quad should produce any
change in the record.
-		 */
-		@Test
-		public void testRecordShouldBeCompact() {
-			final List<QuadOperation<?, ?>> record = new ArrayList<>();
-			final Dataset dataset = DatasetFactory.wrap(new DatasetGraphWithRecord(
-					new DatasetGraphMap(createGraphMem()), new ListBackedOperationRecord<>(record)));
-			final DatasetGraph dsg = dataset.asDatasetGraph();
-
-			dataset.begin(WRITE);
-			try {
-				dsg.addGraph(graphName, createGraphMem());
-				// add the same quad twice
-				dsg.add(q1);
-				dsg.add(q1);
-				// now there should be only one operation in the journal
-				assertEquals(1, record.size());
-
-				dsg.delete(q1);
-				// now there should be two operations in the journal
-				assertEquals(2, record.size());
-				// delete the quad we've already deleted
-				dsg.delete(q1);
-				// now there should still be only two operations in the journal
-				assertEquals(2, record.size());
-			} finally {
-				dataset.end();
-			}
-			dataset.close();
-		}
-
-		/**
-		 * {@link DatasetGraphWithRecord} can only be mutated within a WRITE transaction, not any
other kind of
-		 * transaction.
-		 */
-		@Test(expected = JenaTransactionException.class)
-		public void testDatasetGraphWithRecordIsWriteTransactionalOnlyForGraphWrites() {
-			final Dataset dataset = DatasetFactory.wrap(emptyDataset());
-			final DatasetGraph dsg = dataset.asDatasetGraph();
-
-			dataset.begin(READ);
-			try {
-				dsg.addGraph(graphName, createGraphMem());
-			} finally {
-				dataset.end();
-			}
-		}
-
-		/**
-		 * {@link DatasetGraphWithRecord} can only be mutated within a WRITE transaction, not any
other kind of
-		 * transaction.
-		 */
-		@Test(expected = JenaTransactionException.class)
-		public void testDatasetGraphWithRecordIsWriteTransactionalOnlyForTupleWrites() {
-			final Dataset dataset = DatasetFactory.wrap(emptyDataset());
-			final DatasetGraph dsg = dataset.asDatasetGraph();
-
-			dataset.begin(READ);
-			try {
-				dsg.add(q1);
-			} finally {
-				dataset.end();
-			}
-		}
-
-		/**
-		 * {@link DatasetGraphWithRecord#removeGraph(Node)} should leave a record of quads removed.
-		 */
-		@Test
-		public void testRemoveGraph() {
-			final List<QuadOperation<?, ?>> record = new ArrayList<>();
-			final Dataset dataset = DatasetFactory.wrap(new DatasetGraphWithRecord(
-					new DatasetGraphMap(createGraphMem()), new ListBackedOperationRecord<>(record)));
-			final DatasetGraph dsg = dataset.asDatasetGraph();
-
-			dataset.begin(WRITE);
-			try {
-				dsg.addGraph(graphName, createGraphMem());
-				dsg.add(q1);
-				dataset.commit();
-			} finally {
-				dataset.end();
-			}
-			assertTrue(dsg.containsGraph(graphName));
-			assertTrue(dsg.contains(q1));
-			dataset.begin(WRITE);
-			try {
-				dsg.removeGraph(graphName);
-				// we should see a single deletion resulting from the removeGraph
-				assertEquals(1, record.size());
-				assertEquals(new QuadDeletion(q1), record.get(0));
-				dataset.commit();
-			} finally {
-				dataset.end();
-			}
-			assertFalse(dsg.containsGraph(graphName));
-			assertFalse(dsg.contains(ANY, q1.getSubject(), q1.getPredicate(), q1.getObject()));
-			assertTrue(dsg.isEmpty());
-		}
-
-		/**
-		 * {@link DatasetGraphWithRecord#clear()} should leave a record of quads removed.
-		 */
-		@Test
-		public void testClear() {
-			final List<QuadOperation<?, ?>> record = new ArrayList<>();
-			final Dataset dataset = DatasetFactory.wrap(new DatasetGraphWithRecord(
-					new DatasetGraphMap(createGraphMem()), new ListBackedOperationRecord<>(record)));
-			final DatasetGraph dsg = dataset.asDatasetGraph();
-
-			dataset.begin(WRITE);
-			try {
-				dsg.addGraph(graphName, createGraphMem());
-				dsg.add(q1);
-				dataset.commit();
-			} finally {
-				dataset.end();
-			}
-			assertTrue(dsg.contains(q1));
-			dataset.begin(WRITE);
-			try {
-				dsg.clear();
-				// we should see a single deletion resulting from the clear
-				assertEquals(1, record.size());
-				assertEquals(new QuadDeletion(q1), record.get(0));
-				dataset.commit();
-			} finally {
-				dataset.end();
-			}
-			assertTrue(dsg.isEmpty());
-		}
-	}
-
-	public static class TestDatasetGraphWithRecordConcurrency extends TestDatasetGraphWithLock
{
-		@Override
-		protected Dataset createDataset() {
-			return DatasetFactory.wrap(new DatasetGraphWithRecord(DatasetGraphFactory.create()));
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/06b0aa85/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TestListBackedOperationRecord.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TestListBackedOperationRecord.java
b/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TestListBackedOperationRecord.java
deleted file mode 100644
index d2e9d40..0000000
--- a/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TestListBackedOperationRecord.java
+++ /dev/null
@@ -1,124 +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.apache.jena.sparql.core.journaling;
-
-import static java.util.Arrays.asList;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.jena.sparql.core.journaling.Operation.InvertibleOperation;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class TestListBackedOperationRecord extends Assert {
-
-	private static interface MockOp extends InvertibleOperation<Object, Object, MockOp, MockOp>
{}
-
-	private final MockOp mockOp1 = new MockOp() {
-
-		@Override
-		public MockOp inverse() {
-			return this;
-		}
-
-		@Override
-		public Object data() {
-			return null;
-		}
-
-		@Override
-		public void actOn(final Object service) {}
-	};
-	private final MockOp mockOp2 = mockOp1;
-	private MockOp mockOp3 = mockOp2;
-	private List<MockOp> ops;
-
-	@Before
-	public void setup() {
-		ops = new ArrayList<>(asList(mockOp1, mockOp2, mockOp3));
-	}
-
-	@Test
-	public void testAdd() {
-		final List<MockOp> results = new ArrayList<>();
-		final ListBackedOperationRecord<MockOp> testRecord = new ListBackedOperationRecord<>(results);
-		testRecord.accept(mockOp1);
-		testRecord.accept(mockOp2);
-		testRecord.accept(mockOp3);
-		assertEquals(3, results.size());
-		assertEquals(mockOp1, results.get(0));
-		assertEquals(mockOp2, results.get(1));
-		assertEquals(mockOp3, results.get(2));
-	}
-
-	@Test
-	public void testConsume() {
-		class MarkerException extends RuntimeException {}
-		ListBackedOperationRecord<MockOp> testRecord = new ListBackedOperationRecord<>(ops);
-		testRecord.consume(op -> {}); // /dev/null
-		assertTrue(ops.isEmpty());
-		// now let's try with a problematic consumer
-		mockOp3 = new MockOp() {
-
-			@Override
-			public MockOp inverse() {
-				throw new MarkerException();
-			}
-
-			@Override
-			public Object data() {
-				return null;
-			}
-
-			@Override
-			public void actOn(final Object service) {}
-
-		};
-		ops = new ArrayList<>(asList(mockOp1, mockOp2, mockOp3));
-		testRecord = new ListBackedOperationRecord<>(ops);
-		try {
-			testRecord.consume(MockOp::inverse);
-			fail("Should not have been able to consume the last op!");
-		} catch (MarkerException e) {
-			// should be one op left
-			assertEquals(1, ops.size());
-			// and it should be mockOp3
-			assertEquals(mockOp3, ops.get(0));
-		}
-	}
-
-	@Test
-	public void testClear() {
-		final ListBackedOperationRecord<MockOp> testRecord = new ListBackedOperationRecord<>(ops);
-		testRecord.clear();
-		assertTrue(ops.isEmpty());
-	}
-
-	@Test
-	public void testReverse() {
-		final ListBackedOperationRecord<MockOp> testRecordReversed = new ListBackedOperationRecord<>(ops).reverse();
-		final List<MockOp> results = new ArrayList<>();
-		testRecordReversed.consume(results::add);
-		assertEquals(mockOp3, results.get(0));
-		assertEquals(mockOp2, results.get(1));
-		assertEquals(mockOp1, results.get(2));
-	}
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/06b0aa85/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TestQuadOperation.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TestQuadOperation.java
b/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TestQuadOperation.java
deleted file mode 100644
index 04713b3..0000000
--- a/jena-arq/src/test/java/org/apache/jena/sparql/core/journaling/TestQuadOperation.java
+++ /dev/null
@@ -1,92 +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.apache.jena.sparql.core.journaling;
-
-import static org.apache.jena.graph.NodeFactory.createBlankNode;
-import static org.apache.jena.graph.NodeFactory.createURI;
-import static org.apache.jena.sparql.core.DatasetGraphFactory.createTxnMem;
-
-import org.apache.jena.graph.Node;
-import org.apache.jena.mem.GraphMem;
-import org.apache.jena.sparql.core.DatasetGraph;
-import org.apache.jena.sparql.core.DatasetGraphFactory;
-import org.apache.jena.sparql.core.Quad;
-import org.apache.jena.sparql.core.journaling.QuadOperation.QuadAddition;
-import org.apache.jena.sparql.core.journaling.QuadOperation.QuadDeletion;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class TestQuadOperation extends Assert {
-
-	private static final Node graphName = createURI("info:graph");
-	private static final Quad q = new Quad(graphName, createBlankNode(), createURI("info:test"),
createBlankNode());
-	private static final QuadAddition quadAddition = new QuadAddition(q);
-	private static final QuadDeletion quadDeletion = new QuadDeletion(q);
-
-	@Test
-	public void testEquals() {
-		assertEquals(new QuadAddition(q), new QuadAddition(q));
-		assertEquals(new QuadDeletion(q), new QuadDeletion(q));
-		assertNotEquals(new QuadAddition(q), new QuadDeletion(q));
-		assertNotEquals(new QuadDeletion(q), new QuadAddition(q));
-		assertNotEquals(new QuadAddition(q), q);
-		assertNotEquals(new QuadDeletion(q), q);
-	}
-
-	@Test
-	public void testActOn() {
-		final DatasetGraph testDsg = createTxnMem();
-		quadAddition.actOn(testDsg);
-		assertTrue(testDsg.contains(q));
-		quadDeletion.actOn(testDsg);
-		assertFalse(testDsg.contains(q));
-	}
-
-	@Test
-	public void testInversion() {
-		final DatasetGraph testDsg = createTxnMem();
-		quadDeletion.inverse().actOn(testDsg);
-		assertTrue(testDsg.contains(q));
-		quadAddition.inverse().actOn(testDsg);
-		assertFalse(testDsg.contains(q));
-	}
-
-	@Test
-	public void testInversionInSequence() {
-		final DatasetGraph testDsg = createTxnMem();
-		quadAddition.actOn(testDsg);
-		assertTrue(testDsg.contains(q));
-		quadAddition.inverse().actOn(testDsg);
-		assertFalse(testDsg.contains(q));
-	}
-
-	@Test
-	public void testWithActualGraphStore() {
-		final DatasetGraph realDsg = DatasetGraphFactory.create();
-		realDsg.addGraph(graphName, new GraphMem());
-		quadAddition.actOn(realDsg);
-		assertTrue(realDsg.contains(q));
-		quadDeletion.actOn(realDsg);
-		assertFalse(realDsg.contains(q));
-		quadAddition.actOn(realDsg);
-		assertTrue(realDsg.contains(q));
-		quadAddition.inverse().actOn(realDsg);
-		assertFalse(realDsg.contains(q));
-	}
-}


Mime
View raw message