use of alluxio.master.journal.JournalSystem in project alluxio by Alluxio.
the class Format method format.
/**
* Formats the Alluxio file system.
*
* @param mode either {@code MASTER} or {@code WORKER}
* @param alluxioConf Alluxio configuration
*/
public static void format(Mode mode, AlluxioConfiguration alluxioConf) throws IOException {
NoopUfsManager noopUfsManager = new NoopUfsManager();
switch(mode) {
case MASTER:
URI journalLocation = JournalUtils.getJournalLocation();
LOG.info("Formatting master journal: {}", journalLocation);
JournalSystem journalSystem = new JournalSystem.Builder().setLocation(journalLocation).build(CommonUtils.ProcessType.MASTER);
for (String masterServiceName : ServiceUtils.getMasterServiceNames()) {
journalSystem.createJournal(new NoopMaster(masterServiceName, noopUfsManager));
}
journalSystem.format();
break;
case WORKER:
String workerDataFolder = ServerConfiguration.getString(PropertyKey.WORKER_DATA_FOLDER);
LOG.info("Formatting worker data folder: {}", workerDataFolder);
int storageLevels = ServerConfiguration.getInt(PropertyKey.WORKER_TIERED_STORE_LEVELS);
for (int level = 0; level < storageLevels; level++) {
PropertyKey tierLevelDirPath = PropertyKey.Template.WORKER_TIERED_STORE_LEVEL_DIRS_PATH.format(level);
String[] dirPaths = ServerConfiguration.getString(tierLevelDirPath).split(",");
String name = "Data path for tier " + level;
for (String dirPath : dirPaths) {
String dirWorkerDataFolder = CommonUtils.getWorkerDataDirectory(dirPath, alluxioConf);
LOG.info("Formatting {}:{}", name, dirWorkerDataFolder);
formatWorkerDataFolder(dirWorkerDataFolder);
}
}
break;
default:
throw new RuntimeException(String.format("Unrecognized format mode: %s", mode));
}
}
use of alluxio.master.journal.JournalSystem in project alluxio by Alluxio.
the class AccessTimeUpdaterTest method before.
@Before
public final void before() throws Exception {
mFileSystemMaster = Mockito.mock(FileSystemMaster.class);
when(mFileSystemMaster.getName()).thenReturn(Constants.FILE_SYSTEM_MASTER_NAME);
ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_TYPE, "UFS");
MasterRegistry registry = new MasterRegistry();
JournalSystem journalSystem = JournalTestUtils.createJournalSystem(mTestFolder);
mContext = MasterTestUtils.testMasterContext(journalSystem);
new MetricsMasterFactory().create(registry, mContext);
mBlockMaster = new BlockMasterFactory().create(registry, mContext);
InodeDirectoryIdGenerator directoryIdGenerator = new InodeDirectoryIdGenerator(mBlockMaster);
UfsManager manager = mock(UfsManager.class);
MountTable mountTable = new MountTable(manager, mock(MountInfo.class));
InodeLockManager lockManager = new InodeLockManager();
mInodeStore = mContext.getInodeStoreFactory().apply(lockManager);
mInodeTree = new InodeTree(mInodeStore, mBlockMaster, directoryIdGenerator, mountTable, lockManager);
journalSystem.start();
journalSystem.gainPrimacy();
mBlockMaster.start(true);
ServerConfiguration.set(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_ENABLED, true);
ServerConfiguration.set(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_SUPERGROUP, "test-supergroup");
mInodeTree.initializeRoot(TEST_OWNER, TEST_GROUP, TEST_MODE, NoopJournalContext.INSTANCE);
mScheduler = new ControllableScheduler();
}
use of alluxio.master.journal.JournalSystem in project alluxio by Alluxio.
the class BlockMasterTest method before.
/**
* Sets up the dependencies before a test runs.
*/
@Before
public void before() throws Exception {
mRegistry = new MasterRegistry();
mMetrics = Lists.newArrayList();
JournalSystem journalSystem = new NoopJournalSystem();
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);
}
use of alluxio.master.journal.JournalSystem in project alluxio by Alluxio.
the class ReplicationCheckerTest method before.
@Before
public void before() throws Exception {
ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_TYPE, "UFS");
MasterRegistry registry = new MasterRegistry();
JournalSystem journalSystem = JournalTestUtils.createJournalSystem(mTestFolder);
mContext = MasterTestUtils.testMasterContext(journalSystem);
new MetricsMasterFactory().create(registry, mContext);
mBlockMaster = new BlockMasterFactory().create(registry, mContext);
InodeDirectoryIdGenerator directoryIdGenerator = new InodeDirectoryIdGenerator(mBlockMaster);
UfsManager manager = mock(UfsManager.class);
MountTable mountTable = new MountTable(manager, mock(MountInfo.class));
InodeLockManager lockManager = new InodeLockManager();
mInodeStore = mContext.getInodeStoreFactory().apply(lockManager);
mInodeTree = new InodeTree(mInodeStore, mBlockMaster, directoryIdGenerator, mountTable, lockManager);
journalSystem.start();
journalSystem.gainPrimacy();
mBlockMaster.start(true);
ServerConfiguration.set(PropertyKey.TEST_MODE, true);
ServerConfiguration.set(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_ENABLED, true);
ServerConfiguration.set(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_SUPERGROUP, "test-supergroup");
mInodeTree.initializeRoot(TEST_OWNER, TEST_GROUP, TEST_MODE, NoopJournalContext.INSTANCE);
mMockReplicationHandler = new MockHandler();
mReplicationChecker = new ReplicationChecker(mInodeTree, mBlockMaster, mContext.getSafeModeManager(), mMockReplicationHandler);
}
use of alluxio.master.journal.JournalSystem in project alluxio by Alluxio.
the class PersistenceTest method startServices.
private void startServices() throws Exception {
mRegistry = new MasterRegistry();
JournalSystem journalSystem = JournalTestUtils.createJournalSystem(mJournalFolder.getAbsolutePath());
CoreMasterContext context = MasterTestUtils.testMasterContext(journalSystem);
new MetricsMasterFactory().create(mRegistry, context);
new BlockMasterFactory().create(mRegistry, context);
mFileSystemMaster = new FileSystemMasterFactory().create(mRegistry, context);
journalSystem.start();
journalSystem.gainPrimacy();
mRegistry.start(true);
mMockJobMasterClient = Mockito.mock(JobMasterClient.class);
PowerMockito.mockStatic(JobMasterClient.Factory.class);
Mockito.when(JobMasterClient.Factory.create(any(JobMasterClientContext.class))).thenReturn(mMockJobMasterClient);
}
Aggregations