use of org.apache.hadoop.ozone.recon.spi.ReconContainerMetadataManager in project ozone by apache.
the class TestReconWithOzoneManagerHA method testReconGetsSnapshotFromLeader.
@Test
public void testReconGetsSnapshotFromLeader() throws Exception {
AtomicReference<OzoneManager> ozoneManager = new AtomicReference<>();
// Wait for OM leader election to finish
GenericTestUtils.waitFor(() -> {
OzoneManager om = cluster.getOMLeader();
ozoneManager.set(om);
return om != null;
}, 100, 120000);
Assert.assertNotNull("Timed out waiting OM leader election to finish: " + "no leader or more than one leader.", ozoneManager);
Assert.assertTrue("Should have gotten the leader!", ozoneManager.get().isLeaderReady());
OzoneManagerServiceProviderImpl impl = (OzoneManagerServiceProviderImpl) cluster.getReconServer().getOzoneManagerServiceProvider();
String hostname = ozoneManager.get().getHttpServer().getHttpAddress().getHostName();
String expectedUrl = "http://" + (hostname.equals("0.0.0.0") ? "localhost" : hostname) + ":" + ozoneManager.get().getHttpServer().getHttpAddress().getPort() + OZONE_DB_CHECKPOINT_HTTP_ENDPOINT;
String snapshotUrl = impl.getOzoneManagerSnapshotUrl();
Assert.assertEquals("OM Snapshot should be requested from the leader.", expectedUrl, snapshotUrl);
// Write some data
String keyPrefix = "ratis";
OzoneOutputStream key = objectStore.getVolume(VOL_NAME).getBucket(VOL_NAME).createKey(keyPrefix, 1024, ReplicationType.RATIS, ReplicationFactor.ONE, new HashMap<>());
key.write(keyPrefix.getBytes(UTF_8));
key.flush();
key.close();
// Sync data to Recon
impl.syncDataFromOM();
ReconContainerMetadataManager reconContainerMetadataManager = cluster.getReconServer().getReconContainerMetadataManager();
TableIterator iterator = reconContainerMetadataManager.getContainerTableIterator();
String reconKeyPrefix = null;
while (iterator.hasNext()) {
Table.KeyValue<ContainerKeyPrefix, Integer> keyValue = (Table.KeyValue<ContainerKeyPrefix, Integer>) iterator.next();
reconKeyPrefix = keyValue.getKey().getKeyPrefix();
}
Assert.assertEquals("Container data should be synced to recon.", String.format("/%s/%s/%s", VOL_NAME, VOL_NAME, keyPrefix), reconKeyPrefix);
}
use of org.apache.hadoop.ozone.recon.spi.ReconContainerMetadataManager in project ozone by apache.
the class TestContainerKeyMapperTask method setUp.
@Before
public void setUp() throws Exception {
omMetadataManager = initializeNewOmMetadataManager(temporaryFolder.newFolder());
ozoneManagerServiceProvider = getMockOzoneManagerServiceProvider();
reconOMMetadataManager = getTestReconOmMetadataManager(omMetadataManager, temporaryFolder.newFolder());
ReconTestInjector reconTestInjector = new ReconTestInjector.Builder(temporaryFolder).withReconSqlDb().withReconOm(reconOMMetadataManager).withOmServiceProvider(ozoneManagerServiceProvider).withContainerDB().build();
reconContainerMetadataManager = reconTestInjector.getInstance(ReconContainerMetadataManager.class);
}
use of org.apache.hadoop.ozone.recon.spi.ReconContainerMetadataManager in project ozone by apache.
the class TestReconContainerMetadataManagerImpl method setupOnce.
@BeforeClass
public static void setupOnce() throws Exception {
ReconTestInjector reconTestInjector = new ReconTestInjector.Builder(TEMP_FOLDER).withReconSqlDb().withContainerDB().build();
reconContainerMetadataManager = reconTestInjector.getInstance(ReconContainerMetadataManager.class);
}
use of org.apache.hadoop.ozone.recon.spi.ReconContainerMetadataManager in project ozone by apache.
the class TestContainerEndpoint method initializeInjector.
private void initializeInjector() throws Exception {
reconOMMetadataManager = getTestReconOmMetadataManager(initializeNewOmMetadataManager(temporaryFolder.newFolder()), temporaryFolder.newFolder());
ReconTestInjector reconTestInjector = new ReconTestInjector.Builder(temporaryFolder).withReconSqlDb().withReconOm(reconOMMetadataManager).withOmServiceProvider(mock(OzoneManagerServiceProviderImpl.class)).addBinding(OzoneStorageContainerManager.class, ReconStorageContainerManagerFacade.class).withContainerDB().addBinding(StorageContainerServiceProvider.class, mock(StorageContainerServiceProviderImpl.class)).addBinding(ContainerEndpoint.class).addBinding(ContainerHealthSchemaManager.class).build();
ozoneStorageContainerManager = reconTestInjector.getInstance(OzoneStorageContainerManager.class);
reconContainerManager = (ReconContainerManager) ozoneStorageContainerManager.getContainerManager();
reconPipelineManager = (ReconPipelineManager) ozoneStorageContainerManager.getPipelineManager();
reconContainerMetadataManager = reconTestInjector.getInstance(ReconContainerMetadataManager.class);
containerEndpoint = reconTestInjector.getInstance(ContainerEndpoint.class);
containerHealthSchemaManager = reconTestInjector.getInstance(ContainerHealthSchemaManager.class);
pipeline = getRandomPipeline();
pipelineID = pipeline.getId();
reconPipelineManager.addPipeline(pipeline);
}
Aggregations