use of org.apache.hadoop.ozone.om.OmMetadataManagerImpl in project ozone by apache.
the class TestOMDirectoryCreateRequestWithFSO method setup.
@Before
public void setup() throws Exception {
ozoneManager = Mockito.mock(OzoneManager.class);
omMetrics = OMMetrics.create();
OzoneConfiguration ozoneConfiguration = new OzoneConfiguration();
ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS, folder.newFolder().getAbsolutePath());
OMRequestTestUtils.configureFSOptimizedPaths(ozoneConfiguration, true);
omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration);
when(ozoneManager.getMetrics()).thenReturn(omMetrics);
when(ozoneManager.getMetadataManager()).thenReturn(omMetadataManager);
auditLogger = Mockito.mock(AuditLogger.class);
when(ozoneManager.getAuditLogger()).thenReturn(auditLogger);
Mockito.doNothing().when(auditLogger).logWrite(any(AuditMessage.class));
when(ozoneManager.resolveBucketLink(any(KeyArgs.class), any(OMClientRequest.class))).thenReturn(new ResolvedBucket(Pair.of("", ""), Pair.of("", "")));
}
use of org.apache.hadoop.ozone.om.OmMetadataManagerImpl in project ozone by apache.
the class TestBucketRequest method setup.
@Before
public void setup() throws Exception {
ozoneManager = Mockito.mock(OzoneManager.class);
omMetrics = OMMetrics.create();
OzoneConfiguration ozoneConfiguration = new OzoneConfiguration();
ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS, folder.newFolder().getAbsolutePath());
omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration);
when(ozoneManager.getMetrics()).thenReturn(omMetrics);
when(ozoneManager.getMetadataManager()).thenReturn(omMetadataManager);
when(ozoneManager.isRatisEnabled()).thenReturn(true);
OMLayoutVersionManager lvm = mock(OMLayoutVersionManager.class);
when(lvm.getMetadataLayoutVersion()).thenReturn(0);
when(ozoneManager.getVersionManager()).thenReturn(lvm);
auditLogger = Mockito.mock(AuditLogger.class);
when(ozoneManager.getAuditLogger()).thenReturn(auditLogger);
Mockito.doNothing().when(auditLogger).logWrite(any(AuditMessage.class));
}
use of org.apache.hadoop.ozone.om.OmMetadataManagerImpl in project ozone by apache.
the class TestOzoneManagerDoubleBufferWithOMResponse method setup.
@Before
public void setup() throws IOException {
ozoneManager = Mockito.mock(OzoneManager.class, Mockito.withSettings().stubOnly());
omMetrics = OMMetrics.create();
OzoneConfiguration ozoneConfiguration = new OzoneConfiguration();
ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS, folder.newFolder().getAbsolutePath());
omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration);
when(ozoneManager.getMetrics()).thenReturn(omMetrics);
when(ozoneManager.getMetadataManager()).thenReturn(omMetadataManager);
when(ozoneManager.getMaxUserVolumeCount()).thenReturn(10L);
auditLogger = Mockito.mock(AuditLogger.class);
when(ozoneManager.getAuditLogger()).thenReturn(auditLogger);
Mockito.doNothing().when(auditLogger).logWrite(any(AuditMessage.class));
ozoneManagerRatisSnapshot = index -> {
lastAppliedIndex = index.get(index.size() - 1);
};
doubleBuffer = new OzoneManagerDoubleBuffer.Builder().setOmMetadataManager(omMetadataManager).setOzoneManagerRatisSnapShot(ozoneManagerRatisSnapshot).enableRatis(true).setIndexToTerm((i) -> term).build();
ozoneManagerDoubleBufferHelper = doubleBuffer::add;
}
use of org.apache.hadoop.ozone.om.OmMetadataManagerImpl in project ozone by apache.
the class TestOMDBUpdatesHandler method testDelete.
@Test
public void testDelete() throws Exception {
OzoneConfiguration configuration = createNewTestPath();
OmMetadataManagerImpl metaMgr = new OmMetadataManagerImpl(configuration);
OzoneConfiguration conf2 = createNewTestPath();
OmMetadataManagerImpl metaMgrCopy = new OmMetadataManagerImpl(conf2);
// Write 1 volume, 1 key into source and target OM DBs.
String volumeKey = metaMgr.getVolumeKey("sampleVol");
String nonExistVolumeKey = metaMgr.getVolumeKey("nonExistingVolume");
OmVolumeArgs args = OmVolumeArgs.newBuilder().setVolume("sampleVol").setAdminName("bilbo").setOwnerName("bilbo").build();
metaMgr.getVolumeTable().put(volumeKey, args);
metaMgrCopy.getVolumeTable().put(volumeKey, args);
OmKeyInfo omKeyInfo = getOmKeyInfo("sampleVol", "bucketOne", "key_one");
metaMgr.getKeyTable(getBucketLayout()).put("/sampleVol/bucketOne/key_one", omKeyInfo);
metaMgrCopy.getKeyTable(getBucketLayout()).put("/sampleVol/bucketOne/key_one", omKeyInfo);
// Delete the volume and key from target DB.
metaMgr.getKeyTable(getBucketLayout()).delete("/sampleVol/bucketOne/key_one");
metaMgr.getVolumeTable().delete(volumeKey);
// Delete a non-existing volume and key
metaMgr.getKeyTable(getBucketLayout()).delete("/sampleVol/bucketOne/key_two");
metaMgr.getVolumeTable().delete(metaMgr.getVolumeKey("nonExistingVolume"));
RDBStore rdbStore = (RDBStore) metaMgr.getStore();
RocksDB rocksDB = rdbStore.getDb();
TransactionLogIterator transactionLogIterator = rocksDB.getUpdatesSince(3);
List<byte[]> writeBatches = new ArrayList<>();
while (transactionLogIterator.isValid()) {
TransactionLogIterator.BatchResult result = transactionLogIterator.getBatch();
result.writeBatch().markWalTerminationPoint();
WriteBatch writeBatch = result.writeBatch();
writeBatches.add(writeBatch.data());
transactionLogIterator.next();
}
// OMDBUpdatesHandler has access to target DB. So it has the volume and
// key.
OMDBUpdatesHandler omdbUpdatesHandler = new OMDBUpdatesHandler(metaMgrCopy);
for (byte[] data : writeBatches) {
WriteBatch writeBatch = new WriteBatch(data);
writeBatch.iterate(omdbUpdatesHandler);
}
List<OMDBUpdateEvent> events = omdbUpdatesHandler.getEvents();
assertEquals(4, events.size());
OMDBUpdateEvent keyEvent = events.get(0);
assertEquals(OMDBUpdateEvent.OMDBUpdateAction.DELETE, keyEvent.getAction());
assertEquals("/sampleVol/bucketOne/key_one", keyEvent.getKey());
assertEquals(omKeyInfo, keyEvent.getValue());
OMDBUpdateEvent volEvent = events.get(1);
assertEquals(OMDBUpdateEvent.OMDBUpdateAction.DELETE, volEvent.getAction());
assertEquals(volumeKey, volEvent.getKey());
assertNotNull(volEvent.getValue());
OmVolumeArgs volumeInfo = (OmVolumeArgs) volEvent.getValue();
assertEquals("sampleVol", volumeInfo.getVolume());
// Assert the values of non existent keys are set to null.
OMDBUpdateEvent nonExistKey = events.get(2);
assertEquals(OMDBUpdateEvent.OMDBUpdateAction.DELETE, nonExistKey.getAction());
assertEquals("/sampleVol/bucketOne/key_two", nonExistKey.getKey());
assertNull(nonExistKey.getValue());
OMDBUpdateEvent nonExistVolume = events.get(3);
assertEquals(OMDBUpdateEvent.OMDBUpdateAction.DELETE, nonExistVolume.getAction());
assertEquals(nonExistVolumeKey, nonExistVolume.getKey());
assertNull(nonExistVolume.getValue());
}
use of org.apache.hadoop.ozone.om.OmMetadataManagerImpl 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;
}
Aggregations