Skip to content

Commit 17ef16f

Browse files
committed
Open key table read should be checked only if there are no parts.
1 parent 06b1571 commit 17ef16f

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,15 +1299,21 @@ public OmMultipartUploadListParts listParts(String volumeName,
12991299
Iterator<Map.Entry<Integer, PartKeyInfo>> partKeyInfoMapIterator =
13001300
partKeyInfoMap.entrySet().iterator();
13011301

1302-
OmKeyInfo omKeyInfo =
1303-
metadataManager.getOpenKeyTable().get(multipartKey);
1302+
HddsProtos.ReplicationType replicationType = null;
13041303

1305-
if (omKeyInfo == null) {
1306-
throw new IllegalStateException(
1307-
"Open key is missing for multipart upload " + multipartKey);
1304+
//if there are no parts, use the replicationType from the open key.
1305+
if (partKeyInfoMap.size() == 0) {
1306+
OmKeyInfo omKeyInfo =
1307+
metadataManager.getOpenKeyTable().get(multipartKey);
1308+
1309+
if (omKeyInfo == null) {
1310+
throw new IllegalStateException(
1311+
"Open key is missing for multipart upload " + multipartKey);
1312+
}
1313+
1314+
replicationType = omKeyInfo.getType();
13081315
}
13091316

1310-
HddsProtos.ReplicationType replicationType = omKeyInfo.getType();
13111317
int count = 0;
13121318
List<OmPartInfo> omPartInfoList = new ArrayList<>();
13131319

@@ -1324,11 +1330,16 @@ public OmMultipartUploadListParts listParts(String volumeName,
13241330
partKeyInfo.getPartKeyInfo().getModificationTime(),
13251331
partKeyInfo.getPartKeyInfo().getDataSize());
13261332
omPartInfoList.add(omPartInfo);
1333+
1334+
//if there are parts, use replication type from one of the parts
13271335
replicationType = partKeyInfo.getPartKeyInfo().getType();
13281336
count++;
13291337
}
13301338
}
13311339

1340+
Preconditions.checkNotNull(replicationType,
1341+
"Replication type can't be identified");
1342+
13321343
if (partKeyInfoMapIterator.hasNext()) {
13331344
Map.Entry<Integer, PartKeyInfo> partKeyInfoEntry =
13341345
partKeyInfoMapIterator.next();

0 commit comments

Comments
 (0)