JournalNode implements Tool, Configurable, JournalNodeMXBean { public InetSocketAddress getBoundIpcAddress() { return rpcServer.getAddress(); }  @VisibleForTesting boolean getJournalSyncerStatus(String jid); @VisibleForTesting Journal getOrCreateJournal(String jid); Journal getOrCreateJournal(String jid,
                                    String nameServiceId); @Override void setConf(Configuration conf); @Override Configuration getConf(); @Override int run(String[] args); void start(); boolean isStarted(); InetSocketAddress getBoundIpcAddress(); String getHttpServerURI(); void stop(int rc); void stopAndJoin(int rc); @Override // JournalNodeMXBean String getJournalsStatus(); @Override // JournalNodeMXBean String getHostAndPort(); @Override // JournalNodeMXBean List<String> getClusterIds(); @Override // JournalNodeMXBean String getVersion(); static void main(String[] args); void doPreUpgrade(String journalId); void doUpgrade(String journalId, StorageInfo sInfo); void doFinalize(String journalId,
                         String nameServiceId); Boolean canRollBack(String journalId, StorageInfo storage,
      StorageInfo prevStorage, int targetLayoutVersion,
      String nameServiceId); void doRollback(String journalId,
                         String nameServiceId); void discardSegments(String journalId, long startTxId,
                              String nameServiceId); Long getJournalCTime(String journalId,
                              String nameServiceId); @VisibleForTesting Journal getJournal(String  jid); static InetSocketAddress getHttpAddress(Configuration conf); @VisibleForTesting JournalNodeRpcServer getRpcServer(); InetSocketAddress getBoundHttpAddress(); InetSocketAddress getHttpAddress(); InetSocketAddress getHttpsAddress(); static final Logger LOG; }
@Test(timeout=100000) public void testJournal() throws Exception { MetricsRecordBuilder metrics = MetricsAsserts.getMetrics( journal.getMetrics().getName()); MetricsAsserts.assertCounter("BatchesWritten", 0L, metrics); MetricsAsserts.assertCounter("BatchesWrittenWhileLagging", 0L, metrics); MetricsAsserts.assertGauge("CurrentLagTxns", 0L, metrics); MetricsAsserts.assertGauge("LastJournalTimestamp", 0L, metrics); long beginTimestamp = System.currentTimeMillis(); IPCLoggerChannel ch = new IPCLoggerChannel( conf, FAKE_NSINFO, journalId, jn.getBoundIpcAddress()); ch.newEpoch(1).get(); ch.setEpoch(1); ch.startLogSegment(1, NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION).get(); ch.sendEdits(1L, 1, 1, "hello".getBytes(Charsets.UTF_8)).get(); metrics = MetricsAsserts.getMetrics( journal.getMetrics().getName()); MetricsAsserts.assertCounter("BatchesWritten", 1L, metrics); MetricsAsserts.assertCounter("BatchesWrittenWhileLagging", 0L, metrics); MetricsAsserts.assertGauge("CurrentLagTxns", 0L, metrics); long lastJournalTimestamp = MetricsAsserts.getLongGauge( "LastJournalTimestamp", metrics); assertTrue(lastJournalTimestamp > beginTimestamp); beginTimestamp = lastJournalTimestamp; ch.setCommittedTxId(100L); ch.sendEdits(1L, 2, 1, "goodbye".getBytes(Charsets.UTF_8)).get(); metrics = MetricsAsserts.getMetrics( journal.getMetrics().getName()); MetricsAsserts.assertCounter("BatchesWritten", 2L, metrics); MetricsAsserts.assertCounter("BatchesWrittenWhileLagging", 1L, metrics); MetricsAsserts.assertGauge("CurrentLagTxns", 98L, metrics); lastJournalTimestamp = MetricsAsserts.getLongGauge( "LastJournalTimestamp", metrics); assertTrue(lastJournalTimestamp > beginTimestamp); }