[complement-svn] SF.net SVN: complement: [1408] trunk/complement/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2006-11-24 18:56:32
|
Revision: 1408 http://svn.sourceforge.net/complement/?rev=1408&view=rev Author: complement Date: 2006-11-24 10:53:01 -0800 (Fri, 24 Nov 2006) Log Message: ----------- local delivery work fine; local nameservice work too; polish global id usage Modified Paths: -------------- trunk/complement/explore/include/stem/Event.h trunk/complement/explore/include/stem/EventHandler.h trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/EvManager.cc trunk/complement/explore/lib/stem/Names.cc trunk/complement/explore/lib/stem/NetTransport.cc trunk/complement/explore/lib/stem/_EventHandler.cc trunk/complement/explore/test/libstem/unit/NameService.cc trunk/complement/explore/test/libstem/unit/NameService.h trunk/complement/explore/test/libstem/unit/unit_test.cc Modified: trunk/complement/explore/include/stem/Event.h =================================================================== --- trunk/complement/explore/include/stem/Event.h 2006-11-24 18:47:01 UTC (rev 1407) +++ trunk/complement/explore/include/stem/Event.h 2006-11-24 18:53:01 UTC (rev 1408) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/24 14:50:06 ptr> +// -*- C++ -*- Time-stamp: <06/11/24 20:57:55 ptr> /* * @@ -109,6 +109,24 @@ struct gaddr_type : public __pack_base { + gaddr_type() : + hid(), + pid( -1 ), + addr( badaddr ) + { } + + gaddr_type( const xmt::uuid_type& _hid, pid_t _pid, stem::addr_type _addr ) : + hid( _hid ), + pid( _pid ), + addr( _addr ) + { } + + gaddr_type( const gaddr_type& g ) : + hid( g.hid ), + pid( g.pid ), + addr( g.addr ) + { } + xmt::uuid_type hid; int64_t pid; // pid_t defined as int, so it may be int64_t stem::addr_type addr; @@ -118,6 +136,9 @@ __FIT_DECLSPEC virtual void net_pack( std::ostream& ) const; __FIT_DECLSPEC virtual void net_unpack( std::istream& ); + gaddr_type& operator =( const gaddr_type& g ) + { hid = g.hid; pid = g.pid; addr = g.addr; return *this; } + bool operator ==( const gaddr_type& ga ) const { return hid == ga.hid && pid == ga.pid && addr == ga.addr; } bool operator !=( const gaddr_type& ga ) const Modified: trunk/complement/explore/include/stem/EventHandler.h =================================================================== --- trunk/complement/explore/include/stem/EventHandler.h 2006-11-24 18:47:01 UTC (rev 1407) +++ trunk/complement/explore/include/stem/EventHandler.h 2006-11-24 18:53:01 UTC (rev 1408) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/10/12 14:12:15 ptr> +// -*- C++ -*- Time-stamp: <06/11/24 20:32:06 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -636,6 +636,8 @@ addr_type self_id() const { return _id; } + __FIT_DECLSPEC gaddr_type self_glid() const; + void State( state_type state ) { PushState( state ); } __FIT_DECLSPEC void PushState( state_type state ); Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2006-11-24 18:47:01 UTC (rev 1407) +++ trunk/complement/explore/lib/stem/ChangeLog 2006-11-24 18:53:01 UTC (rev 1408) @@ -9,9 +9,13 @@ addresses and message routing logic. * Names.cc, Names.h, EDSEv.h: return gloabal addresses - list; remove obsolete requests/responses; + list, addresses not associated with communication channel; + remove obsolete NS requests/responses; + + * _EventHandler.cc, EventHandler.h: object can return + own global id. - * Makefile.inc: _EvSession.cc, _SessionMgr.cc removed + * Makefile.inc: _EvSession.cc and _SessionMgr.cc removed from compilation; library version 4.2.0 2006-10-12 Petr Ovtchenkov <pt...@is...> Modified: trunk/complement/explore/lib/stem/EvManager.cc =================================================================== --- trunk/complement/explore/lib/stem/EvManager.cc 2006-11-24 18:47:01 UTC (rev 1407) +++ trunk/complement/explore/lib/stem/EvManager.cc 2006-11-24 18:53:01 UTC (rev 1408) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/24 17:17:05 ptr> +// -*- C++ -*- Time-stamp: <06/11/24 20:11:46 ptr> /* * @@ -112,15 +112,22 @@ { addr_type id; { - Locker _x1( _lock_heap ); + Locker lk( _lock_heap ); id = create_unique(); heap[id] = object; } { - Locker _x1( _lock_iheap ); - iheap[id] = info; + Locker lk( _lock_xheap ); + gaddr_type& gaddr = _ex_heap[id]; + gaddr.hid = xmt::hostid(); + gaddr.pid = getpid(); + gaddr.addr = id; + _ui_heap[gaddr] = id; } + Locker lk( _lock_iheap ); + iheap[id] = info; + return id; } @@ -133,6 +140,14 @@ id = create_unique(); heap[id] = object; } + { + Locker lk( _lock_xheap ); + gaddr_type& gaddr = _ex_heap[id]; + gaddr.hid = xmt::hostid(); + gaddr.pid = getpid(); + gaddr.addr = id; + _ui_heap[gaddr] = id; + } if ( info ) { Locker _x1( _lock_iheap ); iheap[id] = info; @@ -154,6 +169,14 @@ } heap[id] = object; } + { + Locker lk( _lock_xheap ); + gaddr_type& gaddr = _ex_heap[id]; + gaddr.hid = xmt::hostid(); + gaddr.pid = getpid(); + gaddr.addr = id; + _ui_heap[gaddr] = id; + } Locker _x1( _lock_iheap ); iheap[id] = info; @@ -174,6 +197,14 @@ } heap[id] = object; } + { + Locker lk( _lock_xheap ); + gaddr_type& gaddr = _ex_heap[id]; + gaddr.hid = xmt::hostid(); + gaddr.pid = getpid(); + gaddr.addr = id; + _ui_heap[gaddr] = id; + } if ( info ) { Locker _x1( _lock_iheap ); iheap[id] = info; Modified: trunk/complement/explore/lib/stem/Names.cc =================================================================== --- trunk/complement/explore/lib/stem/Names.cc 2006-11-24 18:47:01 UTC (rev 1407) +++ trunk/complement/explore/lib/stem/Names.cc 2006-11-24 18:53:01 UTC (rev 1408) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/24 18:19:55 ptr> +// -*- C++ -*- Time-stamp: <06/11/24 20:17:46 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 @@ -22,6 +22,8 @@ #include <list> #include <mt/xmt.h> +#include <iostream> + namespace stem { using namespace std; Modified: trunk/complement/explore/lib/stem/NetTransport.cc =================================================================== --- trunk/complement/explore/lib/stem/NetTransport.cc 2006-11-24 18:47:01 UTC (rev 1407) +++ trunk/complement/explore/lib/stem/NetTransport.cc 2006-11-24 18:53:01 UTC (rev 1408) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/24 17:09:01 ptr> +// -*- C++ -*- Time-stamp: <06/11/24 21:44:47 ptr> /* * @@ -288,6 +288,8 @@ if ( net->good() ) { // _net_ns = rar_map( ns_addr, __ns_at + hostname ); // addr_type zero_object = rar_map( 0, __at + hostname ); + detail::transport tr( static_cast<NetTransport_base *>(this), detail::transport::socket_tcp, 10 ); + // addr_type zero_object = manager()->SubscribeRemote( tr, src ); _thr.launch( _loop, this, 0, PTHREAD_STACK_MIN * 2 ); // start thread here return 0; // zero_object; } Modified: trunk/complement/explore/lib/stem/_EventHandler.cc =================================================================== --- trunk/complement/explore/lib/stem/_EventHandler.cc 2006-11-24 18:47:01 UTC (rev 1407) +++ trunk/complement/explore/lib/stem/_EventHandler.cc 2006-11-24 18:53:01 UTC (rev 1408) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/10/12 14:09:20 ptr> +// -*- C++ -*- Time-stamp: <06/11/24 20:59:03 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -41,7 +41,7 @@ EventHandler::Init::Init() { MT_REENTRANT_RS( _init_lock, _x ); - if ( _count++ == 0 ) { + if ( _count++ == 0 ) { EventHandler::_mgr = new EvManager(); stem::_ns = new Names( ns_addr, _ns_name ); } @@ -236,4 +236,10 @@ out << endl; } +__FIT_DECLSPEC +gaddr_type EventHandler::self_glid() const +{ + return gaddr_type(xmt::hostid(), getpid(), _id ); +} + } // namespace stem Modified: trunk/complement/explore/test/libstem/unit/NameService.cc =================================================================== --- trunk/complement/explore/test/libstem/unit/NameService.cc 2006-11-24 18:47:01 UTC (rev 1407) +++ trunk/complement/explore/test/libstem/unit/NameService.cc 2006-11-24 18:53:01 UTC (rev 1408) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/10/04 10:57:46 ptr> +// -*- C++ -*- Time-stamp: <06/11/24 20:14:45 ptr> /* * Copyright (c) 2006 @@ -40,40 +40,18 @@ // cnd.wait(); } -void Naming::names_list( const stem::NameRecord& nr ) +void Naming::names_list( const nsrecords_type& nr ) { // std::cerr << hex << nr.addr << " " << nr.record << dec << endl; + copy( nr.container.begin(), nr.container.end(), back_insert_iterator<nsrecords_type::container_type>(lst) ); - if ( nr.addr == stem::badaddr ) { // the last record - cnd.set(true); - } else { - lst.push_back( nr ); - } -} - -void Naming::names_name( const stem::NameRecord& nr ) -{ - // std::cerr << hex << nr.addr << dec << endl; - - if ( nr.addr == stem::badaddr ) { // the last record - cnd.set(true); - } else { - lst.push_back( nr ); - } -} - -void Naming::names_list1( const nsrecords_type& nr ) -{ - // std::cerr << hex << nr.addr << " " << nr.record << dec << endl; - copy( nr.container.begin(), nr.container.end(), back_insert_iterator<nsrecords_type::container_type>(lst1) ); - cnd.set(true); } -void Naming::names_name1( const nsrecords_type& nr ) +void Naming::names_name( const nsrecords_type& nr ) { // std::cerr << hex << nr.addr << dec << endl; - copy( nr.container.begin(), nr.container.end(), back_insert_iterator<nsrecords_type::container_type>(lst1) ); + copy( nr.container.begin(), nr.container.end(), back_insert_iterator<nsrecords_type::container_type>(lst) ); cnd.set(true); } @@ -84,8 +62,6 @@ } DEFINE_RESPONSE_TABLE( Naming ) - EV_T_(0,EV_EDS_NM_LIST,names_list,stem::NameRecord) - EV_T_(0,EV_EDS_NS_ADDR,names_name,stem::NameRecord) - EV_T_(0,EV_STEM_NS1_LIST,names_list1,nsrecords_type) - EV_T_(0,EV_STEM_NS1_NAME,names_name1,nsrecords_type) + EV_T_(0,EV_STEM_NS_LIST,names_list,nsrecords_type) + EV_T_(0,EV_STEM_NS_NAME,names_name,nsrecords_type) END_RESPONSE_TABLE Modified: trunk/complement/explore/test/libstem/unit/NameService.h =================================================================== --- trunk/complement/explore/test/libstem/unit/NameService.h 2006-11-24 18:47:01 UTC (rev 1407) +++ trunk/complement/explore/test/libstem/unit/NameService.h 2006-11-24 18:53:01 UTC (rev 1408) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/10/04 10:55:44 ptr> +// -*- C++ -*- Time-stamp: <06/11/24 19:33:11 ptr> /* * Copyright (c) 2006 @@ -24,20 +24,16 @@ Naming( stem::addr_type id ); ~Naming(); - void names_list( const stem::NameRecord& ); - void names_name( const stem::NameRecord& ); + typedef stem::NameRecords<stem::gaddr_type,std::string> nsrecords_type; - typedef stem::NameRecords<stem::addr_type,std::string> nsrecords_type; + void names_list( const nsrecords_type& ); + void names_name( const nsrecords_type& ); - void names_list1( const nsrecords_type& ); - void names_name1( const nsrecords_type& ); - void wait(); void reset() { cnd.set( false ); } - std::list<stem::NameRecord> lst; - nsrecords_type::container_type lst1; + nsrecords_type::container_type lst; private: xmt::Condition cnd; Modified: trunk/complement/explore/test/libstem/unit/unit_test.cc =================================================================== --- trunk/complement/explore/test/libstem/unit/unit_test.cc 2006-11-24 18:47:01 UTC (rev 1407) +++ trunk/complement/explore/test/libstem/unit/unit_test.cc 2006-11-24 18:53:01 UTC (rev 1408) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/10/12 15:15:13 ptr> +// -*- C++ -*- Time-stamp: <06/11/24 21:05:01 ptr> /* * Copyright (c) 2002, 2003, 2006 @@ -45,7 +45,6 @@ void basic2new(); void dl(); void ns(); - void ns1(); void echo(); void peer(); @@ -176,53 +175,63 @@ Node node( 2003, "Node" ); Naming nm; - stem::Event ev( EV_EDS_RQ_ADDR_LIST ); + stem::Event ev( EV_STEM_GET_NS_LIST ); ev.dest( stem::ns_addr ); nm.Send( ev ); nm.wait(); - list<stem::NameRecord>::const_iterator i = find( nm.lst.begin(), nm.lst.end(), string( "ns" ) ); + // this is sample of all inline find: + Naming::nsrecords_type::const_iterator i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( equal_to<string>(), string( "ns" ) ), select2nd<pair<stem::gaddr_type,string> >() ) ); BOOST_CHECK( i != nm.lst.end() ); - BOOST_CHECK( i->record == "ns" ); - BOOST_CHECK( i->addr == stem::ns_addr ); + BOOST_CHECK( i->second == "ns" ); + BOOST_CHECK( i->first.hid == xmt::hostid() ); + BOOST_CHECK( i->first.pid == getpid() ); + BOOST_CHECK( i->first.addr == stem::ns_addr ); - i = find( nm.lst.begin(), nm.lst.end(), string( "Node" ) ); + // well, but for few seaches declare and reuse functors: + equal_to<string> eq; + equal_to<stem::gaddr_type> eqa; + select1st<pair<stem::gaddr_type,string> > first; + select2nd<pair<stem::gaddr_type,string> > second; + + i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "Node" ) ), second ) ); + BOOST_CHECK( i != nm.lst.end() ); - BOOST_CHECK( i->record == "Node" ); - BOOST_CHECK( i->addr == 2003 ); + BOOST_CHECK( i->second == "Node" ); + BOOST_CHECK( i->first.addr == 2003 ); - i = find( nm.lst.begin(), nm.lst.end(), nm.self_id() ); + i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eqa, nm.self_glid() ), first ) ); BOOST_CHECK( i != nm.lst.end() ); - BOOST_CHECK( i->addr == nm.self_id() ); - BOOST_CHECK( i->record.length() == 0 ); + BOOST_CHECK( i->first == nm.self_glid() ); + BOOST_CHECK( i->second.length() == 0 ); nm.lst.clear(); nm.reset(); BOOST_CHECK( nm.lst.empty() ); - stem::Event evname( EV_EDS_RQ_ADDR_BY_NAME ); + stem::Event evname( EV_STEM_GET_NS_NAME ); evname.dest( stem::ns_addr ); evname.value() = "Node"; nm.Send( evname ); nm.wait(); - i = find( nm.lst.begin(), nm.lst.end(), string( "ns" ) ); + i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "ns" ) ), second ) ); BOOST_CHECK( i == nm.lst.end() ); - i = find( nm.lst.begin(), nm.lst.end(), string( "Node" ) ); + i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "Node" ) ), second ) ); BOOST_CHECK( i != nm.lst.end() ); - BOOST_CHECK( i->record == "Node" ); - BOOST_CHECK( i->addr == 2003 ); + BOOST_CHECK( i->second == "Node" ); + BOOST_CHECK( i->first.addr == 2003 ); - i = find( nm.lst.begin(), nm.lst.end(), nm.self_id() ); + i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eqa, nm.self_glid() ), first ) ); BOOST_CHECK( i == nm.lst.end() ); @@ -239,82 +248,6 @@ BOOST_CHECK( nm.lst.empty() ); } -void stem_test::ns1() -{ - Node node( 2003, "Node" ); - Naming nm; - - stem::Event ev( EV_STEM_RQ_ADDR_LIST1 ); - ev.dest( stem::ns_addr ); - nm.Send( ev ); - - nm.wait(); - - // this is sample of all inline find: - Naming::nsrecords_type::const_iterator i = find_if( nm.lst1.begin(), nm.lst1.end(), compose1( bind2nd( equal_to<string>(), string( "ns" ) ), select2nd<pair<stem::addr_type,string> >() ) ); - - BOOST_CHECK( i != nm.lst1.end() ); - BOOST_CHECK( i->second == "ns" ); - BOOST_CHECK( i->first == stem::ns_addr ); - - // well, but for few seaches declare and reuse functors: - equal_to<string> eq; - equal_to<stem::addr_type> eqa; - - select1st<pair<stem::addr_type,string> > first; - select2nd<pair<stem::addr_type,string> > second; - - i = find_if( nm.lst1.begin(), nm.lst1.end(), compose1( bind2nd( eq, string( "Node" ) ), second ) ); - - BOOST_CHECK( i != nm.lst1.end() ); - BOOST_CHECK( i->second == "Node" ); - BOOST_CHECK( i->first == 2003 ); - - i = find_if( nm.lst1.begin(), nm.lst1.end(), compose1( bind2nd( eqa, nm.self_id() ), first ) ); - - BOOST_CHECK( i != nm.lst1.end() ); - BOOST_CHECK( i->first == nm.self_id() ); - BOOST_CHECK( i->second.length() == 0 ); - - nm.lst1.clear(); - nm.reset(); - - BOOST_CHECK( nm.lst1.empty() ); - - stem::Event evname( EV_STEM_RQ_ADDR_BY_NAME1 ); - evname.dest( stem::ns_addr ); - evname.value() = "Node"; - nm.Send( evname ); - - nm.wait(); - - i = find_if( nm.lst1.begin(), nm.lst1.end(), compose1( bind2nd( eq, string( "ns" ) ), second ) ); - - BOOST_CHECK( i == nm.lst1.end() ); - - i = find_if( nm.lst1.begin(), nm.lst1.end(), compose1( bind2nd( eq, string( "Node" ) ), second ) ); - - BOOST_CHECK( i != nm.lst1.end() ); - BOOST_CHECK( i->second == "Node" ); - BOOST_CHECK( i->first == 2003 ); - - i = find_if( nm.lst1.begin(), nm.lst1.end(), compose1( bind2nd( eqa, nm.self_id() ), first ) ); - - BOOST_CHECK( i == nm.lst1.end() ); - - nm.lst1.clear(); - nm.reset(); - - BOOST_CHECK( nm.lst1.empty() ); - - evname.value() = "No-such-name"; - nm.Send( evname ); - - nm.wait(); - - BOOST_CHECK( nm.lst1.empty() ); -} - void stem_test::echo() { try { @@ -352,7 +285,7 @@ void stem_test::peer() { - +#if 0 /* * Scheme: * / NetTransport / c1 @@ -449,6 +382,7 @@ srv.close(); srv.wait(); +#endif } struct stem_test_suite : @@ -469,7 +403,6 @@ test_case *basic2n_tc = BOOST_CLASS_TEST_CASE( &stem_test::basic2new, instance ); test_case *dl_tc = BOOST_CLASS_TEST_CASE( &stem_test::dl, instance ); test_case *ns_tc = BOOST_CLASS_TEST_CASE( &stem_test::ns, instance ); - test_case *ns1_tc = BOOST_CLASS_TEST_CASE( &stem_test::ns1, instance ); test_case *echo_tc = BOOST_CLASS_TEST_CASE( &stem_test::echo, instance ); test_case *peer_tc = BOOST_CLASS_TEST_CASE( &stem_test::peer, instance ); @@ -479,7 +412,6 @@ basic2n_tc->depends_on( basic1n_tc ); dl_tc->depends_on( basic2n_tc ); ns_tc->depends_on( basic1_tc ); - ns1_tc->depends_on( basic1_tc ); echo_tc->depends_on( basic2_tc ); peer_tc->depends_on( echo_tc ); @@ -490,7 +422,6 @@ add( basic2n_tc ); add( dl_tc ); add( ns_tc ); - add( ns1_tc ); add( echo_tc ); add( peer_tc ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |