/// <summary> /// After one of the BPServiceActors registers successfully with the /// NN, it calls this function to verify that the NN it connected to /// is consistent with other NNs serving the block-pool. /// </summary> /// <exception cref="System.IO.IOException"/> internal virtual void RegistrationSucceeded(BPServiceActor bpServiceActor, DatanodeRegistration reg) { WriteLock(); try { if (bpRegistration != null) { CheckNSEquality(bpRegistration.GetStorageInfo().GetNamespaceID(), reg.GetStorageInfo ().GetNamespaceID(), "namespace ID"); CheckNSEquality(bpRegistration.GetStorageInfo().GetClusterID(), reg.GetStorageInfo ().GetClusterID(), "cluster ID"); } bpRegistration = reg; dn.BpRegistrationSucceeded(bpRegistration, GetBlockPoolId()); // Add the initial block token secret keys to the DN's secret manager. if (dn.isBlockTokenEnabled) { dn.blockPoolTokenSecretManager.AddKeys(GetBlockPoolId(), reg.GetExportedKeys()); } } finally { WriteUnlock(); } }
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 ()); }