public virtual void TestWrappedFailoverProxyProvider() { // setup the config with the dummy provider class Configuration config = new HdfsConfiguration(conf); string logicalName = HATestUtil.GetLogicalHostname(cluster); HATestUtil.SetFailoverConfigurations(cluster, config, logicalName); config.Set(DFSConfigKeys.DfsClientFailoverProxyProviderKeyPrefix + "." + logicalName , typeof(TestDFSClientFailover.DummyLegacyFailoverProxyProvider).FullName); Path p = new Path("hdfs://" + logicalName + "/"); // not to use IP address for token service SecurityUtil.SetTokenServiceUseIp(false); // Logical URI should be used. NUnit.Framework.Assert.IsTrue("Legacy proxy providers should use logical URI.", HAUtil .UseLogicalUri(config, p.ToUri())); }
public virtual void TestLogicalUriShouldNotHavePorts() { Configuration config = new HdfsConfiguration(conf); string logicalName = HATestUtil.GetLogicalHostname(cluster); HATestUtil.SetFailoverConfigurations(cluster, config, logicalName); Path p = new Path("hdfs://" + logicalName + ":12345/"); try { p.GetFileSystem(config).Exists(p); NUnit.Framework.Assert.Fail("Did not fail with fake FS"); } catch (IOException ioe) { GenericTestUtils.AssertExceptionContains("does not use port information", ioe); } }
public virtual void TestDfsClientFailover() { FileSystem fs = HATestUtil.ConfigureFailoverFs(cluster, conf); DFSTestUtil.CreateFile(fs, TestFile, FileLengthToVerify, (short)1, 1L); NUnit.Framework.Assert.AreEqual(fs.GetFileStatus(TestFile).GetLen(), FileLengthToVerify ); cluster.ShutdownNameNode(0); cluster.TransitionToActive(1); NUnit.Framework.Assert.AreEqual(fs.GetFileStatus(TestFile).GetLen(), FileLengthToVerify ); // Check that it functions even if the URL becomes canonicalized // to include a port number. Path withPort = new Path("hdfs://" + HATestUtil.GetLogicalHostname(cluster) + ":" + NameNode.DefaultPort + "/" + TestFile.ToUri().GetPath()); FileSystem fs2 = withPort.GetFileSystem(fs.GetConf()); NUnit.Framework.Assert.IsTrue(fs2.Exists(withPort)); fs.Close(); }