コード例 #1
0
            private void UpdateMasterKeys(NodeHeartbeatResponse response)
            {
                MasterKey updatedMasterKey = response.GetContainerTokenMasterKey();

                if (updatedMasterKey != null)
                {
                    this._enclosing.context.GetContainerTokenSecretManager().SetMasterKey(updatedMasterKey
                                                                                          );
                }
                updatedMasterKey = response.GetNMTokenMasterKey();
                if (updatedMasterKey != null)
                {
                    this._enclosing.context.GetNMTokenSecretManager().SetMasterKey(updatedMasterKey);
                }
            }
コード例 #2
0
ファイル: MockNM.cs プロジェクト: orf53975/hadoop.net
        /// <exception cref="System.Exception"/>
        public virtual NodeHeartbeatResponse NodeHeartbeat(IDictionary <ApplicationId, IList
                                                                        <Org.Apache.Hadoop.Yarn.Api.Records.ContainerStatus> > conts, bool isHealthy, int
                                                           resId)
        {
            NodeHeartbeatRequest req = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <NodeHeartbeatRequest
                                                                                      >();
            NodeStatus status = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <NodeStatus>();

            status.SetResponseId(resId);
            status.SetNodeId(nodeId);
            foreach (KeyValuePair <ApplicationId, IList <Org.Apache.Hadoop.Yarn.Api.Records.ContainerStatus
                                                         > > entry in conts)
            {
                Org.Mortbay.Log.Log.Info("entry.getValue() " + entry.Value);
                status.SetContainersStatuses(entry.Value);
            }
            NodeHealthStatus healthStatus = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <NodeHealthStatus
                                                                                           >();

            healthStatus.SetHealthReport(string.Empty);
            healthStatus.SetIsNodeHealthy(isHealthy);
            healthStatus.SetLastHealthReportTime(1);
            status.SetNodeHealthStatus(healthStatus);
            req.SetNodeStatus(status);
            req.SetLastKnownContainerTokenMasterKey(this.currentContainerTokenMasterKey);
            req.SetLastKnownNMTokenMasterKey(this.currentNMTokenMasterKey);
            NodeHeartbeatResponse heartbeatResponse = resourceTracker.NodeHeartbeat(req);
            MasterKey             masterKeyFromRM   = heartbeatResponse.GetContainerTokenMasterKey();

            if (masterKeyFromRM != null && masterKeyFromRM.GetKeyId() != this.currentContainerTokenMasterKey
                .GetKeyId())
            {
                this.currentContainerTokenMasterKey = masterKeyFromRM;
            }
            masterKeyFromRM = heartbeatResponse.GetNMTokenMasterKey();
            if (masterKeyFromRM != null && masterKeyFromRM.GetKeyId() != this.currentNMTokenMasterKey
                .GetKeyId())
            {
                this.currentNMTokenMasterKey = masterKeyFromRM;
            }
            return(heartbeatResponse);
        }
コード例 #3
0
        /// <exception cref="System.Exception"/>
        private void ValidateRMNMKeyExchange(YarnConfiguration conf)
        {
            // Default rolling and activation intervals are large enough, no need to
            // intervene
            DrainDispatcher dispatcher = new DrainDispatcher();
            ResourceManager rm         = new _ResourceManager_56(dispatcher);

            // Do nothing.
            // Don't need it, skip.
            rm.Init(conf);
            rm.Start();
            // Testing ContainerToken and NMToken
            string containerToken = "Container Token : ";
            string nmToken        = "NM Token : ";
            MockNM nm             = new MockNM("host:1234", 3072, rm.GetResourceTrackerService());
            RegisterNodeManagerResponse registrationResponse = nm.RegisterNode();
            MasterKey containerTokenMasterKey = registrationResponse.GetContainerTokenMasterKey
                                                    ();

            NUnit.Framework.Assert.IsNotNull(containerToken + "Registration should cause a key-update!"
                                             , containerTokenMasterKey);
            MasterKey nmTokenMasterKey = registrationResponse.GetNMTokenMasterKey();

            NUnit.Framework.Assert.IsNotNull(nmToken + "Registration should cause a key-update!"
                                             , nmTokenMasterKey);
            dispatcher.Await();
            NodeHeartbeatResponse response = nm.NodeHeartbeat(true);

            NUnit.Framework.Assert.IsNull(containerToken + "First heartbeat after registration shouldn't get any key updates!"
                                          , response.GetContainerTokenMasterKey());
            NUnit.Framework.Assert.IsNull(nmToken + "First heartbeat after registration shouldn't get any key updates!"
                                          , response.GetNMTokenMasterKey());
            dispatcher.Await();
            response = nm.NodeHeartbeat(true);
            NUnit.Framework.Assert.IsNull(containerToken + "Even second heartbeat after registration shouldn't get any key updates!"
                                          , response.GetContainerTokenMasterKey());
            NUnit.Framework.Assert.IsNull(nmToken + "Even second heartbeat after registration shouldn't get any key updates!"
                                          , response.GetContainerTokenMasterKey());
            dispatcher.Await();
            // Let's force a roll-over
            rm.GetRMContext().GetContainerTokenSecretManager().RollMasterKey();
            rm.GetRMContext().GetNMTokenSecretManager().RollMasterKey();
            // Heartbeats after roll-over and before activation should be fine.
            response = nm.NodeHeartbeat(true);
            NUnit.Framework.Assert.IsNotNull(containerToken + "Heartbeats after roll-over and before activation should not err out."
                                             , response.GetContainerTokenMasterKey());
            NUnit.Framework.Assert.IsNotNull(nmToken + "Heartbeats after roll-over and before activation should not err out."
                                             , response.GetNMTokenMasterKey());
            NUnit.Framework.Assert.AreEqual(containerToken + "Roll-over should have incremented the key-id only by one!"
                                            , containerTokenMasterKey.GetKeyId() + 1, response.GetContainerTokenMasterKey().
                                            GetKeyId());
            NUnit.Framework.Assert.AreEqual(nmToken + "Roll-over should have incremented the key-id only by one!"
                                            , nmTokenMasterKey.GetKeyId() + 1, response.GetNMTokenMasterKey().GetKeyId());
            dispatcher.Await();
            response = nm.NodeHeartbeat(true);
            NUnit.Framework.Assert.IsNull(containerToken + "Second heartbeat after roll-over shouldn't get any key updates!"
                                          , response.GetContainerTokenMasterKey());
            NUnit.Framework.Assert.IsNull(nmToken + "Second heartbeat after roll-over shouldn't get any key updates!"
                                          , response.GetNMTokenMasterKey());
            dispatcher.Await();
            // Let's force activation
            rm.GetRMContext().GetContainerTokenSecretManager().ActivateNextMasterKey();
            rm.GetRMContext().GetNMTokenSecretManager().ActivateNextMasterKey();
            response = nm.NodeHeartbeat(true);
            NUnit.Framework.Assert.IsNull(containerToken + "Activation shouldn't cause any key updates!"
                                          , response.GetContainerTokenMasterKey());
            NUnit.Framework.Assert.IsNull(nmToken + "Activation shouldn't cause any key updates!"
                                          , response.GetNMTokenMasterKey());
            dispatcher.Await();
            response = nm.NodeHeartbeat(true);
            NUnit.Framework.Assert.IsNull(containerToken + "Even second heartbeat after activation shouldn't get any key updates!"
                                          , response.GetContainerTokenMasterKey());
            NUnit.Framework.Assert.IsNull(nmToken + "Even second heartbeat after activation shouldn't get any key updates!"
                                          , response.GetNMTokenMasterKey());
            dispatcher.Await();
            rm.Stop();
        }