jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1559835 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
Date Mon, 20 Jan 2014 21:44:01 GMT
Author: jukka
Date: Mon Jan 20 21:44:00 2014
New Revision: 1559835

URL: http://svn.apache.org/r1559835
Log:
OAK-631: SegmentMK: Implement garbage collection

Make it more obvious that the FileStore.writeSegment() operation is fully synchronized.

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java

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=1559835&r1=1559834&r2=1559835&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
Mon Jan 20 21:44:00 2014
@@ -306,29 +306,25 @@ public class FileStore extends AbstractS
     @Override
     public synchronized void writeSegment(
             UUID segmentId, byte[] data, int offset, int length) {
-        try {
-            writeEntry(segmentId, data, offset, length);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    private void writeEntry(
-            UUID segmentId, byte[] buffer, int offset, int length)
-            throws IOException {
+        // select whether to write a data or a bulk segment
         LinkedList<TarFile> files = dataFiles;
         String base = "data";
         if (isBulkSegmentId(segmentId)) {
             files = bulkFiles;
             base = "bulk";
         }
-        if (files.isEmpty() || !files.getLast().writeEntry(
-                segmentId, buffer, offset, length)) {
-            String name = String.format(FILE_NAME_FORMAT, base, files.size());
-            File file = new File(directory, name);
-            TarFile last = new TarFile(file, maxFileSize, memoryMapping);
-            checkState(last.writeEntry(segmentId, buffer, offset, length));
-            files.add(last);
+
+        try {
+            if (files.isEmpty() || !files.getLast().writeEntry(
+                    segmentId, data, offset, length)) {
+                String name = String.format(FILE_NAME_FORMAT, base, files.size());
+                File file = new File(directory, name);
+                TarFile last = new TarFile(file, maxFileSize, memoryMapping);
+                checkState(last.writeEntry(segmentId, data, offset, length));
+                files.add(last);
+            }
+        } catch (IOException e) {
+            throw new RuntimeException(e);
         }
     }
 



Mime
View raw message