Changeset 183 for osgVisual/trunk/src


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

XML configuration now works also with dataIO cluster

Location:
osgVisual/trunk/src
Files:
4 edited

Legend:

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

    r59 r183  
    2929}
    3030
    31 void dataIO_clusterDummy::init( osg::ArgumentParser& arguments_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool compressionEnabled_, bool asAscii_ )
     31bool dataIO_clusterDummy::init(xmlNode* configurationNode, osgViewer::Viewer* viewer_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool asAscii_)
    3232{
    3333        sendContainer = sendContainer_;
    3434        OSG_NOTIFY( osg::ALWAYS ) << "clusterDummy init();" << std::endl;
     35        return true;
     36}
     37
     38bool dataIO_clusterDummy::processXMLConfiguration(xmlNode* clusterConfig_)
     39{
     40        OSG_NOTIFY( osg::ALWAYS ) << "clusterDummy processXMLConfiguration();" << std::endl;
     41        return true;
    3542}
    3643
     
    4047}
    4148
    42 bool dataIO_clusterDummy::sendTO_OBJvaluesToSlaves()
     49bool dataIO_clusterDummy::sendTO_OBJvaluesToSlaves(osg::Matrixd viewMatrix_)
    4350{
    4451        OSG_NOTIFY( osg::ALWAYS ) << "clusterDummy sendTO_OBJvaluesToSlaves()" << std::endl;
  • 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
  • osgVisual/trunk/src/dataIO/visual_dataIO.cpp

    r160 r183  
    4949void visual_dataIO::init(osgViewer::Viewer* viewer_, osg::ArgumentParser& arguments_, std::string configFileName)
    5050{
    51         OSG_NOTIFY( osg::ALWAYS ) << "visual_dataIO initialize.." << std::endl;
     51        OSG_NOTIFY( osg::ALWAYS ) << "visual_dataIO initialize..";
    5252
    5353        // Init variables
     
    5656        // Process XML configuration
    5757        this->configFileName = configFileName;
    58         if(!processXMLConfiguration())
     58        xmlNode *extLinkConfig=NULL;
     59        if(!processXMLConfiguration(extLinkConfig))
    5960                OSG_FATAL << "ERROR: visual_dataIO::init() - Failed to initialize dataIO via XML configuration!";
    60 
    61 
    62         // Create Cluster.
    63         #ifdef USE_CLUSTER_ASIO_TCP_IOSTREAM
    64                 cluster = new dataIO_clusterAsioTcpIostream();
    65         #endif
    66         #ifdef USE_CLUSTER_ENET
    67                 cluster = new dataIO_clusterENet();
    68                 cluster->enableHardSync( false );       /** \todo : rebuild this structure in cluster.h and move it this way to a general implementation. */
    69         #endif
    70         #ifdef USE_CLUSTER_DUMMY
    71                 cluster = new dataIO_clusterDummy();
    72         #endif
    73         if(cluster.valid())
    74                 //cluster->init(arguments_, clusterMode, slotContainer, true, false);
    75                 cluster->init(arguments_, viewer_, clusterMode, slotContainer, false, false);
    7661
    7762        // Create extLink.
     
    8570
    8671       
    87 
    8872        // Install callbacks to perform DataIO activities every frame:
    8973        //// EventCallback at the absolute beginning of the frame
     
    9781}
    9882
    99 bool visual_dataIO::processXMLConfiguration()
     83bool visual_dataIO::processXMLConfiguration(xmlNode* extLinkConfig_)
    10084{
    10185        // Init XML
     
    10387        bool disabled;
    10488        xmlNode* config = util::getModuleXMLConfig( configFileName, "dataio", tmpDoc, disabled );
     89        xmlNode* clusterConfig = NULL;
    10590
    10691        if( disabled)
    10792                OSG_NOTIFY( osg::ALWAYS ) << "..disabled by XML configuration file. dataIO can't be disabled. Ignoring." << std::endl;
     93        else
     94                OSG_NOTIFY( osg::ALWAYS ) << std::endl;
    10895
    10996        // extract configuration values
     
    152139                        if(cur_node->type == XML_ELEMENT_NODE && node_name == "cluster")
    153140                        {
    154                                 // Check Attributes to determine if the dummy implementation or any other implementation must be instantiated
    155 
    156                                 // Pass XML attributes to cluster to analyse and configure it by cluster itself
     141                                // Pass cluster configuration to the used cluster implementation.
     142                                // The implementation will use the configuration if it matches, otherwise falls back to dummy cluster
     143                                clusterConfig = cur_node;
    157144                        }
    158145
     
    166153
    167154                }       // FOR all nodes END
     155
     156
     157
     158                // Create Cluster.
     159                #ifdef USE_CLUSTER_ASIO_TCP_IOSTREAM
     160                        cluster = new dataIO_clusterAsioTcpIostream();
     161                #endif
     162                #ifdef USE_CLUSTER_ENET
     163                        cluster = new dataIO_clusterENet();
     164                #endif
     165                if( !cluster.valid() || !clusterConfig || !cluster->init(clusterConfig, viewer, clusterMode, slotContainer, false) )
     166                {
     167                        cluster = new dataIO_clusterDummy();
     168                        cluster->init(clusterConfig, viewer, clusterMode, slotContainer, false);
     169                }
     170
     171
    168172
    169173                // clean up
     
    176180                return false;
    177181        }
    178 
    179182        return true;
    180183}
  • osgVisual/trunk/src/sky_Silverlining/visual_skySilverLining.cpp

    r182 r183  
    2121visual_skySilverLining::visual_skySilverLining(osgViewer::Viewer* viewer_, std::string configFileName, bool& disabled)
    2222{
    23         OSG_NOTIFY( osg::ALWAYS ) << "Initialize visual_skySilverlining...";
     23        OSG_NOTIFY( osg::ALWAYS ) << "Initialize visual_skySilverlining..." << std::endl;
    2424
    2525        atmosphereInitialized = false;
     
    4141        if( disabled)
    4242                OSG_NOTIFY( osg::ALWAYS ) << "..disabled by XML configuration file." << std::endl;
    43         else
    44                 OSG_NOTIFY( osg::ALWAYS ) << std::endl;
     43 
    4544        if(config)
    4645                xmlFreeDoc(tmpDoc); xmlCleanupParser();
Note: See TracChangeset for help on using the changeset viewer.