private boolean createEditsSyncDir() { File editsSyncDir = journal.getStorage().getEditsSyncDir(); if (editsSyncDir.exists()) { LOG.info(editsSyncDir + " directory already exists."); return true; } return editsSyncDir.mkdir(); }
JournalNodeSyncer(JournalNode jouranlNode, Journal journal, String jid, Configuration conf, String nameServiceId) { this.jn = jouranlNode; this.journal = journal; this.jid = jid; this.nameServiceId = nameServiceId; this.jnStorage = journal.getStorage(); this.conf = conf; journalSyncInterval = conf.getLong( DFSConfigKeys.DFS_JOURNALNODE_SYNC_INTERVAL_KEY, DFSConfigKeys.DFS_JOURNALNODE_SYNC_INTERVAL_DEFAULT); logSegmentTransferTimeout = conf.getInt( DFSConfigKeys.DFS_EDIT_LOG_TRANSFER_TIMEOUT_KEY, DFSConfigKeys.DFS_EDIT_LOG_TRANSFER_TIMEOUT_DEFAULT); throttler = getThrottler(conf); metrics = journal.getMetrics(); journalSyncerStarted = false; }
void stopSync() { shouldSync = false; // Delete the edits.sync directory File editsSyncDir = journal.getStorage().getEditsSyncDir(); if (editsSyncDir.exists()) { FileUtil.fullyDelete(editsSyncDir); } if (syncJournalDaemon != null) { syncJournalDaemon.interrupt(); } }
LOG.error("Failed to create directory for downloading log " + "segments: %s. Stopping Journal Node Sync.", journal.getStorage().getEditsSyncDir()); return;
.getJournalFromContext(context, journalId).getStorage();
QuorumJournalManager.checkJournalId(journalId); final JNStorage storage = JournalNodeHttpServer .getJournalFromContext(context, journalId).getStorage();
QuorumJournalManager.checkJournalId(journalId); final JNStorage storage = JournalNodeHttpServer .getJournalFromContext(context, journalId).getStorage();
@Test (timeout = 10000) public void testJournalLocking() throws Exception { Assume.assumeTrue(journal.getStorage().getStorageDir(0).isLockSupported()); StorageDirectory sd = journal.getStorage().getStorageDir(0); File lockFile = new File(sd.getRoot(), Storage.STORAGE_FILE_LOCK); // Journal should be locked, since the format() call locks it. GenericTestUtils.assertExists(lockFile); journal.newEpoch(FAKE_NSINFO, 1); try { new Journal(conf, TEST_LOG_DIR, JID, StartupOption.REGULAR, mockErrorReporter); fail("Did not fail to create another journal in same dir"); } catch (IOException ioe) { GenericTestUtils.assertExceptionContains( "Cannot lock storage", ioe); } journal.close(); // Journal should no longer be locked after the close() call. // Hence, should be able to create a new Journal in the same dir. Journal journal2 = new Journal(conf, TEST_LOG_DIR, JID, StartupOption.REGULAR, mockErrorReporter); journal2.newEpoch(FAKE_NSINFO, 2); journal2.close(); }
@Test (timeout = 10000) public void testRestartJournal() throws Exception { journal.newEpoch(FAKE_NSINFO, 1); journal.startLogSegment(makeRI(1), 1, NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION); journal.journal(makeRI(2), 1, 1, 2, QJMTestUtil.createTxnData(1, 2)); // Don't finalize. String storageString = journal.getStorage().toColonSeparatedString(); System.err.println("storage string: " + storageString); journal.close(); // close to unlock the storage dir // Now re-instantiate, make sure history is still there journal = new Journal(conf, TEST_LOG_DIR, JID, StartupOption.REGULAR, mockErrorReporter); // The storage info should be read, even if no writer has taken over. assertEquals(storageString, journal.getStorage().toColonSeparatedString()); assertEquals(1, journal.getLastPromisedEpoch()); NewEpochResponseProtoOrBuilder newEpoch = journal.newEpoch(FAKE_NSINFO, 2); assertEquals(1, newEpoch.getLastSegmentTxId()); }
journal.getStorage().getInProgressEditLog(1)); journal.getStorage().getInProgressEditLog(1)); GenericTestUtils.assertExists( journal.getStorage().getInProgressEditLog(6));