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 mi...@apache.org on 2024/02/06 14:03:50 UTC
(jackrabbit-oak) 02/07: OAK-10636 modify TarFiles builder
This is an automated email from the ASF dual-hosted git repository.
miroslav pushed a commit to branch issue/OAK-10636
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit b23cb42f484dfd41596728bbd178788125e3c764
Author: Miroslav Smiljanic <mi...@apache.com>
AuthorDate: Mon Feb 5 16:44:13 2024 +0100
OAK-10636 modify TarFiles builder
---
.../apache/jackrabbit/oak/segment/file/FileStore.java | 4 +++-
.../jackrabbit/oak/segment/file/ReadOnlyFileStore.java | 3 ++-
.../jackrabbit/oak/segment/file/tar/TarFiles.java | 11 +++++++++++
.../jackrabbit/oak/segment/IdMappingBlobStore.java | 18 +++++++++++++++++-
.../jackrabbit/oak/segment/LongIdMappingBlobStore.java | 17 +++++++++++++++++
.../jackrabbit/oak/segment/file/FileStoreTest.java | 5 ++++-
6 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
index 641b9a9b83..c62304189f 100644
--- a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
+++ b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java
@@ -169,10 +169,12 @@ public class FileStore extends AbstractFileStore {
.withMaxFileSize(builder.getMaxFileSize() * MB)
.withPersistence(builder.getPersistence())
.withReaderCountStats(readerCountStats)
- .withSegmentCountStats(segmentCountStats);
+ .withSegmentCountStats(segmentCountStats)
+ .withInitialisedReaders(false);
this.tarFiles = tarFilesBuilder.build();
this.tarFiles.init();
+
long size = this.tarFiles.size();
this.stats.init(size);
diff --git a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/ReadOnlyFileStore.java b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/ReadOnlyFileStore.java
index bf25f32b74..b90181637c 100644
--- a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/ReadOnlyFileStore.java
+++ b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/ReadOnlyFileStore.java
@@ -77,8 +77,9 @@ public class ReadOnlyFileStore extends AbstractFileStore {
.withMemoryMapping(memoryMapping)
.withReadOnly()
.withPersistence(builder.getPersistence())
+ .withInitialisedReaders(false)
.build();
-
+ tarFiles.init();
writer = defaultSegmentWriterBuilder("read-only").withoutCache().build(this);
gcRetainedGenerations = builder.getGcOptions().getRetainedGenerations();
diff --git a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/tar/TarFiles.java b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/tar/TarFiles.java
index 9a0b77cf6f..31180e4653 100644
--- a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/tar/TarFiles.java
+++ b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/tar/TarFiles.java
@@ -136,6 +136,8 @@ public class TarFiles implements Closeable {
private CounterStats segmentCountStats = NoopStats.INSTANCE;
+ private boolean initialisedReaders = true;
+
private Builder() {
// Prevent external instantiation.
}
@@ -201,6 +203,11 @@ public class TarFiles implements Closeable {
return this;
}
+ public Builder withInitialisedReaders(boolean initialisedReaders) {
+ this.initialisedReaders = initialisedReaders;
+ return this;
+ }
+
public TarFiles build() throws IOException {
checkState(directory != null, "Directory not specified");
checkState(tarRecovery != null, "TAR recovery strategy not specified");
@@ -384,6 +391,10 @@ public class TarFiles implements Closeable {
segmentCount = builder.segmentCountStats;
readOnly = builder.readOnly;
tarRecovery = builder.tarRecovery;
+
+ if (builder.initialisedReaders) {
+ init();
+ }
}
public void init() throws IOException {
diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/IdMappingBlobStore.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/IdMappingBlobStore.java
index 249a37e9af..032b24d0de 100644
--- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/IdMappingBlobStore.java
+++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/IdMappingBlobStore.java
@@ -1,6 +1,22 @@
+/*
+ * 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;
-import org.apache.jackrabbit.guava.common.base.Strings;
import org.apache.jackrabbit.oak.spi.blob.BlobOptions;
import org.apache.jackrabbit.oak.spi.blob.BlobStore;
import org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore;
diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/LongIdMappingBlobStore.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/LongIdMappingBlobStore.java
index 1ca7e2c0af..5bba7ebad9 100644
--- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/LongIdMappingBlobStore.java
+++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/LongIdMappingBlobStore.java
@@ -1,3 +1,20 @@
+/*
+ * 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;
import org.apache.jackrabbit.guava.common.base.Strings;
diff --git a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/FileStoreTest.java b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/FileStoreTest.java
index 442ba0d3d9..903b795c9c 100644
--- a/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/FileStoreTest.java
+++ b/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/FileStoreTest.java
@@ -166,12 +166,15 @@ public class FileStoreTest {
builder.setProperty("foo", "bar");
Blob blob = builder.createBlob(new ZeroStream(100));
- builder.setProperty("binaryProperty", blob);
+
segmentNodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
fileStore.flush();
// create another segment
+
+ builder.setProperty("binaryProperty", blob);
+
builder.setProperty("foo1", "bar1");
segmentNodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
fileStore.flush();