Search in sources :

Example 1 with ReconContainerMetadataManager

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);
}
Also used : Table(org.apache.hadoop.hdds.utils.db.Table) AtomicReference(java.util.concurrent.atomic.AtomicReference) OzoneOutputStream(org.apache.hadoop.ozone.client.io.OzoneOutputStream) OzoneManagerServiceProviderImpl(org.apache.hadoop.ozone.recon.spi.impl.OzoneManagerServiceProviderImpl) TableIterator(org.apache.hadoop.hdds.utils.db.TableIterator) ReconContainerMetadataManager(org.apache.hadoop.ozone.recon.spi.ReconContainerMetadataManager) OzoneManager(org.apache.hadoop.ozone.om.OzoneManager) ContainerKeyPrefix(org.apache.hadoop.ozone.recon.api.types.ContainerKeyPrefix) Test(org.junit.Test)

Example 2 with ReconContainerMetadataManager

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);
}
Also used : ReconContainerMetadataManager(org.apache.hadoop.ozone.recon.spi.ReconContainerMetadataManager) ReconTestInjector(org.apache.hadoop.ozone.recon.ReconTestInjector) Before(org.junit.Before)

Example 3 with ReconContainerMetadataManager

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);
}
Also used : ReconContainerMetadataManager(org.apache.hadoop.ozone.recon.spi.ReconContainerMetadataManager) ReconTestInjector(org.apache.hadoop.ozone.recon.ReconTestInjector) BeforeClass(org.junit.BeforeClass)

Example 4 with ReconContainerMetadataManager

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);
}
Also used : ReconStorageContainerManagerFacade(org.apache.hadoop.ozone.recon.scm.ReconStorageContainerManagerFacade) ContainerHealthSchemaManager(org.apache.hadoop.ozone.recon.persistence.ContainerHealthSchemaManager) ReconContainerMetadataManager(org.apache.hadoop.ozone.recon.spi.ReconContainerMetadataManager) StorageContainerServiceProvider(org.apache.hadoop.ozone.recon.spi.StorageContainerServiceProvider) ReconTestInjector(org.apache.hadoop.ozone.recon.ReconTestInjector) OzoneManagerServiceProviderImpl(org.apache.hadoop.ozone.recon.spi.impl.OzoneManagerServiceProviderImpl) OzoneStorageContainerManager(org.apache.hadoop.hdds.scm.server.OzoneStorageContainerManager)

Aggregations

ReconContainerMetadataManager (org.apache.hadoop.ozone.recon.spi.ReconContainerMetadataManager)4 ReconTestInjector (org.apache.hadoop.ozone.recon.ReconTestInjector)3 OzoneManagerServiceProviderImpl (org.apache.hadoop.ozone.recon.spi.impl.OzoneManagerServiceProviderImpl)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 OzoneStorageContainerManager (org.apache.hadoop.hdds.scm.server.OzoneStorageContainerManager)1 Table (org.apache.hadoop.hdds.utils.db.Table)1 TableIterator (org.apache.hadoop.hdds.utils.db.TableIterator)1 OzoneOutputStream (org.apache.hadoop.ozone.client.io.OzoneOutputStream)1 OzoneManager (org.apache.hadoop.ozone.om.OzoneManager)1 ContainerKeyPrefix (org.apache.hadoop.ozone.recon.api.types.ContainerKeyPrefix)1 ContainerHealthSchemaManager (org.apache.hadoop.ozone.recon.persistence.ContainerHealthSchemaManager)1 ReconStorageContainerManagerFacade (org.apache.hadoop.ozone.recon.scm.ReconStorageContainerManagerFacade)1 StorageContainerServiceProvider (org.apache.hadoop.ozone.recon.spi.StorageContainerServiceProvider)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1