Search in sources :

Example 1 with AlluxioMasterProcess

use of alluxio.master.AlluxioMasterProcess in project alluxio by Alluxio.

the class AlluxioMasterRestServiceHandlerTest method isMounted.

@Test
public void isMounted() {
    String s3Uri = "s3a://test/dir_1/dir-2";
    String hdfsUri = "hdfs://test";
    Map<String, MountPointInfo> mountTable = new HashMap<>();
    mountTable.put("/s3", new MountPointInfo().setUfsUri(s3Uri));
    FileSystemMaster mockMaster = mock(FileSystemMaster.class);
    when(mockMaster.getMountPointInfoSummary(false)).thenReturn(mountTable);
    AlluxioMasterProcess masterProcess = mock(AlluxioMasterProcess.class);
    when(masterProcess.getMaster(FileSystemMaster.class)).thenReturn(mockMaster);
    ServletContext context = mock(ServletContext.class);
    when(context.getAttribute(MasterWebServer.ALLUXIO_MASTER_SERVLET_RESOURCE_KEY)).thenReturn(masterProcess);
    AlluxioMasterRestServiceHandler handler = new AlluxioMasterRestServiceHandler(context);
    assertFalse(handler.isMounted(s3Uri));
    assertTrue(handler.isMounted(MetricsSystem.escape(new AlluxioURI(s3Uri))));
    assertTrue(handler.isMounted(MetricsSystem.escape(new AlluxioURI(s3Uri + "/"))));
    assertFalse(handler.isMounted(hdfsUri));
    assertFalse(handler.isMounted(MetricsSystem.escape(new AlluxioURI(hdfsUri))));
}
Also used : AlluxioMasterProcess(alluxio.master.AlluxioMasterProcess) MountPointInfo(alluxio.wire.MountPointInfo) HashMap(java.util.HashMap) FileSystemMaster(alluxio.master.file.FileSystemMaster) ServletContext(javax.servlet.ServletContext) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 2 with AlluxioMasterProcess

use of alluxio.master.AlluxioMasterProcess in project alluxio by Alluxio.

the class LocalFirstPolicyIntegrationTest method test.

@Test
public void test() throws Exception {
    AlluxioMasterProcess master = AlluxioMasterProcess.Factory.create();
    WorkerProcess worker1 = AlluxioWorkerProcess.Factory.create(TieredIdentityFactory.fromString("node=node1,rack=rack1", ServerConfiguration.global()));
    WorkerProcess worker2 = AlluxioWorkerProcess.Factory.create(TieredIdentityFactory.fromString("node=node2,rack=rack2", ServerConfiguration.global()));
    runProcess(mExecutor, master);
    runProcess(mExecutor, worker1);
    runProcess(mExecutor, worker2);
    TestUtils.waitForReady(master);
    TestUtils.waitForReady(worker1);
    TestUtils.waitForReady(worker2);
    FileSystem fs = FileSystem.Factory.create(ServerConfiguration.global());
    // Write to the worker in node1
    {
        Whitebox.setInternalState(TieredIdentityFactory.class, "sInstance", TieredIdentityFactory.fromString("node=node1,rack=rack1", ServerConfiguration.global()));
        try {
            FileSystemTestUtils.createByteFile(fs, "/file1", WritePType.MUST_CACHE, 100);
        } finally {
            Whitebox.setInternalState(TieredIdentityFactory.class, "sInstance", (Object) null);
        }
        BlockWorker blockWorker1 = worker1.getWorker(BlockWorker.class);
        BlockWorker blockWorker2 = worker2.getWorker(BlockWorker.class);
        assertEquals(100, blockWorker1.getStoreMeta().getUsedBytes());
        assertEquals(0, blockWorker2.getStoreMeta().getUsedBytes());
    }
    // Write to the worker in rack2
    {
        Whitebox.setInternalState(TieredIdentityFactory.class, "sInstance", TieredIdentityFactory.fromString("node=node3,rack=rack2", ServerConfiguration.global()));
        try {
            FileSystemTestUtils.createByteFile(fs, "/file2", WritePType.MUST_CACHE, 10);
        } finally {
            Whitebox.setInternalState(TieredIdentityFactory.class, "sInstance", (Object) null);
        }
        BlockWorker blockWorker1 = worker1.getWorker(BlockWorker.class);
        BlockWorker blockWorker2 = worker2.getWorker(BlockWorker.class);
        assertEquals(100, blockWorker1.getStoreMeta().getUsedBytes());
        assertEquals(10, blockWorker2.getStoreMeta().getUsedBytes());
    }
}
Also used : WorkerProcess(alluxio.worker.WorkerProcess) AlluxioWorkerProcess(alluxio.worker.AlluxioWorkerProcess) AlluxioMasterProcess(alluxio.master.AlluxioMasterProcess) TieredIdentityFactory(alluxio.network.TieredIdentityFactory) FileSystem(alluxio.client.file.FileSystem) BlockWorker(alluxio.worker.block.BlockWorker) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 3 with AlluxioMasterProcess

use of alluxio.master.AlluxioMasterProcess in project alluxio by Alluxio.

the class MetaMasterJournalTest method journalClusterID.

@Test
public void journalClusterID() throws Exception {
    MetaMaster metaMaster = mCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(MetaMaster.class);
    String clusterID = metaMaster.getClusterID();
    assertNotNull(clusterID);
    assertNotEquals(clusterID, DefaultMetaMaster.INVALID_CLUSTER_ID);
    mCluster.stopMasters();
    mCluster.startMasters();
    AlluxioMasterProcess masterProcess = mCluster.getLocalAlluxioMaster().getMasterProcess();
    assertTrue(masterProcess.getMaster(MetaMaster.class).getClusterID().equals(clusterID));
}
Also used : AlluxioMasterProcess(alluxio.master.AlluxioMasterProcess) DefaultMetaMaster(alluxio.master.meta.DefaultMetaMaster) MetaMaster(alluxio.master.meta.MetaMaster) Test(org.junit.Test)

Example 4 with AlluxioMasterProcess

use of alluxio.master.AlluxioMasterProcess in project alluxio by Alluxio.

the class BlockMasterJournalIntegrationTest method journalBlockCreation.

@Test
public void journalBlockCreation() throws Exception {
    FileSystem fs = mCluster.getClient();
    BlockMaster blockMaster = mCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(BlockMaster.class);
    AlluxioURI file = new AlluxioURI("/test");
    FileSystemTestUtils.createByteFile(fs, file, WritePType.MUST_CACHE, 10);
    URIStatus status = fs.getStatus(file);
    Long blockId = status.getBlockIds().get(0);
    assertNotNull(blockMaster.getBlockInfo(blockId));
    mCluster.stopMasters();
    mCluster.startMasters();
    AlluxioMasterProcess masterProcess = mCluster.getLocalAlluxioMaster().getMasterProcess();
    CommonUtils.waitFor("Master up", () -> !masterProcess.isInSafeMode());
    assertNotNull(masterProcess.getMaster(BlockMaster.class).getBlockInfo(blockId));
}
Also used : BlockMaster(alluxio.master.block.BlockMaster) AlluxioMasterProcess(alluxio.master.AlluxioMasterProcess) FileSystem(alluxio.client.file.FileSystem) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 5 with AlluxioMasterProcess

use of alluxio.master.AlluxioMasterProcess in project alluxio by Alluxio.

the class BlockMasterJournalIntegrationTest method journalBlockDeletion.

@Test
public void journalBlockDeletion() throws Exception {
    FileSystem fs = mCluster.getClient();
    BlockMaster blockMaster = mCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(BlockMaster.class);
    AlluxioURI file = new AlluxioURI("/test");
    FileSystemTestUtils.createByteFile(fs, file, WritePType.MUST_CACHE, 10);
    URIStatus status = fs.getStatus(file);
    Long blockId = status.getBlockIds().get(0);
    assertNotNull(blockMaster.getBlockInfo(blockId));
    fs.delete(file);
    WorkerNetAddress workerAddress = mCluster.getWorkerAddress();
    try {
        blockMaster.getBlockInfo(blockId);
        fail("Expected the block to be deleted");
    } catch (BlockInfoException e) {
    // expected
    }
    mCluster.stopMasters();
    mCluster.startMasters();
    AlluxioMasterProcess masterProcess = mCluster.getLocalAlluxioMaster().getMasterProcess();
    CommonUtils.waitFor("Master up", () -> !masterProcess.isInSafeMode());
    try {
        masterProcess.getMaster(BlockMaster.class).getBlockInfo(blockId);
        fail("Expected the block to be deleted after restart");
    } catch (BlockInfoException e) {
    // expected
    }
}
Also used : BlockMaster(alluxio.master.block.BlockMaster) AlluxioMasterProcess(alluxio.master.AlluxioMasterProcess) WorkerNetAddress(alluxio.wire.WorkerNetAddress) FileSystem(alluxio.client.file.FileSystem) BlockInfoException(alluxio.exception.BlockInfoException) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

AlluxioMasterProcess (alluxio.master.AlluxioMasterProcess)5 Test (org.junit.Test)5 AlluxioURI (alluxio.AlluxioURI)3 FileSystem (alluxio.client.file.FileSystem)3 URIStatus (alluxio.client.file.URIStatus)2 BlockMaster (alluxio.master.block.BlockMaster)2 BlockInfoException (alluxio.exception.BlockInfoException)1 FileSystemMaster (alluxio.master.file.FileSystemMaster)1 DefaultMetaMaster (alluxio.master.meta.DefaultMetaMaster)1 MetaMaster (alluxio.master.meta.MetaMaster)1 TieredIdentityFactory (alluxio.network.TieredIdentityFactory)1 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)1 MountPointInfo (alluxio.wire.MountPointInfo)1 WorkerNetAddress (alluxio.wire.WorkerNetAddress)1 AlluxioWorkerProcess (alluxio.worker.AlluxioWorkerProcess)1 WorkerProcess (alluxio.worker.WorkerProcess)1 BlockWorker (alluxio.worker.block.BlockWorker)1 HashMap (java.util.HashMap)1 ServletContext (javax.servlet.ServletContext)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1