use of alluxio.master.CoreMasterContext in project alluxio by Alluxio.
the class BlockMasterWorkerServiceHandlerTest method initServiceHandler.
public void initServiceHandler(boolean leaseEnabled) throws Exception {
if (leaseEnabled) {
ServerConfiguration.set(PropertyKey.MASTER_WORKER_REGISTER_LEASE_ENABLED, true);
ServerConfiguration.set(PropertyKey.MASTER_WORKER_REGISTER_LEASE_TTL, "3s");
// Tests on the JVM check logic will be done separately
ServerConfiguration.set(PropertyKey.MASTER_WORKER_REGISTER_LEASE_RESPECT_JVM_SPACE, false);
ServerConfiguration.set(PropertyKey.MASTER_WORKER_REGISTER_LEASE_COUNT, 1);
} else {
ServerConfiguration.set(PropertyKey.MASTER_WORKER_REGISTER_LEASE_ENABLED, false);
}
mRegistry = new MasterRegistry();
CoreMasterContext masterContext = MasterTestUtils.testMasterContext();
mMetricsMaster = new MetricsMasterFactory().create(mRegistry, masterContext);
mClock = new ManualClock();
mExecutorService = Executors.newFixedThreadPool(2, ThreadFactoryUtils.build("TestBlockMaster-%d", true));
mBlockMaster = new DefaultBlockMaster(mMetricsMaster, masterContext, mClock, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService));
mRegistry.add(BlockMaster.class, mBlockMaster);
mRegistry.start(true);
mHandler = new BlockMasterWorkerServiceHandler(mBlockMaster);
}
use of alluxio.master.CoreMasterContext 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