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))));
}
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());
}
}
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));
}
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));
}
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
}
}
Aggregations