You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ch...@apache.org on 2017/05/31 06:44:16 UTC
svn commit: r1796983 - in
/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli:
BlobStoreFixtureProvider.java BlobStoreOptions.java DummyDataStore.java
Author: chetanm
Date: Wed May 31 06:44:16 2017
New Revision: 1796983
URL: http://svn.apache.org/viewvc?rev=1796983&view=rev
Log:
OAK-6282 - Implement a DummyDataStore to be used to test setup with no BlobStore access
Added:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/DummyDataStore.java (with props)
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreFixtureProvider.java
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreOptions.java
Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreFixtureProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreFixtureProvider.java?rev=1796983&r1=1796982&r2=1796983&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreFixtureProvider.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreFixtureProvider.java Wed May 31 06:44:16 2017
@@ -81,6 +81,11 @@ public class BlobStoreFixtureProvider {
azureds.init(homeDir.getAbsolutePath());
closer.register(asCloseable(homeDir));
delegate = azureds;
+ } else if (bsType == Type.FAKE) {
+ FileDataStore fakeDs = new DummyDataStore();
+ fakeDs.setPath(bsopts.getFakeDataStorePath());
+ fakeDs.init(null);
+ delegate = fakeDs;
} else {
FileDataStore fds = new OakFileDataStore();
delegate = fds;
Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreOptions.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreOptions.java?rev=1796983&r1=1796982&r2=1796983&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreOptions.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreOptions.java Wed May 31 06:44:16 2017
@@ -29,11 +29,12 @@ import joptsimple.OptionSpec;
import static java.util.Arrays.asList;
public class BlobStoreOptions implements OptionsBean {
- public enum Type {FDS, S3, AZURE, NONE}
+ public enum Type {FDS, S3, AZURE, FAKE, NONE}
private final OptionSpec<String> fdsOption;
private final OptionSpec<String> s3Option;
private final OptionSpec<String> azureOption;
private final OptionSpec<String> fdsPathOption;
+ private final OptionSpec<String> fakeDsPathOption;
private OptionSet options;
public BlobStoreOptions(OptionParser parser){
@@ -41,6 +42,9 @@ public class BlobStoreOptions implements
.withRequiredArg().ofType(String.class);
fdsPathOption = parser.acceptsAll(asList("fds-path"), "FileDataStore path")
.withRequiredArg().ofType(String.class);
+ fakeDsPathOption = parser.acceptsAll(asList("fake-ds-path"), "Path to be used to construct a Fake " +
+ "FileDataStore. It return an empty stream for any Blob but allows writes if used in read-write mode")
+ .withRequiredArg().ofType(String.class);
s3Option = parser.accepts("s3ds", "S3DataStore config path")
.withRequiredArg().ofType(String.class);
azureOption = parser.acceptsAll(asList("azureblobds", "azureds"), "AzureBlobStorageDataStore config path")
@@ -89,6 +93,10 @@ public class BlobStoreOptions implements
return azureOption.value(options);
}
+ public String getFakeDataStorePath() {
+ return fakeDsPathOption.value(options);
+ }
+
public Type getBlobStoreType(){
if (options.has(fdsOption) || options.has(fdsPathOption)){
return Type.FDS;
@@ -96,6 +104,8 @@ public class BlobStoreOptions implements
return Type.S3;
} else if (options.has(azureOption)){
return Type.AZURE;
+ } else if (options.has(fakeDsPathOption)){
+ return Type.FAKE;
}
return Type.NONE;
}
Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/DummyDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/DummyDataStore.java?rev=1796983&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/DummyDataStore.java (added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/DummyDataStore.java Wed May 31 06:44:16 2017
@@ -0,0 +1,68 @@
+/*
+ * 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.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.apache.jackrabbit.core.data.AbstractDataRecord;
+import org.apache.jackrabbit.core.data.AbstractDataStore;
+import org.apache.jackrabbit.core.data.DataIdentifier;
+import org.apache.jackrabbit.core.data.DataRecord;
+import org.apache.jackrabbit.core.data.DataStoreException;
+import org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore;
+
+/**
+ * DataStore implementation which creates empty files matching given identifier.
+ *
+ * This can be use to try migration of repositories where DataStore size is large
+ * and cannot be accessed as transferring them would take quite a bit of time. As migration
+ * does not involve accessing the actual binary content and only binary identifiers are
+ * transferred it should enable us to get past the migration phase
+ */
+public class DummyDataStore extends OakFileDataStore {
+
+ public DummyDataStore() {
+ //Set min size to match the one in ClusterDataStore
+ setMinRecordLength(4096);
+ }
+
+ public DataRecord getRecordIfStored(DataIdentifier identifier) throws DataStoreException {
+ return new DummyDataRecord(this, identifier);
+ }
+
+ private static final class DummyDataRecord extends AbstractDataRecord {
+
+ private DummyDataRecord(AbstractDataStore store, DataIdentifier identifier) {
+ super(store, identifier);
+ }
+
+ public long getLength() throws DataStoreException {
+ return 0;
+ }
+
+ public InputStream getStream() throws DataStoreException {
+ return new ByteArrayInputStream(new byte[0]);
+ }
+
+ public long getLastModified() {
+ return 0;
+ }
+ }
+}
Propchange: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/DummyDataStore.java
------------------------------------------------------------------------------
svn:eol-style = native