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
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public abstract class AbstractKeyDeletingService extends BackgroundService
private final AtomicLong movedDirsCount;
private final AtomicLong movedFilesCount;
private final AtomicLong runCount;
private final AtomicLong callId;
private final BootstrapStateHandler.Lock lock =
new BootstrapStateHandler.Lock();

Expand All @@ -97,6 +98,7 @@ public AbstractKeyDeletingService(String serviceName, long interval,
this.runCount = new AtomicLong(0);
this.metrics = ozoneManager.getDeletionMetrics();
this.perfMetrics = ozoneManager.getPerfMetrics();
this.callId = new AtomicLong(0);
}

protected int processKeyDeletes(List<BlockGroup> keyBlocksList,
Expand Down Expand Up @@ -220,7 +222,7 @@ private int submitPurgeKeysRequest(List<DeleteBlockGroupResult> results,

// Submit PurgeKeys request to OM
try {
OzoneManagerRatisUtils.submitRequest(ozoneManager, omRequest, clientId, runCount.get());
submitRequest(omRequest);
} catch (ServiceException e) {
LOG.error("PurgeKey request failed. Will retry at next run.", e);
return 0;
Expand All @@ -229,6 +231,10 @@ private int submitPurgeKeysRequest(List<DeleteBlockGroupResult> results,
return deletedCount;
}

protected OzoneManagerProtocolProtos.OMResponse submitRequest(OMRequest omRequest) throws ServiceException {
return OzoneManagerRatisUtils.submitRequest(ozoneManager, omRequest, clientId, callId.incrementAndGet());
Copy link
Contributor

Choose a reason for hiding this comment

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

and i think this API is easy to misuse. We need a little more javadoc for the callId so caller is expected to ensure callId is unique for different requests but remains the same for the same request.

Copy link
Contributor

Choose a reason for hiding this comment

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

HDDS-11807 is another example of misuse.

}

/**
* Parse Volume and Bucket Name from ObjectKey and add it to given map of
* keys to be purged per bucket.
Expand All @@ -250,7 +256,7 @@ private void addToMap(Map<Pair<String, String>, List<String>> map, String object

protected void submitPurgePaths(List<PurgePathRequest> requests,
String snapTableKey,
UUID expectedPreviousSnapshotId, long rnCnt) {
UUID expectedPreviousSnapshotId) {
OzoneManagerProtocolProtos.PurgeDirectoriesRequest.Builder purgeDirRequest =
OzoneManagerProtocolProtos.PurgeDirectoriesRequest.newBuilder();

Expand All @@ -275,7 +281,7 @@ protected void submitPurgePaths(List<PurgePathRequest> requests,

// Submit Purge paths request to OM
try {
OzoneManagerRatisUtils.submitRequest(ozoneManager, omRequest, clientId, rnCnt);
submitRequest(omRequest);
} catch (ServiceException e) {
LOG.error("PurgePaths request failed. Will retry at next run.", e);
}
Expand Down Expand Up @@ -403,7 +409,7 @@ public void optimizeDirDeletesAndSubmitRequest(
}

if (!purgePathRequestList.isEmpty()) {
submitPurgePaths(purgePathRequestList, snapTableKey, expectedPreviousSnapshotId, rnCnt);
submitPurgePaths(purgePathRequestList, snapTableKey, expectedPreviousSnapshotId);
}

if (dirNum != 0 || subDirNum != 0 || subFileNum != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.apache.hadoop.ozone.om.SnapshotChainManager;
import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
import org.apache.hadoop.ozone.om.helpers.SnapshotInfo;
import org.apache.hadoop.ozone.om.ratis.utils.OzoneManagerRatisUtils;
import org.apache.hadoop.ozone.om.snapshot.ReferenceCounted;
import org.apache.hadoop.ozone.om.snapshot.SnapshotUtils;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
Expand Down Expand Up @@ -260,7 +259,7 @@ private void submitSnapshotPurgeRequest(List<String> purgeSnapshotKeys) throws I
.build();

try (BootstrapStateHandler.Lock lock = getBootstrapStateLock().lock()) {
submitRequest(omRequest);
submitOMRequest(omRequest);
}
}
}
Expand Down Expand Up @@ -298,14 +297,13 @@ private void submitSnapshotMoveDeletedKeys(SnapshotInfo snapInfo,
.setClientId(clientId.toString())
.build();
try (BootstrapStateHandler.Lock lock = getBootstrapStateLock().lock()) {
submitRequest(omRequest);
submitOMRequest(omRequest);
}
}

private void submitRequest(OMRequest omRequest) {
private void submitOMRequest(OMRequest omRequest) {
try {
Status status =
OzoneManagerRatisUtils.submitRequest(ozoneManager, omRequest, clientId, getRunCount().get()).getStatus();
Status status = submitRequest(omRequest).getStatus();
if (!Objects.equals(status, Status.OK)) {
LOG.error("Request: {} failed with an status: {}. Will retry in the next run.", omRequest, status);
}
Expand Down
Loading