Journal implements Closeable { void format(NamespaceInfo nsInfo, boolean force) throws IOException { Preconditions.checkState(nsInfo.getNamespaceID() != 0, "can't format with uninitialized namespace info: %s", nsInfo); LOG.info("Formatting journal id : " + journalId + " with namespace info: " + nsInfo + " and force: " + force); storage.format(nsInfo, force); this.cache = createCache(); refreshCachedData(); } Journal(Configuration conf, File logDir, String journalId,
      StartupOption startOpt, StorageErrorReporter errorReporter); void setTriedJournalSyncerStartedwithnsId(boolean started); boolean getTriedJournalSyncerStartedwithnsId(); @Override // Closeable void close(); synchronized long getLastWriterEpoch(); void heartbeat(RequestInfo reqInfo); synchronized boolean isFormatted(); synchronized void startLogSegment(RequestInfo reqInfo, long txid,
      int layoutVersion); synchronized void finalizeLogSegment(RequestInfo reqInfo, long startTxId,
      long endTxId); synchronized void purgeLogsOlderThan(RequestInfo reqInfo,
      long minTxIdToKeep); RemoteEditLogManifest getEditLogManifest(long sinceTxId,
      boolean inProgressOk); GetJournaledEditsResponseProto getJournaledEdits(long sinceTxId,
      int maxTxns); synchronized PrepareRecoveryResponseProto prepareRecovery(
      RequestInfo reqInfo, long segmentTxId); synchronized void acceptRecovery(RequestInfo reqInfo,
      SegmentStateProto segment, URL fromUrl); synchronized void doPreUpgrade(); synchronized void doUpgrade(StorageInfo sInfo); synchronized void doFinalize(); Boolean canRollBack(StorageInfo storage, StorageInfo prevStorage,
      int targetLayoutVersion); synchronized void doRollback(); Long getJournalCTime(); static final String LAST_PROMISED_FILENAME; static final String LAST_WRITER_EPOCH; }
@Test public void testFormatNonEmptyStorageDirectories() throws Exception { try { journal.format(FAKE_NSINFO, false); fail("Did not fail to format non-empty directories in journal node."); } catch (IOException ioe) { GenericTestUtils.assertExceptionContains( "Can't format the storage directory because the current " + "directory is not empty.", ioe); } }
@Test public void testFormatNonEmptyStorageDirectoriesWhenforceOptionIsTrue() throws Exception { try { journal.format(FAKE_NSINFO, true); } catch (IOException ioe) { fail("Format should be success with force option."); } }