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
8 changes: 8 additions & 0 deletions hadoop-hdds/common/src/main/resources/ozone-default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,14 @@
hdds.container.ratis.datanode.storage.dir be configured separately.
</description>
</property>
<property>
<name>ozone.path.deleting.limit.per.task</name>
<value>20000</value>
<tag>OZONE, PERFORMANCE, OM</tag>
<description>A maximum number of paths(dirs/files) to be deleted by
directory deleting service per time interval.
</description>
</property>
<property>
<name>ozone.metadata.dirs.permissions</name>
<value>750</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@ public final class OMConfigKeys {
public static final String OZONE_DIR_DELETING_SERVICE_INTERVAL_DEFAULT
= "60s";

public static final String OZONE_PATH_DELETING_LIMIT_PER_TASK =
"ozone.path.deleting.limit.per.task";
// default is 20000 taking account of 32MB buffer size
public static final int OZONE_PATH_DELETING_LIMIT_PER_TASK_DEFAULT = 20000;

/**
* Configuration properties for Snapshot Directory Service.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.LongSupplier;
import org.apache.commons.lang3.RandomStringUtils;
Expand Down Expand Up @@ -623,9 +624,9 @@ public void testAOSKeyDeletingWithSnapshotCreateParallelExecution()
}
return null;
}).when(service).optimizeDirDeletesAndSubmitRequest(anyLong(), anyLong(),
anyLong(), anyList(), anyList(), eq(null), anyLong(), anyLong(), any(),
anyLong(), anyList(), anyList(), eq(null), anyLong(), any(),
any(ReclaimableDirFilter.class), any(ReclaimableKeyFilter.class), anyMap(), any(),
anyLong());
anyLong(), any(AtomicInteger.class));

Mockito.doAnswer(i -> {
store.createSnapshot(testVolumeName, testBucketName, snap2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,20 @@
public class DeleteKeysResult {

private List<OmKeyInfo> keysToDelete;
private long consumedSize;

private boolean processedKeys;

public DeleteKeysResult(List<OmKeyInfo> keysToDelete,
long consumedSize, boolean processedKeys) {
public DeleteKeysResult(List<OmKeyInfo> keysToDelete, boolean processedKeys) {
this.keysToDelete = keysToDelete;
this.consumedSize = consumedSize;
this.processedKeys = processedKeys;
}

public List<OmKeyInfo> getKeysToDelete() {
return keysToDelete;
}

public long getConsumedSize() {
return consumedSize;
}

public boolean isProcessedKeys() {
return processedKeys;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ default List<Table.KeyValue<String, OmKeyInfo>> getDeletedDirEntries(String volu
* @return list of dirs
* @throws IOException
*/
DeleteKeysResult getPendingDeletionSubDirs(long volumeId, long bucketId,
OmKeyInfo parentInfo, CheckedFunction<Table.KeyValue<String, OmKeyInfo>, Boolean, IOException> filter,
long remainingBufLimit) throws IOException;
DeleteKeysResult getPendingDeletionSubDirs(long volumeId, long bucketId, OmKeyInfo parentInfo,
CheckedFunction<Table.KeyValue<String, OmKeyInfo>, Boolean, IOException> filter, int remainingNum)
throws IOException;

/**
* Returns all sub files under the given parent directory.
Expand All @@ -317,10 +317,9 @@ DeleteKeysResult getPendingDeletionSubDirs(long volumeId, long bucketId,
* @return list of files
* @throws IOException
*/
DeleteKeysResult getPendingDeletionSubFiles(long volumeId,
long bucketId, OmKeyInfo parentInfo,
CheckedFunction<Table.KeyValue<String, OmKeyInfo>, Boolean, IOException> filter, long remainingBufLimit)
throws IOException;
DeleteKeysResult getPendingDeletionSubFiles(long volumeId, long bucketId, OmKeyInfo parentInfo,
CheckedFunction<Table.KeyValue<String, OmKeyInfo>, Boolean, IOException> filter, int remainingNum)
throws IOException;

/**
* Returns the instance of Directory Deleting Service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2264,49 +2264,37 @@ private void slimLocationVersion(OmKeyInfo... keyInfos) {
}

@Override
public DeleteKeysResult getPendingDeletionSubDirs(long volumeId, long bucketId,
OmKeyInfo parentInfo, CheckedFunction<KeyValue<String, OmKeyInfo>, Boolean, IOException> filter,
long remainingBufLimit) throws IOException {
public DeleteKeysResult getPendingDeletionSubDirs(long volumeId, long bucketId, OmKeyInfo parentInfo,
CheckedFunction<KeyValue<String, OmKeyInfo>, Boolean, IOException> filter, int remainingNum) throws IOException {
return gatherSubPathsWithIterator(volumeId, bucketId, parentInfo, metadataManager.getDirectoryTable(),
kv -> Table.newKeyValue(metadataManager.getOzoneDeletePathKey(kv.getValue().getObjectID(), kv.getKey()),
OMFileRequest.getKeyInfoWithFullPath(parentInfo, kv.getValue())),
filter, remainingBufLimit);
OMFileRequest.getKeyInfoWithFullPath(parentInfo, kv.getValue())), filter, remainingNum);
}

private <T extends WithParentObjectId> DeleteKeysResult gatherSubPathsWithIterator(
long volumeId, long bucketId, OmKeyInfo parentInfo,
Table<String, T> table,
private <T extends WithParentObjectId> DeleteKeysResult gatherSubPathsWithIterator(long volumeId, long bucketId,
OmKeyInfo parentInfo, Table<String, T> table,
CheckedFunction<KeyValue<String, T>, KeyValue<String, OmKeyInfo>, IOException> deleteKeyTransformer,
CheckedFunction<KeyValue<String, OmKeyInfo>, Boolean, IOException> deleteKeyFilter,
long remainingBufLimit) throws IOException {
CheckedFunction<KeyValue<String, OmKeyInfo>, Boolean, IOException> deleteKeyFilter, int remainingNum)
throws IOException {
List<OmKeyInfo> keyInfos = new ArrayList<>();
String seekFileInDB = metadataManager.getOzonePathKey(volumeId, bucketId,
parentInfo.getObjectID(), "");
long consumedSize = 0;
String seekFileInDB = metadataManager.getOzonePathKey(volumeId, bucketId, parentInfo.getObjectID(), "");
try (TableIterator<String, ? extends KeyValue<String, T>> iterator = table.iterator(seekFileInDB)) {
while (iterator.hasNext() && remainingBufLimit > 0) {
while (iterator.hasNext() && remainingNum > 0) {
KeyValue<String, T> entry = iterator.next();
final long objectSerializedSize = entry.getValueByteSize();
// No need to check the table again as the value in cache and iterator would be same when directory
// deleting service runs.
if (remainingBufLimit - objectSerializedSize < 0) {
break;
}
KeyValue<String, OmKeyInfo> keyInfo = deleteKeyTransformer.apply(entry);
if (deleteKeyFilter.apply(keyInfo)) {
keyInfos.add(keyInfo.getValue());
remainingBufLimit -= objectSerializedSize;
consumedSize += objectSerializedSize;
remainingNum--;
}
}
return new DeleteKeysResult(keyInfos, consumedSize, !iterator.hasNext());
return new DeleteKeysResult(keyInfos, !iterator.hasNext());
}
}

@Override
public DeleteKeysResult getPendingDeletionSubFiles(long volumeId,
long bucketId, OmKeyInfo parentInfo,
CheckedFunction<Table.KeyValue<String, OmKeyInfo>, Boolean, IOException> filter, long remainingBufLimit)
CheckedFunction<Table.KeyValue<String, OmKeyInfo>, Boolean, IOException> filter, int remainingNum)
throws IOException {
CheckedFunction<KeyValue<String, OmKeyInfo>, KeyValue<String, OmKeyInfo>, IOException> tranformer = kv -> {
OmKeyInfo keyInfo = OMFileRequest.getKeyInfoWithFullPath(parentInfo, kv.getValue());
Expand All @@ -2315,7 +2303,7 @@ public DeleteKeysResult getPendingDeletionSubFiles(long volumeId,
return Table.newKeyValue(deleteKey, keyInfo);
};
return gatherSubPathsWithIterator(volumeId, bucketId, parentInfo, metadataManager.getFileTable(), tranformer,
filter, remainingBufLimit);
filter, remainingNum);
}

public boolean isBucketFSOptimized(String volName, String buckName)
Expand Down
Loading
Loading