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

Examples of org.apache.hadoop.hdfs.server.namenode.AvatarNode$InvalidatesCleaner


  protected void doTestAcrossRestarts(boolean enableQJM) throws Exception {
    setUp("testAcrossRestarts", enableQJM);
    // 3 initial checkpoint
    createEdits(20); //23
    cluster.restartAvatarNodes(); //25 + 2 restart finalizes the segment + checkpoint
    AvatarNode primary = cluster.getPrimaryAvatar(0).avatar;
    AvatarNode standby = cluster.getStandbyAvatar(0).avatar;
   
    assertEquals(27, getCurrentTxId(primary));
    // give time to the standby to start-up
    Thread.sleep(2000);
    assertEquals(getCurrentTxId(primary), getCurrentTxId(standby));
    createEdits(20);
    if (!enableQJM) {
      standby.quiesceStandby(getCurrentTxId(primary)-1);
      assertEquals(47, getCurrentTxId(primary));
      assertEquals(getCurrentTxId(primary), getCurrentTxId(standby));
    }
  }
View Full Code Here


    TestAvatarTxIdsHandler h = new TestAvatarTxIdsHandler();
    InjectionHandler.set(h);
    setUp("testCheckpointAndRestart", false);
    // 3 initial checkpoint
    createEdits(20); //23
    AvatarNode primary = cluster.getPrimaryAvatar(0).avatar;
    AvatarNode standby = cluster.getStandbyAvatar(0).avatar;
    h.doCheckpoint(); //25 checkpoint adds 2 transactions
    createEdits(20);
    standby.quiesceStandby(getCurrentTxId(primary)-1);
    assertEquals(45, getCurrentTxId(primary));
    assertEquals(getCurrentTxId(primary), getCurrentTxId(standby));

    cluster.restartAvatarNodes(); //49 (restart + initial checkpoint)
    primary = cluster.getPrimaryAvatar(0).avatar;
    standby = cluster.getStandbyAvatar(0).avatar;
    createEdits(20);
    standby.quiesceStandby(getCurrentTxId(primary)-1);
     assertEquals(69, getCurrentTxId(primary));
     assertEquals(getCurrentTxId(primary), getCurrentTxId(standby));
    InjectionHandler.clear();
  }
View Full Code Here

  public void testStandbySaveNamespace() throws Exception {
    TestAvatarCheckpointingHandler h = new TestAvatarCheckpointingHandler();
    InjectionHandler.set(h);
    setUp(3600, "testStandbySaveNamespace", true);

    AvatarNode primary = cluster.getPrimaryAvatar(0).avatar;
    AvatarNode standby = cluster.getStandbyAvatar(0).avatar;
    createEdits(40);

    // trigger checkpoint on the standby
    AvatarShell shell = new AvatarShell(conf);

    // trigger regular checkpoint
    runAndAssertCommand(shell, 0, new String[] { "-one", "-saveNamespace" });
    assertCheckpointDone(h);

    // trigger regular checkpoint with uncompressed option
    // this will fail, as we do not support uncompressed
    runAndAssertCommand(shell, -1, new String[] { "-one", "-saveNamespace",
        "uncompressed" });

    // trigger regular checkpoint with force option
    runAndAssertCommand(shell, 0, new String[] { "-one", "-saveNamespace",
        "force" });
    assertCheckpointDone(h);

    // trigger regular checkpoint with force, uncompressed option
    // this will fail, as we do not support uncompressed
    runAndAssertCommand(shell, -1, new String[] { "-one", "-saveNamespace",
        "force", "uncompressed" });

    // ///////////////////

    // some incorrect option
    runAndAssertCommand(shell, -1, new String[] { "-one", "-saveNamespace",
        "someOption" });

    standby.quiesceStandby(DFSAvatarTestUtil.getCurrentTxId(primary) - 1);
    // edits + SLS + 2 * 2(for each successful checkpoint)
    assertEquals(45, DFSAvatarTestUtil.getCurrentTxId(primary));
  }
View Full Code Here

    InjectionHandler.set(h);
    setUp("testInodeIdWithCheckPoint", false);
    long expectedLastINodeId = INodeId.ROOT_INODE_ID;

    DFSTestUtil.createFile(fs, new Path("/testtwo/fileone"), 1024, (short) 1, 0);
    AvatarNode primaryAvatar = cluster.getPrimaryAvatar(0).avatar;
    AvatarNode standbyAvatar = cluster.getStandbyAvatar(0).avatar;
    FSNamesystem primaryNS = primaryAvatar.namesystem;
    FSNamesystem standbyNS = standbyAvatar.namesystem;
    expectedLastINodeId += 2;

    DFSAvatarTestUtil.assertTxnIdSync(primaryAvatar, standbyAvatar);
View Full Code Here

    TestAvatarCheckpointingHandler h = new TestAvatarCheckpointingHandler(null,
        null, true);
    InjectionHandler.set(h);
    setUp("testFailSuccFailQuiesce", enableQJM);
    createEdits(20);
    AvatarNode primary = cluster.getPrimaryAvatar(0).avatar;
    AvatarNode standby = cluster.getStandbyAvatar(0).avatar;
   
    try {
      h.failNextCheckpoint = true;
      h.doCheckpoint();
      fail("Should get IOException here");
    } catch (Exception e) {
      // checkpoint fails during finalizations (see the checkpointing handler)
      assertTrue(e instanceof FinalizeCheckpointException);
      assertTrue(AvatarSetupUtil.isIngestAlive(standby));
      LOG.warn("Expected: Checkpoint failed", e);
    }
   
    // current txid should be 20 + SLS + ENS + SLS + initial
    assertEquals(25, getCurrentTxId(primary));
   
    h.failNextCheckpoint = false;
   
    // checkpoint should succeed
    h.doCheckpoint();
   
    // another roll adds 2 transactions
    assertEquals(27, getCurrentTxId(primary));
   
    h.failNextCheckpoint = true;   
    try {
      h.doCheckpoint();
      fail("Should get IOException here");
    } catch (Exception e) {
      LOG.warn("Expected: Checkpoint failed", e);
    }
   
    // another roll adds 2 transactions
    assertEquals(29, getCurrentTxId(primary));
   
    if (!enableQJM) {
      createEdits(20);
      standby.quiesceStandby(getCurrentTxId(primary)-1);
      assertEquals(49, getCurrentTxId(primary));
      assertEquals(getCurrentTxId(primary), getCurrentTxId(standby));
    }
  }
View Full Code Here

    TestAvatarCheckpointingHandler h = new TestAvatarCheckpointingHandler(null,
        null, true);
    InjectionHandler.set(h);
    setUp("testFailCheckpointOnceAndRestartStandby", enableQJM);
    createEdits(20);
    AvatarNode primary = cluster.getPrimaryAvatar(0).avatar;
    AvatarNode standby = cluster.getStandbyAvatar(0).avatar;

    // Wait for first checkpoint.
    while (standby.getStandby().getLastCheckpointTime() == 0) {
      LOG.info("Waiting for standby to do checkpoint");
      Thread.sleep(1000);
    }
   
    try {
      h.failNextCheckpoint = true;
      h.doCheckpoint();
      fail("Should get IOException here");
    } catch (IOException e) {
      // checkpoint fails during finalization (see the checkpointing handler)
      assertTrue(e instanceof FinalizeCheckpointException);
      assertTrue(AvatarSetupUtil.isIngestAlive(standby));
      LOG.info("Expected: Checkpoint failed", e);
    }
   
    // current txid should be 20 + SLS + ENS + SLS + initial ckpt
    assertEquals(25, getCurrentTxId(primary));
   
    cluster.killStandby(0);
    h.failNextCheckpoint = false;
   
    cluster.restartStandby(0); // ads one checkpoint
    standby = cluster.getStandbyAvatar(0).avatar;
    while (standby.getStandby().getLastCheckpointTime() == 0) {
      LOG.info("Waiting for standby to do checkpoint");
      Thread.sleep(1000);
    }
   
    LOG.info("Start another checkpointing...");
    // checkpoint should succeed
    h.doCheckpoint();
   
    LOG.info("Second checkpointing succeeded.");
    // roll adds two transactions
    assertEquals(29, getCurrentTxId(primary));
   
    if (!enableQJM) {
      createEdits(20);
      standby.quiesceStandby(getCurrentTxId(primary)-1);
      assertEquals(49, getCurrentTxId(primary));
      assertEquals(getCurrentTxId(primary), getCurrentTxId(standby));
    }
  }
View Full Code Here

    TestAvatarCheckpointingHandler h = new TestAvatarCheckpointingHandler(
        stopOnEvent, waitUntilEvent, scf);
    InjectionHandler.set(h);
    setUp(3, "testQuiesceInterruption", false, enableQJM); //simulate interruption, no ckpt failure  
   
    AvatarNode primary = cluster.getPrimaryAvatar(0).avatar;
    AvatarNode standby = cluster.getStandbyAvatar(0).avatar;
    createEdits(40);

    while (!h.receivedEvents.contains(stopOnEvent)) {
      LOG.info("Waiting for event : " + stopOnEvent);
      Thread.sleep(1000);
    }
   
    if (!enableQJM) {
      standby.quiesceStandby(getCurrentTxId(primary)-1);
      // only assert this for FileJournalManager.
      // edits + SLS + ELS + SLS (checkpoint fails, but roll happened)
      assertEquals(43, getCurrentTxId(primary));
     
      // if quiesce happened before roll, the standby will be behind by 1 transaction
      // which will be reclaimed by opening the log after
      long extraTransaction = rollAfterQuiesce ? 1 : 0;
      assertEquals(getCurrentTxId(primary), getCurrentTxId(standby) + extraTransaction);
    } else {
      standby.quiesceStandby(FSEditLogLoader.TXID_IGNORE);
    }
   
    // make sure the checkpoint indeed failed
    assertTrue(h.receivedEvents
        .contains(InjectionEvent.STANDBY_EXIT_CHECKPOINT_EXCEPTION));
View Full Code Here

  public static void tearDownAfterClass() throws Exception {
    MiniAvatarCluster.shutDownZooKeeper();
  }

  private long getSessionId(int index) throws Exception {
    AvatarNode primaryAvatar = cluster.getPrimaryAvatar(index).avatar;
    String address = primaryAvatar.getStartupConf().get(
        NameNode.DFS_NAMENODE_RPC_ADDRESS_KEY);
    return zkClient.getPrimarySsId(address, false);
  }
View Full Code Here

        StartupOption.SERVICE.getName(), nnInfo.nameserviceId,
        AvatarConstants.StartupOption.STANDBY.getName() };
    String[] federationArgs = (!standby) ? federationPrimaryArgs
        : federationStandbyArgs;
    String[] args = (federation) ? federationArgs : normalArgs;
    AvatarNode primary1 = MiniAvatarCluster.instantiateAvatarNode(
        args,
        MiniAvatarCluster.getServerConf(instance, nnInfo));
    extraNodes.add(primary1);
    if (singleStartup) {
      if (!standby) {
        assertEquals(primary1.getSessionId(), getSessionId(index));
      }
      return;
    }
    try {     
      AvatarNode second = MiniAvatarCluster.instantiateAvatarNode(args,
          MiniAvatarCluster.getServerConf(instance, nnInfo));
      extraNodes.add(second);
      fail("Did not throw exception");
    } catch (Exception e) {
      LOG.info("Expected exception : ", e);
View Full Code Here

    TestAvatarCheckpointingHandler h = new TestAvatarCheckpointingHandler(null,
        null, true);
    InjectionHandler.set(h);
    setUp("testFailCheckpointMultiAndCrash", true);
    createEdits(20);
    AvatarNode primary = cluster.getPrimaryAvatar(0).avatar;
    AvatarNode standby = cluster.getStandbyAvatar(0).avatar;
   
    try {
      h.failNextCheckpoint = true;
      h.doCheckpoint();
      fail("Should get IOException here");
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.server.namenode.AvatarNode$InvalidatesCleaner

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.