/// <exception cref="System.Exception"/> public virtual void TestResourceTrackerOnHA() { NodeId nodeId = NodeId.NewInstance("localhost", 0); Resource resource = Resource.NewInstance(2048, 4); // make sure registerNodeManager works when failover happens RegisterNodeManagerRequest request = RegisterNodeManagerRequest.NewInstance(nodeId , 0, resource, YarnVersionInfo.GetVersion(), null, null); resourceTracker.RegisterNodeManager(request); NUnit.Framework.Assert.IsTrue(WaitForNodeManagerToConnect(10000, nodeId)); // restart the failover thread, and make sure nodeHeartbeat works failoverThread = CreateAndStartFailoverThread(); NodeStatus status = NodeStatus.NewInstance(NodeId.NewInstance("localhost", 0), 0, null, null, null); NodeHeartbeatRequest request2 = NodeHeartbeatRequest.NewInstance(status, null, null ); resourceTracker.NodeHeartbeat(request2); }
protected internal virtual void RegisterWithRM() { IList <NMContainerStatus> containerReports = GetNMContainerStatuses(); RegisterNodeManagerRequest request = RegisterNodeManagerRequest.NewInstance(nodeId , httpPort, totalResource, nodeManagerVersionId, containerReports, GetRunningApplications ()); if (containerReports != null) { Log.Info("Registering with RM using containers :" + containerReports); } RegisterNodeManagerResponse regNMResponse = resourceTracker.RegisterNodeManager(request ); this.rmIdentifier = regNMResponse.GetRMIdentifier(); // if the Resourcemanager instructs NM to shutdown. if (NodeAction.Shutdown.Equals(regNMResponse.GetNodeAction())) { string message = "Message from ResourceManager: " + regNMResponse.GetDiagnosticsMessage (); throw new YarnRuntimeException("Recieved SHUTDOWN signal from Resourcemanager ,Registration of NodeManager failed, " + message); } // if ResourceManager version is too old then shutdown if (!minimumResourceManagerVersion.Equals("NONE")) { if (minimumResourceManagerVersion.Equals("EqualToNM")) { minimumResourceManagerVersion = nodeManagerVersionId; } string rmVersion = regNMResponse.GetRMVersion(); if (rmVersion == null) { string message = "The Resource Manager's did not return a version. " + "Valid version cannot be checked."; throw new YarnRuntimeException("Shutting down the Node Manager. " + message); } if (VersionUtil.CompareVersions(rmVersion, minimumResourceManagerVersion) < 0) { string message = "The Resource Manager's version (" + rmVersion + ") is less than the minimum " + "allowed version " + minimumResourceManagerVersion; throw new YarnRuntimeException("Shutting down the Node Manager on RM " + "version error, " + message); } } MasterKey masterKey = regNMResponse.GetContainerTokenMasterKey(); // do this now so that its set before we start heartbeating to RM // It is expected that status updater is started by this point and // RM gives the shared secret in registration during // StatusUpdater#start(). if (masterKey != null) { this.context.GetContainerTokenSecretManager().SetMasterKey(masterKey); } masterKey = regNMResponse.GetNMTokenMasterKey(); if (masterKey != null) { this.context.GetNMTokenSecretManager().SetMasterKey(masterKey); } Log.Info("Registered with ResourceManager as " + this.nodeId + " with total resource of " + this.totalResource); Log.Info("Notifying ContainerManager to unblock new container-requests"); ((ContainerManagerImpl)this.context.GetContainerManager()).SetBlockNewContainerRequests (false); }