AlluxioJobMasterProcess(JournalSystem journalSystem, ServerSocket rpcBindSocket, ServerSocket webBindSocket) { super(journalSystem, rpcBindSocket, webBindSocket); mRpcConnectAddress = NetworkAddressUtils.getConnectAddress(ServiceType.JOB_MASTER_RPC, ServerConfiguration.global()); if (!ServerConfiguration.isSet(PropertyKey.JOB_MASTER_HOSTNAME)) { ServerConfiguration.set(PropertyKey.JOB_MASTER_HOSTNAME, NetworkAddressUtils.getLocalHostName( (int) ServerConfiguration.getMs(PropertyKey.NETWORK_HOST_RESOLUTION_TIMEOUT_MS))); } mUfsManager = new JobUfsManager(); try { // Create master. mJobMaster = new JobMaster(new MasterContext(mJournalSystem), mUfsManager); } catch (Exception e) { LOG.error(e.getMessage(), e); throw Throwables.propagate(e); } }
/** * @param masterContext the context for Alluxio master * @param clock the Clock to use for determining the time * @param executorServiceFactory a factory for creating the executor service to use for * running maintenance threads */ protected AbstractMaster(MasterContext masterContext, Clock clock, ExecutorServiceFactory executorServiceFactory) { Preconditions.checkNotNull(masterContext, "masterContext"); mJournal = masterContext.getJournalSystem().createJournal(this); mMasterContext = masterContext; mClock = clock; mExecutorServiceFactory = executorServiceFactory; }
@Override public JournalContext createJournalContext() throws UnavailableException { // All modifications to journaled state must happen inside of a journal context so that we can // persist the state change. As a mechanism to allow for state pauses, we acquire the state // change lock before entering any code paths that could modify journaled state. try (LockResource l = new LockResource(mMasterContext.stateChangeLock())) { return mJournal.createJournalContext(); } } }
/** * @param masterContext the context for Alluxio master * @param clock the Clock to use for determining the time * @param executorServiceFactory a factory for creating the executor service to use for * running maintenance threads */ protected AbstractMaster(MasterContext masterContext, Clock clock, ExecutorServiceFactory executorServiceFactory) { Preconditions.checkNotNull(masterContext, "masterContext"); mJournal = masterContext.getJournalSystem().createJournal(this); mSafeModeManager = masterContext.getSafeModeManager(); mBackupManager = masterContext.getBackupManager(); mStateChangeLock = masterContext.stateChangeLock(); mPauseStateLock = masterContext.pauseStateLock(); mClock = clock; mExecutorServiceFactory = executorServiceFactory; }
mBackupManager = new BackupManager(mRegistry); MasterContext context = new MasterContext(mJournalSystem, mSafeModeManager, mBackupManager, mStartTimeMs, mPort); mPauseStateLock = context.pauseStateLock(); MasterUtils.createMasters(mRegistry, context); } catch (Exception e) {
/** * Creates a new instance of {@link DefaultMetaMaster}. * * @param blockMaster a block master handle * @param masterContext the context for Alluxio master * @param executorServiceFactory a factory for creating the executor service to use for running * maintenance threads */ DefaultMetaMaster(BlockMaster blockMaster, MasterContext masterContext, ExecutorServiceFactory executorServiceFactory) { super(masterContext, new SystemClock(), executorServiceFactory); mSafeModeManager = masterContext.getSafeModeManager(); mStartTimeMs = masterContext.getStartTimeMs(); mMasterAddress = new Address().setHost(Configuration.getOrDefault(PropertyKey.MASTER_HOSTNAME, "localhost")) .setRpcPort(masterContext.getPort()); mBlockMaster = blockMaster; mBlockMaster.registerLostWorkerFoundListener(mWorkerConfigStore::lostNodeFound); mBlockMaster.registerWorkerLostListener(mWorkerConfigStore::handleNodeLost); mBlockMaster.registerNewWorkerConfListener(mWorkerConfigStore::registerNewConf); }
try (LockResource lr = new LockResource(mMasterContext.pauseStateLock())) { Instant now = Instant.now(); String backupFileName = String.format(BackupManager.BACKUP_FILE_FORMAT,
.getPort(ServiceType.MASTER_RPC, ServerConfiguration.global())) .build(); mPauseStateLock = context.pauseStateLock(); MasterUtils.createMasters(mRegistry, context); } catch (Exception e) {
@Before public void before() throws Exception { // Can't use ConfigurationRule due to conflicts with PowerMock. ServerConfiguration.set(PropertyKey.JOB_MASTER_JOB_CAPACITY, TEST_JOB_MASTER_JOB_CAPACITY); mJobMaster = new JobMaster(new MasterContext(new NoopJournalSystem()), Mockito.mock(UfsManager.class)); mJobMaster.start(true); }
/** * Creates a {@link AlluxioSecondaryMaster}. */ AlluxioSecondaryMaster() { try { URI journalLocation = JournalUtils.getJournalLocation(); mJournalSystem = new JournalSystem.Builder().setLocation(journalLocation).build(); mRegistry = new MasterRegistry(); mSafeModeManager = new DefaultSafeModeManager(); mBackupManager = new BackupManager(mRegistry); mStartTimeMs = System.currentTimeMillis(); mPort = Configuration.getInt(PropertyKey.MASTER_RPC_PORT); // Create masters. MasterUtils.createMasters(mRegistry, new MasterContext(mJournalSystem, mSafeModeManager, mBackupManager, mStartTimeMs, mPort)); // Check that journals of each service have been formatted. if (!mJournalSystem.isFormatted()) { throw new RuntimeException( String.format("Journal %s has not been formatted!", journalLocation)); } mLatch = new CountDownLatch(1); } catch (IOException e) { throw new RuntimeException(e); } }