コード例 #1
0
        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);
        }
コード例 #2
0
 public virtual void TestCompareVersions()
 {
     // Equal versions are equal.
     Assert.Equal(0, VersionUtil.CompareVersions("2.0.0", "2.0.0"));
     Assert.Equal(0, VersionUtil.CompareVersions("2.0.0a", "2.0.0a"
                                                 ));
     Assert.Equal(0, VersionUtil.CompareVersions("2.0.0-SNAPSHOT",
                                                 "2.0.0-SNAPSHOT"));
     Assert.Equal(0, VersionUtil.CompareVersions("1", "1"));
     Assert.Equal(0, VersionUtil.CompareVersions("1", "1.0"));
     Assert.Equal(0, VersionUtil.CompareVersions("1", "1.0.0"));
     Assert.Equal(0, VersionUtil.CompareVersions("1.0", "1"));
     Assert.Equal(0, VersionUtil.CompareVersions("1.0", "1.0"));
     Assert.Equal(0, VersionUtil.CompareVersions("1.0", "1.0.0"));
     Assert.Equal(0, VersionUtil.CompareVersions("1.0.0", "1"));
     Assert.Equal(0, VersionUtil.CompareVersions("1.0.0", "1.0"));
     Assert.Equal(0, VersionUtil.CompareVersions("1.0.0", "1.0.0"));
     Assert.Equal(0, VersionUtil.CompareVersions("1.0.0-alpha-1", "1.0.0-a1"
                                                 ));
     Assert.Equal(0, VersionUtil.CompareVersions("1.0.0-alpha-2", "1.0.0-a2"
                                                 ));
     Assert.Equal(0, VersionUtil.CompareVersions("1.0.0-alpha1", "1.0.0-alpha-1"
                                                 ));
     Assert.Equal(0, VersionUtil.CompareVersions("1a0", "1.0.0-alpha-0"
                                                 ));
     Assert.Equal(0, VersionUtil.CompareVersions("1a0", "1-a0"));
     Assert.Equal(0, VersionUtil.CompareVersions("1.a0", "1-a0"));
     Assert.Equal(0, VersionUtil.CompareVersions("1.a0", "1.0.0-alpha-0"
                                                 ));
     // Assert that lower versions are lower, and higher versions are higher.
     AssertExpectedValues("1", "2.0.0");
     AssertExpectedValues("1.0.0", "2");
     AssertExpectedValues("1.0.0", "2.0.0");
     AssertExpectedValues("1.0", "2.0.0");
     AssertExpectedValues("1.0.0", "2.0.0");
     AssertExpectedValues("1.0.0", "1.0.0a");
     AssertExpectedValues("1.0.0.0", "2.0.0");
     AssertExpectedValues("1.0.0", "1.0.0-dev");
     AssertExpectedValues("1.0.0", "1.0.1");
     AssertExpectedValues("1.0.0", "1.0.2");
     AssertExpectedValues("1.0.0", "1.1.0");
     AssertExpectedValues("2.0.0", "10.0.0");
     AssertExpectedValues("1.0.0", "1.0.0a");
     AssertExpectedValues("1.0.2a", "1.0.10");
     AssertExpectedValues("1.0.2a", "1.0.2b");
     AssertExpectedValues("1.0.2a", "1.0.2ab");
     AssertExpectedValues("1.0.0a1", "1.0.0a2");
     AssertExpectedValues("1.0.0a2", "1.0.0a10");
     // The 'a' in "1.a" is not followed by digit, thus not treated as "alpha",
     // and treated larger than "1.0", per maven's ComparableVersion class
     // implementation.
     AssertExpectedValues("1.0", "1.a");
     //The 'a' in "1.a0" is followed by digit, thus treated as "alpha-<digit>"
     AssertExpectedValues("1.a0", "1.0");
     AssertExpectedValues("1a0", "1.0");
     AssertExpectedValues("1.0.1-alpha-1", "1.0.1-alpha-2");
     AssertExpectedValues("1.0.1-beta-1", "1.0.1-beta-2");
     // Snapshot builds precede their eventual releases.
     AssertExpectedValues("1.0-SNAPSHOT", "1.0");
     AssertExpectedValues("1.0.0-SNAPSHOT", "1.0");
     AssertExpectedValues("1.0.0-SNAPSHOT", "1.0.0");
     AssertExpectedValues("1.0.0", "1.0.1-SNAPSHOT");
     AssertExpectedValues("1.0.1-SNAPSHOT", "1.0.1");
     AssertExpectedValues("1.0.1-SNAPSHOT", "1.0.2");
     AssertExpectedValues("1.0.1-alpha-1", "1.0.1-SNAPSHOT");
     AssertExpectedValues("1.0.1-beta-1", "1.0.1-SNAPSHOT");
     AssertExpectedValues("1.0.1-beta-2", "1.0.1-SNAPSHOT");
 }
コード例 #3
0
 private static void AssertExpectedValues(string lower, string higher)
 {
     Assert.True(VersionUtil.CompareVersions(lower, higher) < 0);
     Assert.True(VersionUtil.CompareVersions(higher, lower) > 0);
 }
コード例 #4
0
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        public virtual RegisterNodeManagerResponse RegisterNodeManager(RegisterNodeManagerRequest
                                                                       request)
        {
            NodeId   nodeId                      = request.GetNodeId();
            string   host                        = nodeId.GetHost();
            int      cmPort                      = nodeId.GetPort();
            int      httpPort                    = request.GetHttpPort();
            Resource capability                  = request.GetResource();
            string   nodeManagerVersion          = request.GetNMVersion();
            RegisterNodeManagerResponse response = recordFactory.NewRecordInstance <RegisterNodeManagerResponse
                                                                                    >();

            if (!minimumNodeManagerVersion.Equals("NONE"))
            {
                if (minimumNodeManagerVersion.Equals("EqualToRM"))
                {
                    minimumNodeManagerVersion = YarnVersionInfo.GetVersion();
                }
                if ((nodeManagerVersion == null) || (VersionUtil.CompareVersions(nodeManagerVersion
                                                                                 , minimumNodeManagerVersion)) < 0)
                {
                    string message = "Disallowed NodeManager Version " + nodeManagerVersion + ", is less than the minimum version "
                                     + minimumNodeManagerVersion + " sending SHUTDOWN signal to " + "NodeManager.";
                    Log.Info(message);
                    response.SetDiagnosticsMessage(message);
                    response.SetNodeAction(NodeAction.Shutdown);
                    return(response);
                }
            }
            // Check if this node is a 'valid' node
            if (!this.nodesListManager.IsValidNode(host))
            {
                string message = "Disallowed NodeManager from  " + host + ", Sending SHUTDOWN signal to the NodeManager.";
                Log.Info(message);
                response.SetDiagnosticsMessage(message);
                response.SetNodeAction(NodeAction.Shutdown);
                return(response);
            }
            // Check if this node has minimum allocations
            if (capability.GetMemory() < minAllocMb || capability.GetVirtualCores() < minAllocVcores)
            {
                string message = "NodeManager from  " + host + " doesn't satisfy minimum allocations, Sending SHUTDOWN"
                                 + " signal to the NodeManager.";
                Log.Info(message);
                response.SetDiagnosticsMessage(message);
                response.SetNodeAction(NodeAction.Shutdown);
                return(response);
            }
            response.SetContainerTokenMasterKey(containerTokenSecretManager.GetCurrentKey());
            response.SetNMTokenMasterKey(nmTokenSecretManager.GetCurrentKey());
            RMNode rmNode = new RMNodeImpl(nodeId, rmContext, host, cmPort, httpPort, Resolve
                                               (host), capability, nodeManagerVersion);
            RMNode oldNode = this.rmContext.GetRMNodes().PutIfAbsent(nodeId, rmNode);

            if (oldNode == null)
            {
                this.rmContext.GetDispatcher().GetEventHandler().Handle(new RMNodeStartedEvent(nodeId
                                                                                               , request.GetNMContainerStatuses(), request.GetRunningApplications()));
            }
            else
            {
                Log.Info("Reconnect from the node at: " + host);
                this.nmLivelinessMonitor.Unregister(nodeId);
                // Reset heartbeat ID since node just restarted.
                oldNode.ResetLastNodeHeartBeatResponse();
                this.rmContext.GetDispatcher().GetEventHandler().Handle(new RMNodeReconnectEvent(
                                                                            nodeId, rmNode, request.GetRunningApplications(), request.GetNMContainerStatuses
                                                                                ()));
            }
            // On every node manager register we will be clearing NMToken keys if
            // present for any running application.
            this.nmTokenSecretManager.RemoveNodeKey(nodeId);
            this.nmLivelinessMonitor.Register(nodeId);
            // Handle received container status, this should be processed after new
            // RMNode inserted
            if (!rmContext.IsWorkPreservingRecoveryEnabled())
            {
                if (!request.GetNMContainerStatuses().IsEmpty())
                {
                    Log.Info("received container statuses on node manager register :" + request.GetNMContainerStatuses
                                 ());
                    foreach (NMContainerStatus status in request.GetNMContainerStatuses())
                    {
                        HandleNMContainerStatus(status, nodeId);
                    }
                }
            }
            string message_1 = "NodeManager from node " + host + "(cmPort: " + cmPort + " httpPort: "
                               + httpPort + ") " + "registered with capability: " + capability + ", assigned nodeId "
                               + nodeId;

            Log.Info(message_1);
            response.SetNodeAction(NodeAction.Normal);
            response.SetRMIdentifier(ResourceManager.GetClusterTimeStamp());
            response.SetRMVersion(YarnVersionInfo.GetVersion());
            return(response);
        }