Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion hadoop-hdds/common/src/main/resources/ozone-default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4282,7 +4282,7 @@
</property>

<property>
<name>ozone.om.snapshot.diff.cleanup.service.run.internal</name>
<name>ozone.om.snapshot.diff.cleanup.service.run.interval</name>
<value>1m</value>
<tag>OZONE, OM</tag>
<description>
Expand All @@ -4301,6 +4301,16 @@
</description>
</property>

<property>
<name>ozone.om.snapshot.cache.cleanup.service.run.interval</name>
<value>1m</value>
<tag>OZONE, OM</tag>
<description>
Interval at which snapshot cache clean up will run.
Uses millisecond by default when no time unit is specified.
</description>
</property>

<property>
<name>ozone.om.snapshot.load.native.lib</name>
<value>true</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ private void createSstBackUpDir() {
}

@Override
public void close() throws Exception {
public void close() {
if (!closed) {
synchronized (this) {
if (!closed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,13 +569,20 @@ private OMConfigKeys() {
= TimeUnit.DAYS.toMillis(7);

public static final String OZONE_OM_SNAPSHOT_DIFF_CLEANUP_SERVICE_RUN_INTERVAL
= "ozone.om.snapshot.diff.cleanup.service.run.internal";
= "ozone.om.snapshot.diff.cleanup.service.run.interval";
public static final String
OZONE_OM_SNAPSHOT_CACHE_CLEANUP_SERVICE_RUN_INTERVAL
= "ozone.om.snapshot.cache.cleanup.service.run.interval";
public static final long
OZONE_OM_SNAPSHOT_DIFF_CLEANUP_SERVICE_RUN_INTERVAL_DEFAULT
= TimeUnit.MINUTES.toMillis(1);
public static final long
OZONE_OM_SNAPSHOT_CACHE_CLEANUP_SERVICE_RUN_INTERVAL_DEFAULT
= TimeUnit.MINUTES.toMillis(1);

public static final String OZONE_OM_SNAPSHOT_DIFF_CLEANUP_SERVICE_TIMEOUT
= "ozone.om.snapshot.diff.cleanup.service.timeout";

public static final long
OZONE_OM_SNAPSHOT_DIFF_CLEANUP_SERVICE_TIMEOUT_DEFAULT
= TimeUnit.MINUTES.toMillis(5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;

/**
Expand Down Expand Up @@ -74,6 +75,7 @@ public class OmSnapshot implements IOmMetadataReader, Closeable {
private final String volumeName;
private final String bucketName;
private final String snapshotName;
private final UUID snapshotID;
// To access snapshot checkpoint DB metadata
private final OMMetadataManager omMetadataManager;
private final KeyManager keyManager;
Expand All @@ -83,7 +85,8 @@ public OmSnapshot(KeyManager keyManager,
OzoneManager ozoneManager,
String volumeName,
String bucketName,
String snapshotName) {
String snapshotName,
UUID snapshotID) {
IAccessAuthorizer accessAuthorizer =
OzoneAuthorizerFactory.forSnapshot(ozoneManager,
keyManager, prefixManager);
Expand All @@ -93,6 +96,7 @@ public OmSnapshot(KeyManager keyManager,
this.snapshotName = snapshotName;
this.bucketName = bucketName;
this.volumeName = volumeName;
this.snapshotID = snapshotID;
this.keyManager = keyManager;
this.omMetadataManager = keyManager.getMetadataManager();
}
Expand Down Expand Up @@ -295,6 +299,10 @@ public String getName() {
return snapshotName;
}

public UUID getSnapshotID() {
return snapshotID;
}

@Override
public void close() throws IOException {
// Close DB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
import static org.apache.hadoop.ozone.OzoneConsts.OM_SNAPSHOT_CHECKPOINT_DIR;
import static org.apache.hadoop.ozone.OzoneConsts.OM_SNAPSHOT_DIFF_DB_NAME;
import static org.apache.hadoop.ozone.OzoneConsts.OM_SNAPSHOT_INDICATOR;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_CACHE_CLEANUP_SERVICE_RUN_INTERVAL;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_CACHE_CLEANUP_SERVICE_RUN_INTERVAL_DEFAULT;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_CACHE_MAX_SIZE;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_CACHE_MAX_SIZE_DEFAULT;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_DB_MAX_OPEN_FILES;
Expand Down Expand Up @@ -272,7 +274,12 @@ public OmSnapshotManager(OzoneManager ozoneManager) {
};

// Init snapshot cache
this.snapshotCache = new SnapshotCache(loader, softCacheSize, ozoneManager.getMetrics());
long cacheCleanupServiceInterval = ozoneManager.getConfiguration()
.getTimeDuration(OZONE_OM_SNAPSHOT_CACHE_CLEANUP_SERVICE_RUN_INTERVAL,
OZONE_OM_SNAPSHOT_CACHE_CLEANUP_SERVICE_RUN_INTERVAL_DEFAULT,
TimeUnit.MILLISECONDS);
this.snapshotCache = new SnapshotCache(loader, softCacheSize, ozoneManager.getMetrics(),
cacheCleanupServiceInterval);

this.snapshotDiffManager = new SnapshotDiffManager(snapshotDiffDb, differ,
ozoneManager, snapDiffJobCf, snapDiffReportCf,
Expand Down Expand Up @@ -382,7 +389,8 @@ public OmSnapshot load(@Nonnull UUID snapshotId) throws IOException {
return new OmSnapshot(km, pm, ozoneManager,
snapshotInfo.getVolumeName(),
snapshotInfo.getBucketName(),
snapshotInfo.getName());
snapshotInfo.getName(),
snapshotInfo.getSnapshotId());
} catch (Exception e) {
// Close RocksDB if there is any failure.
if (!snapshotMetadataManager.getStore().isClosed()) {
Expand Down Expand Up @@ -426,7 +434,7 @@ public void invalidateCache() {
*
* @param key SnapshotId.
*/
public void invalidateCacheEntry(UUID key) throws IOException {
public void invalidateCacheEntry(UUID key) {
if (snapshotCache != null) {
snapshotCache.invalidate(key);
}
Expand Down Expand Up @@ -949,7 +957,9 @@ public void close() {
snapshotDiffManager.close();
}

invalidateCache();
if (snapshotCache != null) {
snapshotCache.close();
}

if (snapshotDiffCleanupService != null) {
snapshotDiffCleanupService.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public class ReferenceCounted<T>
/**
* Parent instance whose callback will be triggered upon this RC closure.
*/
private final Object parentWithCallback;
private final ReferenceCountedCallback parentWithCallback;

public ReferenceCounted(T obj, boolean disableCounter,
Object parentWithCallback) {
ReferenceCountedCallback parentWithCallback) {
// A param to allow disabling ref counting to reduce active DB
// access penalties due to AtomicLong operations.
this.obj = obj;
Expand Down Expand Up @@ -126,7 +126,9 @@ public long decrementRefCount() {
Preconditions.checkState(newValTotal >= 0L,
"Total reference count underflow");
}

if (refCount.get() == 0) {
this.parentWithCallback.callback(this);
}
return refCount.get();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.hadoop.ozone.om.snapshot;

/**
* Callback interface for ReferenceCounted.
*/
public interface ReferenceCountedCallback {
void callback(ReferenceCounted referenceCounted);
}
Loading