Skip to content

Commit

Permalink
HDDS-11699. Fix review notices.
Browse files Browse the repository at this point in the history
  • Loading branch information
juncevich committed Dec 13, 2024
1 parent 0d758ad commit 41abc0e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1807,7 +1807,7 @@ private OmKeyInfo getS3PartKeyInfo(
.setSortDatanodesInPipeline(topologyAwareReadEnabled)
.setLatestVersionLocation(getLatestVersionLocation)
.setForceUpdateContainerCacheFromSCM(false)
.setPartNumber(partNumber)
.setMultipartUploadPartNumber(partNumber)
.build();
KeyInfoWithVolumeContext keyInfoWithS3Context =
ozoneManagerClient.getKeyInfo(keyArgs, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public final class OmKeyArgs implements Auditable {
private final boolean headOp;
private final boolean forceUpdateContainerCacheFromSCM;
private final Map<String, String> tags;
private final Integer partNumber;
// expectedDataGeneration, when used in key creation indicates that a
// key with the same keyName should exist with the given generation.
// For a key commit to succeed, the original key should still be present with the
Expand Down Expand Up @@ -83,7 +82,6 @@ private OmKeyArgs(Builder b) {
this.ownerName = b.ownerName;
this.tags = b.tags;
this.expectedDataGeneration = b.expectedDataGeneration;
this.partNumber = b.partNumber;
}

public boolean getIsMultipartKey() {
Expand Down Expand Up @@ -170,10 +168,6 @@ public Long getExpectedDataGeneration() {
return expectedDataGeneration;
}

public Integer getPartNumber() {
return partNumber;
}

@Override
public Map<String, String> toAuditMap() {
Map<String, String> auditMap = new LinkedHashMap<>();
Expand Down Expand Up @@ -220,10 +214,6 @@ public OmKeyArgs.Builder toBuilder() {
builder.setExpectedDataGeneration(expectedDataGeneration);
}

if (partNumber != null) {
builder.setPartNumber(partNumber);
}

return builder;
}

Expand All @@ -240,8 +230,8 @@ public KeyArgs toProtobuf() {
.setForceUpdateContainerCacheFromSCM(
isForceUpdateContainerCacheFromSCM()
);
if (partNumber != null) {
builder.setPartNumber(partNumber);
if (multipartUploadPartNumber != 0) {
builder.setMultipartNumber(multipartUploadPartNumber);
}
if (expectedDataGeneration != null) {
builder.setExpectedDataGeneration(expectedDataGeneration);
Expand Down Expand Up @@ -272,7 +262,6 @@ public static class Builder {
private boolean forceUpdateContainerCacheFromSCM;
private final Map<String, String> tags = new HashMap<>();
private Long expectedDataGeneration = null;
private Integer partNumber;

public Builder setVolumeName(String volume) {
this.volumeName = volume;
Expand Down Expand Up @@ -387,11 +376,6 @@ public Builder setExpectedDataGeneration(long generation) {
return this;
}

public Builder setPartNumber(int partNumber) {
this.partNumber = partNumber;
return this;
}

public OmKeyArgs build() {
return new OmKeyArgs(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.hadoop.hdds.client.ContainerBlockID;
import org.apache.hadoop.hdds.client.ECReplicationConfig;
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.hdds.scm.storage.BlockLocationInfo;
import org.apache.hadoop.hdds.utils.db.Codec;
import org.apache.hadoop.hdds.utils.db.DelegatedCodec;
import org.apache.hadoop.hdds.utils.db.CopyObject;
Expand All @@ -48,7 +47,6 @@
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;

/**
* Args for key block. The block instance for the key requested in putKey.
Expand Down Expand Up @@ -81,8 +79,6 @@ public static Codec<OmKeyInfo> getCodec(boolean ignorePipeline) {
private String keyName;
private long dataSize;
private List<OmKeyLocationInfoGroup> keyLocationVersions;
private Map<Integer, List<OmKeyLocationInfo>> currentlocationsPartsMap;
private Map<Integer, Long> currentDataSizePartsMap;
private final long creationTime;
private long modificationTime;
private ReplicationConfig replicationConfig;
Expand Down Expand Up @@ -191,17 +187,6 @@ public String getOwnerName() {
return ownerName;
}

public Map<Integer, List<OmKeyLocationInfo>> getCurrentlocationsPartsMap() {
if (currentDataSizePartsMap == null) {
refreshCurrentLocationPartsMap();
}
return currentlocationsPartsMap;
}

public Map<Integer, Long> getCurrentDataSizePartsMap() {
return currentDataSizePartsMap;
}

/**
* Returns the generation of the object. Note this is currently the same as updateID for a key.
* @return long
Expand All @@ -224,25 +209,6 @@ public void setKeyLocationVersions(
this.keyLocationVersions = keyLocationVersions;
}

private void refreshCurrentLocationPartsMap() {
if (this.keyLocationVersions.size() > 0) {
this.currentlocationsPartsMap = this.keyLocationVersions.get(keyLocationVersions.size() - 1)
.getLocationList()
.stream()
.filter(it -> it.getPartNumber() != 0)
.collect(Collectors.groupingBy(OmKeyLocationInfo::getPartNumber));
this.currentDataSizePartsMap = this.currentlocationsPartsMap.entrySet().stream()
.map(it -> Pair.of(
it.getKey(),
it.getValue().stream().
mapToLong(BlockLocationInfo::getLength)
.sum()
)
)
.collect(Collectors.toMap(Pair::getKey, Pair::getValue));
}
}

public void setFile(boolean file) {
isFile = file;
}
Expand Down Expand Up @@ -384,7 +350,6 @@ public synchronized void appendNewBlocks(
if (updateTime) {
setModificationTime(Time.now());
}
refreshCurrentLocationPartsMap();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,8 +1079,6 @@ message KeyArgs {
// This allows a key to be created an committed atomically if the original has not
// been modified.
optional uint64 expectedDataGeneration = 23;

optional int32 partNumber = 24;
}

message KeyLocation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,25 +509,31 @@ private OmKeyInfo readKeyInfo(OmKeyArgs args, BucketLayout bucketLayout)
if (args.getLatestVersionLocation()) {
slimLocationVersion(value);
}
Integer partNumberParam = args.getPartNumber();
if (partNumberParam != null && partNumberParam > 0) {
int partNumberParam = args.getMultipartUploadPartNumber();
if (partNumberParam > 0) {
OmKeyLocationInfoGroup latestLocationVersion = value.getLatestVersionLocations();
if (latestLocationVersion != null && latestLocationVersion.isMultipartKey()) {
List<OmKeyLocationInfo> currentLocations =
value.getKeyLocationVersions().get(value.getKeyLocationVersions().size() - 1)
.getLocationList()
.stream()
.filter(it -> it.getPartNumber() == partNumberParam)
.collect(Collectors.toList());

value.setKeyLocationVersions(
Collections.singletonList(
new OmKeyLocationInfoGroup(
latestLocationVersion.getVersion(),
value.getCurrentlocationsPartsMap()
.getOrDefault(partNumberParam, Collections.emptyList()),
currentLocations,
true
)
)
);
value.setDataSize(
value.getCurrentDataSizePartsMap()
.getOrDefault(partNumberParam, 0L)
);

long dataLength = currentLocations.stream()
.mapToLong(BlockLocationInfo::getLength)
.sum();
value.setDataSize(dataLength);
}
}
return value;
Expand Down Expand Up @@ -822,7 +828,7 @@ public boolean isSstFilteringSvcEnabled() {
TimeUnit.MILLISECONDS);
return serviceInterval != DISABLE_VALUE;
}

@Override
public OmMultipartUploadList listMultipartUploads(String volumeName,
String bucketName, String prefix) throws OMException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ private GetKeyInfoResponse getKeyInfo(GetKeyInfoRequest request,
.setHeadOp(keyArgs.getHeadOp())
.setForceUpdateContainerCacheFromSCM(
keyArgs.getForceUpdateContainerCacheFromSCM())
.setPartNumber(keyArgs.getPartNumber())
.setMultipartUploadPartNumber(keyArgs.getMultipartNumber())
.build();
KeyInfoWithVolumeContext keyInfo = impl.getKeyInfo(omKeyArgs,
request.getAssumeS3Context());
Expand Down

0 comments on commit 41abc0e

Please sign in to comment.