From f69abcb85ff77978d544d65481aee9ad079205e4 Mon Sep 17 00:00:00 2001 From: Juan Hernando Vieites Date: Wed, 21 Dec 2016 18:14:57 +0100 Subject: [PATCH] Assign explicit node names to autodetected nodes. The naming convention allows to know the order in which nodes appear in the configuration using a lexicographic sorting of the nodes by name. --- doc/Changelog.md | 2 ++ eq/server/config/resources.cpp | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/doc/Changelog.md b/doc/Changelog.md index e133a32160..15038e3253 100644 --- a/doc/Changelog.md +++ b/doc/Changelog.md @@ -3,6 +3,8 @@ Changelog {#Changelog} # git master +* [604](https://github.com/Eyescale/Equalizer/pull/604): + Give names to nodes in order in autogenerated configurations. * [602](https://github.com/Eyescale/Equalizer/pull/602): Remove PBuffer support diff --git a/eq/server/config/resources.cpp b/eq/server/config/resources.cpp index 5a702bae31..ccae088db6 100644 --- a/eq/server/config/resources.cpp +++ b/eq/server/config/resources.cpp @@ -61,6 +61,9 @@ _putenv_s( name, value ) #endif +#include +#include + #define USE_IPv4 namespace eq @@ -243,6 +246,12 @@ bool Resources::discover( ServerPtr server, Config* config, std::string excludedDisplays; // for VGL_EXCLUDE + size_t nodeCounter = 0; + char nameFormatStr[128]; + std::sprintf( nameFormatStr, "node_%%0%dd", + int( std::floor( std::log( gpuInfos.size( )) / + std::log( 10 ))) + 1 ); + for( const hwsd::GPUInfo& info : gpuInfos ) { if( info.flags & hwsd::GPUInfo::FLAG_VIRTUALGL_DISPLAY ) @@ -256,7 +265,9 @@ bool Resources::discover( ServerPtr server, Config* config, if( isApplicationNode ) appNodeID = info.id; mtNode = new Node( config ); - mtNode->setName( info.nodeName ); + char name[128]; + std::sprintf( name, nameFormatStr, ++nodeCounter ); + mtNode->setName( name ); mtNode->setHost( info.nodeName ); mtNode->setApplicationNode( isApplicationNode ); @@ -287,7 +298,9 @@ bool Resources::discover( ServerPtr server, Config* config, else if( multiProcess ) { mpNode = new Node( config ); - mpNode->setName( info.nodeName ); + char name[128]; + std::sprintf( name, nameFormatStr, ++nodeCounter ); + mpNode->setName( name ); mpNode->setHost( info.nodeName ); LBASSERT( multiNode ); @@ -355,6 +368,9 @@ bool Resources::discover( ServerPtr server, Config* config, if( !node ) { node = new Node( config ); + char name[128]; + std::sprintf( name, nameFormatStr, 0 ); + node->setName( name ); node->setApplicationNode( true ); node->addConnectionDescription( new ConnectionDescription ); }