diff options
author | huangming <huangminghuang@users.noreply.github.com> | 2003-11-22 18:49:25 +0000 |
---|---|---|
committer | huangming <huangminghuang@users.noreply.github.com> | 2003-11-22 18:49:25 +0000 |
commit | 6aed8df739c1f28b92c77d96e267d35220674875 (patch) | |
tree | 1ad23598284a2e87ef5ebaf8c00f217cf8eb44bd | |
parent | 7247209a8c13c53e74317c0fbb5d2568dfc9afa9 (diff) | |
download | ATCD-6aed8df739c1f28b92c77d96e267d35220674875.tar.gz |
*** empty log message ***
20 files changed, 233 insertions, 138 deletions
diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Primary_Replication_Strategy.cpp b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Primary_Replication_Strategy.cpp index 9b93e4da855..91973a8a12c 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Primary_Replication_Strategy.cpp +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Primary_Replication_Strategy.cpp @@ -179,7 +179,7 @@ AMI_Primary_Replication_Strategy::replicate_request( } -void +void AMI_Primary_Replication_Strategy::add_member(const FTRT::ManagerInfo & info, CORBA::ULong object_group_ref_version ACE_ENV_ARG_DECL) @@ -198,18 +198,18 @@ AMI_Primary_Replication_Strategy::add_member(const FTRT::ManagerInfo & info, TAO::Utils::Implicit_Deactivator deactivator(&add_member_handler); - CORBA::Object_var obj = + CORBA::Object_var obj = root_poa_->id_to_reference(oid.in() ACE_ENV_ARG_PARAMETER); ACE_CHECK; - FTRT::AMI_ObjectGroupManagerHandler_var handler = + FTRT::AMI_ObjectGroupManagerHandler_var handler = FTRT::AMI_ObjectGroupManagerHandler::_narrow(obj.in() ACE_ENV_ARG_PARAMETER); for (unsigned i = 0; i < num_backups; ++i) { ACE_TRY { backups[i].in()->sendc_add_member(handler.in(), info, - object_group_ref_version + object_group_ref_version ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; } @@ -218,7 +218,7 @@ AMI_Primary_Replication_Strategy::add_member(const FTRT::ManagerInfo & info, } ACE_ENDTRY; } - // decrement the number of members so the event can be signaled once + // decrement the number of members so the event can be signaled once // all replys have been received. add_member_handler.add_member_excep(NULL); diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Primary_Replication_Strategy.h b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Primary_Replication_Strategy.h index 5d7ed81b3e3..d40adbe3786 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Primary_Replication_Strategy.h +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Primary_Replication_Strategy.h @@ -33,7 +33,7 @@ class AMI_Primary_Replication_Strategy : public Replication_Strategy { public: /** - * @param mt Specifies whether multithreaded ORB is used. + * @param mt Specifies whether multithreaded ORB is used. */ AMI_Primary_Replication_Strategy(bool mt); virtual ~AMI_Primary_Replication_Strategy(); diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Replication_Strategy.cpp b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Replication_Strategy.cpp index 1772fce6b76..b343c0e9af7 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Replication_Strategy.cpp +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Replication_Strategy.cpp @@ -28,7 +28,7 @@ AMI_Replication_Strategy::replicate_request( ACE_UNUSED_ARG(oid); } -void +void AMI_Replication_Strategy::add_member(const FTRT::ManagerInfo & info, CORBA::ULong object_group_ref_version ACE_ENV_ARG_DECL_NOT_USED) diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Replication_Strategy.h b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Replication_Strategy.h index 537c4ae0099..d99dc087eee 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Replication_Strategy.h +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/AMI_Replication_Strategy.h @@ -32,7 +32,7 @@ class AMI_Replication_Strategy: public Replication_Strategy { public: /** - * @param mt Specifies whether multithreaded ORB is used. + * @param mt Specifies whether multithreaded ORB is used. */ AMI_Replication_Strategy(bool mt); ~AMI_Replication_Strategy(); diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Basic_Replication_Strategy.cpp b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Basic_Replication_Strategy.cpp index 524431a10f3..99f7b816696 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Basic_Replication_Strategy.cpp +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Basic_Replication_Strategy.cpp @@ -10,7 +10,7 @@ ACE_RCSID (EventChannel, Basic_Replication_Strategy, "$Id$") -/// The mutex has to be recursive; otherwise, if the second replicate_request() is +/// The mutex has to be recursive; otherwise, if the second replicate_request() is /// called while the first replicate_request() is waiting for reply, we will get /// a deadlock. Basic_Replication_Strategy::Basic_Replication_Strategy(bool mt) @@ -81,14 +81,25 @@ Basic_Replication_Strategy::replicate_request( Request_Context_Repository().set_transaction_depth(transaction_depth-1 ACE_ENV_ARG_PARAMETER); ACE_CHECK; - TAO_FTRTEC::Log::hexdump(4, (const char*)state.get_buffer(), state.length(), " sending state "); if (transaction_depth > 1) { - successor->set_update(state ACE_ENV_ARG_PARAMETER); + bool finished = true; + do { + ACE_TRY_EX(SET_UPDATE) { + successor->set_update(state ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK_EX(SET_UPDATE); + } + ACE_CATCH(CORBA::COMM_FAILURE, ex) { + if (ex.minor() == 6) finished = false; + else ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; + } while(!finished); } else { - ACE_TRY { + ACE_TRY_EX(ONEWAY_SET_UPDATE) { successor->oneway_set_update(state ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_TRY_CHECK_EX(ONEWAY_SET_UPDATE); } ACE_CATCHANY { } @@ -101,13 +112,25 @@ Basic_Replication_Strategy::replicate_request( } } -void +void Basic_Replication_Strategy::add_member(const FTRT::ManagerInfo & info, CORBA::ULong object_group_ref_version ACE_ENV_ARG_DECL_NOT_USED) { FtRtecEventChannelAdmin::EventChannel_var successor = GroupInfoPublisher::instance()->successor(); - successor->add_member(info, object_group_ref_version ACE_ENV_ARG_PARAMETER); + bool finished = true; + do { + ACE_TRY { + successor->add_member(info, object_group_ref_version ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH(CORBA::COMM_FAILURE, ex) { + if (ex.minor() == 6) finished = false; + else ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; + } while (!finished); } int Basic_Replication_Strategy::acquire_read (void) diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Basic_Replication_Strategy.h b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Basic_Replication_Strategy.h index 63ade2a797b..09244173bf5 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Basic_Replication_Strategy.h +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Basic_Replication_Strategy.h @@ -28,7 +28,7 @@ class Basic_Replication_Strategy : public Replication_Strategy { public: /** - * @param mt Specifies whether multithreaded ORB is used. + * @param mt Specifies whether multithreaded ORB is used. */ Basic_Replication_Strategy(bool mt); ~Basic_Replication_Strategy(); diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Event_Channel.cpp b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Event_Channel.cpp index 6b8bdbfba04..859c6674b3f 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Event_Channel.cpp +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Event_Channel.cpp @@ -46,10 +46,11 @@ void setup_object_group(TAO_FTEC_Event_Channel* es, member_list[0].the_location = Fault_Detector::instance()->my_location(); member_list[0].ior = FTRT::ObjectGroupManager::_duplicate(ec); - if (membership == TAO_FTEC_Event_Channel::PRIMARY) + if (membership == TAO_FTEC_Event_Channel::PRIMARY) { es->create_group(member_list, 0 ACE_ENV_ARG_PARAMETER); - + ACE_CHECK; + } else { // BACKUP FtRtecEventChannelAdmin::EventChannel_var primary = resolve<FtRtecEventChannelAdmin::EventChannel>(naming_context, @@ -59,9 +60,20 @@ void setup_object_group(TAO_FTEC_Event_Channel* es, TAO_FTRTEC::Log(1, "Got Primary address from Naming Service\n"); - primary->join_group(member_list[0] ACE_ENV_ARG_PARAMETER); + bool finished = true; + do { + ACE_TRY { + primary->join_group(member_list[0] ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH(CORBA::COMM_FAILURE, ex) { + if (ex.minor() == 6) finished = false; + else ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; + } while(! finished); } - ACE_CHECK; } } diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Event_Channel_Impl.cpp b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Event_Channel_Impl.cpp index 0f0869e32e0..81dda05ae1a 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Event_Channel_Impl.cpp +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Event_Channel_Impl.cpp @@ -153,7 +153,7 @@ namespace { TAO_FTEC_ProxyPushSupplier* proxy = ec->find_proxy_push_supplier(op.object_id); - if (proxy == NULL) {// proxy not found + if (proxy == NULL) {// proxy not found TAO_FTRTEC::Log(3, "Throwing FTRT::InvalidUpdate\n"); ACE_THROW(FTRT::InvalidUpdate()); } @@ -450,7 +450,7 @@ void TAO_FTEC_Event_Channel_Impl::suspend_push_supplier ( TAO_FTEC_ProxyPushSupplier* proxy = this->find_proxy_push_supplier(oid); - if (proxy == NULL) { // proxy not found + if (proxy == NULL) { // proxy not found TAO_FTRTEC::Log(3, "Throwing FtRtecEventComm::InvalidObjectID\n"); ACE_THROW(FtRtecEventComm::InvalidObjectID()); } @@ -472,7 +472,7 @@ void TAO_FTEC_Event_Channel_Impl::resume_push_supplier ( TAO_FTEC_ProxyPushSupplier* proxy = this->find_proxy_push_supplier(oid); - if (proxy == NULL) { // proxy not found + if (proxy == NULL) { // proxy not found TAO_FTRTEC::Log(3, "Throwing FtRtecEventComm::InvalidObjectID\n"); ACE_THROW(FtRtecEventComm::InvalidObjectID()); } @@ -491,7 +491,7 @@ void TAO_FTEC_Event_Channel_Impl::push ( FTRTEC_TRACE("TAO_FTEC_Event_Channel_Impl::push"); TAO_FTEC_ProxyPushConsumer* proxy = this->find_proxy_push_consumer(oid); - if (proxy == NULL) { // proxy not found + if (proxy == NULL) { // proxy not found TAO_FTRTEC::Log(3, "Throwing FtRtecEventComm::InvalidObjectID\n"); ACE_THROW(FtRtecEventComm::InvalidObjectID()); } diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Group_Manager.cpp b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Group_Manager.cpp index a01bdaae252..68439bc8b86 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Group_Manager.cpp +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Group_Manager.cpp @@ -66,7 +66,6 @@ struct TAO_FTEC_Group_Manager_Impl { FTRT::ManagerInfoList info_list; unsigned my_position; - FTRT::FaultListener_var listener; }; TAO_FTEC_Group_Manager::TAO_FTEC_Group_Manager() @@ -89,7 +88,7 @@ CORBA::Boolean TAO_FTEC_Group_Manager::start ( CORBA::SystemException )) { - impl_->listener = listener; + listener_ = listener; ACE_NEW_RETURN(cur , FTRT::Location(Fault_Detector::instance()->my_location()), false); return true; } @@ -101,26 +100,20 @@ void TAO_FTEC_Group_Manager::create_group ( ACE_ENV_ARG_DECL) { TAO_FTRTEC::Log(1, "create_group\n"); - IOGR_Maker::instance()->set_ref_version( object_group_ref_version ); impl_->info_list = info_list; impl_->my_position = find_by_location(info_list, Fault_Detector::instance()->my_location()); GroupInfoPublisherBase* publisher = GroupInfoPublisher::instance(); - - publisher->update(impl_->info_list, impl_->my_position + GroupInfoPublisherBase::Info_ptr info = + publisher->setup_info(impl_->info_list, impl_->my_position ACE_ENV_ARG_PARAMETER); ACE_CHECK; - FtRtecEventChannelAdmin::EventChannel_var successor - = publisher->successor(); + publisher->update_info(info); - if (!CORBA::is_nil(successor.in())) { - successor->create_group(info_list, object_group_ref_version - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } + IOGR_Maker::instance()->set_ref_version( object_group_ref_version ); if (impl_->my_position > 0) { Fault_Detector* detector = Fault_Detector::instance(); @@ -129,6 +122,15 @@ void TAO_FTEC_Group_Manager::create_group ( ACE_THROW(FTRT::PredecessorUnreachable()); } } + + FtRtecEventChannelAdmin::EventChannel_var successor + = publisher->successor(); + + if (!CORBA::is_nil(successor.in())) { + successor->create_group(info_list, object_group_ref_version + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } } void TAO_FTEC_Group_Manager::join_group ( @@ -152,17 +154,25 @@ void TAO_FTEC_Group_Manager::add_member ( TAO_FTRTEC::Log(1, "add_member location = <%s>\n", (const char*)info.the_location[0].id); + auto_ptr<TAO_FTEC_Group_Manager_Impl> new_impl(new TAO_FTEC_Group_Manager_Impl); + + new_impl->my_position = impl_->my_position; size_t pos = impl_->info_list.length(); - impl_->info_list.length(pos+1); - impl_->info_list[pos] = info; + new_impl->info_list.length(pos+1); + for (size_t i = 0; i < pos; ++i) { + new_impl->info_list[i] = impl_->info_list[i]; + } + new_impl->info_list[pos] = info; - IOGR_Maker::instance()->set_ref_version( object_group_ref_version ); GroupInfoPublisherBase* publisher = GroupInfoPublisher::instance(); - publisher->update(impl_->info_list, impl_->my_position - ACE_ENV_ARG_PARAMETER); + GroupInfoPublisherBase::Info_ptr group_info = + publisher->setup_info(new_impl->info_list, new_impl->my_position + ACE_ENV_ARG_PARAMETER); ACE_CHECK; - if (impl_->my_position < impl_->info_list.length()-2) + int last_one = (impl_->my_position == impl_->info_list.length()-1); + + if (!last_one) { // I am not the last of replica, tell my successor that // a new member has joined in. @@ -170,46 +180,61 @@ void TAO_FTEC_Group_Manager::add_member ( FTRTEC::Replication_Service::instance()->add_member(info, object_group_ref_version ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK_EX(block); - return; } ACE_CATCHANY { // Unable to send request to all the successors. // Now this node become the last replica of the object group. + // update the info list again + new_impl->info_list.length(new_impl->my_position+2); + new_impl->info_list[new_impl->my_position+1] = info; + + group_info = + publisher->setup_info(new_impl->info_list, + new_impl->my_position + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + last_one = true; } ACE_ENDTRY; + ACE_CHECK; + } - // update the info list again - impl_->info_list.length(impl_->my_position+2); - impl_->info_list[impl_->my_position+1] = info; - - publisher->update(impl_->info_list, impl_->my_position - ACE_ENV_ARG_PARAMETER); - } - - - // this is the last replica in the list - // synchornize the state with the newly joined replica. - FtRtecEventChannelAdmin::EventChannelState state; - get_state(state ACE_ENV_ARG_PARAMETER); - - TAO_OutputCDR cdr; - cdr << state; + if (last_one) + { + // this is the last replica in the list + // synchornize the state with the newly joined replica. + FtRtecEventChannelAdmin::EventChannelState state; + get_state(state ACE_ENV_ARG_PARAMETER); + + TAO_OutputCDR cdr; + cdr << state; + + FTRT::State s; + if (cdr.begin()->cont()) { + ACE_Message_Block* blk; + ACE_NEW_THROW_EX(blk, ACE_Message_Block, CORBA::NO_MEMORY()); + ACE_CDR::consolidate(blk, cdr.begin()); + s.replace(blk->length(), blk); + blk->release(); + } + else + s.replace(cdr.begin()->length(), cdr.begin()); - FTRT::State s; - if (cdr.begin()->cont()) { - ACE_Message_Block* blk; - ACE_NEW_THROW_EX(blk, ACE_Message_Block, CORBA::NO_MEMORY()); - ACE_CDR::consolidate(blk, cdr.begin()); - s.replace(blk->length(), blk); - blk->release(); + TAO_FTRTEC::Log(2, "Setting state\n"); + info.ior->set_state(s ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + info.ior->create_group(new_impl->info_list, + object_group_ref_version + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + TAO_FTRTEC::Log(2, "After create_group\n"); } - else - s.replace(cdr.begin()->length(), cdr.begin()); - TAO_FTRTEC::Log(2, "Setting state\n"); - info.ior->set_state(s ACE_ENV_ARG_PARAMETER); - info.ior->create_group(impl_->info_list, object_group_ref_version); - TAO_FTRTEC::Log(2, "After create_group\n"); + // commit the changes + IOGR_Maker::instance()->set_ref_version( object_group_ref_version ); + publisher->update_info(group_info); + delete impl_; + impl_ = new_impl.release(); } template <class SEQ> @@ -252,20 +277,26 @@ void TAO_FTEC_Group_Manager::remove_member ( GroupInfoPublisherBase* publisher = GroupInfoPublisher::instance(); - publisher->update(impl_->info_list, impl_->my_position - ACE_ENV_ARG_PARAMETER); + GroupInfoPublisherBase::Info_ptr info = + publisher->setup_info(impl_->info_list, impl_->my_position + ACE_ENV_ARG_PARAMETER); ACE_CHECK; + publisher->update_info(info); FtRtecEventChannelAdmin::EventChannel_var successor = publisher->successor(); IOGR_Maker::instance()->set_ref_version(object_group_ref_version); if (!CORBA::is_nil(successor.in())) { - - successor->remove_member(crashed_location, + ACE_TRY { + successor->remove_member(crashed_location, object_group_ref_version ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_TRY_CHECK; + } + ACE_CATCHALL { + } + ACE_ENDTRY; } TAO_FTRTEC::Log(3, "my_position = %d, crashed_pos = %d\n", impl_->my_position, crashed_pos); @@ -285,6 +316,7 @@ void TAO_FTEC_Group_Manager::connection_closed() ACE_DECLARE_NEW_CORBA_ENV; if (impl_->my_position > 1) { + // if I am not the new primary, tell the new primary ACE_TRY_EX(block1) { TAO_IOP::TAO_IOR_Manipulation::IORList iors; iors.length(impl_->my_position-1); diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Group_Manager.h b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Group_Manager.h index 9fd05992ef1..f2720fa1393 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Group_Manager.h +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/FTEC_Group_Manager.h @@ -33,11 +33,8 @@ public: virtual CORBA::Boolean start ( FTRT::FaultListener_ptr listener, FTRT::Location_out cur - ACE_ENV_ARG_DECL - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); void create_group ( const FTRT::ManagerInfoList & info_list, @@ -71,6 +68,7 @@ private: virtual void connection_closed(); protected: + FTRT::FaultListener_var listener_; TAO_FTEC_Group_Manager_Impl* impl_; }; diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/GroupInfoPublisher.cpp b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/GroupInfoPublisher.cpp index bb1e15f7b45..8b6cdce1b9c 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/GroupInfoPublisher.cpp +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/GroupInfoPublisher.cpp @@ -14,8 +14,9 @@ ACE_RCSID (EventChannel, GroupInfoPublisherBase::GroupInfoPublisherBase() -: primary_(false) +: info_(new Info) { + info_->primary = false; } @@ -34,19 +35,19 @@ void GroupInfoPublisherBase::set_naming_context(CosNaming::NamingContext_var nam bool GroupInfoPublisherBase::is_primary() const { - return primary_; + return info_->primary; } CORBA::Object_var GroupInfoPublisherBase::group_reference() const { - return iogr_; + return info_->iogr; } FtRtecEventChannelAdmin::EventChannel_var GroupInfoPublisherBase::successor() const { - return successor_; + return info_->successor; } @@ -54,16 +55,17 @@ GroupInfoPublisherBase::successor() const const GroupInfoPublisherBase::BackupList& GroupInfoPublisherBase::backups() const { - return backups_; + return info_->backups; } -void -GroupInfoPublisherBase::update(const FTRT::ManagerInfoList & info_list, - int my_position - ACE_ENV_ARG_DECL) +GroupInfoPublisherBase::Info_ptr +GroupInfoPublisherBase::setup_info(const FTRT::ManagerInfoList & info_list, + int my_position + ACE_ENV_ARG_DECL) { - bool become_primary = (my_position == 0 && !primary_); - primary_ = (my_position == 0); + Info_ptr result(new Info); + + result->primary = (my_position == 0); /// create the object group size_t len = info_list.length(); @@ -80,52 +82,70 @@ GroupInfoPublisherBase::update(const FTRT::ManagerInfoList & info_list, IOGR_Maker::instance()->make_iogr(iors ACE_ENV_ARG_PARAMETER); ACE_CHECK; - iogr_ = + result->iogr = ::FtRtecEventChannelAdmin::EventChannel::_narrow(obj.in() ACE_ENV_ARG_PARAMETER); ACE_CHECK; - if (primary_ && !CORBA::is_nil(naming_context_.in())) { - TAO_FTRTEC::Log(1, "Registering to the Name Service\n"); - naming_context_->rebind(FTRTEC::Identification_Service::instance()->name(), - iogr_.in() ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } - /// check if sucessor changed size_t successors_length = info_list.length() - my_position -1; - if (successors_length != backups_.length()) { + if (successors_length != info_->backups.length()) { // successor changed, update successor iors.length(successors_length); for (i = 0; i < successors_length; ++i) { iors[i] = CORBA::Object::_duplicate(info_list[i+ my_position+1].ior.in()); - } obj = IOGR_Maker::instance()->merge_iors(iors ACE_ENV_ARG_PARAMETER); ACE_CHECK; - successor_ = FtRtecEventChannelAdmin::EventChannel::_narrow(obj.in() - ACE_ENV_ARG_PARAMETER); - FtRtecEventChannelAdmin::EventChannel_var t = successor_; + result->successor = + FtRtecEventChannelAdmin::EventChannel::_narrow(obj.in() + ACE_ENV_ARG_PARAMETER); ACE_CHECK; + } + else { + result->successor = info_->successor; + } - // update backups - backups_.length(successors_length); - for (i = 0; i < successors_length; ++i) { - backups_[i] = - FtRtecEventChannelAdmin::EventChannel::_narrow( - info_list[i+ my_position+1].ior.in() - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } + // update backups + result->backups.length(successors_length); + for (i = 0; i < successors_length; ++i) { + result->backups[i] = + FtRtecEventChannelAdmin::EventChannel::_narrow( + info_list[i+ my_position+1].ior.in() + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; } - if (become_primary) { - // notify the subscribers - for (i = 0; i < subscribers_.size(); ++i) - subscribers_[i]->become_primary(); + return result; +} + +void +GroupInfoPublisherBase::update_info(GroupInfoPublisherBase::Info_ptr info) +{ + if (info->primary) { + if (!info_->primary) { + // now we become the primary, notify the subscribers + for (size_t i = 0; i < subscribers_.size(); ++i) + subscribers_[i]->become_primary(); + } + + if (!CORBA::is_nil(naming_context_.in())) { + TAO_FTRTEC::Log(1, "Registering to the Name Service\n"); + ACE_TRY_NEW_ENV { + naming_context_->rebind(FTRTEC::Identification_Service::instance()->name(), + info->iogr.in() ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHALL { + /// there's nothing we can do if the naming service is down + } + ACE_ENDTRY; + } } + info_ = info; } + diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/GroupInfoPublisher.h b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/GroupInfoPublisher.h index 3ee00248d93..b8cae6d4524 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/GroupInfoPublisher.h +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/GroupInfoPublisher.h @@ -27,7 +27,19 @@ class TAO_FTEC_Become_Primary_Listener; class GroupInfoPublisherBase { + + public: + typedef FtRtecEventChannelAdmin::EventChannelList BackupList; + + struct Info { + bool primary; + CORBA::Object_var iogr; + FtRtecEventChannelAdmin::EventChannel_var successor; + BackupList backups; + }; + + typedef auto_ptr<Info> Info_ptr; friend class ACE_Singleton<GroupInfoPublisherBase, ACE_Thread_Mutex>; void subscribe(TAO_FTEC_Become_Primary_Listener* listener); @@ -37,13 +49,14 @@ public: FtRtecEventChannelAdmin::EventChannel_var successor() const; - typedef FtRtecEventChannelAdmin::EventChannelList BackupList; const BackupList& backups() const; - void update(const FTRT::ManagerInfoList & info_list, + Info_ptr setup_info(const FTRT::ManagerInfoList & info_list, int my_position ACE_ENV_ARG_DECL); + void update_info(Info_ptr info); + const PortableServer::ObjectId& object_id() const; const CosNaming::Name& name() const; @@ -53,15 +66,12 @@ public: private: GroupInfoPublisherBase(); - bool primary_; CosNaming::NamingContext_var naming_context_; - CORBA::Object_var iogr_; - FtRtecEventChannelAdmin::EventChannel_var successor_; - BackupList backups_; typedef ACE_Vector<TAO_FTEC_Become_Primary_Listener*, 2> Subscribers; Subscribers subscribers_; PortableServer::ObjectId object_id_; CosNaming::Name name_; + Info_ptr info_; }; typedef ACE_Singleton<GroupInfoPublisherBase, ACE_Thread_Mutex> GroupInfoPublisher; diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Replication_Service.cpp b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Replication_Service.cpp index 30eaa5d8ed7..5e9cbc64805 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Replication_Service.cpp +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Replication_Service.cpp @@ -46,14 +46,14 @@ namespace FTRTEC initialized = 1; bool ami = false; - + // Parse any service configurator parameters. while (argc > 0) { if (ACE_OS::strcasecmp (argv[0], ACE_LIB_TEXT("AMI")) ==0 ) ami = true; if (ACE_OS::strcasecmp (argv[0], ACE_LIB_TEXT("-threads")) ==0 && argc > 1) { FTRTEC::threads = ACE_OS::atoi(argv[1]); - if (FTRTEC::threads ==0 ) + if (FTRTEC::threads ==0 ) FTRTEC::threads = 1; ++argv; --argc; } diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Replication_Service.h b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Replication_Service.h index 1b755218b63..f89bccf0038 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Replication_Service.h +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Replication_Service.h @@ -25,7 +25,7 @@ namespace FTRTEC { - class TAO_FTRTEC_Export Replication_Service + class TAO_FTRTEC_Export Replication_Service : public TAO_FTEC_Become_Primary_Listener , public ACE_Service_Object { diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Replication_Strategy.h b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Replication_Strategy.h index 8b5ae5737fa..a4eb29a6efd 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Replication_Strategy.h +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Replication_Strategy.h @@ -32,8 +32,8 @@ public: virtual ~Replication_Strategy(); /** - * Check if the incoming set_update() request is out of sequence. This is only - * used for basic replication strategy. It throws FTRT::OutOfSequence when the + * Check if the incoming set_update() request is out of sequence. This is only + * used for basic replication strategy. It throws FTRT::OutOfSequence when the * incoming request is not valid. */ virtual void check_validity(ACE_ENV_SINGLE_ARG_DECL); diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Update_Manager.h b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Update_Manager.h index f51bf7988d8..bf5700c2b4f 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Update_Manager.h +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/Update_Manager.h @@ -25,8 +25,8 @@ typedef Dynamic_Bitset bit_vector; /** * @class Update_Manager * - * @brief Manages the set_update() requests to the replicas for in AMI replication strategy. - * Once the primary get the first n replies from the backup replicas and n >= + * @brief Manages the set_update() requests to the replicas for in AMI replication strategy. + * Once the primary get the first n replies from the backup replicas and n >= * transaction_depth, it will signal the event specified in the constructor. */ @@ -43,7 +43,7 @@ public: void handle_exception(int id); private: - ACE_Auto_Event& evt_; + ACE_Auto_Event& evt_; bit_vector replied_; bit_vector signal_condition_; bit_vector suicide_condition_; diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/FTEC_Gateway.cpp b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/FTEC_Gateway.cpp index f73fd01d7b0..444eb65e460 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/FTEC_Gateway.cpp +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/FTEC_Gateway.cpp @@ -406,7 +406,7 @@ void FTEC_Gateway_ProxyPushConsumer::push (const RtecEventComm::EventSet & data PortableServer::ObjectId** oid_ptr = get_remote_oid_ptr(impl_->orb.in() ACE_ENV_ARG_PARAMETER); ACE_CHECK; - /* + /* if (CORBA::is_nil(impl_->push_handler.in())) { impl_->push_handler = impl_->push_handler_servant._this(ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.inl b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.inl index 9eb35bdca87..909d297eea0 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.inl +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Log.inl @@ -22,7 +22,7 @@ namespace TAO_FTRTEC { { log_level_ = log_level; } - + ACE_INLINE void Log::hexdump(unsigned int level, const char* buf, size_t len, const char* msg) { diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.h b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.h index e7f34dea183..7f0cfb993fb 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.h +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.h @@ -19,9 +19,9 @@ class Safe_InputCDR : public TAO_InputCDR public: /** * Create an input stream from an arbitrary buffer. - * + * * This contructor will work no matter the buffer is aligned properly - * or not. If the buffer is not properly aligned, it will make a copy + * or not. If the buffer is not properly aligned, it will make a copy * of the buffer. */ Safe_InputCDR(const char* buf, int size); diff --git a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.inl b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.inl index 7e6bef5d72a..5a0a41e0716 100644 --- a/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.inl +++ b/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/Safe_InputCDR.inl @@ -1,6 +1,6 @@ // $Id$ -inline +inline Safe_InputCDR::Safe_InputCDR(const char* buf, int size) : TAO_InputCDR((ACE_Message_Block*)0) { |