예제 #1
0
        public void Handle(NodeDescriptorProto node)
        {
            string rackName = node.rack_name == null ? node.rack_name : defaultRackName;
            string message  = string.Format(
                CultureInfo.InvariantCulture,
                "Catalog new node: id[{0}], rack[{1}], host[{2}], port[{3}], memory[{4}]",
                node.identifier,
                rackName,
                node.host_name,
                node.port,
                node.memory_size);

            LOGGER.Log(Level.Info, message);
            if (!string.IsNullOrWhiteSpace(rackName) && !_racks.ContainsKey(rackName))
            {
                RackDescriptorImpl newRack = new RackDescriptorImpl(rackName);
                _racks.Add(rackName, newRack);
            }
            RackDescriptorImpl rack      = _racks[rackName];
            IPAddress          ipAddress = null;

            IPAddress.TryParse(node.host_name, out ipAddress);
            if (ipAddress == null)
            {
                Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException("cannot parse host ipaddress: " + node.host_name), LOGGER);
            }
            IPEndPoint         ipEndPoint     = new IPEndPoint(ipAddress, node.port);
            RAM                ram            = new RAM(node.memory_size);
            NodeDescriptorImpl nodeDescriptor = new NodeDescriptorImpl(node.identifier, ipEndPoint, rack, ram);

            _nodes.Add(nodeDescriptor.Id, nodeDescriptor);
        }
예제 #2
0
 public void AddNodeDescriptor(NodeDescriptorImpl node)
 {
     Nodes.Add(node);
 }