use of org.apache.hadoop.ozone.om.helpers.OmKeyArgs in project ozone by apache.
the class TestStorageContainerManagerHelper method createKeys.
public Map<String, OmKeyInfo> createKeys(int numOfKeys, int keySize) throws Exception {
Map<String, OmKeyInfo> keyLocationMap = Maps.newHashMap();
OzoneBucket bucket = TestDataUtil.createVolumeAndBucket(cluster);
// Write 20 keys in bucketName.
Set<String> keyNames = Sets.newHashSet();
for (int i = 0; i < numOfKeys; i++) {
String keyName = RandomStringUtils.randomAlphabetic(5) + i;
keyNames.add(keyName);
TestDataUtil.createKey(bucket, keyName, RandomStringUtils.randomAlphabetic(5));
}
for (String key : keyNames) {
OmKeyArgs arg = new OmKeyArgs.Builder().setVolumeName(bucket.getVolumeName()).setBucketName(bucket.getName()).setKeyName(key).setRefreshPipeline(true).build();
OmKeyInfo location = cluster.getOzoneManager().lookupKey(arg);
keyLocationMap.put(key, location);
}
return keyLocationMap;
}
use of org.apache.hadoop.ozone.om.helpers.OmKeyArgs in project ozone by apache.
the class RpcClient method completeMultipartUpload.
@Override
public OmMultipartUploadCompleteInfo completeMultipartUpload(String volumeName, String bucketName, String keyName, String uploadID, Map<Integer, String> partsMap) throws IOException {
verifyVolumeName(volumeName);
verifyBucketName(bucketName);
HddsClientUtils.checkNotNull(keyName, uploadID);
OmKeyArgs keyArgs = new OmKeyArgs.Builder().setVolumeName(volumeName).setBucketName(bucketName).setKeyName(keyName).setMultipartUploadID(uploadID).setAcls(getAclList()).build();
OmMultipartUploadCompleteList omMultipartUploadCompleteList = new OmMultipartUploadCompleteList(partsMap);
OmMultipartUploadCompleteInfo omMultipartUploadCompleteInfo = ozoneManagerClient.completeMultipartUpload(keyArgs, omMultipartUploadCompleteList);
return omMultipartUploadCompleteInfo;
}
use of org.apache.hadoop.ozone.om.helpers.OmKeyArgs in project ozone by apache.
the class RpcClient method createMultipartKey.
@Override
public OzoneOutputStream createMultipartKey(String volumeName, String bucketName, String keyName, long size, int partNumber, String uploadID) throws IOException {
verifyVolumeName(volumeName);
verifyBucketName(bucketName);
if (checkKeyNameEnabled) {
HddsClientUtils.verifyKeyName(keyName);
}
HddsClientUtils.checkNotNull(keyName, uploadID);
Preconditions.checkArgument(partNumber > 0 && partNumber <= 10000, "Part " + "number should be greater than zero and less than or equal to 10000");
Preconditions.checkArgument(size >= 0, "size should be greater than or " + "equal to zero");
String requestId = UUID.randomUUID().toString();
OmKeyArgs keyArgs = new OmKeyArgs.Builder().setVolumeName(volumeName).setBucketName(bucketName).setKeyName(keyName).setDataSize(size).setIsMultipartKey(true).setMultipartUploadID(uploadID).setMultipartUploadPartNumber(partNumber).setAcls(getAclList()).build();
OpenKeySession openKey = ozoneManagerClient.openKey(keyArgs);
KeyOutputStream keyOutputStream = createKeyOutputStream(openKey, requestId).setMultipartNumber(partNumber).setMultipartUploadID(uploadID).setIsMultipartKey(true).build();
keyOutputStream.addPreallocateBlocks(openKey.getKeyInfo().getLatestVersionLocations(), openKey.getOpenVersion());
FileEncryptionInfo feInfo = openKey.getKeyInfo().getFileEncryptionInfo();
if (feInfo != null) {
KeyProvider.KeyVersion decrypted = getDEK(feInfo);
final CryptoOutputStream cryptoOut = new CryptoOutputStream(keyOutputStream, OzoneKMSUtil.getCryptoCodec(conf, feInfo), decrypted.getMaterial(), feInfo.getIV());
return new OzoneOutputStream(cryptoOut);
} else {
return new OzoneOutputStream(keyOutputStream);
}
}
use of org.apache.hadoop.ozone.om.helpers.OmKeyArgs in project ozone by apache.
the class RpcClient method abortMultipartUpload.
@Override
public void abortMultipartUpload(String volumeName, String bucketName, String keyName, String uploadID) throws IOException {
verifyVolumeName(volumeName);
verifyBucketName(bucketName);
HddsClientUtils.checkNotNull(keyName, uploadID);
OmKeyArgs omKeyArgs = new OmKeyArgs.Builder().setVolumeName(volumeName).setBucketName(bucketName).setKeyName(keyName).setMultipartUploadID(uploadID).build();
ozoneManagerClient.abortMultipartUpload(omKeyArgs);
}
use of org.apache.hadoop.ozone.om.helpers.OmKeyArgs in project ozone by apache.
the class RpcClient method getKey.
@Override
public OzoneInputStream getKey(String volumeName, String bucketName, String keyName) throws IOException {
verifyVolumeName(volumeName);
verifyBucketName(bucketName);
Preconditions.checkNotNull(keyName);
OmKeyArgs keyArgs = new OmKeyArgs.Builder().setVolumeName(volumeName).setBucketName(bucketName).setKeyName(keyName).setRefreshPipeline(true).setSortDatanodesInPipeline(topologyAwareReadEnabled).setLatestVersionLocation(getLatestVersionLocation).build();
OmKeyInfo keyInfo = ozoneManagerClient.lookupKey(keyArgs);
return getInputStreamWithRetryFunction(keyInfo);
}
Aggregations