synchronized Journal getOrCreateJournal(String jid) throws IOException {
    QuorumJournalManager.checkJournalId(jid);

    Journal journal = journalsById.get(jid);
    if (journal == null) {
      File logDir = getLogDir(jid);
      LOG.info("Initializing journal in directory " + logDir);
      journal = new Journal(conf, logDir, jid, new ErrorReporter());
      journalsById.put(jid, journal);
    }

    return journal;
  }
  @Before
  public void setup() throws Exception {
    File editsDir =
        new File(MiniDFSCluster.getBaseDirectory(null) + File.separator + "TestJournalNode");
    FileUtil.fullyDelete(editsDir);

    conf.set(JournalConfigKeys.DFS_JOURNALNODE_DIR_KEY, editsDir.getAbsolutePath());
    conf.set(JournalConfigKeys.DFS_JOURNALNODE_RPC_ADDRESS_KEY, "0.0.0.0:0");
    int port = MiniJournalCluster.getFreeHttpPortAndUpdateConf(conf, true);
    httpAddress = "http://localhost:" + port;

    jn = new JournalNode();
    jn.setConf(conf);
    jn.start();
    journalId = "test-journalid-" + QJMTestUtil.uniqueSequenceId();
    journal = jn.getOrCreateJournal(QuorumJournalManager.journalIdStringToBytes(journalId));
    journal.transitionJournal(FAKE_NSINFO, Transition.FORMAT, null);
    journal.transitionImage(FAKE_NSINFO, Transition.FORMAT, null);
  }