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);
}
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);
}
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);
}
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;
}
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);
}
}
Aggregations