/// <summary> /// Test to verify that InterDatanode RPC timesout as expected when /// the server DN does not respond. /// </summary> /// <exception cref="System.Exception"/> public virtual void TestInterDNProtocolTimeout() { Org.Apache.Hadoop.Ipc.Server server = new TestInterDatanodeProtocol.TestServer(1, true); server.Start(); IPEndPoint addr = NetUtils.GetConnectAddress(server); DatanodeID fakeDnId = DFSTestUtil.GetLocalDatanodeID(addr.Port); DatanodeInfo dInfo = new DatanodeInfo(fakeDnId); InterDatanodeProtocol proxy = null; try { proxy = DataNode.CreateInterDataNodeProtocolProxy(dInfo, conf, 500, false); proxy.InitReplicaRecovery(new BlockRecoveryCommand.RecoveringBlock(new ExtendedBlock ("bpid", 1), null, 100)); NUnit.Framework.Assert.Fail("Expected SocketTimeoutException exception, but did not get." ); } finally { if (proxy != null) { RPC.StopProxy(proxy); } server.Stop(); } }
public virtual void TestBlockTokenRpcLeak() { Configuration conf = new Configuration(); conf.Set(CommonConfigurationKeysPublic.HadoopSecurityAuthentication, "kerberos"); UserGroupInformation.SetConfiguration(conf); Assume.AssumeTrue(FdDir.Exists()); BlockTokenSecretManager sm = new BlockTokenSecretManager(blockKeyUpdateInterval, blockTokenLifetime, 0, "fake-pool", null); Org.Apache.Hadoop.Security.Token.Token <BlockTokenIdentifier> token = sm.GenerateToken (block3, EnumSet.AllOf <BlockTokenSecretManager.AccessMode>()); Server server = CreateMockDatanode(sm, token, conf); server.Start(); IPEndPoint addr = NetUtils.GetConnectAddress(server); DatanodeID fakeDnId = DFSTestUtil.GetLocalDatanodeID(addr.Port); ExtendedBlock b = new ExtendedBlock("fake-pool", new Org.Apache.Hadoop.Hdfs.Protocol.Block (12345L)); LocatedBlock fakeBlock = new LocatedBlock(b, new DatanodeInfo[0]); fakeBlock.SetBlockToken(token); // Create another RPC proxy with the same configuration - this will never // attempt to connect anywhere -- but it causes the refcount on the // RPC "Client" object to stay above 0 such that RPC.stopProxy doesn't // actually close the TCP connections to the real target DN. ClientDatanodeProtocol proxyToNoWhere = RPC.GetProxy <ClientDatanodeProtocol>(ClientDatanodeProtocol .versionID, new IPEndPoint("1.1.1.1", 1), UserGroupInformation.CreateRemoteUser( "junk"), conf, NetUtils.GetDefaultSocketFactory(conf)); ClientDatanodeProtocol proxy = null; int fdsAtStart = CountOpenFileDescriptors(); try { long endTime = Time.Now() + 3000; while (Time.Now() < endTime) { proxy = DFSUtil.CreateClientDatanodeProtocolProxy(fakeDnId, conf, 1000, false, fakeBlock ); NUnit.Framework.Assert.AreEqual(block3.GetBlockId(), proxy.GetReplicaVisibleLength (block3)); if (proxy != null) { RPC.StopProxy(proxy); } Log.Info("Num open fds:" + CountOpenFileDescriptors()); } int fdsAtEnd = CountOpenFileDescriptors(); if (fdsAtEnd - fdsAtStart > 50) { NUnit.Framework.Assert.Fail("Leaked " + (fdsAtEnd - fdsAtStart) + " fds!"); } } finally { server.Stop(); } RPC.StopProxy(proxyToNoWhere); }
public virtual void TestConvertDatanodeID() { DatanodeID dn = DFSTestUtil.GetLocalDatanodeID(); HdfsProtos.DatanodeIDProto dnProto = PBHelper.Convert(dn); DatanodeID dn2 = PBHelper.Convert(dnProto); Compare(dn, dn2); }
public static DatanodeDescriptor GetLocalDatanodeDescriptor(bool initializeStorage ) { DatanodeDescriptor dn = new DatanodeDescriptor(DFSTestUtil.GetLocalDatanodeID()); if (initializeStorage) { dn.UpdateStorage(new DatanodeStorage(DatanodeStorage.GenerateUuid())); } return(dn); }
public virtual void TestConvertDatanodeRegistration() { DatanodeID dnId = DFSTestUtil.GetLocalDatanodeID(); BlockKey[] keys = new BlockKey[] { GetBlockKey(2), GetBlockKey(3) }; ExportedBlockKeys expKeys = new ExportedBlockKeys(true, 9, 10, GetBlockKey(1), keys ); DatanodeRegistration reg = new DatanodeRegistration(dnId, new StorageInfo(HdfsServerConstants.NodeType .DataNode), expKeys, "3.0.0"); DatanodeProtocolProtos.DatanodeRegistrationProto proto = PBHelper.Convert(reg); DatanodeRegistration reg2 = PBHelper.Convert(proto); Compare(reg.GetStorageInfo(), reg2.GetStorageInfo()); Compare(reg.GetExportedKeys(), reg2.GetExportedKeys()); Compare(reg, reg2); NUnit.Framework.Assert.AreEqual(reg.GetSoftwareVersion(), reg2.GetSoftwareVersion ()); }