Author: adulceanu
Date: Tue May 28 11:43:19 2019
New Revision: 1860247

URL: http://svn.apache.org/viewvc?rev=1860247&view=rev
Log:
OAK-8358 - oak-run check should have an option for specifying memory mapping

Modified:
    jackrabbit/oak/trunk/oak-doc/src/site/markdown/nodestore/segment/overview.md
    
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/CheckCommand.java
    
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/Check.java

Modified: 
jackrabbit/oak/trunk/oak-doc/src/site/markdown/nodestore/segment/overview.md
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-doc/src/site/markdown/nodestore/segment/overview.md?rev=1860247&r1=1860246&r2=1860247&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-doc/src/site/markdown/nodestore/segment/overview.md 
(original)
+++ 
jackrabbit/oak/trunk/oak-doc/src/site/markdown/nodestore/segment/overview.md 
Tue May 28 11:43:19 2019
@@ -727,7 +727,7 @@ This tool is the counterpart of `backup`
 ### <a name="check"/> Check
 
 ```
-java -jar oak-run.jar check PATH [--journal JOURNAL] [--notify SECS] [--bin] 
[--head] [--checkpoints all | cp1[,cp2,..,cpn]]  [--filter 
PATH1[,PATH2,..,PATHn]] [--io-stats]
+java -jar oak-run.jar check PATH [--mmap] [--journal JOURNAL] [--notify SECS] 
[--bin] [--head] [--checkpoints all | cp1[,cp2,..,cpn]]  [--filter 
PATH1[,PATH2,..,PATHn]] [--io-stats]
 ```
 
 The `check` tool inspects an existing Segment Store at `PATH` for eventual 
inconsistencies. 
@@ -735,6 +735,9 @@ The algorithm implemented by this tool t
 For every revision, the actual nodes and properties are traversed, verifying 
that every piece of data is reachable and undamaged. Moreover, if `--head` and 
`--checkpoints` options are used, the scope of the traversal can be limited to 
head state and/or a subset of checkpoints.
 A deep scan of the content tree, traversing every node and every property will 
be performed by default. The default scope includes head state and all 
checkpoints.
   
+The optional `--mmap [Boolean]` argument can be used to control the file 
access mode. Set
+to `true` for memory mapped access and `false` for file access (default is 
`true`).
+
 If the `--journal` option is specified, the tool will use the journal file at 
`JOURNAL` instead of picking up the one contained in `PATH`. 
 `JOURNAL` must be a path to a valid journal file for the Segment Store. 
 

Modified: 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/CheckCommand.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/CheckCommand.java?rev=1860247&r1=1860246&r2=1860247&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/CheckCommand.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/CheckCommand.java
 Tue May 28 11:43:19 2019
@@ -34,6 +34,10 @@ class CheckCommand implements Command {
     @Override
     public void execute(String... args) throws Exception {
         OptionParser parser = new OptionParser();
+        OptionSpec<Boolean> mmapArg = parser.accepts("mmap", "use memory 
mapping for the file store (default: true)")
+            .withOptionalArg()
+            .ofType(Boolean.class)
+            .defaultsTo(true);
         OptionSpec<File> journal = parser.accepts("journal", "journal file")
             .withRequiredArg()
             .ofType(File.class);
@@ -69,6 +73,7 @@ class CheckCommand implements Command {
 
         Check.Builder builder = Check.builder()
             .withPath(options.valueOf(dir))
+            .withMmap(mmapArg.value(options))
             .withDebugInterval(notify.value(options))
             .withCheckBinaries(options.has(bin))
             .withCheckHead(shouldCheckHead(options, head, cp))

Modified: 
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/Check.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/Check.java?rev=1860247&r1=1860246&r2=1860247&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/Check.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/tool/Check.java
 Tue May 28 11:43:19 2019
@@ -68,22 +68,24 @@ public class Check {
 
         private File path;
 
+        private boolean mmap;
+
         private File journal;
 
         private long debugInterval = Long.MAX_VALUE;
 
         private boolean checkBinaries;
-        
+
         private boolean checkHead;
-        
+
         private Set<String> checkpoints;
-        
+
         private Set<String> filterPaths;
 
         private boolean ioStatistics;
-        
+
         private PrintWriter outWriter;
-        
+
         private PrintWriter errWriter;
 
         private Builder() {
@@ -102,6 +104,20 @@ public class Check {
         }
 
         /**
+         * Whether to use memory mapped access or file access.
+         *
+         * @param mmap {@code true} for memory mapped access, {@code false} for
+         *             file access {@code null} to determine the access mode
+         *             from the system architecture: memory mapped on 64 bit
+         *             systems, file access on  32 bit systems.
+         * @return this builder.
+         */
+        public Builder withMmap(boolean mmap) {
+            this.mmap = mmap;
+            return this;
+        }
+
+        /**
          * The path to the journal of the segment store. This parameter is
          * optional. If not provided, the journal in the default location is
          * used.
@@ -140,7 +156,7 @@ public class Check {
             this.checkBinaries = checkBinaries;
             return this;
         }
-        
+
         /**
          * Instruct the command to check head state.
          * This parameter is not required and defaults to {@code true}.
@@ -151,12 +167,12 @@ public class Check {
             this.checkHead = checkHead;
             return this;
         }
-        
+
         /**
          * Instruct the command to check specified checkpoints.
-         * This parameter is not required and defaults to "/checkpoints", 
+         * This parameter is not required and defaults to "/checkpoints",
          * i.e. will check all checkpoints when not explicitly overridden.
-         * 
+         *
          * @param checkpoints   checkpoints to be checked
          * @return this builder.
          */
@@ -164,11 +180,11 @@ public class Check {
             this.checkpoints = checkpoints;
             return this;
         }
-        
+
         /**
          * Content paths to be checked. This parameter is not required and
          * defaults to "/".
-         * 
+         *
          * @param filterPaths
          *            paths to be checked
          * @return this builder.
@@ -191,7 +207,7 @@ public class Check {
             this.ioStatistics = ioStatistics;
             return this;
         }
-        
+
         /**
          * The text output stream writer used to print normal output.
          * @param outWriter the output writer.
@@ -199,10 +215,10 @@ public class Check {
          */
         public Builder withOutWriter(PrintWriter outWriter) {
             this.outWriter = outWriter;
-            
+
             return this;
         }
-        
+
         /**
          * The text error stream writer used to print erroneous output.
          * @param errWriter the error writer.
@@ -210,7 +226,7 @@ public class Check {
          */
         public Builder withErrWriter(PrintWriter errWriter) {
             this.errWriter = errWriter;
-            
+
             return this;
         }
 
@@ -245,16 +261,18 @@ public class Check {
 
     private final File path;
 
+    private final boolean mmap;
+
     private final File journal;
 
     private final long debugInterval;
 
     private final boolean checkBinaries;
-    
+
     private final boolean checkHead;
 
     private final Set<String> requestedCheckpoints;
-    
+
     private final Set<String> filterPaths;
 
     private final boolean ioStatistics;
@@ -271,6 +289,7 @@ public class Check {
 
     private Check(Builder builder) {
         this.path = builder.path;
+        this.mmap = builder.mmap;
         this.debugInterval = builder.debugInterval;
         this.checkHead = builder.checkHead;
         this.checkBinaries = builder.checkBinaries;
@@ -293,6 +312,7 @@ public class Check {
         StatisticsIOMonitor ioMonitor = new StatisticsIOMonitor();
 
         FileStoreBuilder builder = fileStoreBuilder(path)
+            .withMemoryMapping(mmap)
             .withCustomPersistence(new TarPersistence(this.path, 
this.journal));
 
         if (ioStatistics) {


Reply via email to