Search in sources :

Example 1 with Builder

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);
}
Also used : Builder(org.apache.hadoop.ozone.om.helpers.OmKeyArgs.Builder) Builder(org.apache.hadoop.ozone.om.helpers.OmKeyArgs.Builder) ArrayList(java.util.ArrayList) ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) OmKeyArgs(org.apache.hadoop.ozone.om.helpers.OmKeyArgs) OmKeyLocationInfo(org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo) MockPipeline(org.apache.hadoop.hdds.scm.pipeline.MockPipeline) ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline) OmKeyLocationInfoGroup(org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) BlockID(org.apache.hadoop.hdds.client.BlockID) OzoneFileStatus(org.apache.hadoop.ozone.om.helpers.OzoneFileStatus) Test(org.junit.Test)

Example 2 with Builder

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;
}
Also used : Builder(org.apache.hadoop.ozone.om.helpers.OmKeyArgs.Builder) ArrayList(java.util.ArrayList) OmMultipartInfo(org.apache.hadoop.ozone.om.helpers.OmMultipartInfo) OmKeyArgs(org.apache.hadoop.ozone.om.helpers.OmKeyArgs)

Example 3 with Builder

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;
    });
}
Also used : Builder(org.apache.hadoop.ozone.om.helpers.OmKeyArgs.Builder) OpenKeySession(org.apache.hadoop.ozone.om.helpers.OpenKeySession) OmKeyArgs(org.apache.hadoop.ozone.om.helpers.OmKeyArgs) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Aggregations

OmKeyArgs (org.apache.hadoop.ozone.om.helpers.OmKeyArgs)3 Builder (org.apache.hadoop.ozone.om.helpers.OmKeyArgs.Builder)3 ArrayList (java.util.ArrayList)2 BlockID (org.apache.hadoop.hdds.client.BlockID)1 ContainerInfo (org.apache.hadoop.hdds.scm.container.ContainerInfo)1 ContainerWithPipeline (org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline)1 MockPipeline (org.apache.hadoop.hdds.scm.pipeline.MockPipeline)1 Pipeline (org.apache.hadoop.hdds.scm.pipeline.Pipeline)1 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)1 OmKeyLocationInfo (org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo)1 OmKeyLocationInfoGroup (org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup)1 OmMultipartInfo (org.apache.hadoop.ozone.om.helpers.OmMultipartInfo)1 OpenKeySession (org.apache.hadoop.ozone.om.helpers.OpenKeySession)1 OzoneFileStatus (org.apache.hadoop.ozone.om.helpers.OzoneFileStatus)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 Test (org.junit.Test)1