Author: chetanm
Date: Thu Aug 3 06:51:54 2017
New Revision: 1803956
URL: http://svn.apache.org/viewvc?rev=1803956&view=rev
Log:
OAK-6497 - Support old Segment NodeStore setups for oak-run index tooling
Added:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/SegmentFixtureProvider.java
(with props)
Modified:
jackrabbit/oak/trunk/oak-run/pom.xml
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/CommonOptions.java
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/NodeStoreFixtureProvider.java
Modified: jackrabbit/oak/trunk/oak-run/pom.xml
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/pom.xml?rev=1803956&r1=1803955&r2=1803956&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-run/pom.xml Thu Aug 3 06:51:54 2017
@@ -226,6 +226,11 @@
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
+ <artifactId>oak-segment</artifactId>
+ <version>1.6.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-aws-ext</artifactId>
<version>${jackrabbit.version}</version>
<optional>true</optional>
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/CommonOptions.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/CommonOptions.java?rev=1803956&r1=1803955&r2=1803956&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/CommonOptions.java
(original)
+++
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/CommonOptions.java
Thu Aug 3 06:51:54 2017
@@ -35,12 +35,14 @@ public class CommonOptions implements Op
private final OptionSpec<Void> readWriteOption;
private final OptionSpec<String> nonOption;
private final OptionSpec<Void> metrics;
+ private final OptionSpec<Void> segment;
private OptionSet options;
public CommonOptions(OptionParser parser){
help = parser.acceptsAll(asList("h", "?", "help"), "Show
help").forHelp();
readWriteOption = parser.accepts("read-write", "Connect to repository
in read-write mode");
metrics = parser.accepts("metrics", "Enables metrics based statistics
collection");
+ segment = parser.accepts("segment", "Use older oak-segment support");
nonOption = parser.nonOptions(DEFAULT_CONNECTION_STRING);
}
@@ -69,8 +71,8 @@ public class CommonOptions implements Op
return getStoreArg().startsWith("jdbc");
}
- public boolean isSegment(){
- return !isDocument();
+ public boolean isOldSegment(){
+ return options.has(segment);
}
public boolean isDocument(){
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/NodeStoreFixtureProvider.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/NodeStoreFixtureProvider.java?rev=1803956&r1=1803955&r2=1803956&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/NodeStoreFixtureProvider.java
(original)
+++
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/NodeStoreFixtureProvider.java
Thu Aug 3 06:51:54 2017
@@ -79,6 +79,8 @@ public class NodeStoreFixtureProvider {
NodeStore store;
if (commonOpts.isMongo() || commonOpts.isRDB()) {
store = configureDocumentMk(options, blobStore,
statisticsProvider, closer, wb, readOnly);
+ } else if (commonOpts.isOldSegment()) {
+ store = SegmentFixtureProvider.create(options, blobStore,
statisticsProvider, closer, readOnly);
} else {
store = configureSegment(options, blobStore, statisticsProvider,
closer, readOnly);
}
Added:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/SegmentFixtureProvider.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/SegmentFixtureProvider.java?rev=1803956&view=auto
==============================================================================
---
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/SegmentFixtureProvider.java
(added)
+++
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/SegmentFixtureProvider.java
Thu Aug 3 06:51:54 2017
@@ -0,0 +1,63 @@
+/*
+ * 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.run.cli;
+
+import java.io.File;
+import java.io.IOException;
+
+import com.google.common.io.Closer;
+import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore;
+import org.apache.jackrabbit.oak.plugins.segment.file.FileStore;
+import
org.apache.jackrabbit.oak.plugins.segment.file.InvalidFileStoreVersionException;
+import org.apache.jackrabbit.oak.spi.blob.BlobStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.stats.StatisticsProvider;
+
+class SegmentFixtureProvider {
+
+ static NodeStore create(Options options, BlobStore blobStore,
StatisticsProvider statisticsProvider, Closer closer, boolean readOnly)
+ throws IOException, InvalidFileStoreVersionException {
+
+ String path = options.getOptionBean(CommonOptions.class).getStoreArg();
+ FileStore.Builder builder = FileStore.builder(new File(path))
+ .withMaxFileSize(256).withDefaultMemoryMapping();
+
+ if (blobStore != null) {
+ builder.withBlobStore(blobStore);
+ }
+
+ NodeStore nodeStore;
+ if (readOnly) {
+ FileStore.ReadOnlyStore fileStore = builder
+ .withStatisticsProvider(statisticsProvider)
+ .buildReadOnly();
+ closer.register(fileStore);
+ nodeStore = SegmentNodeStore.builder(fileStore).build();
+ } else {
+ FileStore fileStore = builder
+ .withStatisticsProvider(statisticsProvider)
+ .build();
+ closer.register(fileStore);
+ nodeStore = SegmentNodeStore.builder(fileStore).build();
+ }
+
+ return nodeStore;
+ }
+}
Propchange:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/SegmentFixtureProvider.java
------------------------------------------------------------------------------
svn:eol-style = native