Ejemplo n.º 1
0
        internal override void UpdateFromUserConfig(IUserConfig userConfig)
        {
            base.UpdateFromUserConfig(userConfig);

            this.NodeTypes = userConfig.NodeTypes.ConvertAll <NodeTypeDescriptionGA>(
                nodeType => NodeTypeDescriptionGA.ReadFromInternal(nodeType));

            this.Security = new SecurityJanuary2017();
            if (userConfig.Security != null)
            {
                this.Security.FromInternal(userConfig.Security);
            }
        }
Ejemplo n.º 2
0
        private void ValidateNodeList()
        {
            if (this.Nodes == null || this.Nodes.Count == 0)
            {
                throw new ValidationException(ClusterManagementErrorCode.BestPracticesAnalyzerModelInvalid, StringResources.Error_BPAInvalidNodeList);
            }

            var nodeNameDuplicateDetector = new HashSet <string>();
            var faultDomainSize           = -1;

            foreach (var node in this.Nodes)
            {
                node.Verify();
                if (nodeNameDuplicateDetector.Contains(node.NodeName))
                {
                    throw new ValidationException(
                              ClusterManagementErrorCode.BestPracticesAnalyzerModelInvalid,
                              StringResources.Error_BPADuplicateNodeName,
                              node.NodeName);
                }
                else
                {
                    nodeNameDuplicateDetector.Add(node.NodeName);
                }

                if (faultDomainSize == -1)
                {
                    faultDomainSize = node.FaultDomain.Split('/').Length;
                }
                else
                {
                    if (faultDomainSize != node.FaultDomain.Split('/').Length)
                    {
                        throw new ValidationException(
                                  ClusterManagementErrorCode.BestPracticesAnalyzerModelInvalid,
                                  StringResources.Error_BPAInvalidFD,
                                  node.NodeName);
                    }
                }
            }

            var groupNodesOnSameMachine = this.Nodes.GroupBy(n => n.IPAddress).Where(group => group.Count() > 1);

            // Validate nodes on same machine don't use same NodeType, to avoid port collisions.
            bool sameNodeTypeOnSameMachine = groupNodesOnSameMachine
                                             .Any(group => (group.Count() != group.Select(m => m.NodeTypeRef).Distinct().Count()));

            if (sameNodeTypeOnSameMachine)
            {
                throw new ValidationException(ClusterManagementErrorCode.BestPracticesAnalyzerModelInvalid, StringResources.Error_BPAJsonNodesCannotReferenceSameNodeType);
            }

            // Validate nodes on same machine with different NodeType, have no port collisions.
            var  nodeTypeDictionary       = this.GetUserConfig().NodeTypes.ToDictionary(nodeType => nodeType.Name, nodeType => NodeTypeDescriptionGA.ReadFromInternal(nodeType));
            bool sameMachinePortCollision = groupNodesOnSameMachine
                                            .Any(group => this.NodeTypesHavePortCollisions(group.Select(g => nodeTypeDictionary[g.NodeTypeRef])));

            if (sameMachinePortCollision)
            {
                throw new ValidationException(ClusterManagementErrorCode.BestPracticesAnalyzerModelInvalid, StringResources.Error_BPAJsonNodesSameMachinePortCollision);
            }
        }