jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1528585 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment: AbstractStore.java SegmentNodeStoreService.java file/FileStore.java memory/MemoryStore.java mongo/MongoStore.java
Date Wed, 02 Oct 2013 18:16:26 GMT
Author: jukka
Date: Wed Oct  2 18:16:26 2013
New Revision: 1528585

URL: http://svn.apache.org/r1528585
Log:
OAK-1032: SegmentMK: One SegmentWriter per SegmentNodeStore

Push the SegmentWriter instance to the AbstractStore base class

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/AbstractStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/memory/MemoryStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/mongo/MongoStore.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/AbstractStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/AbstractStore.java?rev=1528585&r1=1528584&r2=1528585&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/AbstractStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/AbstractStore.java
Wed Oct  2 18:16:26 2013
@@ -27,6 +27,13 @@ public abstract class AbstractStore impl
     private final Cache<RecordId, Object> records =
             CacheLIRS.newBuilder().maximumSize(1000).build();
 
+    private final SegmentWriter writer = new SegmentWriter(this);
+
+    @Override
+    public SegmentWriter getWriter() {
+        return writer;
+    }
+
     @Override
     public <T> T getRecord(RecordId id, Callable<T> loader) {
         @SuppressWarnings("unchecked")

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java?rev=1528585&r1=1528584&r2=1528585&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
Wed Oct  2 18:16:26 2013
@@ -119,8 +119,7 @@ public class SegmentNodeStoreService imp
             int cache = Integer.parseInt(String.valueOf(properties.get(CACHE)));
 
             mongo = new Mongo(host, port);
-            SegmentCache sc = SegmentCache.create(cache * MB);
-            store = new MongoStore(mongo.getDB(db), sc);
+            store = new MongoStore(mongo.getDB(db), cache * MB);
         }
 
         delegate = new SegmentNodeStore(store);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java?rev=1528585&r1=1528584&r2=1528585&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
Wed Oct  2 18:16:26 2013
@@ -39,7 +39,6 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.segment.Segment;
 import org.apache.jackrabbit.oak.plugins.segment.SegmentCache;
 import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState;
-import org.apache.jackrabbit.oak.plugins.segment.SegmentWriter;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 
 public class FileStore extends AbstractStore {
@@ -64,8 +63,6 @@ public class FileStore extends AbstractS
 
     private final SegmentCache cache = SegmentCache.create();
 
-    private final SegmentWriter writer = new SegmentWriter(this);
-
     public FileStore(File directory, int maxFileSize, boolean memoryMapping)
             throws IOException {
         checkNotNull(directory).mkdirs();
@@ -83,7 +80,7 @@ public class FileStore extends AbstractS
             }
         }
 
-        Segment segment = writer.getDummySegment();
+        Segment segment = getWriter().getDummySegment();
         for (TarFile tar : files) {
             ByteBuffer buffer = tar.readEntry(JOURNALS_UUID);
             if (buffer != null) {
@@ -110,11 +107,6 @@ public class FileStore extends AbstractS
     }
 
     @Override
-    public SegmentWriter getWriter() {
-        return writer;
-    }
-
-    @Override
     public synchronized void close() {
         try {
             for (TarFile file : files) {
@@ -141,7 +133,7 @@ public class FileStore extends AbstractS
     @Override
     public Segment readSegment(final UUID id) {
         try {
-            Segment segment = writer.getCurrentSegment(id);
+            Segment segment = getWriter().getCurrentSegment(id);
             if (segment == null) {
                 segment = cache.getSegment(id, new Callable<Segment>() {
                     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/memory/MemoryStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/memory/MemoryStore.java?rev=1528585&r1=1528584&r2=1528585&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/memory/MemoryStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/memory/MemoryStore.java
Wed Oct  2 18:16:26 2013
@@ -27,7 +27,6 @@ import java.util.concurrent.ConcurrentMa
 import org.apache.jackrabbit.oak.plugins.segment.AbstractStore;
 import org.apache.jackrabbit.oak.plugins.segment.Journal;
 import org.apache.jackrabbit.oak.plugins.segment.Segment;
-import org.apache.jackrabbit.oak.plugins.segment.SegmentWriter;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
@@ -41,8 +40,6 @@ public class MemoryStore extends Abstrac
     private final ConcurrentMap<UUID, Segment> segments =
             Maps.newConcurrentMap();
 
-    private final SegmentWriter writer = new SegmentWriter(this);
-
     public MemoryStore(NodeState root) {
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setChildNode("root", root);
@@ -54,11 +51,6 @@ public class MemoryStore extends Abstrac
     }
 
     @Override
-    public SegmentWriter getWriter() {
-        return writer;
-    }
-
-    @Override
     public void close() {
     }
 
@@ -74,7 +66,7 @@ public class MemoryStore extends Abstrac
 
     @Override
     public Segment readSegment(UUID id) {
-        Segment segment = writer.getCurrentSegment(id);
+        Segment segment = getWriter().getCurrentSegment(id);
         if (segment == null) {
             segment = segments.get(id);
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/mongo/MongoStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/mongo/MongoStore.java?rev=1528585&r1=1528584&r2=1528585&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/mongo/MongoStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/mongo/MongoStore.java
Wed Oct  2 18:16:26 2013
@@ -33,7 +33,6 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.segment.Journal;
 import org.apache.jackrabbit.oak.plugins.segment.Segment;
 import org.apache.jackrabbit.oak.plugins.segment.SegmentCache;
-import org.apache.jackrabbit.oak.plugins.segment.SegmentWriter;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 
 import com.google.common.collect.Lists;
@@ -57,12 +56,10 @@ public class MongoStore extends Abstract
 
     private final SegmentCache cache;
 
-    private final SegmentWriter writer = new SegmentWriter(this);
-
-    public MongoStore(DB db, SegmentCache cache) {
+    public MongoStore(DB db, int cacheSize) {
         this.db = checkNotNull(db);
         this.segments = db.getCollection("segments");
-        this.cache = cache;
+        this.cache = SegmentCache.create(cacheSize);
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.child("root");
         journals.put("root", new MongoJournal(
@@ -70,21 +67,11 @@ public class MongoStore extends Abstract
                 concern, builder.getNodeState()));
     }
 
-    public MongoStore(DB db, int cacheSize) {
-        this(db, SegmentCache.create(cacheSize));
-    }
-
-
     public MongoStore(Mongo mongo, int cacheSize) {
         this(mongo.getDB("Oak"), cacheSize);
     }
 
     @Override
-    public SegmentWriter getWriter() {
-        return writer;
-    }
-
-    @Override
     public void close() {
     }
 
@@ -102,7 +89,7 @@ public class MongoStore extends Abstract
     @Override
     public Segment readSegment(final UUID segmentId) {
         try {
-            Segment segment = writer.getCurrentSegment(segmentId);
+            Segment segment = getWriter().getCurrentSegment(segmentId);
             if (segment == null) {
                 segment = cache.getSegment(segmentId, new Callable<Segment>() {
                     @Override



Mime
View raw message