Skip to content

Commit

Permalink
Assign explicit node names to autodetected nodes.
Browse files Browse the repository at this point in the history
The naming convention allows to know the order in which nodes
appear in the configuration using a lexicographic sorting of the
nodes by name.
  • Loading branch information
Juan Hernando Vieites committed Dec 22, 2016
1 parent 48d2e37 commit f69abcb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 18 additions & 2 deletions eq/server/config/resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
_putenv_s( name, value )
#endif

#include <cstdio>
#include <cmath>

#define USE_IPv4

namespace eq
Expand Down Expand Up @@ -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 )
Expand All @@ -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 );

Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
}
Expand Down

0 comments on commit f69abcb

Please sign in to comment.