@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(); }
@Test public void testPrimaryWithFederation() throws Exception { setUp(true, "testPrimaryWithFederation"); LOG.info("DAFS testPrimary"); cluster.killStandby(0); checkPrimary(); }
/** Read from primary avatar. */ @Test public void testPrimary() throws Exception { setUp(false, "testPrimary"); LOG.info("DAFS testPrimary"); cluster.killStandby(); checkPrimary(); }
@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); }
@After public void shutDown() throws Exception { if (dafs != null) { dafs.close(); } if (cluster != null) { cluster.shutDown(); } InjectionHandler.clear(); }
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); } }
@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(); }
@AfterClass public static void shutDownStatic() throws Exception { try { if (bookKeeperClient != null) { bookKeeperClient.close(); } } finally { if (bookKeeperCluster != null) { bookKeeperCluster.shutdown(); } MiniAvatarCluster.shutDownZooKeeper(); } }
/** 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) { } }
@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(); }
@BeforeClass public static void setUpClass() throws Exception { MiniAvatarCluster.createAndStartZooKeeper(); }
@AfterClass public static void shutDownClass() throws Exception { MiniAvatarCluster.shutDownZooKeeper(); }
@After public void shutDown() throws Exception { dafs.close(); cluster.shutDown(); }
private long getLastTxId() { return cluster.getPrimaryAvatar(0).avatar.getFSImage().getEditLog().getCurrentTxId() - 1; }