Skip to content
Closed
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
10 changes: 10 additions & 0 deletions hadoop-hdds/common/src/main/resources/ozone-default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4449,6 +4449,16 @@
</description>
</property>

<property>
<name>ozone.om.snapshot.cache.lock.timeout</name>
<value>5s</value>
<tag>OZONE, OM</tag>
<description>
Wait Timeout for snapshot cache lock.
Uses milliseconds 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 @@ -591,6 +591,12 @@ private OMConfigKeys() {
public static final long
OZONE_OM_SNAPSHOT_DIFF_CLEANUP_SERVICE_RUN_INTERVAL_DEFAULT
= TimeUnit.MINUTES.toMillis(1);
public static final String
OZONE_OM_SNAPSHOT_CACHE_LOCK_TIMEOUT
= "ozone.om.snapshot.cache.lock.timeout";
public static final long
OZONE_OM_SNAPSHOT_CACHE_LOCK_TIMEOUT_DEFAULT
= TimeUnit.SECONDS.toMillis(5);
public static final long
OZONE_OM_SNAPSHOT_CACHE_CLEANUP_SERVICE_RUN_INTERVAL_DEFAULT
= TimeUnit.MINUTES.toMillis(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
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_LOCK_TIMEOUT;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_CACHE_LOCK_TIMEOUT_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 @@ -279,8 +281,12 @@ public OmSnapshotManager(OzoneManager ozoneManager) {
.getTimeDuration(OZONE_OM_SNAPSHOT_CACHE_CLEANUP_SERVICE_RUN_INTERVAL,
OZONE_OM_SNAPSHOT_CACHE_CLEANUP_SERVICE_RUN_INTERVAL_DEFAULT,
TimeUnit.MILLISECONDS);
long cacheLockTimeout = ozoneManager.getConfiguration()
.getTimeDuration(OZONE_OM_SNAPSHOT_CACHE_LOCK_TIMEOUT,
OZONE_OM_SNAPSHOT_CACHE_LOCK_TIMEOUT_DEFAULT,
TimeUnit.MILLISECONDS);
this.snapshotCache = new SnapshotCache(loader, softCacheSize, ozoneManager.getMetrics(),
cacheCleanupServiceInterval);
cacheCleanupServiceInterval, cacheLockTimeout);

this.snapshotDiffManager = new SnapshotDiffManager(snapshotDiffDb, differ,
ozoneManager, snapDiffJobCf, snapDiffReportCf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package org.apache.hadoop.ozone.om.snapshot;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

Expand Down Expand Up @@ -50,10 +52,10 @@ public class ReferenceCounted<T>
/**
* Parent instance whose callback will be triggered upon this RC closure.
*/
private final ReferenceCountedCallback parentWithCallback;
private final ReferenceCountedCallback<T> parentWithCallback;

public ReferenceCounted(T obj, boolean disableCounter,
ReferenceCountedCallback parentWithCallback) {
ReferenceCountedCallback<T> 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 @@ -125,9 +127,7 @@ public long decrementRefCount() {
Preconditions.checkState(newValTotal >= 0L,
"Total reference count underflow");
}
if (refCount.get() == 0) {
this.parentWithCallback.callback(this);
}
this.parentWithCallback.callback(this);
return refCount.get();
}

Expand Down Expand Up @@ -160,4 +160,8 @@ public void close() {
// so it is eligible to be used with try-with-resources.
decrementRefCount();
}

public Map<Long, Long> getThreadCntMap() {
return ImmutableMap.copyOf(threadMap);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this be expensive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be very expensive as the reference to a snapshot shouldn't be held by a lot of threads.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
/**
* Callback interface for ReferenceCounted.
*/
public interface ReferenceCountedCallback {
void callback(ReferenceCounted referenceCounted);
public interface ReferenceCountedCallback<T> {
void callback(ReferenceCounted<T> referenceCounted);
}
Loading