You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2013/07/22 13:10:33 UTC
git commit: the commit monitor in the value factory was not properly
done, because it would not ensure that data was committed
Updated Branches:
refs/heads/develop a6a441011 -> 28aa7006f
the commit monitor in the value factory was not properly done, because it would not ensure that data was committed
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/28aa7006
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/28aa7006
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/28aa7006
Branch: refs/heads/develop
Commit: 28aa7006fca0fa6d1a308a74b04bb2984bcca0e9
Parents: a6a4410
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Mon Jul 22 13:10:26 2013 +0200
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Mon Jul 22 13:10:26 2013 +0200
----------------------------------------------------------------------
.../marmotta/kiwi/sail/KiWiValueFactory.java | 36 +++++++++++---------
1 file changed, 19 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/28aa7006/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
index 3331704..477efaf 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
@@ -90,7 +90,13 @@ public class KiWiValueFactory implements ValueFactory {
// used for generating sequence numbers for RDF nodes
private KiWiConnection batchConnection;
- private Monitor commitLock;
+ private Monitor commitLock = new Monitor();
+ private Monitor.Guard commitGuard = new Monitor.Guard(commitLock) {
+ @Override
+ public boolean isSatisfied() {
+ return batchCommit && nodeBatch.size() > 0;
+ }
+ };
public KiWiValueFactory(KiWiStore store, String defaultContext) {
resourceLocks = CacheBuilder.newBuilder().weakValues().build(new LockCacheLoader());
@@ -104,7 +110,6 @@ public class KiWiValueFactory implements ValueFactory {
// batch commits
this.nodeBatch = new ArrayList<KiWiNode>(batchSize);
- this.commitLock = new Monitor();
this.batchCommit = store.getPersistence().getConfiguration().isBatchCommit();
this.batchSize = store.getPersistence().getConfiguration().getBatchSize();
@@ -757,30 +762,26 @@ public class KiWiValueFactory implements ValueFactory {
* the node batch.
*/
public void flushBatch(KiWiConnection con) throws SQLException {
- if(commitLock.tryEnter()) {
+ if(commitLock.enterIf(commitGuard)) {
try {
- if(batchCommit && nodeBatch.size() > 0) {
- con.startNodeBatch();
-
- synchronized (nodeBatch) {
- for(KiWiNode n : nodeBatch) {
- con.storeNode(n,true);
- }
- nodeBatch.clear();
+ con.startNodeBatch();
- batchLiteralLookup.clear();
- batchUriLookup.clear();
- batchBNodeLookup.clear();
+ synchronized (nodeBatch) {
+ for(KiWiNode n : nodeBatch) {
+ con.storeNode(n,true);
}
+ nodeBatch.clear();
- con.commitNodeBatch();
-
+ batchLiteralLookup.clear();
+ batchUriLookup.clear();
+ batchBNodeLookup.clear();
}
+
+ con.commitNodeBatch();
} finally {
commitLock.leave();
}
}
-
}
public void close() {
@@ -803,4 +804,5 @@ public class KiWiValueFactory implements ValueFactory {
return new Monitor();
}
}
+
}