use of org.apache.hadoop.ozone.om.OMMetadataManager in project ozone by apache.
the class TestNSSummaryEndpoint method initializeNewOmMetadataManager.
/**
* Create a new OM Metadata manager instance with one user, one vol, and two
* buckets.
* @throws IOException ioEx
*/
private static OMMetadataManager initializeNewOmMetadataManager(File omDbDir) throws IOException {
OzoneConfiguration omConfiguration = new OzoneConfiguration();
omConfiguration.set(OZONE_OM_DB_DIRS, omDbDir.getAbsolutePath());
OMMetadataManager omMetadataManager = new OmMetadataManagerImpl(omConfiguration);
String volumeKey = omMetadataManager.getVolumeKey(VOL);
OmVolumeArgs args = OmVolumeArgs.newBuilder().setObjectID(VOL_OBJECT_ID).setVolume(VOL).setAdminName(TEST_USER).setOwnerName(TEST_USER).setQuotaInBytes(VOL_QUOTA).build();
omMetadataManager.getVolumeTable().put(volumeKey, args);
OmBucketInfo bucketInfo = OmBucketInfo.newBuilder().setVolumeName(VOL).setBucketName(BUCKET_ONE).setObjectID(BUCKET_ONE_OBJECT_ID).setQuotaInBytes(BUCKET_ONE_QUOTA).build();
OmBucketInfo bucketInfo2 = OmBucketInfo.newBuilder().setVolumeName(VOL).setBucketName(BUCKET_TWO).setObjectID(BUCKET_TWO_OBJECT_ID).setQuotaInBytes(BUCKET_TWO_QUOTA).build();
String bucketKey = omMetadataManager.getBucketKey(bucketInfo.getVolumeName(), bucketInfo.getBucketName());
String bucketKey2 = omMetadataManager.getBucketKey(bucketInfo2.getVolumeName(), bucketInfo2.getBucketName());
omMetadataManager.getBucketTable().put(bucketKey, bucketInfo);
omMetadataManager.getBucketTable().put(bucketKey2, bucketInfo2);
return omMetadataManager;
}
use of org.apache.hadoop.ozone.om.OMMetadataManager in project ozone by apache.
the class OMMetadataManagerTestUtils method getMockOzoneManagerServiceProviderWithFSO.
public static OzoneManagerServiceProviderImpl getMockOzoneManagerServiceProviderWithFSO() throws IOException {
OzoneManagerServiceProviderImpl omServiceProviderMock = mock(OzoneManagerServiceProviderImpl.class);
OMMetadataManager omMetadataManagerMock = mock(OMMetadataManager.class);
Table keyTableMock = mock(Table.class);
Table dirTableMock = mock(Table.class);
Table volTableMock = mock(Table.class);
Table bucketTableMock = mock(Table.class);
when(keyTableMock.getName()).thenReturn(FILE_TABLE);
when(omMetadataManagerMock.getKeyTable(BucketLayout.FILE_SYSTEM_OPTIMIZED)).thenReturn(keyTableMock);
when(dirTableMock.getName()).thenReturn(DIRECTORY_TABLE);
when(omMetadataManagerMock.getDirectoryTable()).thenReturn(dirTableMock);
when(volTableMock.getName()).thenReturn(VOLUME_TABLE);
when(omMetadataManagerMock.getVolumeTable()).thenReturn(volTableMock);
when(bucketTableMock.getName()).thenReturn(BUCKET_TABLE);
when(omMetadataManagerMock.getBucketTable()).thenReturn(bucketTableMock);
when(omServiceProviderMock.getOMMetadataManagerInstance()).thenReturn(omMetadataManagerMock);
return omServiceProviderMock;
}
use of org.apache.hadoop.ozone.om.OMMetadataManager in project ozone by apache.
the class TestReconOmMetadataManagerImpl method getOMMetadataManager.
/**
* Get test OM metadata manager.
* @return OMMetadataManager instance
* @throws IOException
*/
private OMMetadataManager getOMMetadataManager() throws IOException {
// Create a new OM Metadata Manager instance + DB.
File omDbDir = temporaryFolder.newFolder();
OzoneConfiguration omConfiguration = new OzoneConfiguration();
omConfiguration.set(OZONE_OM_DB_DIRS, omDbDir.getAbsolutePath());
OMMetadataManager omMetadataManager = new OmMetadataManagerImpl(omConfiguration);
// Create a volume + bucket + 2 keys.
String volumeKey = omMetadataManager.getVolumeKey("sampleVol");
OmVolumeArgs args = OmVolumeArgs.newBuilder().setVolume("sampleVol").setAdminName("TestUser").setOwnerName("TestUser").build();
omMetadataManager.getVolumeTable().put(volumeKey, args);
OmBucketInfo bucketInfo = OmBucketInfo.newBuilder().setVolumeName("sampleVol").setBucketName("bucketOne").build();
String bucketKey = omMetadataManager.getBucketKey(bucketInfo.getVolumeName(), bucketInfo.getBucketName());
omMetadataManager.getBucketTable().put(bucketKey, bucketInfo);
omMetadataManager.getKeyTable(getBucketLayout()).put("/sampleVol/bucketOne/key_one", new OmKeyInfo.Builder().setBucketName("bucketOne").setVolumeName("sampleVol").setKeyName("key_one").setReplicationConfig(StandaloneReplicationConfig.getInstance(HddsProtos.ReplicationFactor.ONE)).build());
omMetadataManager.getKeyTable(getBucketLayout()).put("/sampleVol/bucketOne/key_two", new OmKeyInfo.Builder().setBucketName("bucketOne").setVolumeName("sampleVol").setKeyName("key_two").setReplicationConfig(StandaloneReplicationConfig.getInstance(HddsProtos.ReplicationFactor.ONE)).build());
return omMetadataManager;
}
use of org.apache.hadoop.ozone.om.OMMetadataManager in project ozone by apache.
the class TestOzoneRpcClientAbstract method testDeletedKeyForGDPR.
/**
* Tests deletedKey for GDPR.
* 1. Create GDPR Enabled bucket.
* 2. Create a Key in this bucket so it gets encrypted via GDPRSymmetricKey.
* 3. Read key and validate the content/metadata is as expected because the
* readKey will decrypt using the GDPR Symmetric Key with details from KeyInfo
* Metadata.
* 4. Delete this key in GDPR enabled bucket
* 5. Confirm the deleted key metadata in deletedTable does not contain the
* GDPR encryption details (flag, secret, algorithm).
* @throws Exception
*/
@Test
public void testDeletedKeyForGDPR() throws Exception {
// Step 1
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
String keyName = UUID.randomUUID().toString();
store.createVolume(volumeName);
OzoneVolume volume = store.getVolume(volumeName);
BucketArgs args = BucketArgs.newBuilder().addMetadata(OzoneConsts.GDPR_FLAG, "true").build();
volume.createBucket(bucketName, args);
OzoneBucket bucket = volume.getBucket(bucketName);
Assert.assertEquals(bucketName, bucket.getName());
Assert.assertNotNull(bucket.getMetadata());
Assert.assertEquals("true", bucket.getMetadata().get(OzoneConsts.GDPR_FLAG));
// Step 2
String text = "hello world";
Map<String, String> keyMetadata = new HashMap<>();
keyMetadata.put(OzoneConsts.GDPR_FLAG, "true");
OzoneOutputStream out = bucket.createKey(keyName, text.getBytes(UTF_8).length, RATIS, ONE, keyMetadata);
out.write(text.getBytes(UTF_8));
out.close();
// Step 3
OzoneKeyDetails key = bucket.getKey(keyName);
Assert.assertEquals(keyName, key.getName());
Assert.assertEquals("true", key.getMetadata().get(OzoneConsts.GDPR_FLAG));
Assert.assertEquals("AES", key.getMetadata().get(OzoneConsts.GDPR_ALGORITHM));
Assert.assertTrue(key.getMetadata().get(OzoneConsts.GDPR_SECRET) != null);
OzoneInputStream is = bucket.readKey(keyName);
byte[] fileContent = new byte[text.getBytes(UTF_8).length];
is.read(fileContent);
Assert.assertTrue(verifyRatisReplication(volumeName, bucketName, keyName, RATIS, ONE));
Assert.assertEquals(text, new String(fileContent, UTF_8));
// Step 4
bucket.deleteKey(keyName);
// Step 5
OMMetadataManager omMetadataManager = ozoneManager.getMetadataManager();
String objectKey = omMetadataManager.getOzoneKey(volumeName, bucketName, keyName);
RepeatedOmKeyInfo deletedKeys = omMetadataManager.getDeletedTable().get(objectKey);
if (deletedKeys != null) {
Map<String, String> deletedKeyMetadata = deletedKeys.getOmKeyInfoList().get(0).getMetadata();
Assert.assertFalse(deletedKeyMetadata.containsKey(OzoneConsts.GDPR_FLAG));
Assert.assertFalse(deletedKeyMetadata.containsKey(OzoneConsts.GDPR_SECRET));
Assert.assertFalse(deletedKeyMetadata.containsKey(OzoneConsts.GDPR_ALGORITHM));
}
}
use of org.apache.hadoop.ozone.om.OMMetadataManager in project ozone by apache.
the class TestOzoneRpcClientAbstract method testDefaultS3GVolumeExists.
@Test
public void testDefaultS3GVolumeExists() throws Exception {
String s3VolumeName = HddsClientUtils.getS3VolumeName(cluster.getConf());
OzoneVolume ozoneVolume = store.getVolume(s3VolumeName);
Assert.assertEquals(ozoneVolume.getName(), s3VolumeName);
OMMetadataManager omMetadataManager = cluster.getOzoneManager().getMetadataManager();
long transactionID = MAX_TRXN_ID + 1;
long objectID = OmUtils.addEpochToTxId(omMetadataManager.getOmEpoch(), transactionID);
OmVolumeArgs omVolumeArgs = cluster.getOzoneManager().getMetadataManager().getVolumeTable().get(omMetadataManager.getVolumeKey(s3VolumeName));
Assert.assertEquals(objectID, omVolumeArgs.getObjectID());
Assert.assertEquals(DEFAULT_OM_UPDATE_ID, omVolumeArgs.getUpdateID());
}
Aggregations