예제 #1
0
bool Client::_cmdExit( co::ICommand& command )
{
    _impl->running = false;
    // Close connection here, this is the last command we'll get on it
    command.getLocalNode()->disconnect( command.getRemoteNode( ));
    return true;
}
예제 #2
0
파일: client.cpp 프로젝트: VMML/Equalizer
bool Client::dispatchCommand( co::ICommand& command )
{
    LBVERB << "dispatch " << command << std::endl;

    if( command.getCommand() >= co::CMD_NODE_CUSTOM &&
        command.getCommand() < CMD_SERVER_CUSTOM )
    {
        co::NodePtr node = command.getRemoteNode();
        return node->co::Dispatcher::dispatchCommand( command );
    }

    return co::LocalNode::dispatchCommand( command );
}
예제 #3
0
//---------------------------------------------------------------------------
// command handlers
//---------------------------------------------------------------------------
bool Server::_cmdChooseConfigReply( co::ICommand& command )
{
    co::LocalNodePtr  localNode = command.getLocalNode();
    const UUID configID = command.get< UUID >();
    const uint32_t requestID = command.get< uint32_t >();

    LBVERB << "Handle choose config reply " << command << " req " << requestID
           << " id " << configID << std::endl;

    if( configID == UUID::ZERO )
    {
        localNode->serveRequest( requestID, (void*)0 );
        return true;
    }

    const std::string connectionData = command.get< std::string >();
    const Configs& configs = getConfigs();
    for( Configs::const_iterator i = configs.begin(); i != configs.end(); ++i )
    {
        Config* config = *i;
        if( config->getID() == configID )
        {
            config->setupServerConnections( connectionData );
            localNode->serveRequest( requestID, config );
            return true;
        }
    }

    LBUNIMPLEMENTED
    return true;
}
예제 #4
0
bool Server::_cmdShutdownReply( co::ICommand& command )
{
    co::LocalNodePtr localNode = command.getLocalNode();
    const uint32_t requestID = command.get< uint32_t >();
    const bool result = command.get< bool >();
    localNode->serveRequest( requestID, result );
    return true;
}
예제 #5
0
파일: command.cpp 프로젝트: qqdiguo/Collage
 bool _cmdData( co::ICommand& command )
 {
     TEST( _gotAsync );
     command.getNode()->send( CMD_DATA_REPLY )
         << command.get< uint32_t >() << ++_counter;
     TEST( command.get< std::string >() == payload );
     return true;
 }
예제 #6
0
bool Server::_cmdReleaseConfig( co::ICommand& command )
{
    UUID configID = command.get< UUID >();
    uint32_t requestID = command.get< uint32_t >();

    LBVERB << "Handle release config " << command << " config " << configID
           << std::endl;

    co::NodePtr node = command.getNode();

    Config* config = 0;
    const Configs& configs = getConfigs();
    for( Configs::const_iterator i = configs.begin();
         i != configs.end() && !config; ++i )
    {
        Config* candidate = *i;
        if( candidate->getID() == configID )
            config = candidate;
    }

    if( !config )
    {
        LBWARN << "Release request for unknown config" << std::endl;
        node->send( fabric::CMD_SERVER_RELEASE_CONFIG_REPLY ) << requestID;
        return true;
    }

    if( config->isRunning( ))
    {
        LBWARN << "Release of running configuration" << std::endl;
        config->exit(); // Make sure config is exited
    }

    const uint32_t destroyRequestID = registerRequest();
    node->send( fabric::CMD_SERVER_DESTROY_CONFIG )
            << config->getID() << destroyRequestID;
    waitRequest( destroyRequestID );

#ifdef EQUALIZER_USE_HWSD
    if( config->isAutoConfig( ))
    {
        LBASSERT( _admins.empty( ));
        config->deregister();
        config::Server::release( config );
    }
    else
#endif
    {
        ConfigRestoreVisitor restore;
        config->accept( restore );
        config->commit();
    }

    node->send( fabric::CMD_SERVER_RELEASE_CONFIG_REPLY ) << requestID;
    LBLOG( lunchbox::LOG_ANY ) << "----- Released Config -----" << std::endl;
    return true;
}
예제 #7
0
bool Server::_cmdMap( co::ICommand& command )
{
    co::NodePtr node = command.getNode();
    _admins.push_back( node );

    const Configs& configs = getConfigs();
    for( Configs::const_iterator i = configs.begin(); i != configs.end(); ++i )
    {
        Config* config = *i;
        node->send( fabric::CMD_SERVER_CREATE_CONFIG )
                << co::ObjectVersion( config ) << LB_UNDEFINED_UINT32;
    }

    node->send( fabric::CMD_SERVER_MAP_REPLY ) << command.get< uint32_t >();
    return true;
}
예제 #8
0
bool Server::_cmdShutdown( co::ICommand& command )
{
    const uint32_t requestID = command.get< uint32_t >();

    co::NodePtr node = command.getNode();

    if( !_admins.empty( ))
    {
        LBWARN << "Ignoring shutdown request, " << _admins.size()
               << " admin clients connected" << std::endl;

        node->send( fabric::CMD_SERVER_SHUTDOWN_REPLY ) << requestID << false;
        return true;
    }

    const Configs& configs = getConfigs();
    for( Configs::const_iterator i = configs.begin(); i != configs.end(); ++i )
    {
        Config* candidate = *i;
        if( candidate->isUsed( ))
        {
            LBWARN << "Ignoring shutdown request due to used config"
                   << std::endl;

            node->send( fabric::CMD_SERVER_SHUTDOWN_REPLY )
                    << requestID << false;
            return true;
        }
    }

    LBINFO << "Shutting down server" << std::endl;

    _running = false;
    node->send( fabric::CMD_SERVER_SHUTDOWN_REPLY ) << requestID << true;

#ifndef WIN32
    // WAR for 2874188: Lockup at shutdown
    lunchbox::sleep( 100 );
#endif

    return true;
}
예제 #9
0
bool Server::_cmdUnmap( co::ICommand& command )
{
    co::NodePtr node = command.getNode();
    co::Nodes::iterator i = stde::find( _admins, node );

    LBASSERT( i != _admins.end( ));
    if( i != _admins.end( ))
    {
        _admins.erase( i );
        const Configs& configs = getConfigs();
        for( Configs::const_iterator j = configs.begin();
             j != configs.end(); ++j )
        {
            Config* config = *j;
            node->send( fabric::CMD_SERVER_DESTROY_CONFIG )
                    << config->getID() << LB_UNDEFINED_UINT32;
        }
    }

    node->send( fabric::CMD_SERVER_UNMAP_REPLY ) << command.get< uint32_t >();
    return true;
}
예제 #10
0
bool Server::_cmdReleaseConfigReply( co::ICommand& command )
{
    co::LocalNodePtr localNode = command.getLocalNode();
    localNode->serveRequest( command.get< uint32_t >( ));
    return true;
}
예제 #11
0
bool Server::_cmdChooseConfig( co::ICommand& command )
{
    const uint32_t requestID = command.get< uint32_t >();
    const fabric::ConfigParams& params = command.get< fabric::ConfigParams >();

    LBVERB << "Handle choose config " << command << " req " << requestID
           << " renderer " << params.getWorkDir() << '/'
           << params.getRenderClient() << std::endl;

    Config* config = 0;
    const Configs& configs = getConfigs();
    for( ConfigsCIter i = configs.begin(); i != configs.end() && !config; ++i )
    {
        Config* candidate = *i;
        const float version = candidate->getFAttribute( Config::FATTR_VERSION );
        LBASSERT( version == 1.2f );
        if( !candidate->isUsed() && version == 1.2f )
            config = candidate;
    }

#ifdef EQUALIZER_USE_HWSD
    if( !config )
    {
        const std::string& configFile = command.get< std::string >();
        config = config::Server::configure( this, configFile, params );
        if( config )
        {
            config->register_();
            LBINFO << "Configured\n" << *this << std::endl;
        }
    }
#endif

    co::NodePtr node = command.getNode();

    if( !config )
    {
        node->send( fabric::CMD_SERVER_CHOOSE_CONFIG_REPLY )
            << UUID() << requestID;
        return true;
    }

    ConfigBackupVisitor backup;
    config->accept( backup );
    config->setApplicationNetNode( node );
    config->setWorkDir( params.getWorkDir( ));
    config->setRenderClient( params.getRenderClient( ));
    config->commit();

    node->send( fabric::CMD_SERVER_CREATE_CONFIG )
            << co::ObjectVersion( config ) << LB_UNDEFINED_UINT32;

    server::Node* appNode = config->findApplicationNode();
    const co::ConnectionDescriptions& descs =
        appNode->getConnectionDescriptions();

    if( config->getNodes().size() > 1 )
    {
        if( descs.empty() && node->getConnectionDescriptions().empty( ))
        {
            LBWARN << "Likely misconfiguration: Neither the application nor the"
                   << " config file has a connection for this multi-node "
                   << "config. Render clients will be unable to communicate "
                   << "with the application process." << std::endl;
        }
        if( getConnectionDescriptions().empty( ))
        {
            LBWARN << "Likely misconfiguration: The server has no listening "
                   << "connection for this multi-node config. Render clients "
                   << "will be unable to communicate with the server."
                   << std::endl;
        }
    }

    node->send( fabric::CMD_SERVER_CHOOSE_CONFIG_REPLY )
            << config->getID() << requestID << co::serialize( descs );
    return true;
}
예제 #12
0
파일: command.cpp 프로젝트: qqdiguo/Collage
 bool _cmdSync( co::ICommand& command )
 {
     TEST( _gotAsync );
     ackRequest( command.getNode(), command.get< uint32_t >( ));
     return true;
 }