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

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


   * - 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


    }
  }
 
  @Test
  public void testWriteEdits() throws Exception {
    EditLogOutputStream stm = createLogSegment();
    writeOp(stm, 1);
    writeOp(stm, 2);
   
    stm.setReadyToFlush();
    writeOp(stm, 3);
   
    // The flush should log txn 1-2
    futureReturns(null).when(spyLoggers.get(0)).sendEdits(
        anyLong(), eq(1L), eq(2), Mockito.<byte[]>any());
    futureReturns(null).when(spyLoggers.get(1)).sendEdits(
        anyLong(), eq(1L), eq(2), Mockito.<byte[]>any());
    futureReturns(null).when(spyLoggers.get(2)).sendEdits(
        anyLong(), eq(1L), eq(2), Mockito.<byte[]>any());
    stm.flush();

    // Another flush should now log txn #3
    stm.setReadyToFlush();
    futureReturns(null).when(spyLoggers.get(0)).sendEdits(
        anyLong(), eq(3L), eq(1), Mockito.<byte[]>any());
    futureReturns(null).when(spyLoggers.get(1)).sendEdits(
        anyLong(), eq(3L), eq(1), Mockito.<byte[]>any());
    futureReturns(null).when(spyLoggers.get(2)).sendEdits(
        anyLong(), eq(3L), eq(1), Mockito.<byte[]>any());
    stm.flush();
  }
View Full Code Here

    stm.flush();
  }
 
  @Test
  public void testWriteEditsOneSlow() throws Exception {
    EditLogOutputStream stm = createLogSegment();
    writeOp(stm, 1);
    stm.setReadyToFlush();
   
    // Make the first two logs respond immediately
    futureReturns(null).when(spyLoggers.get(0)).sendEdits(
        anyLong(), eq(1L), eq(1), Mockito.<byte[]>any());
    futureReturns(null).when(spyLoggers.get(1)).sendEdits(
        anyLong(), eq(1L), eq(1), Mockito.<byte[]>any());
   
    // And the third log not respond
    SettableFuture<Void> slowLog = SettableFuture.<Void>create();
    Mockito.doReturn(slowLog).when(spyLoggers.get(2)).sendEdits(
        anyLong(), eq(1L), eq(1), Mockito.<byte[]>any());
    stm.flush();
   
    Mockito.verify(spyLoggers.get(0)).setCommittedTxId(1L);
  }
View Full Code Here

  private EditLogOutputStream createLogSegment() throws IOException {
    futureReturns(null).when(spyLoggers.get(0)).startLogSegment(Mockito.anyLong());
    futureReturns(null).when(spyLoggers.get(1)).startLogSegment(Mockito.anyLong());
    futureReturns(null).when(spyLoggers.get(2)).startLogSegment(Mockito.anyLong());
    EditLogOutputStream stm = qjm.startLogSegment(1);
    return stm;
  }
View Full Code Here

  }
 
  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

        try {
          FileJournalManager jm = new FileJournalManager(storageDirectory);
          for (int segment = 0; segment < numSegments; segment++) {
            // start new segment
            int firstTxId = currentTxId;
            EditLogOutputStream out = jm.startLogSegment(currentTxId);

            // starting transaction
            FSEditLogOp startOp = new LogSegmentOp(
                FSEditLogOpCodes.OP_START_LOG_SEGMENT);
            startOp.setTransactionId(firstTxId);
View Full Code Here

  }

  @Test
  public void testGetNumberOfTransactions() throws Exception {
    setupTest("test-get-number-of-transactions");
    EditLogOutputStream eos = bkjm.startLogSegment(1);
    FSEditLogTestUtil.populateStreams(1, 100, eos);
    bkjm.finalizeLogSegment(1, 100);
    assertEquals(
        "getNumberOfTransactions() is correct with a finalized log segment",
        100, FSEditLogTestUtil.getNumberOfTransactions(bkjm, 1, false, true));
View Full Code Here

    File tempEditsFile = FSEditLogTestUtil.createTempEditsFile(
        "test-get-input-stream-with-validation");
    try {
      TestBKJMInjectionHandler h = new TestBKJMInjectionHandler();
      InjectionHandler.set(h);
      EditLogOutputStream bkeos = bkjm.startLogSegment(1);
      EditLogOutputStream elfos =
          new EditLogFileOutputStream(tempEditsFile, null);
      elfos.create();
      FSEditLogTestUtil.populateStreams(1, 100, bkeos, elfos);
      EditLogInputStream bkeis =
          FSEditLogTestUtil.getJournalInputStream(bkjm, 1, true);
      EditLogInputStream elfis = new EditLogFileInputStream(tempEditsFile);
      Map<String, EditLogInputStream> streamByName =
View Full Code Here

  public void testGetInputStreamNoValidationNoCheckLastTxId() throws Exception {
    setupTest("test-get-input-stream-no-validation-no-check-last-txid");
    File tempEditsFile = FSEditLogTestUtil.createTempEditsFile(
        "test-get-input-stream-with-validation");
    try {
      EditLogOutputStream bkeos = bkjm.startLogSegment(1);
      EditLogOutputStream elfos =
          new EditLogFileOutputStream(tempEditsFile, null);
      elfos.create();
      FSEditLogTestUtil.populateStreams(1, 100, bkeos, elfos);
      EditLogInputStream bkeis =
          getJournalInputStreamDontCheckLastTxId(bkjm, 1);
      EditLogInputStream elfis = new EditLogFileInputStream(tempEditsFile);
      Map<String, EditLogInputStream> streamByName =
View Full Code Here

  @Test
  public void testRecoverUnfinalizedSegments() throws Exception {
    setupTest("test-recover-unfinalized-segments");
    TestBKJMInjectionHandler h = new TestBKJMInjectionHandler();
    InjectionHandler.set(h);
    EditLogOutputStream eos = bkjm.startLogSegment(1);
    FSEditLogTestUtil.populateStreams(1, 100, eos);

    bkjm.currentInProgressPath = null;
    bkjm.recoverUnfinalizedSegments();
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.