Ejemplo n.º 1
0
 @Test
 public void testStandbyWithFederation() throws Exception {
   setUp(true, "testStandbyWithFederation");
   LOG.info("DAFS testStandby");
   long lastTxId = getLastTxId();
   cluster.killPrimary(0, false);
   // make sure to consume all transactions
   cluster.getStandbyAvatar(0).avatar.quiesceStandby(lastTxId);
   checkStandby();
 }
Ejemplo n.º 2
0
 @Test
 public void testPrimaryWithFederation() throws Exception {
   setUp(true, "testPrimaryWithFederation");
   LOG.info("DAFS testPrimary");
   cluster.killStandby(0);
   checkPrimary();
 }
Ejemplo n.º 3
0
 /** Read from primary avatar. */
 @Test
 public void testPrimary() throws Exception {
   setUp(false, "testPrimary");
   LOG.info("DAFS testPrimary");
   cluster.killStandby();
   checkPrimary();
 }
Ejemplo n.º 4
0
 @BeforeClass
 public static void setUpStatic() throws Exception {
   MiniAvatarCluster.createAndStartZooKeeper();
   createAndStartBookKeeperCluster();
   zooKeeperClient = bookKeeperCluster.initZK();
   bookKeeperClient = new BookKeeper(new ClientConfiguration(), zooKeeperClient);
   recoveringZooKeeperClient =
       new RecoveringZooKeeper(new BasicZooKeeper(zooKeeperClient), MAX_ZK_RETRIES, ZK_RETRY_MS);
 }
Ejemplo n.º 5
0
 @After
 public void shutDown() throws Exception {
   if (dafs != null) {
     dafs.close();
   }
   if (cluster != null) {
     cluster.shutDown();
   }
   InjectionHandler.clear();
 }
Ejemplo n.º 6
0
  public void setUp(boolean federation, Configuration conf, String name, boolean createFiles)
      throws Exception {
    LOG.info("------------------- test: " + name + " START ----------------");
    this.conf = conf;
    if (!federation) {
      cluster = new MiniAvatarCluster(conf, 3, true, null, null);
      dafs = cluster.getFileSystem();
    } else {
      cluster = new MiniAvatarCluster(conf, 3, true, null, null, 1, true);
      dafs = cluster.getFileSystem(0);
    }

    if (createFiles) {
      path = new Path(FILE_PATH);
      DFSTestUtil.createFile(dafs, path, FILE_LEN, (short) 1, 0L);
      Path hardlink1 = new Path("/hardlink1");
      Path hardlink2 = new Path("/hardlink2");
      DFSTestUtil.createFile(dafs, hardlink1, FILE_LEN, (short) 1, 0L);
      dafs.hardLink(hardlink1, hardlink2);
    }
  }
Ejemplo n.º 7
0
 @Test
 public void testPrimaryShutdownFailure() throws Exception {
   setUp(false, "testPrimaryShutdownFailure");
   InjectionHandler.set(new TestAvatarAPIHandler());
   LOG.info("DAFS testPrimary");
   try {
     cluster.killPrimary();
     fail("Shutting down the node should fail");
   } catch (IOException e) {
     assertTrue(e.toString().contains("number of required edit streams"));
   }
   InjectionHandler.clear();
 }
Ejemplo n.º 8
0
 @AfterClass
 public static void shutDownStatic() throws Exception {
   try {
     if (bookKeeperClient != null) {
       bookKeeperClient.close();
     }
   } finally {
     if (bookKeeperCluster != null) {
       bookKeeperCluster.shutdown();
     }
     MiniAvatarCluster.shutDownZooKeeper();
   }
 }
Ejemplo n.º 9
0
  /** Set up MiniAvatarCluster. */
  public void setUp(boolean federation, String name) throws Exception {
    LOG.info("------------------- test: " + name + " START ----------------");
    conf = new Configuration();
    // populate repl queues on standby (in safe mode)
    conf.setFloat("dfs.namenode.replqueue.threshold-pct", 0f);
    conf.setLong("fs.avatar.standbyfs.initinterval", 1000);
    conf.setLong("fs.avatar.standbyfs.checkinterval", 1000);
    if (!federation) {
      cluster = new MiniAvatarCluster(conf, 3, true, null, null);
      dafs = cluster.getFileSystem();
    } else {
      cluster = new MiniAvatarCluster(conf, 3, true, null, null, 1, true);
      dafs = cluster.getFileSystem(0);
    }

    path = new Path(FILE_PATH);
    dirPath = new Path(DIR_PATH);
    DFSTestUtil.createFile(dafs, path, FILE_LEN, (short) 1, 0L);
    DFSTestUtil.waitReplication(dafs, path, (short) 1);
    try {
      Thread.sleep(4000);
    } catch (InterruptedException ignore) {
    }
  }
Ejemplo n.º 10
0
  @Test
  public void testFailOverWithFederation() throws Exception {
    setUp(true, "testFailoverWithFederation");
    LOG.info("DAFS testFailOver");
    long lastTxId = getLastTxId();
    cluster.killPrimary(0);
    cluster.failOver(0);
    cluster.restartStandby(0);
    cluster.waitAvatarNodesActive(0);
    cluster.waitDataNodesActive(0);
    // make sure to consume all transactions.
    cluster.getStandbyAvatar(0).avatar.quiesceStandby(lastTxId);

    try {
      Thread.sleep(2000);
    } catch (InterruptedException ignore) {
    }

    checkStandby();
    checkPrimary();
  }
Ejemplo n.º 11
0
 @BeforeClass
 public static void setUpClass() throws Exception {
   MiniAvatarCluster.createAndStartZooKeeper();
 }
Ejemplo n.º 12
0
 @AfterClass
 public static void shutDownClass() throws Exception {
   MiniAvatarCluster.shutDownZooKeeper();
 }
Ejemplo n.º 13
0
 @After
 public void shutDown() throws Exception {
   dafs.close();
   cluster.shutDown();
 }
Ejemplo n.º 14
0
 private long getLastTxId() {
   return cluster.getPrimaryAvatar(0).avatar.getFSImage().getEditLog().getCurrentTxId() - 1;
 }