diff --git a/oak-segment-tar-tool-api/pom.xml b/oak-segment-tar-tool-api/pom.xml new file mode 100644 index 0000000000..1b69ee8da4 --- /dev/null +++ b/oak-segment-tar-tool-api/pom.xml @@ -0,0 +1,23 @@ + + + + 4.0.0 + + + org.apache.jackrabbit + jackrabbit-oak + 1.10-SNAPSHOT + + + + oak-segment-tar-tool-api + + + + ${project.groupId} + oak-store-spi + ${project.version} + + + \ No newline at end of file diff --git a/oak-segment-tar-tool-api/src/main/java/org/apache/jackrabbit/oak/segment/tool/api/ProcFactory.java b/oak-segment-tar-tool-api/src/main/java/org/apache/jackrabbit/oak/segment/tool/api/ProcFactory.java new file mode 100644 index 0000000000..4e4111ff2b --- /dev/null +++ b/oak-segment-tar-tool-api/src/main/java/org/apache/jackrabbit/oak/segment/tool/api/ProcFactory.java @@ -0,0 +1,30 @@ +/* + * 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.tool.api; + +import java.io.IOException; + +import org.apache.jackrabbit.oak.spi.state.NodeState; + +public interface ProcFactory { + + NodeState buildProc() throws IOException; + +} diff --git a/oak-segment-tar-tool-api/src/main/java/org/apache/jackrabbit/oak/segment/tool/api/ToolingSuport.java b/oak-segment-tar-tool-api/src/main/java/org/apache/jackrabbit/oak/segment/tool/api/ToolingSuport.java new file mode 100644 index 0000000000..22a719a299 --- /dev/null +++ b/oak-segment-tar-tool-api/src/main/java/org/apache/jackrabbit/oak/segment/tool/api/ToolingSuport.java @@ -0,0 +1,30 @@ +/* + * 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.tool.api; + +import org.apache.jackrabbit.oak.spi.state.NodeStore; + +public interface ToolingSuport { + + NodeStore getNodeStore(); + + ProcFactory getProcFactory(); + +} diff --git a/oak-segment-tar-tool-api/src/main/java/org/apache/jackrabbit/oak/segment/tool/api/ToolingSupportFactory.java b/oak-segment-tar-tool-api/src/main/java/org/apache/jackrabbit/oak/segment/tool/api/ToolingSupportFactory.java new file mode 100644 index 0000000000..2293379e0d --- /dev/null +++ b/oak-segment-tar-tool-api/src/main/java/org/apache/jackrabbit/oak/segment/tool/api/ToolingSupportFactory.java @@ -0,0 +1,29 @@ +/* + * 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.tool.api; + +import java.io.File; +import java.io.IOException; + +public interface ToolingSupportFactory { + + ToolingSuport buildToolingSupport(File directory) throws IOException; + +} diff --git a/oak-segment-tar-tool/pom.xml b/oak-segment-tar-tool/pom.xml new file mode 100644 index 0000000000..311ab6774b --- /dev/null +++ b/oak-segment-tar-tool/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + + jackrabbit-oak + org.apache.jackrabbit + 1.10-SNAPSHOT + + + + oak-segment-tar-tool + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.1 + + + + shade + + + false + + + ${project.groupId}:* + javax.jcr:jcr + commons-io:commons-io + commons-codec:commons-codec + com.google.guava:guava + org.slf4j:slf4j-api + org.slf4j:slf4j-nop + io.netty + com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru + org.slf4j:jcl-over-slf4j + + + + + + + + + + + + ${project.groupId} + oak-segment-tar + ${project.version} + + + ${project.groupId} + oak-blob + ${project.version} + + + ${project.groupId} + oak-segment-tar-tool-api + ${project.version} + + + org.slf4j + slf4j-nop + 1.7.6 + + + \ No newline at end of file diff --git a/oak-segment-tar-tool/src/main/java/org/apache/jackrabbit/oak/segment/tar/tool/ToolingSupportFactoryProvider.java b/oak-segment-tar-tool/src/main/java/org/apache/jackrabbit/oak/segment/tar/tool/ToolingSupportFactoryProvider.java new file mode 100644 index 0000000000..247491c01c --- /dev/null +++ b/oak-segment-tar-tool/src/main/java/org/apache/jackrabbit/oak/segment/tar/tool/ToolingSupportFactoryProvider.java @@ -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.segment.tar.tool; + +import java.io.File; +import java.io.IOException; + +import org.apache.jackrabbit.oak.segment.SegmentNodeStore; +import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders; +import org.apache.jackrabbit.oak.segment.file.FileStoreBuilder; +import org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException; +import org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore; +import org.apache.jackrabbit.oak.segment.file.proc.Proc; +import org.apache.jackrabbit.oak.segment.tool.api.ProcFactory; +import org.apache.jackrabbit.oak.segment.tool.api.ToolingSuport; +import org.apache.jackrabbit.oak.segment.tool.api.ToolingSupportFactory; +import org.apache.jackrabbit.oak.spi.state.NodeStore; + +class ToolingSupportFactoryProvider implements ToolingSupportFactory { + + @Override + public ToolingSuport buildToolingSupport(File directory) throws IOException { + FileStoreBuilder builder = FileStoreBuilder.fileStoreBuilder(directory); + + ReadOnlyFileStore fileStore; + + try { + fileStore = builder.buildReadOnly(); + } catch (InvalidFileStoreVersionException e) { + throw new IOException(e); + } + + SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build(); + ProcFactory procFactory = () -> Proc.of(builder.buildProcBackend(fileStore)); + + return new ToolingSuport() { + + @Override + public NodeStore getNodeStore() { + return nodeStore; + } + + @Override + public ProcFactory getProcFactory() { + return procFactory; + } + + }; + } + +} diff --git a/oak-segment-tar-tool/src/main/resources/META-INF/services/org.apache.jackrabbit.oak.segment.tool.api.ToolingSupportFactory b/oak-segment-tar-tool/src/main/resources/META-INF/services/org.apache.jackrabbit.oak.segment.tool.api.ToolingSupportFactory new file mode 100644 index 0000000000..1263f3243d --- /dev/null +++ b/oak-segment-tar-tool/src/main/resources/META-INF/services/org.apache.jackrabbit.oak.segment.tool.api.ToolingSupportFactory @@ -0,0 +1 @@ +org.apache.jackrabbit.oak.segment.tar.tool.ToolingSupportFactoryProvider diff --git a/pom.xml b/pom.xml index 5274001246..244896fde1 100644 --- a/pom.xml +++ b/pom.xml @@ -73,6 +73,8 @@ oak-segment-tar oak-segment-azure oak-benchmarks + oak-segment-tar-tool-api + oak-segment-tar-tool