pelican/server/src/PelicanServer.cpp
/**
 * @details
 * Runs the server thread starting its event loop.
 *
 * Sets up the data manager which handles stream and service data buffers
 * which are set up on request of the chunkers.
 */
@details
Runs the server thread starting its event loop.

Sets up the data manager which handles stream and service data buffers
which are set up on request of the chunkers.
@details Runs the server thread starting its event loop . Sets up the data manager which handles stream and service data buffers which are set up on request of the chunkers .
void PelicanServer::run()
{
    try {
        QVector<boost::shared_ptr<PelicanPortServer> > servers;
        DataManager dataManager(_config);
        dataManager.setVerbosity(_verboseLevel);
        _chunkerManager->init(dataManager);
        QList<quint16> ports = _protocolPortMap.keys();
        for (int i = 0; i < ports.size(); ++i) {
            boost::shared_ptr<PelicanPortServer> server(
                    new PelicanPortServer(_protocolPortMap[ports[i]], &dataManager) );
            server->setVerbosity(_verboseLevel);
            servers.append(server);
            if ( !server->listen(QHostAddress::Any, ports[i]) )
                throw QString("Cannot run PelicanServer on port %1").arg(ports[i]);
            verbose( QString("PelicanServer: listening on port %1").arg(ports[i]), 1 );
        }
        _mutex.lock();
        _ready = true;
        _mutex.unlock();
        exec();
    }
    catch( QString& e ) {
        std::cerr << "PelicanServer caught an error: " << e.toStdString() << std::endl;
        verbose(QString("Shutting down server thread: ") + e);
        exit(1);
    }
}
void PelicanServer :: run ( ) { try { QVector < boost :: shared_ptr < PelicanPortServer > > servers ; DataManager dataManager ( _config ) ; dataManager . setVerbosity ( _verboseLevel ) ; _chunkerManager -> init ( dataManager ) ; QList < quint16 > ports = _protocolPortMap . keys ( ) ; for ( int i = 0 ; i < ports . size ( ) ; ++ i ) { boost :: shared_ptr < PelicanPortServer > server ( new PelicanPortServer ( _protocolPortMap [ ports [ i ] ] , & dataManager ) ) ; server -> setVerbosity ( _verboseLevel ) ; servers . append ( server ) ; if ( ! server -> listen ( QHostAddress :: Any , ports [ i ] ) ) throw QString ( " " ) . arg ( ports [ i ] ) ; verbose ( QString ( " " ) . arg ( ports [ i ] ) , 1 ) ; } _mutex . lock ( ) ; _ready = true ; _mutex . unlock ( ) ; exec ( ) ; } catch ( QString & e ) { std :: cerr << " " << e . toStdString ( ) << std :: endl ; verbose ( QString ( " " ) + e ) ; exit ( 1 ) ; } }
@details
 Runs the server thread starting its event loop.
@details Runs the server thread starting its event loop .
// Set up the data manager. // Set up listening servers. // Set ready flag. // Enter the server's event loop.