use of alluxio.master.file.FileSystemMasterFactory in project alluxio by Alluxio.
the class JournalSinkTest method startMasters.
private void startMasters(MasterRegistry registry, JournalSystem journalSystem, JournalSink sink, boolean leader) throws Exception {
CoreMasterContext masterContext = MasterTestUtils.testMasterContext(journalSystem);
new MetricsMasterFactory().create(registry, masterContext);
new BlockMasterFactory().create(registry, masterContext);
new FileSystemMasterFactory().create(registry, masterContext);
if (sink != null) {
// add journal sink
journalSystem.addJournalSink(registry.get(FileSystemMaster.class), sink);
}
journalSystem.start();
if (leader) {
journalSystem.gainPrimacy();
}
registry.start(leader);
}
use of alluxio.master.file.FileSystemMasterFactory in project alluxio by Alluxio.
the class AlluxioMasterRestServiceHandlerTest method before.
@Before
public void before() throws Exception {
mMasterProcess = mock(AlluxioMasterProcess.class);
ServletContext context = mock(ServletContext.class);
mRegistry = new MasterRegistry();
CoreMasterContext masterContext = MasterTestUtils.testMasterContext();
mMetricsMaster = new MetricsMasterFactory().create(mRegistry, masterContext);
mRegistry.add(MetricsMaster.class, mMetricsMaster);
registerMockUfs();
mBlockMaster = new BlockMasterFactory().create(mRegistry, masterContext);
mFileSystemMaster = new FileSystemMasterFactory().create(mRegistry, masterContext);
mRegistry.start(true);
when(mMasterProcess.getMaster(BlockMaster.class)).thenReturn(mBlockMaster);
when(mMasterProcess.getMaster(FileSystemMaster.class)).thenReturn(mFileSystemMaster);
when(context.getAttribute(MasterWebServer.ALLUXIO_MASTER_SERVLET_RESOURCE_KEY)).thenReturn(mMasterProcess);
mHandler = new AlluxioMasterRestServiceHandler(context);
// Register two workers
long worker1 = mBlockMaster.getWorkerId(NET_ADDRESS_1);
long worker2 = mBlockMaster.getWorkerId(NET_ADDRESS_2);
List<String> tiers = Arrays.asList(Constants.MEDIUM_MEM, Constants.MEDIUM_SSD);
mBlockMaster.workerRegister(worker1, tiers, WORKER1_TOTAL_BYTES_ON_TIERS, WORKER1_USED_BYTES_ON_TIERS, NO_BLOCKS_ON_LOCATIONS, NO_LOST_STORAGE, RegisterWorkerPOptions.getDefaultInstance());
mBlockMaster.workerRegister(worker2, tiers, WORKER2_TOTAL_BYTES_ON_TIERS, WORKER2_USED_BYTES_ON_TIERS, NO_BLOCKS_ON_LOCATIONS, NO_LOST_STORAGE, RegisterWorkerPOptions.getDefaultInstance());
String filesPinnedProperty = MetricKey.MASTER_FILES_PINNED.getName();
MetricsSystem.METRIC_REGISTRY.remove(filesPinnedProperty);
}
use of alluxio.master.file.FileSystemMasterFactory in project alluxio by Alluxio.
the class MasterTestUtils method createFileSystemMasterFromJournal.
/**
* Creates a new {@link FileSystemMaster} from journal along with its dependencies, and returns
* the master registry and the journal system.
*
* @param isLeader whether to start as a leader
* @param userState the user state for the server. if null, will use ServerUserState.global()
* @param journalFolder the folder of the master journal
* @return a resource that contains the master registry and the journal system
*/
private static FsMasterResource createFileSystemMasterFromJournal(boolean isLeader, UserState userState, String journalFolder) throws Exception {
String masterJournal = journalFolder;
MasterRegistry registry = new MasterRegistry();
SafeModeManager safeModeManager = new TestSafeModeManager();
long startTimeMs = System.currentTimeMillis();
int port = ServerConfiguration.getInt(PropertyKey.MASTER_RPC_PORT);
String baseDir = ServerConfiguration.getString(PropertyKey.MASTER_METASTORE_DIR);
JournalSystem journalSystem = JournalTestUtils.createJournalSystem(masterJournal);
if (userState == null) {
userState = ServerUserState.global();
}
CoreMasterContext masterContext = CoreMasterContext.newBuilder().setJournalSystem(journalSystem).setSafeModeManager(safeModeManager).setBackupManager(mock(BackupManager.class)).setBlockStoreFactory(MasterUtils.getBlockStoreFactory(baseDir)).setInodeStoreFactory(MasterUtils.getInodeStoreFactory(baseDir)).setStartTimeMs(startTimeMs).setUserState(userState).setPort(port).setUfsManager(new MasterUfsManager()).build();
new MetricsMasterFactory().create(registry, masterContext);
new BlockMasterFactory().create(registry, masterContext);
new FileSystemMasterFactory().create(registry, masterContext);
journalSystem.start();
if (isLeader) {
journalSystem.gainPrimacy();
}
registry.start(isLeader);
return new FsMasterResource(registry, journalSystem);
}
Aggregations