jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1575327 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/ o...
Date Fri, 07 Mar 2014 17:09:02 GMT
Author: jukka
Date: Fri Mar  7 17:09:02 2014
New Revision: 1575327

URL: http://svn.apache.org/r1575327
Log:
OAK-633: SegmentMK: Hierarchy of journals

Drop this feature for now as we won't have time to complete it
before Oak 1.0 / Jackrabbit 3.0, and keeping it around complicates
other work.

Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/Journal.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/memory/MemoryJournal.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/JournalTest.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreBackup.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreRestore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.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/http/HttpStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/memory/MemoryStore.java
    jackrabbit/oak/trunk/oak-http/src/main/java/org/apache/jackrabbit/oak/http/segment/SegmentServlet.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreBackup.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreBackup.java?rev=1575327&r1=1575326&r2=1575327&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreBackup.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreBackup.java
Fri Mar  7 17:09:02 2014
@@ -22,7 +22,6 @@ import java.io.File;
 import java.io.IOException;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.jackrabbit.oak.plugins.segment.Journal;
 import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeBuilder;
 import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState;
 import org.apache.jackrabbit.oak.plugins.segment.file.FileStore;
@@ -56,10 +55,7 @@ public class FileStoreBackup {
         // 2. init filestore
         FileStore backup = new FileStore(destination, MAX_FILE_SIZE, false);
         try {
-            Journal journal = backup.getJournal("root");
-
-            SegmentNodeState state = new SegmentNodeState(
-                    backup.getWriter().getDummySegment(), journal.getHead());
+            SegmentNodeState state = backup.getHead();
             SegmentNodeBuilder builder = state.builder();
 
             String beforeCheckpoint = state.getString("checkpoint");
@@ -81,8 +77,7 @@ public class FileStoreBackup {
             builder.setProperty("checkpoint", checkpoint);
 
             // 4. commit the backup
-            journal.setHead(
-                    state.getRecordId(), builder.getNodeState().getRecordId());
+            backup.setHead(state, builder.getNodeState());
         } finally {
             backup.close();
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreRestore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreRestore.java?rev=1575327&r1=1575326&r2=1575327&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreRestore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/backup/FileStoreRestore.java
Fri Mar  7 17:09:02 2014
@@ -22,7 +22,6 @@ import java.io.File;
 import java.io.IOException;
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.plugins.segment.Journal;
 import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState;
 import org.apache.jackrabbit.oak.plugins.segment.file.FileStore;
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
@@ -54,9 +53,7 @@ public class FileStoreRestore {
         // 2. init filestore
         FileStore restore = new FileStore(source, MAX_FILE_SIZE, false);
         try {
-            Journal journal = restore.getJournal("root");
-            SegmentNodeState state = new SegmentNodeState(restore.getWriter()
-                    .getDummySegment(), journal.getHead());
+            SegmentNodeState state = restore.getHead();
             restore(state.getChildNode("root"), store);
         } finally {
             restore.close();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java?rev=1575327&r1=1575326&r2=1575327&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
Fri Mar  7 17:09:02 2014
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.oak.plugin
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
 import static java.lang.System.currentTimeMillis;
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import static java.util.concurrent.TimeUnit.NANOSECONDS;
@@ -56,8 +55,6 @@ public class SegmentNodeStore implements
 
     private final SegmentStore store;
 
-    private final Journal journal;
-
     private final ChangeDispatcher changeDispatcher;
 
     /**
@@ -74,21 +71,14 @@ public class SegmentNodeStore implements
 
     private long maximumBackoff = MILLISECONDS.convert(10, SECONDS);
 
-    public SegmentNodeStore(SegmentStore store, String journal) {
+    public SegmentNodeStore(SegmentStore store) {
         this.store = store;
-        this.journal = store.getJournal(journal);
-        checkState(this.journal != null);
-        this.head = new AtomicReference<SegmentNodeState>(new SegmentNodeState(
-                store.getWriter().getDummySegment(), this.journal.getHead()));
+        this.head = new AtomicReference<SegmentNodeState>(store.getHead());
         this.changeDispatcher = new ChangeDispatcher(getRoot());
     }
 
-    public SegmentNodeStore(SegmentStore store) {
-        this(store, "root");
-    }
-
     public SegmentNodeStore() {
-        this(new MemoryStore(), "root");
+        this(new MemoryStore());
     }
 
     void setMaximumBackoff(long max) {
@@ -100,10 +90,8 @@ public class SegmentNodeStore implements
      * permit from the {@link #commitSemaphore}.
      */
     private void refreshHead() {
-        RecordId id = journal.getHead();
-        if (!id.equals(head.get().getRecordId())) {
-            SegmentNodeState state = new SegmentNodeState(
-                    store.getWriter().getDummySegment(), id);
+        SegmentNodeState state = store.getHead();
+        if (!state.getRecordId().equals(head.get().getRecordId())) {
             head.set(state);
             changeDispatcher.contentChanged(state.getChildNode(ROOT), null);
         }
@@ -206,7 +194,6 @@ public class SegmentNodeStore implements
                     refreshHead();
 
                     SegmentNodeState state = head.get();
-                    RecordId ri = state.getRecordId();
 
                     SegmentNodeBuilder builder = state.builder();
                     NodeBuilder cp = builder.child(name);
@@ -214,8 +201,7 @@ public class SegmentNodeStore implements
                             + lifetime);
                     cp.setChildNode(ROOT, state.getChildNode(ROOT));
 
-                    if (journal.setHead(ri, builder.getNodeState()
-                            .getRecordId())) {
+                    if (store.setHead(state, builder.getNodeState())) {
                         refreshHead();
                         return name;
                     }
@@ -265,7 +251,7 @@ public class SegmentNodeStore implements
             SegmentNodeState after = builder.getNodeState();
 
             refreshHead();
-            if (journal.setHead(before.getRecordId(), after.getRecordId())) {
+            if (store.setHead(before, after)) {
                 head.set(after);
                 changeDispatcher.contentChanged(after.getChildNode(ROOT), info);
                 refreshHead();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java?rev=1575327&r1=1575326&r2=1575327&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentStore.java
Fri Mar  7 17:09:02 2014
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.plugin
 import java.util.UUID;
 
 import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.Blob;
 
@@ -27,13 +28,14 @@ public interface SegmentStore {
     SegmentWriter getWriter();
 
     /**
-     * Returns the named journal.
+     * Returns the head state.
      *
-     * @param name journal name
-     * @return named journal, or {@code null} if not found
+     * @return head state
      */
-    @CheckForNull
-    Journal getJournal(String name);
+    @Nonnull
+    SegmentNodeState getHead();
+
+    boolean setHead(SegmentNodeState base, SegmentNodeState head);
 
     /**
      * Reads the identified segment from this 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=1575327&r1=1575326&r2=1575327&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
Fri Mar  7 17:09:02 2014
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.oak.plugins.segment.file;
 
-import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 import static com.google.common.collect.Lists.newArrayList;
@@ -38,9 +37,9 @@ import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.plugins.segment.AbstractStore;
-import org.apache.jackrabbit.oak.plugins.segment.Journal;
 import org.apache.jackrabbit.oak.plugins.segment.RecordId;
 import org.apache.jackrabbit.oak.plugins.segment.Segment;
+import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.slf4j.Logger;
@@ -69,7 +68,7 @@ public class FileStore extends AbstractS
     private final RandomAccessFile journalFile;
 
     /**
-     * The latest head of the root journal.
+     * The latest head state.
      */
     private final AtomicReference<RecordId> head;
 
@@ -255,23 +254,15 @@ public class FileStore extends AbstractS
     }
 
     @Override
-    public Journal getJournal(String name) {
-        checkArgument("root".equals(name)); // only root supported for now
-        return new Journal() {
-            @Override
-            public RecordId getHead() {
-                return head.get();
-            }
-            @Override
-            public boolean setHead(RecordId before, RecordId after) {
-                RecordId id = head.get();
-                return id.equals(before) && head.compareAndSet(id, after);
-            }
-            @Override
-            public void merge() {
-                throw new UnsupportedOperationException();
-            }
-        };
+    public SegmentNodeState getHead() {
+        return new SegmentNodeState(getWriter().getDummySegment(), head.get());
+    }
+
+    @Override
+    public boolean setHead(SegmentNodeState base, SegmentNodeState head) {
+        RecordId id = this.head.get();
+        return id.equals(base.getRecordId())
+                && this.head.compareAndSet(id, head.getRecordId());
     }
 
     @Override @Nonnull

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/http/HttpStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/http/HttpStore.java?rev=1575327&r1=1575326&r2=1575327&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/http/HttpStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/http/HttpStore.java
Fri Mar  7 17:09:02 2014
@@ -32,10 +32,10 @@ import java.util.UUID;
 import javax.annotation.CheckForNull;
 
 import org.apache.jackrabbit.oak.plugins.segment.AbstractStore;
-import org.apache.jackrabbit.oak.plugins.segment.Journal;
 import org.apache.jackrabbit.oak.plugins.segment.RecordId;
 import org.apache.jackrabbit.oak.plugins.segment.Segment;
 import org.apache.jackrabbit.oak.plugins.segment.SegmentIdFactory;
+import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState;
 
 import com.google.common.io.ByteStreams;
 
@@ -62,47 +62,39 @@ public class HttpStore extends AbstractS
     }
 
     @Override
-    public Journal getJournal(final String name) {
-        return new Journal() {
-            @Override
-            public RecordId getHead() {
-                try {
-                    final URLConnection connection = get("j/" + name);
-                    InputStream stream = connection.getInputStream();
-                    try {
-                        BufferedReader reader = new BufferedReader(
-                                new InputStreamReader(stream, UTF_8));
-                        return RecordId.fromString(reader.readLine());
-                    } finally {
-                        stream.close();
-                    }
-                } catch (IllegalArgumentException e) {
-                    throw new IllegalStateException(e);
-                } catch (MalformedURLException e) {
-                    throw new IllegalStateException(e);
-                } catch (IOException e) {
-                    throw new RuntimeException(e);
-                }
-            }
-
-            @Override
-            public boolean setHead(RecordId base, RecordId head) {
-                // TODO throw new UnsupportedOperationException();
-                return true;
+    public SegmentNodeState getHead() {
+        try {
+            URLConnection connection = base.openConnection();
+            InputStream stream = connection.getInputStream();
+            try {
+                BufferedReader reader = new BufferedReader(
+                        new InputStreamReader(stream, UTF_8));
+                return new SegmentNodeState(
+                        getWriter().getDummySegment(),
+                        RecordId.fromString(reader.readLine()));
+            } finally {
+                stream.close();
             }
+        } catch (IllegalArgumentException e) {
+            throw new IllegalStateException(e);
+        } catch (MalformedURLException e) {
+            throw new IllegalStateException(e);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
 
-            @Override
-            public void merge() {
-                throw new UnsupportedOperationException();
-            }
-        };
+    @Override
+    public boolean setHead(SegmentNodeState base, SegmentNodeState head) {
+        // TODO throw new UnsupportedOperationException();
+        return true;
     }
 
     @Override
     @CheckForNull
     protected Segment loadSegment(UUID id) {
         try {
-            final URLConnection connection = get("s/" + id);
+            final URLConnection connection = get(id.toString());
             InputStream stream = connection.getInputStream();
             try {
                 byte[] data = ByteStreams.toByteArray(stream);
@@ -121,7 +113,7 @@ public class HttpStore extends AbstractS
     public void writeSegment(UUID segmentId, byte[] bytes, int offset,
             int length) {
         try {
-            URLConnection connection = get("s/" + segmentId);
+            URLConnection connection = get(segmentId.toString());
             connection.setDoInput(false);
             connection.setDoOutput(true);
             OutputStream stream = connection.getOutputStream();

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=1575327&r1=1575326&r2=1575327&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
Fri Mar  7 17:09:02 2014
@@ -19,15 +19,15 @@ package org.apache.jackrabbit.oak.plugin
 import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
 
 import java.nio.ByteBuffer;
-import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentMap;
 
 import javax.annotation.Nonnull;
 
 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.SegmentNodeState;
+import org.apache.jackrabbit.oak.plugins.segment.SegmentWriter;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
@@ -35,16 +35,20 @@ import com.google.common.collect.Maps;
 
 public class MemoryStore extends AbstractStore {
 
-    private final Map<String, Journal> journals = Maps.newHashMap();
+    private SegmentNodeState head;
 
     private final ConcurrentMap<UUID, Segment> segments =
             Maps.newConcurrentMap();
 
     public MemoryStore(NodeState root) {
         super(0);
+
         NodeBuilder builder = EMPTY_NODE.builder();
         builder.setChildNode("root", root);
-        journals.put("root", new MemoryJournal(this, builder.getNodeState()));
+
+        SegmentWriter writer = getWriter();
+        this.head = writer.writeNode(builder.getNodeState());
+        writer.flush();
     }
 
     public MemoryStore() {
@@ -56,13 +60,18 @@ public class MemoryStore extends Abstrac
     }
 
     @Override
-    public synchronized Journal getJournal(final String name) {
-        Journal journal = journals.get(name);
-        if (journal == null) {
-            journal = new MemoryJournal(this, "root");
-            journals.put(name, journal);
+    public synchronized SegmentNodeState getHead() {
+        return head;
+    }
+
+    @Override
+    public synchronized boolean setHead(SegmentNodeState base, SegmentNodeState head) {
+        if (this.head.getRecordId().equals(base.getRecordId())) {
+            this.head = head;
+            return true;
+        } else {
+            return false;
         }
-        return journal;
     }
 
     @Override @Nonnull

Modified: jackrabbit/oak/trunk/oak-http/src/main/java/org/apache/jackrabbit/oak/http/segment/SegmentServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-http/src/main/java/org/apache/jackrabbit/oak/http/segment/SegmentServlet.java?rev=1575327&r1=1575326&r2=1575327&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-http/src/main/java/org/apache/jackrabbit/oak/http/segment/SegmentServlet.java
(original)
+++ jackrabbit/oak/trunk/oak-http/src/main/java/org/apache/jackrabbit/oak/http/segment/SegmentServlet.java
Fri Mar  7 17:09:02 2014
@@ -25,9 +25,9 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.jackrabbit.oak.plugins.segment.Journal;
 import org.apache.jackrabbit.oak.plugins.segment.RecordId;
 import org.apache.jackrabbit.oak.plugins.segment.Segment;
+import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState;
 import org.apache.jackrabbit.oak.plugins.segment.SegmentStore;
 
 import com.google.common.io.ByteStreams;
@@ -57,12 +57,12 @@ public abstract class SegmentServlet ext
             HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException {
         String info = request.getPathInfo();
-        if (info == null) {
-            response.sendError(HttpServletResponse.SC_NOT_FOUND);
-        } else if (info.startsWith("/s/")) {
-            doGetSegment(info.substring(3, info.length()), response);
-        } else if (info.startsWith("/j/")) {
-            doGetJournal(info.substring(3, info.length()), response);
+        if (info == null || info.equals("") || info.equals("/")) {
+            response.setContentType("text/plain; charset=UTF-8");
+            SegmentNodeState head = getSegmentStore().getHead();
+            response.getWriter().write(head.getRecordId().toString());
+        } else if (info.startsWith("/")) {
+            doGetSegment(info.substring(1, info.length()), response);
         } else {
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
         }
@@ -73,12 +73,22 @@ public abstract class SegmentServlet ext
             HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException {
         String info = request.getPathInfo();
-        if (info == null) {
-            response.sendError(HttpServletResponse.SC_NOT_FOUND);
-        } else if (info.startsWith("/s/")) {
-            doPutSegment(info.substring(3, info.length()), request, response);
-        } else if (info.startsWith("/j/")) {
-            doPutJournal(info.substring(3, info.length()), request, response);
+        if (info == null || info.equals("") || info.equals("/")) {
+            RecordId id = getRecordId(request.getReader());
+            if (id == null) {
+                response.sendError(HttpServletResponse.SC_BAD_REQUEST);
+            } else {
+                SegmentStore store = getSegmentStore();
+                SegmentNodeState head = new SegmentNodeState(
+                        store.getWriter().getDummySegment(), id);
+                if (store.setHead(store.getHead(), head)) {
+                    response.setStatus(HttpServletResponse.SC_OK);
+                } else {
+                    response.sendError(HttpServletResponse.SC_CONFLICT);
+                }
+            }
+        } else if (info.startsWith("/")) {
+            doPutSegment(info.substring(1, info.length()), request, response);
         } else {
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
         }
@@ -121,40 +131,4 @@ public abstract class SegmentServlet ext
         }
     }
 
-    private void doGetJournal(
-            String info, HttpServletResponse response)
-            throws ServletException, IOException {
-        Journal journal = getSegmentStore().getJournal(info);
-        if (journal == null) {
-            response.sendError(HttpServletResponse.SC_NOT_FOUND);
-            return;
-        }
-
-        response.setContentType("text/plain; charset=UTF-8");
-        response.getWriter().write(journal.getHead().toString());
-    }
-
-    private void doPutJournal(
-            String info,
-            HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        Journal journal = getSegmentStore().getJournal(info);
-        if (journal == null) {
-            response.sendError(HttpServletResponse.SC_NOT_FOUND);
-            return;
-        }
-
-        RecordId head = getRecordId(request.getReader());
-        if (head == null) {
-            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
-            return;
-        }
-
-        if (journal.setHead(journal.getHead(), head)) {
-            response.setStatus(HttpServletResponse.SC_OK);
-        } else {
-            response.sendError(HttpServletResponse.SC_CONFLICT);
-        }
-    }
-
 }

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java?rev=1575327&r1=1575326&r2=1575327&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java Fri
Mar  7 17:09:02 2014
@@ -136,7 +136,7 @@ public class Main {
 
                         Set<UUID> garbage = newHashSet(idmap.keySet());
                         Queue<UUID> queue = Queues.newArrayDeque();
-                        queue.add(store.getJournal("root").getHead().getSegmentId());
+                        queue.add(store.getHead().getRecordId().getSegmentId());
                         while (!queue.isEmpty()) {
                             UUID id = queue.remove();
                             if (garbage.remove(id)) {



Mime
View raw message