-
Notifications
You must be signed in to change notification settings - Fork 620
HDDS-11603. Reclaimable Filter for Snapshots garbage reclaimation #7345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
a9f3630
80713fd
dcfec3d
e2a8cfe
7096a1c
7514ac3
889cb9d
7c141fd
acdaffe
b94a54f
df8c562
8b7c738
fdafee8
8bc3cc6
4c9bdfb
b7e20ca
0ee6b06
890eeb4
0d209b7
7e1e9d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * 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.util; | ||
|
|
||
| /** | ||
| * | ||
| * Represents a function that accepts one argument and produces a result. | ||
| * This is a functional interface whose functional method is apply(Object). | ||
| * Type parameters: | ||
| * <T> – the type of the input to the function <R> – the type of the result of the function | ||
| * <E> - the type of exception thrown. | ||
| */ | ||
| public interface CheckedExceptionOperation<T, R, E extends Exception> { | ||
| R apply(T t) throws E; | ||
|
|
||
| default <V> CheckedExceptionOperation<T, V, E> andThen(CheckedExceptionOperation<R, V, E> operation) { | ||
|
swamirishi marked this conversation as resolved.
Outdated
|
||
| return (T t) -> operation.apply(this.apply(t)); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -604,6 +604,11 @@ default String getOpenFileName(long volumeId, long bucketId, long parentObjectId | |
| */ | ||
| String getRenameKey(String volume, String bucket, long objectID); | ||
|
|
||
| /** | ||
| * Given renameKey, return the volume, bucket and objectID from the key. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is the correct place to keep this function but I'll let you decide it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems ok because metadata manager is the translation layer b/w rocksdb & OM. We also have the function Given a volume name,bucket name & object give the renameTable key corresponding to the entry. |
||
| */ | ||
| String[] splitRenameKey(String renameKey); | ||
|
|
||
| /** | ||
| * Returns the DB key name of a multipart upload key in OM metadata store | ||
| * for FSO-enabled buckets. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * 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.lock; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.LinkedList; | ||
| import java.util.Queue; | ||
| import org.apache.hadoop.ozone.om.exceptions.OMException; | ||
|
|
||
| /** | ||
| * Class to take multiple locks on a resource. | ||
| */ | ||
| public class MultiLocks<T> { | ||
|
swamirishi marked this conversation as resolved.
Outdated
|
||
| private final Queue<T> objectLocks; | ||
| private final IOzoneManagerLock lock; | ||
| private final OzoneManagerLock.Resource resource; | ||
| private final boolean writeLock; | ||
|
|
||
| public MultiLocks(IOzoneManagerLock lock, OzoneManagerLock.Resource resource, boolean writeLock) { | ||
| this.writeLock = writeLock; | ||
|
hemantk-12 marked this conversation as resolved.
Outdated
|
||
| this.resource = resource; | ||
| this.lock = lock; | ||
| this.objectLocks = new LinkedList<>(); | ||
| } | ||
|
|
||
| public OMLockDetails acquireLock(Collection<T> objects) throws OMException { | ||
| if (!objectLocks.isEmpty()) { | ||
|
hemantk-12 marked this conversation as resolved.
Outdated
|
||
| throw new OMException("More locks cannot be acquired when locks have been already acquired. Locks acquired : " | ||
| + objectLocks, OMException.ResultCodes.INTERNAL_ERROR); | ||
| } | ||
| OMLockDetails omLockDetails = OMLockDetails.EMPTY_DETAILS_LOCK_ACQUIRED; | ||
| for (T object : objects) { | ||
| if (object != null) { | ||
|
hemantk-12 marked this conversation as resolved.
Outdated
|
||
| omLockDetails = this.writeLock ? lock.acquireWriteLock(resource, object.toString()) | ||
| : lock.acquireReadLock(resource, object.toString()); | ||
| objectLocks.add(object); | ||
| if (!omLockDetails.isLockAcquired()) { | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (!omLockDetails.isLockAcquired()) { | ||
| releaseLock(); | ||
| } | ||
| return omLockDetails; | ||
| } | ||
|
|
||
| public void releaseLock() { | ||
| while (!objectLocks.isEmpty()) { | ||
| T object = objectLocks.poll(); | ||
| if (this.writeLock) { | ||
| lock.releaseWriteLock(resource, object.toString()); | ||
| } else { | ||
| lock.releaseReadLock(resource, object.toString()); | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.