Adjust the order of the host entries
Adjust the order of the host entries to let <NetworkType>.<NodeName> entries at the end.
This commit is contained in:
Родитель
677e6f5d9d
Коммит
2bbf7b0d2d
|
@ -58,8 +58,16 @@ namespace Microsoft.Hpc.Communicators.LinuxCommunicator
|
|||
{
|
||||
try
|
||||
{
|
||||
LinuxCommunicator.Instance.Tracer.TraceInfo("Linux RegisterRequested. NodeName {0}, Distro {1} ", registerInfo.NodeName, registerInfo.DistroInfo);
|
||||
LinuxCommunicator.Instance.OnRegisterRequested(registerInfo);
|
||||
if (!nodeName.Equals(registerInfo.NodeName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
LinuxCommunicator.Instance.Tracer.TraceError("Linux RegisterRequested: the node name '{0}' in register info mismatches the expected node name {1}.", nodeName, registerInfo.NodeName);
|
||||
LinuxCommunicator.Instance.Tracer.TraceInfo("The IP address(es) of the node {0}: {1}.", registerInfo.NodeName, string.Join(",", registerInfo.NetworksInfo.Select(ni => ni.IpV4)));
|
||||
}
|
||||
else
|
||||
{
|
||||
LinuxCommunicator.Instance.Tracer.TraceInfo("Linux RegisterRequested. NodeName {0}, Distro {1} ", registerInfo.NodeName, registerInfo.DistroInfo);
|
||||
LinuxCommunicator.Instance.OnRegisterRequested(registerInfo);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -155,7 +155,10 @@ namespace Microsoft.Hpc.Communicators.LinuxCommunicator.HostsFile
|
|||
{
|
||||
if (newEntries.Count != this.ManagedEntries.Count || !(new HashSet<HostEntry>(this.ManagedEntries)).SetEquals(new HashSet<HostEntry>(newEntries.Values)))
|
||||
{
|
||||
this.ManagedEntries = newEntries.Values.ToList();
|
||||
// Put the <NetworkType>.<NodeName> entries at the end of the list
|
||||
var newHostList = newEntries.Values.Where(entry => !entry.Name.Contains('.')).ToList();
|
||||
newHostList.AddRange(newEntries.Values.Where(entry => entry.Name.Contains('.')));
|
||||
this.ManagedEntries = newHostList;
|
||||
this.UpdateId = Guid.NewGuid();
|
||||
LinuxCommunicator.Instance.Tracer.TraceInfo("[HostsFileManager] The managed host entries updated, current update Id is {0}", this.UpdateId);
|
||||
}
|
||||
|
|
|
@ -92,12 +92,23 @@ void HostsManager::UpdateHostsFile(const std::vector<HostEntry>& hostEntries)
|
|||
}
|
||||
|
||||
// Append the HPC entries at the end
|
||||
// Make the <NetworkType>.<NodeName> entries at the end
|
||||
for(std::size_t i=0; i<hostEntries.size(); i++)
|
||||
{
|
||||
Logger::Debug("Add HPC host entry: ({0}, {1})", hostEntries[i].HostName, hostEntries[i].IPAddress);
|
||||
ofs << std::left << std::setw(24) << hostEntries[i].IPAddress << std::setw(30) << hostEntries[i].HostName << "#HPC" << std::endl;
|
||||
if (hostEntries[i].HostName.find('.') == std::string::npos)
|
||||
{
|
||||
Logger::Debug("Add HPC host entry: ({0}, {1})", hostEntries[i].HostName, hostEntries[i].IPAddress);
|
||||
ofs << std::left << std::setw(24) << hostEntries[i].IPAddress << std::setw(30) << hostEntries[i].HostName << "#HPC" << std::endl;
|
||||
}
|
||||
}
|
||||
for(std::size_t i=0; i<hostEntries.size(); i++)
|
||||
{
|
||||
if (hostEntries[i].HostName.find('.') != std::string::npos)
|
||||
{
|
||||
Logger::Debug("Add HPC host entry: ({0}, {1})", hostEntries[i].HostName, hostEntries[i].IPAddress);
|
||||
ofs << std::left << std::setw(24) << hostEntries[i].IPAddress << std::setw(30) << hostEntries[i].HostName << "#HPC" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
ofs.close();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче