示例#1
0
 public bool Equals(AvailableNodes rhs)
 {
     if (object.ReferenceEquals(rhs, null) || GetType() != rhs.GetType())
     {
         return(false);
     }
     return(object.ReferenceEquals(this, rhs) || nodes.SequenceEqual(rhs.nodes));
 }
        private static void UpdateWinhostsFile(string rsName)
        {
            var currentNodes = GetAvailableNodes(rsName);

            if (!currentNodes.Equals(availableNodes))
            {
                Trace.TraceInformation("Node information changed from {0} to {1}",
                                       (availableNodes == null) ? null : availableNodes.ToString(),
                                       currentNodes);
                availableNodes = currentNodes;
                WriteWinhostsFile();
            }
        }
        private static AvailableNodes GetAvailableNodes(string rsName)
        {
            var nodes = new AvailableNodes();

            foreach (var instance in RoleEnvironment.Roles[Constants.MongoDBWorkerRoleName].Instances)
            {
                nodes.Add(new NodeAlias()
                {
                    Alias     = ConnectionUtilities.GetNodeAlias(rsName, ConnectionUtilities.ParseNodeInstanceId(instance.Id)),
                    IpAddress = instance.InstanceEndpoints[Constants.MongodPortSetting].IPEndpoint.Address.ToString()
                });
            }
            return(nodes);
        }