use of org.apache.hadoop.ozone.om.helpers.OmKeyArgs.Builder in project ozone by apache.
the class TestKeyManagerUnit method listStatus.
@Test
public void listStatus() throws Exception {
String volume = "vol";
String bucket = "bucket";
String keyPrefix = "key";
String client = "client.host";
OMRequestTestUtils.addVolumeToDB(volume, OzoneConsts.OZONE, metadataManager);
OMRequestTestUtils.addBucketToDB(volume, bucket, metadataManager);
final Pipeline pipeline = MockPipeline.createPipeline(3);
final List<String> nodes = pipeline.getNodes().stream().map(DatanodeDetails::getUuidString).collect(toList());
List<Long> containerIDs = new ArrayList<>();
List<ContainerWithPipeline> containersWithPipeline = new ArrayList<>();
for (long i = 1; i <= 10; i++) {
final OmKeyLocationInfo keyLocationInfo = new OmKeyLocationInfo.Builder().setBlockID(new BlockID(i, 1L)).setPipeline(pipeline).setOffset(0).setLength(256000).build();
ContainerInfo containerInfo = new ContainerInfo.Builder().setContainerID(i).build();
containersWithPipeline.add(new ContainerWithPipeline(containerInfo, pipeline));
containerIDs.add(i);
OmKeyInfo keyInfo = new OmKeyInfo.Builder().setVolumeName(volume).setBucketName(bucket).setCreationTime(Time.now()).setOmKeyLocationInfos(singletonList(new OmKeyLocationInfoGroup(0, new ArrayList<>()))).setReplicationConfig(RatisReplicationConfig.getInstance(ReplicationFactor.THREE)).setKeyName(keyPrefix + i).setObjectID(i).setUpdateID(i).build();
keyInfo.appendNewBlocks(singletonList(keyLocationInfo), false);
OMRequestTestUtils.addKeyToOM(metadataManager, keyInfo);
}
when(containerClient.getContainerWithPipelineBatch(containerIDs)).thenReturn(containersWithPipeline);
OmKeyArgs.Builder builder = new OmKeyArgs.Builder().setVolumeName(volume).setBucketName(bucket).setKeyName("").setSortDatanodesInPipeline(true);
List<OzoneFileStatus> fileStatusList = keyManager.listStatus(builder.build(), false, null, Long.MAX_VALUE, client);
Assert.assertEquals(10, fileStatusList.size());
verify(containerClient).getContainerWithPipelineBatch(containerIDs);
verify(blockClient).sortDatanodes(nodes, client);
}
use of org.apache.hadoop.ozone.om.helpers.OmKeyArgs.Builder in project ozone by apache.
the class TestKeyManagerUnit method initMultipartUpload.
private OmMultipartInfo initMultipartUpload(OzoneManagerProtocol omtest, String volume, String bucket, String key) throws IOException {
OmKeyArgs key1 = new Builder().setVolumeName(volume).setBucketName(bucket).setKeyName(key).setReplicationConfig(RatisReplicationConfig.getInstance(ReplicationFactor.THREE)).setAcls(new ArrayList<>()).build();
OmMultipartInfo omMultipartInfo = omtest.initiateMultipartUpload(key1);
return omMultipartInfo;
}
use of org.apache.hadoop.ozone.om.helpers.OmKeyArgs.Builder in project ozone by apache.
the class OmKeyGenerator method createKey.
private void createKey(long counter) throws Exception {
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
OmKeyArgs keyArgs = new Builder().setBucketName(bucketName).setVolumeName(volumeName).setReplicationConfig(RatisReplicationConfig.getInstance(factor)).setKeyName(generateObjectName(counter)).setLocationInfoList(new ArrayList<>()).setAcls(OzoneAclUtil.getAclList(ugi.getUserName(), ugi.getGroupNames(), ALL, ALL)).build();
timer.time(() -> {
OpenKeySession openKeySession = ozoneManagerClient.openKey(keyArgs);
ozoneManagerClient.commitKey(keyArgs, openKeySession.getId());
return null;
});
}
Aggregations