Author: frm
Date: Tue May  9 15:00:04 2017
New Revision: 1794593

URL: http://svn.apache.org/viewvc?rev=1794593&view=rev
Log:
OAK-6195 - Reduce visibility of some member of Segment

Added:
    
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentTestConstants.java
   (with props)
Modified:
    
jackrabbit/oak/trunk/oak-it/src/test/java/org/apache/jackrabbit/oak/federated/FederatedNodeStoreTest.java
    jackrabbit/oak/trunk/oak-lucene/pom.xml
    
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakDirectoryTest.java
    
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/Segment.java
    
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/ExternalBlobReferenceTest.java
    
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/FileStoreIT.java

Modified: 
jackrabbit/oak/trunk/oak-it/src/test/java/org/apache/jackrabbit/oak/federated/FederatedNodeStoreTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/src/test/java/org/apache/jackrabbit/oak/federated/FederatedNodeStoreTest.java?rev=1794593&r1=1794592&r2=1794593&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-it/src/test/java/org/apache/jackrabbit/oak/federated/FederatedNodeStoreTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-it/src/test/java/org/apache/jackrabbit/oak/federated/FederatedNodeStoreTest.java
 Tue May  9 15:00:04 2017
@@ -45,6 +45,10 @@ import java.util.concurrent.TimeUnit;
 import javax.annotation.Nullable;
 import javax.sql.DataSource;
 
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
@@ -55,9 +59,9 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.document.rdb.RDBOptions;
 import org.apache.jackrabbit.oak.plugins.document.util.CountingDiff;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
-import org.apache.jackrabbit.oak.segment.Segment;
 import org.apache.jackrabbit.oak.segment.SegmentNodeStore;
 import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders;
+import org.apache.jackrabbit.oak.segment.SegmentTestConstants;
 import org.apache.jackrabbit.oak.segment.file.FileStore;
 import org.apache.jackrabbit.oak.segment.file.FileStoreBuilder;
 import org.apache.jackrabbit.oak.spi.blob.BlobStore;
@@ -77,11 +81,6 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
 @RunWith(Parameterized.class)
 public class FederatedNodeStoreTest {
 
@@ -925,7 +924,7 @@ public class FederatedNodeStoreTest {
     private ByteArrayInputStream createLargeBlob() {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
 
-        for ( int i = 0 ; i <= Segment.MEDIUM_LIMIT; i++) {
+        for (int i = 0; i <= SegmentTestConstants.MEDIUM_LIMIT; i++) {
             out.write('a');
         }
 
@@ -947,4 +946,4 @@ public class FederatedNodeStoreTest {
         assertThat("Incorrect number of elements", 
Iterables.size(childNodeNames), equalTo(names.length));
         assertThat("Mismatched elements", childNodeNames, hasItems(names));
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/oak/trunk/oak-lucene/pom.xml
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/pom.xml?rev=1794593&r1=1794592&r2=1794593&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-lucene/pom.xml Tue May  9 15:00:04 2017
@@ -307,6 +307,13 @@
     </dependency>
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>oak-segment-tar</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
       <artifactId>oak-jcr</artifactId>
       <version>${project.version}</version>
       <scope>test</scope>

Modified: 
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakDirectoryTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakDirectoryTest.java?rev=1794593&r1=1794592&r2=1794593&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakDirectoryTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakDirectoryTest.java
 Tue May  9 15:00:04 2017
@@ -24,11 +24,11 @@ import static com.google.common.collect.
 import static org.apache.commons.io.FileUtils.ONE_GB;
 import static org.apache.commons.io.FileUtils.ONE_MB;
 import static org.apache.jackrabbit.JcrConstants.JCR_DATA;
+import static org.apache.jackrabbit.oak.InitialContent.INITIAL_CONTENT;
 import static org.apache.jackrabbit.oak.api.Type.BINARIES;
 import static 
org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INDEX_DATA_CHILD_NAME;
 import static 
org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory.PROP_BLOB_SIZE;
 import static 
org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory.UNIQUE_KEY_SIZE;
-import static org.apache.jackrabbit.oak.InitialContent.INITIAL_CONTENT;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -56,9 +56,9 @@ import org.apache.jackrabbit.oak.api.Typ
 import org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob;
 import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
-import org.apache.jackrabbit.oak.segment.Segment;
 import org.apache.jackrabbit.oak.segment.SegmentNodeStore;
 import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders;
+import org.apache.jackrabbit.oak.segment.SegmentTestConstants;
 import org.apache.jackrabbit.oak.segment.file.FileStore;
 import org.apache.jackrabbit.oak.segment.file.FileStoreBuilder;
 import org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore;
@@ -403,7 +403,7 @@ public class OakDirectoryTest {
 
         String indexPath = "/foo/bar";
 
-        int minFileSize = Segment.MEDIUM_LIMIT;
+        int minFileSize = SegmentTestConstants.MEDIUM_LIMIT;
         int blobSize = minFileSize + 1000;
 
         builder = nodeStore.getRoot().builder();
@@ -572,4 +572,4 @@ public class OakDirectoryTest {
             fail = false;
         }
     }
-}
\ No newline at end of file
+}

Modified: 
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/Segment.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/Segment.java?rev=1794593&r1=1794592&r2=1794593&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/Segment.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/Segment.java
 Tue May  9 15:00:04 2017
@@ -96,7 +96,7 @@ public class Segment {
      * The number of bytes (or bits of address space) to use for the
      * alignment boundary of segment records.
      */
-    public static final int RECORD_ALIGN_BITS = 2; // align at the four-byte 
boundary
+    static final int RECORD_ALIGN_BITS = 2; // align at the four-byte boundary
 
     /**
      * Maximum segment size. Record identifiers are stored as three-byte
@@ -105,7 +105,7 @@ public class Segment {
      * at four-byte boundaries, the two bytes can address up to 256kB of
      * record data.
      */
-    public static final int MAX_SEGMENT_SIZE = 1 << (16 + RECORD_ALIGN_BITS); 
// 256kB
+    static final int MAX_SEGMENT_SIZE = 1 << (16 + RECORD_ALIGN_BITS); // 256kB
 
     /**
      * The size limit for small values. The variable length of small values
@@ -121,7 +121,7 @@ public class Segment {
      * value. And since small values are never stored as medium ones, we can
      * extend the size range to cover that many longer values.
      */
-    public static final int MEDIUM_LIMIT = (1 << (16 - 2)) + SMALL_LIMIT;
+    static final int MEDIUM_LIMIT = (1 << (16 - 2)) + SMALL_LIMIT;
 
     /**
      * Maximum size of small blob IDs. A small blob ID is stored in a value
@@ -130,13 +130,13 @@ public class Segment {
      * and the actual length of the blob ID, a maximum of 2^12 values can be
      * stored in the length field.
      */
-    public static final int BLOB_ID_SMALL_LIMIT = 1 << 12;
+    static final int BLOB_ID_SMALL_LIMIT = 1 << 12;
 
-    public static final int GC_GENERATION_OFFSET = 10;
+    static final int GC_GENERATION_OFFSET = 10;
 
-    public static final int REFERENCED_SEGMENT_ID_COUNT_OFFSET = 14;
+    static final int REFERENCED_SEGMENT_ID_COUNT_OFFSET = 14;
 
-    public static final int RECORD_NUMBER_COUNT_OFFSET = 18;
+    static final int RECORD_NUMBER_COUNT_OFFSET = 18;
 
     @Nonnull
     private final SegmentReader reader;
@@ -171,7 +171,7 @@ public class Segment {
      * @return  {@code n = address + a} such that {@code n % boundary == 0} and
      *          {@code 0 <= a < boundary}.
      */
-    public static int align(int address, int boundary) {
+    static int align(int address, int boundary) {
         return (address + boundary - 1) & ~(boundary - 1);
     }
 
@@ -366,7 +366,7 @@ public class Segment {
         return data.getInt(REFERENCED_SEGMENT_ID_COUNT_OFFSET);
     }
 
-    public int getRecordNumberCount() {
+    private int getRecordNumberCount() {
         return data.getInt(RECORD_NUMBER_COUNT_OFFSET);
     }
 
@@ -415,7 +415,7 @@ public class Segment {
      * @return the segment meta data
      */
     @CheckForNull
-    public String getSegmentInfo() {
+    String getSegmentInfo() {
         if (info == null && id.isDataSegmentId()) {
             info = 
readString(recordNumbers.iterator().next().getRecordNumber());
         }
@@ -719,7 +719,7 @@ public class Segment {
      * Estimate of how much memory this instance would occupy in the segment
      * cache.
      */
-    public int estimateMemoryUsage() {
+    int estimateMemoryUsage() {
         int size = OBJECT_HEADER_SIZE + 76;
         size += 56; // 7 refs x 8 bytes
 

Added: 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentTestConstants.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentTestConstants.java?rev=1794593&view=auto
==============================================================================
--- 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentTestConstants.java
 (added)
+++ 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentTestConstants.java
 Tue May  9 15:00:04 2017
@@ -0,0 +1,34 @@
+/*
+ * 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.jackrabbit.oak.segment;
+
+/**
+ * Exposes selected constants for testing purposes. This class prevents those
+ * constants to be visible to production code.
+ */
+public class SegmentTestConstants {
+
+    private SegmentTestConstants() {
+        // Prevent instantiation.
+    }
+
+    public static final int MEDIUM_LIMIT = Segment.MEDIUM_LIMIT;
+
+    public static final int BLOB_ID_SMALL_LIMIT = Segment.BLOB_ID_SMALL_LIMIT;
+
+}

Propchange: 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentTestConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/ExternalBlobReferenceTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/ExternalBlobReferenceTest.java?rev=1794593&r1=1794592&r2=1794593&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/ExternalBlobReferenceTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/ExternalBlobReferenceTest.java
 Tue May  9 15:00:04 2017
@@ -30,8 +30,8 @@ import java.io.IOException;
 import java.io.InputStream;
 
 import com.google.common.base.Strings;
-import org.apache.jackrabbit.oak.segment.Segment;
 import org.apache.jackrabbit.oak.segment.SegmentBlob;
+import org.apache.jackrabbit.oak.segment.SegmentTestConstants;
 import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 import org.junit.After;
 import org.junit.Before;
@@ -74,7 +74,7 @@ public class ExternalBlobReferenceTest {
      */
     @Test
     public void testShortBlobId() throws Exception {
-        testBlobIdWithLength(Segment.BLOB_ID_SMALL_LIMIT - 1);
+        testBlobIdWithLength(SegmentTestConstants.BLOB_ID_SMALL_LIMIT - 1);
     }
 
     /**
@@ -94,12 +94,12 @@ public class ExternalBlobReferenceTest {
      */
     @Test
     public void testLongBlobId() throws Exception {
-        testBlobIdWithLength(Segment.BLOB_ID_SMALL_LIMIT);
+        testBlobIdWithLength(SegmentTestConstants.BLOB_ID_SMALL_LIMIT);
     }
 
     private void testBlobIdWithLength(int blobIdLength) throws Exception {
         String blobId = Strings.repeat("x", blobIdLength);
-        long blobLength = Segment.MEDIUM_LIMIT;
+        long blobLength = SegmentTestConstants.MEDIUM_LIMIT;
 
         doReturn(blobId).when(blobStore).writeBlob(any(InputStream.class));
         doReturn(blobLength).when(blobStore).getBlobLength(blobId);

Modified: 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/FileStoreIT.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/FileStoreIT.java?rev=1794593&r1=1794592&r2=1794593&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/FileStoreIT.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/FileStoreIT.java
 Tue May  9 15:00:04 2017
@@ -32,10 +32,10 @@ import java.util.Random;
 import com.google.common.base.Strings;
 import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.segment.RecordId;
-import org.apache.jackrabbit.oak.segment.Segment;
 import org.apache.jackrabbit.oak.segment.SegmentNodeBuilder;
 import org.apache.jackrabbit.oak.segment.SegmentNodeState;
 import org.apache.jackrabbit.oak.segment.SegmentWriter;
+import org.apache.jackrabbit.oak.segment.SegmentTestConstants;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
@@ -142,7 +142,7 @@ public class FileStoreIT {
                 // 1 byte per char, 2 byte to store the length and 3 bytes for 
the
                 // alignment to the integer boundary
                 
writer.writeString(Strings.repeat("abcdefghijklmno".substring(k, k + 1),
-                        Segment.MEDIUM_LIMIT - 1));
+                        SegmentTestConstants.MEDIUM_LIMIT - 1));
             }
 
             // adding 14280 bytes. 1 byte per char, and 2 bytes to store the 
length


Reply via email to