Search in sources :

Example 66 with OmVolumeArgs

use of org.apache.hadoop.ozone.om.helpers.OmVolumeArgs in project ozone by apache.

the class TestOmMetadataManager method testListAllVolumes.

@Test
public void testListAllVolumes() throws Exception {
    OmVolumeArgs.Builder argsBuilder = OmVolumeArgs.newBuilder().setAdminName("admin");
    String volName;
    String ownerName;
    for (int i = 0; i < 50; i++) {
        ownerName = "owner" + i;
        volName = "vola" + i;
        OmVolumeArgs omVolumeArgs = argsBuilder.setOwnerName(ownerName).setVolume(volName).build();
        OMRequestTestUtils.addVolumeToOM(omMetadataManager, omVolumeArgs);
        OMRequestTestUtils.addUserToDB(volName, ownerName, omMetadataManager);
    }
    for (int i = 0; i < 50; i++) {
        ownerName = "owner" + i;
        volName = "volb" + i;
        OmVolumeArgs omVolumeArgs = argsBuilder.setOwnerName(ownerName).setVolume(volName).build();
        OMRequestTestUtils.addVolumeToOM(omMetadataManager, omVolumeArgs);
        OMRequestTestUtils.addUserToDB(volName, ownerName, omMetadataManager);
    }
    String prefix = "";
    String startKey = "";
    // Test list all volumes
    List<OmVolumeArgs> volListA = omMetadataManager.listVolumes(null, prefix, startKey, 1000);
    Assert.assertEquals(volListA.size(), 100);
    // Test list all volumes with prefix
    prefix = "volb";
    List<OmVolumeArgs> volListB = omMetadataManager.listVolumes(null, prefix, startKey, 1000);
    Assert.assertEquals(volListB.size(), 50);
    // Test list all volumes with setting startVolume
    // that was not part of result.
    prefix = "";
    int totalVol = volListB.size();
    int startOrder = 0;
    startKey = "volb" + startOrder;
    List<OmVolumeArgs> volListC = omMetadataManager.listVolumes(null, prefix, startKey, 1000);
    Assert.assertEquals(volListC.size(), totalVol - startOrder - 1);
}
Also used : OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs) Test(org.junit.Test)

Example 67 with OmVolumeArgs

use of org.apache.hadoop.ozone.om.helpers.OmVolumeArgs in project ozone by apache.

the class TestOmMetadataManager method testListVolumes.

@Test
public void testListVolumes() throws Exception {
    String ownerName = "owner";
    OmVolumeArgs.Builder argsBuilder = OmVolumeArgs.newBuilder().setAdminName("admin").setOwnerName(ownerName);
    String volName;
    OmVolumeArgs omVolumeArgs;
    for (int i = 0; i < 50; i++) {
        volName = "vol" + i;
        omVolumeArgs = argsBuilder.setVolume(volName).build();
        OMRequestTestUtils.addVolumeToOM(omMetadataManager, omVolumeArgs);
        OMRequestTestUtils.addUserToDB(volName, ownerName, omMetadataManager);
    }
    // Test list volumes with setting startVolume that
    // was not part of the result.
    String prefix = "";
    int totalVol = omMetadataManager.listVolumes(ownerName, prefix, null, 100).size();
    int startOrder = 10;
    String startVolume = "vol" + startOrder;
    List<OmVolumeArgs> volumeList = omMetadataManager.listVolumes(ownerName, prefix, startVolume, 100);
    Assert.assertEquals(volumeList.size(), totalVol - startOrder - 1);
}
Also used : OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs) Test(org.junit.Test)

Example 68 with OmVolumeArgs

use of org.apache.hadoop.ozone.om.helpers.OmVolumeArgs in project ozone by apache.

the class TestOMBucketCreateRequest method addCreateVolumeToTable.

public static void addCreateVolumeToTable(String volumeName, OMMetadataManager omMetadataManager) throws Exception {
    OmVolumeArgs omVolumeArgs = OmVolumeArgs.newBuilder().setCreationTime(Time.now()).setVolume(volumeName).setAdminName(UUID.randomUUID().toString()).setOwnerName(UUID.randomUUID().toString()).build();
    OMRequestTestUtils.addVolumeToOM(omMetadataManager, omVolumeArgs);
}
Also used : OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs)

Example 69 with OmVolumeArgs

use of org.apache.hadoop.ozone.om.helpers.OmVolumeArgs in project ozone by apache.

the class OzoneManagerProtocolClientSideTranslatorPB method listVolume.

private List<OmVolumeArgs> listVolume(ListVolumeRequest request) throws IOException {
    OMRequest omRequest = createOMRequest(Type.ListVolume).setListVolumeRequest(request).build();
    ListVolumeResponse resp = handleError(submitRequest(omRequest)).getListVolumeResponse();
    List<OmVolumeArgs> list = new ArrayList<>(resp.getVolumeInfoList().size());
    for (VolumeInfo info : resp.getVolumeInfoList()) {
        list.add(OmVolumeArgs.getFromProtobuf(info));
    }
    return list;
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) ListVolumeResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ListVolumeResponse) OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs) ArrayList(java.util.ArrayList) VolumeInfo(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.VolumeInfo)

Example 70 with OmVolumeArgs

use of org.apache.hadoop.ozone.om.helpers.OmVolumeArgs in project ozone by apache.

the class TestVolumeOwner method prepareTestVols.

// create 2 volumes
private static void prepareTestVols() throws IOException {
    for (int i = 0; i < 2; i++) {
        OmVolumeArgs volumeArgs = OmVolumeArgs.newBuilder().setVolume(getTestVolumeName(i)).setAdminName("om").setOwnerName(getTestVolOwnerName(i)).build();
        OMRequestTestUtils.addVolumeToOM(metadataManager, volumeArgs);
    }
}
Also used : OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs)

Aggregations

OmVolumeArgs (org.apache.hadoop.ozone.om.helpers.OmVolumeArgs)70 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)19 IOException (java.io.IOException)18 Test (org.junit.Test)18 OmBucketInfo (org.apache.hadoop.ozone.om.helpers.OmBucketInfo)16 OMResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)15 OMClientResponse (org.apache.hadoop.ozone.om.response.OMClientResponse)13 OMMetadataManager (org.apache.hadoop.ozone.om.OMMetadataManager)12 ArrayList (java.util.ArrayList)9 OMMetrics (org.apache.hadoop.ozone.om.OMMetrics)8 OzoneManagerProtocolProtos (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos)7 OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)7 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)6 OzoneAcl (org.apache.hadoop.ozone.OzoneAcl)6 PersistedUserVolumeInfo (org.apache.hadoop.ozone.storage.proto.OzoneManagerStorageProtos.PersistedUserVolumeInfo)6 AuditLogger (org.apache.hadoop.ozone.audit.AuditLogger)5 OmMetadataManagerImpl (org.apache.hadoop.ozone.om.OmMetadataManagerImpl)5 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)5 CertificateSignRequest.getEncodedString (org.apache.hadoop.hdds.security.x509.certificates.utils.CertificateSignRequest.getEncodedString)4 GET (javax.ws.rs.GET)3