Ignore:
Timestamp:
Jan 7, 2011, 5:41:45 PM (13 years ago)
Author:
Torben Dannhauer
Message:

XML configuration now works also with dataIO cluster

File:
1 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/src/cluster/dataIO_clusterENet.cpp

    r88 r183  
    3535
    3636
    37 void dataIO_clusterENet::init( osg::ArgumentParser& arguments_, osgViewer::Viewer* viewer_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool compressionEnabled_, bool asAscii_ )
    38 {
     37bool dataIO_clusterENet::init(xmlNode* configurationNode, osgViewer::Viewer* viewer_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool asAscii_)
     38{
     39        if (!configurationNode || !processXMLConfiguration(configurationNode))
     40                return false;
     41
    3942        OSG_NOTIFY( osg::ALWAYS ) << "clusterENet init();" << std::endl;
    4043       
     
    5659                writeOptionString = "Ascii";
    5760        }
    58         if (compressionEnabled_)
     61        if (compressionEnabled)
    5962                writeOptionString+=" Compressor=zlib";
    6063        readOptions = new osgDB::Options( readOptionString.c_str() );
     
    7780        if(clusterMode == SLAVE)
    7881        {
    79                 // Get the server IP
    80                 if(!arguments_.read("--server",serverToConnect, port))
    81                 {
    82                         // try server discovery
    83                         //discoverServer(serverToConnect,port);
    84                         /* todo : implement a udp server discovery based on ASIO */
    85                 }
    86 
    8782                // Init ENet
    8883                enet_impl->init(dataIO_clusterENet_implementation::CLIENT, port);
     
    105100                        initialized = false;
    106101                        std::cout << "Finally failed to establish connection to server " << serverToConnect << std::endl;
    107                         exit(-1);
     102                        return false;
    108103                }
    109104        }       // IF SLAVE END
     105
     106        return true;
     107}
     108
     109bool dataIO_clusterENet::processXMLConfiguration(xmlNode* clusterConfig_)
     110{
     111                                // Extract cluster role
     112                                xmlAttr  *attr = clusterConfig_->properties;
     113                                while ( attr )
     114                                {
     115                                        std::string attr_name=reinterpret_cast<const char*>(attr->name);
     116                                        std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     117                                        if( attr_name == "implementation" )
     118                                        {
     119                                                if(attr_value != "enet")
     120                                                {
     121                                                        OSG_NOTIFY( osg::ALWAYS ) << "WARNING: Cluster configuration does not match the 'enet' implementation, falling back to clusterDummy" << std::endl;
     122                                                        return false;
     123                                                }
     124                                        }
     125                                        if( attr_name == "hardsync" )
     126                                        {
     127                                                if(attr_value == "yes")
     128                                                        hardSync = true;
     129                                                else
     130                                                        hardSync = false;
     131                                        }
     132                                        if( attr_name == "master_ip" )
     133                                        {
     134                                                serverToConnect = attr_value;
     135                                        }
     136                                        if( attr_name == "port" )
     137                                        {
     138                                                std::istringstream i(attr_value);
     139                                                if (!(i >> port))
     140                                                {
     141                                                        OSG_NOTIFY( osg::ALWAYS ) << "WARNING: Cluster configuration : Invalid port number '" << attr_value << "', falling back to clusterDummy" << std::endl;
     142                                                        return false;
     143                                                }
     144                                        }
     145                                        if( attr_name == "use_zlib_compressor" )
     146                                        {
     147                                                if(attr_value == "yes")
     148                                                        compressionEnabled = true;
     149                                                else
     150                                                        compressionEnabled = false;
     151                                        }
     152                                        attr = attr->next;
     153                                }       // WHILE attrib END
     154
     155        return true;
    110156}
    111157
Note: See TracChangeset for help on using the changeset viewer.