use of org.apache.hadoop.ozone.om.helpers.OmPartInfo in project ozone by apache.
the class RpcClient method listParts.
@Override
public OzoneMultipartUploadPartListParts listParts(String volumeName, String bucketName, String keyName, String uploadID, int partNumberMarker, int maxParts) throws IOException {
verifyVolumeName(volumeName);
verifyBucketName(bucketName);
HddsClientUtils.checkNotNull(uploadID);
Preconditions.checkArgument(maxParts > 0, "Max Parts Should be greater " + "than zero");
Preconditions.checkArgument(partNumberMarker >= 0, "Part Number Marker " + "Should be greater than or equal to zero, as part numbers starts from" + " 1 and ranges till 10000");
OmMultipartUploadListParts omMultipartUploadListParts = ozoneManagerClient.listParts(volumeName, bucketName, keyName, uploadID, partNumberMarker, maxParts);
OzoneMultipartUploadPartListParts ozoneMultipartUploadPartListParts = new OzoneMultipartUploadPartListParts(omMultipartUploadListParts.getReplicationConfig(), omMultipartUploadListParts.getNextPartNumberMarker(), omMultipartUploadListParts.isTruncated());
for (OmPartInfo omPartInfo : omMultipartUploadListParts.getPartInfoList()) {
ozoneMultipartUploadPartListParts.addPart(new OzoneMultipartUploadPartListParts.PartInfo(omPartInfo.getPartNumber(), omPartInfo.getPartName(), omPartInfo.getModificationTime(), omPartInfo.getSize()));
}
return ozoneMultipartUploadPartListParts;
}
use of org.apache.hadoop.ozone.om.helpers.OmPartInfo in project ozone by apache.
the class OzoneManagerRequestHandler method listParts.
private MultipartUploadListPartsResponse listParts(MultipartUploadListPartsRequest multipartUploadListPartsRequest) throws IOException {
MultipartUploadListPartsResponse.Builder response = MultipartUploadListPartsResponse.newBuilder();
OmMultipartUploadListParts omMultipartUploadListParts = impl.listParts(multipartUploadListPartsRequest.getVolume(), multipartUploadListPartsRequest.getBucket(), multipartUploadListPartsRequest.getKey(), multipartUploadListPartsRequest.getUploadID(), multipartUploadListPartsRequest.getPartNumbermarker(), multipartUploadListPartsRequest.getMaxParts());
List<OmPartInfo> omPartInfoList = omMultipartUploadListParts.getPartInfoList();
List<PartInfo> partInfoList = new ArrayList<>();
omPartInfoList.forEach(partInfo -> partInfoList.add(partInfo.getProto()));
response.setType(omMultipartUploadListParts.getReplicationConfig().getReplicationType());
response.setFactor(ReplicationConfig.getLegacyFactor(omMultipartUploadListParts.getReplicationConfig()));
response.setNextPartNumberMarker(omMultipartUploadListParts.getNextPartNumberMarker());
response.setIsTruncated(omMultipartUploadListParts.isTruncated());
return response.addAllPartsList(partInfoList).build();
}
use of org.apache.hadoop.ozone.om.helpers.OmPartInfo in project ozone by apache.
the class KeyManagerImpl method listParts.
@Override
public OmMultipartUploadListParts listParts(String volumeName, String bucketName, String keyName, String uploadID, int partNumberMarker, int maxParts) throws IOException {
Preconditions.checkNotNull(volumeName);
Preconditions.checkNotNull(bucketName);
Preconditions.checkNotNull(keyName);
Preconditions.checkNotNull(uploadID);
boolean isTruncated = false;
int nextPartNumberMarker = 0;
BucketLayout bucketLayout = BucketLayout.DEFAULT;
if (ozoneManager != null) {
String buckKey = ozoneManager.getMetadataManager().getBucketKey(volumeName, bucketName);
OmBucketInfo buckInfo = ozoneManager.getMetadataManager().getBucketTable().get(buckKey);
bucketLayout = buckInfo.getBucketLayout();
}
metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName, bucketName);
try {
String multipartKey = metadataManager.getMultipartKey(volumeName, bucketName, keyName, uploadID);
OmMultipartKeyInfo multipartKeyInfo = metadataManager.getMultipartInfoTable().get(multipartKey);
if (multipartKeyInfo == null) {
throw new OMException("No Such Multipart upload exists for this key.", ResultCodes.NO_SUCH_MULTIPART_UPLOAD_ERROR);
} else {
TreeMap<Integer, PartKeyInfo> partKeyInfoMap = multipartKeyInfo.getPartKeyInfoMap();
Iterator<Map.Entry<Integer, PartKeyInfo>> partKeyInfoMapIterator = partKeyInfoMap.entrySet().iterator();
ReplicationConfig replicationConfig = null;
int count = 0;
List<OmPartInfo> omPartInfoList = new ArrayList<>();
while (count < maxParts && partKeyInfoMapIterator.hasNext()) {
Map.Entry<Integer, PartKeyInfo> partKeyInfoEntry = partKeyInfoMapIterator.next();
nextPartNumberMarker = partKeyInfoEntry.getKey();
// than part number marker
if (partKeyInfoEntry.getKey() > partNumberMarker) {
PartKeyInfo partKeyInfo = partKeyInfoEntry.getValue();
String partName = getPartName(partKeyInfo, volumeName, bucketName, keyName);
OmPartInfo omPartInfo = new OmPartInfo(partKeyInfo.getPartNumber(), partName, partKeyInfo.getPartKeyInfo().getModificationTime(), partKeyInfo.getPartKeyInfo().getDataSize());
omPartInfoList.add(omPartInfo);
// if there are parts, use replication type from one of the parts
replicationConfig = ReplicationConfig.fromProtoTypeAndFactor(partKeyInfo.getPartKeyInfo().getType(), partKeyInfo.getPartKeyInfo().getFactor());
count++;
}
}
if (replicationConfig == null) {
// if there are no parts, use the replicationType from the open key.
if (isBucketFSOptimized(volumeName, bucketName)) {
multipartKey = getMultipartOpenKeyFSO(volumeName, bucketName, keyName, uploadID);
}
OmKeyInfo omKeyInfo = metadataManager.getOpenKeyTable(bucketLayout).get(multipartKey);
if (omKeyInfo == null) {
throw new IllegalStateException("Open key is missing for multipart upload " + multipartKey);
}
replicationConfig = omKeyInfo.getReplicationConfig();
}
Preconditions.checkNotNull(replicationConfig, "ReplicationConfig can't be identified");
if (partKeyInfoMapIterator.hasNext()) {
Map.Entry<Integer, PartKeyInfo> partKeyInfoEntry = partKeyInfoMapIterator.next();
isTruncated = true;
} else {
isTruncated = false;
nextPartNumberMarker = 0;
}
OmMultipartUploadListParts omMultipartUploadListParts = new OmMultipartUploadListParts(replicationConfig, nextPartNumberMarker, isTruncated);
omMultipartUploadListParts.addPartList(omPartInfoList);
return omMultipartUploadListParts;
}
} catch (OMException ex) {
throw ex;
} catch (IOException ex) {
LOG.error("List Multipart Upload Parts Failed: volume: {}, bucket: {}, ,key: " + "{} ", volumeName, bucketName, keyName, ex);
throw new OMException(ex.getMessage(), ResultCodes.LIST_MULTIPART_UPLOAD_PARTS_FAILED);
} finally {
metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volumeName, bucketName);
}
}
Aggregations