Package org.apache.hadoop.hdfs.server.namenode

Examples of org.apache.hadoop.hdfs.server.namenode.EditLogOutputStream


  }
 
  public static EditLogOutputStream writeSegment(MiniJournalCluster cluster,
      QuorumJournalManager qjm, long startTxId, int numTxns,
      boolean finalize) throws IOException {
    EditLogOutputStream stm = qjm.startLogSegment(startTxId);
    // Should create in-progress
    assertExistsInQuorum(cluster,
        NNStorage.getInProgressEditsFileName(startTxId));
   
    writeTxns(stm, startTxId, numTxns);
    if (finalize) {
      stm.close();
      qjm.finalizeLogSegment(startTxId, startTxId + numTxns - 1);
      return null;
    } else {
      return stm;
    }
View Full Code Here


  }
 
  public static EditLogOutputStream writeRandomSegment(MiniJournalCluster cluster,
      QuorumJournalManager qjm, long startTxId, int numTxns,
      boolean finalize, List<FSEditLogOp> writtenTxns) throws IOException {
    EditLogOutputStream stm = qjm.startLogSegment(startTxId);
    // Should create in-progress
    assertExistsInQuorum(cluster,
        NNStorage.getInProgressEditsFileName(startTxId));
   
    List<FSEditLogOp> txns = FSEditLogTestUtil.getContiguousLogSegment(
        (int) startTxId, ((int) startTxId + numTxns - 1));
    for (FSEditLogOp op : txns) {
      stm.write(op);
      stm.setReadyToFlush();
      stm.flush();
      if (writtenTxns != null) {
        writtenTxns.add(op);
      }
    }
   
    if (finalize) {
      stm.close();
      qjm.finalizeLogSegment(startTxId, startTxId + numTxns - 1);
      return null;
    } else {
      return stm;
    }
View Full Code Here

      QuorumJournalManager qjm, long txid, int numTxns, Holder<Throwable> thrown) {
   
    long firstTxId = txid;
    long lastAcked = txid - 1;
    try {
      EditLogOutputStream stm = qjm.startLogSegment(txid);
     
      for (int i = 0; i < numTxns; i++) {
        QJMTestUtil.writeTxns(stm, txid++, 1);
        lastAcked++;
      }
     
      stm.close();
      qjm.finalizeLogSegment(firstTxId, lastAcked);
    } catch (Throwable t) {
      thrown.held = t;
    }
    return lastAcked;
View Full Code Here

  public void testTailing() throws Exception {
    // Unlike the other unit test, numEdits here is constant as this is
    // a longer running test
    final int numEdits = 1000;
    final AtomicBoolean finishedProducing = new AtomicBoolean(false);
    final EditLogOutputStream out = qjm.startLogSegment(0);

    Callable<Void> producerThread = new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        try {
View Full Code Here

  @Test
  public void testCrashAtBeginningOfSegment() throws Exception {
    writeSegment(cluster, qjm, 1, 3, true);
    waitForAllPendingCalls(qjm.getLoggerSetForTests());
   
    EditLogOutputStream stm = qjm.startLogSegment(4);
    try {
      waitForAllPendingCalls(qjm.getLoggerSetForTests());
    } finally {
      stm.abort();
    }
   
   
    // Make a new QJM
    qjm = new QuorumJournalManager(
View Full Code Here

    writeSegment(cluster, qjm, 1, 3, true);
    waitForAllPendingCalls(qjm.getLoggerSetForTests());
    cluster.getJournalNode(nodeMissingSegment).stopAndJoin(0);
   
    // Open segment on 2/3 nodes
    EditLogOutputStream stm = qjm.startLogSegment(4);
    try {
      waitForAllPendingCalls(qjm.getLoggerSetForTests());
     
      // Write transactions to only 1/3 nodes
      failLoggerAtTxn(spies.get(nodeWithEmptySegment), 4);
      try {
        writeTxns(stm, 4, 1);
        fail("Did not fail even though 2/3 failed");
      } catch (QuorumException qe) {
        GenericTestUtils.assertExceptionContains("mock failure", qe);
      }
    } finally {
      stm.abort();
    }
   
    // Bring back the down JN.
    cluster.restartJournalNode(nodeMissingSegment);
   
View Full Code Here

   
    // Logger 1: fail at txn id 4
    failLoggerAtTxn(spies.get(1), 4L);
   
    writeSegment(cluster, qjm, 1, 3, true);
    EditLogOutputStream stm = qjm.startLogSegment(4);
    try {
      writeTxns(stm, 4, 1);
      fail("Did not fail to write");
    } catch (QuorumException qe) {
      // Should fail, because logger 1 had an injected fault and
      // logger 0 should detect writer out of sync
      GenericTestUtils.assertExceptionContains("Writer out of sync",
          qe);
    } finally {
      stm.abort();
      qjm.close();
    }
   
    // State:
    // Logger 0: 1-3 in-progress (since it missed finalize)
View Full Code Here

   * - JN2: edits 1-5 in progress
   *
   * None of the loggers have any associated paxos info.
   */
  private void setupLoggers345() throws Exception {
    EditLogOutputStream stm = qjm.startLogSegment(1);
   
    failLoggerAtTxn(spies.get(0), 4);
    failLoggerAtTxn(spies.get(1), 5);
   
    writeTxns(stm, 1, 3);
View Full Code Here

   * it should be disabled.
   */
  @Test
  public void testRefresh() throws Exception {
    // start new segment
    EditLogOutputStream stm = qjm.startLogSegment(0);
    // write a bunch of transactions
    QJMTestUtil.writeTxns(stm, 0, 10);
   
    // get input stream
    List<EditLogInputStream> streams = Lists.newArrayList();
View Full Code Here

   * startup)
   */
  @Test
  public void testRefreshOnlyForInprogress() throws Exception {
    // start new segment
    EditLogOutputStream stm = qjm.startLogSegment(0);
    // write a bunch of transactions
    QJMTestUtil.writeTxns(stm, 0, 10);
    qjm.finalizeLogSegment(0, 9);
   
    // get input stream
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.server.namenode.EditLogOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.