use of org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList in project ozone by apache.
the class TestOmBlockVersioning method testAllocateCommit.
@Test
public void testAllocateCommit() throws Exception {
String volumeName = "volume" + RandomStringUtils.randomNumeric(5);
String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);
String keyName = "key" + RandomStringUtils.randomNumeric(5);
OzoneBucket bucket = TestDataUtil.createVolumeAndBucket(cluster, volumeName, bucketName);
// Versioning isn't supported currently, but just preserving old behaviour
bucket.setVersioning(true);
OmKeyArgs keyArgs = new OmKeyArgs.Builder().setVolumeName(volumeName).setBucketName(bucketName).setKeyName(keyName).setDataSize(1000).setRefreshPipeline(true).setAcls(new ArrayList<>()).setReplicationConfig(StandaloneReplicationConfig.getInstance(ONE)).build();
// 1st update, version 0
OpenKeySession openKey = writeClient.openKey(keyArgs);
// explicitly set the keyLocation list before committing the key.
keyArgs.setLocationInfoList(openKey.getKeyInfo().getLatestVersionLocations().getBlocksLatestVersionOnly());
writeClient.commitKey(keyArgs, openKey.getId());
OmKeyInfo keyInfo = ozoneManager.lookupKey(keyArgs);
OmKeyLocationInfoGroup highestVersion = checkVersions(keyInfo.getKeyLocationVersions());
assertEquals(0, highestVersion.getVersion());
assertEquals(1, highestVersion.getLocationList().size());
// 2nd update, version 1
openKey = writeClient.openKey(keyArgs);
// OmKeyLocationInfo locationInfo =
// writeClient.allocateBlock(keyArgs, openKey.getId());
// explicitly set the keyLocation list before committing the key.
keyArgs.setLocationInfoList(openKey.getKeyInfo().getLatestVersionLocations().getBlocksLatestVersionOnly());
writeClient.commitKey(keyArgs, openKey.getId());
keyInfo = ozoneManager.lookupKey(keyArgs);
highestVersion = checkVersions(keyInfo.getKeyLocationVersions());
assertEquals(1, highestVersion.getVersion());
assertEquals(1, highestVersion.getLocationList().size());
// 3rd update, version 2
openKey = writeClient.openKey(keyArgs);
// this block will be appended to the latest version of version 2.
OmKeyLocationInfo locationInfo = writeClient.allocateBlock(keyArgs, openKey.getId(), new ExcludeList());
List<OmKeyLocationInfo> locationInfoList = openKey.getKeyInfo().getLatestVersionLocations().getBlocksLatestVersionOnly();
Assert.assertTrue(locationInfoList.size() == 1);
locationInfoList.add(locationInfo);
keyArgs.setLocationInfoList(locationInfoList);
writeClient.commitKey(keyArgs, openKey.getId());
keyInfo = ozoneManager.lookupKey(keyArgs);
highestVersion = checkVersions(keyInfo.getKeyLocationVersions());
assertEquals(2, highestVersion.getVersion());
assertEquals(2, highestVersion.getLocationList().size());
}
use of org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList in project ozone by apache.
the class TestKeyDeletingService method createAndDeleteKeys.
private void createAndDeleteKeys(KeyManager keyManager, int keyCount, int numBlocks) throws IOException {
for (int x = 0; x < keyCount; x++) {
String volumeName = String.format("volume%s", RandomStringUtils.randomAlphanumeric(5));
String bucketName = String.format("bucket%s", RandomStringUtils.randomAlphanumeric(5));
String keyName = String.format("key%s", RandomStringUtils.randomAlphanumeric(5));
String volumeBytes = keyManager.getMetadataManager().getVolumeKey(volumeName);
String bucketBytes = keyManager.getMetadataManager().getBucketKey(volumeName, bucketName);
// cheat here, just create a volume and bucket entry so that we can
// create the keys, we put the same data for key and value since the
// system does not decode the object
OMRequestTestUtils.addVolumeToOM(keyManager.getMetadataManager(), OmVolumeArgs.newBuilder().setOwnerName("o").setAdminName("a").setVolume(volumeName).build());
OMRequestTestUtils.addBucketToOM(keyManager.getMetadataManager(), OmBucketInfo.newBuilder().setVolumeName(volumeName).setBucketName(bucketName).build());
OmKeyArgs arg = new OmKeyArgs.Builder().setVolumeName(volumeName).setBucketName(bucketName).setKeyName(keyName).setAcls(Collections.emptyList()).setReplicationConfig(StandaloneReplicationConfig.getInstance(HddsProtos.ReplicationFactor.ONE)).setLocationInfoList(new ArrayList<>()).build();
// Open, Commit and Delete the Keys in the Key Manager.
OpenKeySession session = writeClient.openKey(arg);
for (int i = 0; i < numBlocks; i++) {
arg.addLocationInfo(writeClient.allocateBlock(arg, session.getId(), new ExcludeList()));
}
writeClient.commitKey(arg, session.getId());
writeClient.deleteKey(arg);
}
}
use of org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList in project ozone by apache.
the class TestBlockManager method testMultipleBlockAllocation.
@Test(timeout = 10000)
public void testMultipleBlockAllocation() throws IOException, TimeoutException, InterruptedException {
pipelineManager.createPipeline(replicationConfig);
pipelineManager.createPipeline(replicationConfig);
HddsTestUtils.openAllRatisPipelines(pipelineManager);
AllocatedBlock allocatedBlock = blockManager.allocateBlock(DEFAULT_BLOCK_SIZE, replicationConfig, OzoneConsts.OZONE, new ExcludeList());
// block should be allocated in different pipelines
GenericTestUtils.waitFor(() -> {
try {
AllocatedBlock block = blockManager.allocateBlock(DEFAULT_BLOCK_SIZE, replicationConfig, OzoneConsts.OZONE, new ExcludeList());
return !block.getPipeline().getId().equals(allocatedBlock.getPipeline().getId());
} catch (IOException e) {
}
return false;
}, 100, 1000);
}
use of org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList in project ozone by apache.
the class TestBlockManager method testAllocateBlockFailureInSafeMode.
@Test
public void testAllocateBlockFailureInSafeMode() throws Exception {
scm.getScmContext().updateSafeModeStatus(new SCMSafeModeManager.SafeModeStatus(true, true));
// Test1: In safe mode expect an SCMException.
thrown.expectMessage("SafeModePrecheck failed for " + "allocateBlock");
blockManager.allocateBlock(DEFAULT_BLOCK_SIZE, replicationConfig, OzoneConsts.OZONE, new ExcludeList());
}
use of org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList in project ozone by apache.
the class TestBlockManager method testAllocateBlockWithExclusion.
@Test
public void testAllocateBlockWithExclusion() throws Exception {
try {
while (true) {
pipelineManager.createPipeline(replicationConfig);
}
} catch (IOException e) {
}
HddsTestUtils.openAllRatisPipelines(pipelineManager);
ExcludeList excludeList = new ExcludeList();
excludeList.addPipeline(pipelineManager.getPipelines(replicationConfig).get(0).getId());
AllocatedBlock block = blockManager.allocateBlock(DEFAULT_BLOCK_SIZE, replicationConfig, OzoneConsts.OZONE, excludeList);
Assert.assertNotNull(block);
for (PipelineID id : excludeList.getPipelineIds()) {
Assert.assertNotEquals(block.getPipeline().getId(), id);
}
for (Pipeline pipeline : pipelineManager.getPipelines(replicationConfig)) {
excludeList.addPipeline(pipeline.getId());
}
block = blockManager.allocateBlock(DEFAULT_BLOCK_SIZE, replicationConfig, OzoneConsts.OZONE, excludeList);
Assert.assertNotNull(block);
Assert.assertTrue(excludeList.getPipelineIds().contains(block.getPipeline().getId()));
}
Aggregations