Search in sources :

Example 11 with OMMetadataManager

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;
}
Also used : OmMetadataManagerImpl(org.apache.hadoop.ozone.om.OmMetadataManagerImpl) OmBucketInfo(org.apache.hadoop.ozone.om.helpers.OmBucketInfo) OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs) ReconOMMetadataManager(org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager) OMMetadataManager(org.apache.hadoop.ozone.om.OMMetadataManager) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration)

Example 12 with 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;
}
Also used : Table(org.apache.hadoop.hdds.utils.db.Table) ReconOMMetadataManager(org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager) OMMetadataManager(org.apache.hadoop.ozone.om.OMMetadataManager) OzoneManagerServiceProviderImpl(org.apache.hadoop.ozone.recon.spi.impl.OzoneManagerServiceProviderImpl)

Example 13 with OMMetadataManager

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;
}
Also used : OmMetadataManagerImpl(org.apache.hadoop.ozone.om.OmMetadataManagerImpl) OmBucketInfo(org.apache.hadoop.ozone.om.helpers.OmBucketInfo) OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs) OMMetadataManager(org.apache.hadoop.ozone.om.OMMetadataManager) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) File(java.io.File)

Example 14 with 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));
    }
}
Also used : OzoneVolume(org.apache.hadoop.ozone.client.OzoneVolume) OzoneBucket(org.apache.hadoop.ozone.client.OzoneBucket) OzoneInputStream(org.apache.hadoop.ozone.client.io.OzoneInputStream) OzoneKeyDetails(org.apache.hadoop.ozone.client.OzoneKeyDetails) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) BucketArgs(org.apache.hadoop.ozone.client.BucketArgs) OMMetadataManager(org.apache.hadoop.ozone.om.OMMetadataManager) OzoneOutputStream(org.apache.hadoop.ozone.client.io.OzoneOutputStream) RepeatedOmKeyInfo(org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo) Test(org.junit.Test)

Example 15 with OMMetadataManager

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());
}
Also used : OzoneVolume(org.apache.hadoop.ozone.client.OzoneVolume) OmVolumeArgs(org.apache.hadoop.ozone.om.helpers.OmVolumeArgs) OMMetadataManager(org.apache.hadoop.ozone.om.OMMetadataManager) Test(org.junit.Test)

Aggregations

OMMetadataManager (org.apache.hadoop.ozone.om.OMMetadataManager)79 IOException (java.io.IOException)45 OMClientResponse (org.apache.hadoop.ozone.om.response.OMClientResponse)43 OMResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)40 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)32 OmBucketInfo (org.apache.hadoop.ozone.om.helpers.OmBucketInfo)30 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)29 OMMetrics (org.apache.hadoop.ozone.om.OMMetrics)26 Test (org.junit.Test)22 AuditLogger (org.apache.hadoop.ozone.audit.AuditLogger)19 OzoneManagerProtocolProtos (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos)19 ArrayList (java.util.ArrayList)17 KeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs)17 OmVolumeArgs (org.apache.hadoop.ozone.om.helpers.OmVolumeArgs)13 ReconOMMetadataManager (org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager)12 OmKeyLocationInfo (org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo)11 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)9 HashMap (java.util.HashMap)8 OmMetadataManagerImpl (org.apache.hadoop.ozone.om.OmMetadataManagerImpl)7 RepeatedOmKeyInfo (org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo)7