ChenSammi commented on code in PR #4913:
URL: https://github.com/apache/ozone/pull/4913#discussion_r1331051495
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/DeleteBlocksCommandHandler.java:
##########
@@ -232,40 +267,44 @@ public DeleteBlockTransactionResult call() {
ContainerType containerType = cont.getContainerType();
switch (containerType) {
case KeyValueContainer:
+ KeyValueContainer keyValueContainer = (KeyValueContainer)cont;
KeyValueContainerData containerData = (KeyValueContainerData)
cont.getContainerData();
- cont.writeLock();
- try {
- if (containerData.hasSchema(SCHEMA_V1)) {
- markBlocksForDeletionSchemaV1(containerData, tx);
- } else if (containerData.hasSchema(SCHEMA_V2)) {
- markBlocksForDeletionSchemaV2(containerData, tx,
- newDeletionBlocks, tx.getTxID());
- } else if (containerData.hasSchema(SCHEMA_V3)) {
- markBlocksForDeletionSchemaV3(containerData, tx,
- newDeletionBlocks, tx.getTxID());
- } else {
- throw new UnsupportedOperationException(
- "Only schema version 1,2,3 are supported.");
+ if (keyValueContainer.
+ writeLockTryLock(tryLockTimeoutMs, TimeUnit.MILLISECONDS)) {
+ try {
+ String schemaVersion = containerData
+ .getSupportedSchemaVersionOrDefault();
+ if (getSchemaHandlers().containsKey(schemaVersion)) {
+ schemaHandlers.get(schemaVersion).handle(containerData, tx);
+ } else {
+ throw new UnsupportedOperationException(
+ "Only schema version 1,2,3 are supported.");
+ }
+ } finally {
+ cont.writeUnlock();
}
- } finally {
- cont.writeUnlock();
+ txResultBuilder.setContainerID(containerId)
+ .setSuccess(true);
+ } else {
+ lockAcquisitionFailed = true;
+ txResultBuilder.setContainerID(containerId)
+ .setSuccess(false);
}
- txResultBuilder.setContainerID(containerId)
- .setSuccess(true);
break;
default:
LOG.error(
"Delete Blocks Command Handler is not implemented for " +
"containerType {}", containerType);
}
- } catch (IOException e) {
+ } catch (IOException | InterruptedException e) {
Review Comment:
Please call Thread.currentThread().interrupt() if it's an
InterruptedException.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]