return null; startOpt.setClusterId(clusterId); if (i + 2 < argsLen) { i += 2; startOpt.setClusterId(args[i]); } else { LOG.error("Must specify a valid cluster ID after the "
LayoutVersion.Feature.FEDERATION, layoutVersion)) { if (startOpt.getClusterId() == null) { startOpt.setClusterId(newClusterID());
return null; startOpt.setClusterId(clusterId); if (i + 2 < argsLen) { i += 2; startOpt.setClusterId(args[i]); } else { LOG.error("Must specify a valid cluster ID after the "
StartupOption.FORMAT.setClusterId(clusterId); } else { StartupOption.FORMAT.setClusterId(nn.getClusterId());
return null; startOpt.setClusterId(clusterId); if (i + 2 < argsLen) { i += 2; startOpt.setClusterId(args[i]); } else { LOG.error("Must specify a valid cluster ID after the "
Configuration nn2 = cluster.getConfiguration(1); StartupOption.FORMAT.setClusterId("cluster-2"); DFSTestUtil.formatNameNode(nn1); MiniDFSCluster.copyNameDirs(FSNamesystem.getNamespaceDirs(nn1),
operation.setClusterId(clusterId);
StartupOption.FORMAT.setClusterId("DifferentCID"); cluster.addNameNode(conf, 9948); NameNode nn4 = cluster.getNameNode(3);
LayoutVersion.Feature.FEDERATION, layoutVersion)) { if (startOpt.getClusterId() == null) { startOpt.setClusterId(newClusterID());
LayoutVersion.Feature.FEDERATION, layoutVersion)) { if (startOpt.getClusterId() == null) { startOpt.setClusterId(newClusterID());
@Test public void testFormatClusterIdOption() throws IOException { // 1. should format without cluster id //StartupOption.FORMAT.setClusterId(""); NameNode.format(config); // see if cluster id not empty. String cid = getClusterId(config); assertTrue("Didn't get new ClusterId", (cid != null && !cid.equals("")) ); // 2. successful format with given clusterid StartupOption.FORMAT.setClusterId("mycluster"); NameNode.format(config); // see if cluster id matches with given clusterid. cid = getClusterId(config); assertTrue("ClusterId didn't match", cid.equals("mycluster")); // 3. format without any clusterid again. It should generate new //clusterid. StartupOption.FORMAT.setClusterId(""); NameNode.format(config); String newCid = getClusterId(config); assertFalse("ClusterId should not be the same", newCid.equals(cid)); }
/** * Tests the upgrade from one version of Federation to another Federation * version Test with correct clusterid case: -upgrade -clusterid <cid> * Expected to reuse existing clusterid and ignore user given clusterid * * @throws Exception */ @Test public void testStartupOptUpgradeFromFederationWithCID() throws Exception { startOpt.setClusterId("currentcid"); storage.setClusterID("currentcid"); layoutVersion = Feature.FEDERATION.getInfo().getLayoutVersion(); storage.processStartupOptionsForUpgrade(startOpt, layoutVersion); assertEquals("Clusterid should match with the existing one", "currentcid", storage.getClusterID()); } }
/** * Tests the upgrade from one version of Federation to another Federation * version Test with wrong clusterid case: -upgrade -clusterid <cid> * Expected to reuse existing clusterid and ignore user given clusterid * * @throws Exception */ @Test public void testStartupOptUpgradeFromFederationWithWrongCID() throws Exception { startOpt.setClusterId("wrong-cid"); storage.setClusterID("currentcid"); layoutVersion = Feature.FEDERATION.getInfo().getLayoutVersion(); storage.processStartupOptionsForUpgrade(startOpt, layoutVersion); assertEquals("Clusterid should match with the existing one", "currentcid", storage.getClusterID()); }
/** * Tests the upgrade from version 0.22 to Federation version Test with * clusterid case: -upgrade -clusterid <cid> * Expected to reuse user given clusterid * * @throws Exception */ @Test public void testStartupOptUpgradeFrom22WithCID() throws Exception { startOpt.setClusterId("cid"); layoutVersion = Feature.RESERVED_REL22.getInfo().getLayoutVersion(); storage.processStartupOptionsForUpgrade(startOpt, layoutVersion); assertEquals("Clusterid should match with the given clusterid", "cid", storage.getClusterID()); }
@Before public void setUp() throws Exception { conf = new HdfsConfiguration(); startOpt.setClusterId(null); storage = new NNStorage(conf, Collections.<URI>emptyList(), Collections.<URI>emptyList()); }
/** * when formatting a namenode - we must provide clusterid. * @param conf * @throws IOException */ public static void formatNameNode(Configuration conf) throws IOException { String clusterId = StartupOption.FORMAT.getClusterId(); if(clusterId == null || clusterId.isEmpty()) StartupOption.FORMAT.setClusterId("testClusterID"); // Use a copy of conf as it can be altered by namenode during format. NameNode.format(new Configuration(conf)); }