code: public static void format(Mode mode, AlluxioConfiguration alluxioConf) throws IOException {
      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));
          }
          journalSystem.format();
          break;
        case WORKER:
          String workerDataFolder = ServerConfiguration.get(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.get(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));
      }
    }
docs: Formats the Alluxio file system.
  
  @param mode either {@code MASTER} or {@code WORKER}
  @param alluxioConf Alluxio configuration