summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Mesnier <mesnier_p@ociweb.com>2013-05-12 17:08:14 +0000
committerPhil Mesnier <mesnier_p@ociweb.com>2013-05-12 17:08:14 +0000
commit2bddc612d90cb0d0c7a83ade794bd764f2a2cc16 (patch)
tree96d2635b610f913e1c3502d02d607aeaaf2cce6c
parent86e49d072e322b4d1170cd92b87cbec808f3a553 (diff)
downloadATCD-2bddc612d90cb0d0c7a83ade794bd764f2a2cc16.tar.gz
Sun May 12 16:45:48 UTC 2013 Phil Mesnier <mesnier_p@ociweb.com>
-rw-r--r--TAO/ChangeLog_Asynch_ImR23
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp148
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h40
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/AsyncListManager.cpp273
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/AsyncListManager.h106
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp126
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImplRepo_Service.mpc1
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Iterator.cpp31
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Iterator.h26
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp124
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/LiveCheck.h34
-rwxr-xr-xTAO/orbsvcs/tests/ImplRepo/ReconnectServer/run_test.pl2
-rwxr-xr-xTAO/orbsvcs/tests/ImplRepo/servers_interact_on_startup/run_test.pl13
-rwxr-xr-xTAO/orbsvcs/tests/ImplRepo/servers_list/run_test.pl5
14 files changed, 518 insertions, 434 deletions
diff --git a/TAO/ChangeLog_Asynch_ImR b/TAO/ChangeLog_Asynch_ImR
index 858655f565f..0b4baeddc79 100644
--- a/TAO/ChangeLog_Asynch_ImR
+++ b/TAO/ChangeLog_Asynch_ImR
@@ -1,3 +1,26 @@
+Sun May 12 16:45:48 UTC 2013 Phil Mesnier <mesnier_p@ociweb.com>
+
+ * orbsvcs/ImplRepo_Service/AsyncAccessManager.h:
+ * orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp:
+ * orbsvcs/ImplRepo_Service/AsyncListManager.h:
+ * orbsvcs/ImplRepo_Service/AsyncListManager.cpp:
+ * orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp:
+ * orbsvcs/ImplRepo_Service/ImplRepo_Service.mpc:
+ * orbsvcs/ImplRepo_Service/Iterator.h:
+ * orbsvcs/ImplRepo_Service/Iterator.cpp:
+ * orbsvcs/ImplRepo_Service/LiveCheck.h:
+ * orbsvcs/ImplRepo_Service/LiveCheck.cpp:
+
+ Asynchronous List operation implementation. Since the list operation
+ may trigger pings, it needed to be event driven similar to the access
+ and start up of registered servers.
+
+ * orbsvcs/tests/ImplRepo/ReconnectServer/run_test.pl:
+ * orbsvcs/tests/ImplRepo/servers_interact_on_startup/run_test.pl:
+ * orbsvcs/tests/ImplRepo/servers_list/run_test.pl:
+
+ Improve debugging and shutdown performance.
+
Wed May 8 22:13:12 UTC 2013 Phil Mesnier <mesnier_p@ociweb.com>
* tao/Intrusive_Ref_Count_Handle_T.h:
diff --git a/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp b/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp
index 4cfe53ee5e4..5ccef1c12d2 100644
--- a/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp
@@ -76,8 +76,8 @@ AsyncAccessManager::add_interest (ImR_ResponseHandler *rh)
{
// This is not a leak. The listener registers with
// the pinger and will delete itself when done.
- AsyncLiveListener *l = 0;
- ACE_NEW (l, AsyncLiveListener (this->info_->name.c_str(),
+ AccessLiveListener *l = 0;
+ ACE_NEW (l, AccessLiveListener (this->info_->name.c_str(),
this,
this->locator_.pinger()));
LiveListener_ptr llp(l);
@@ -199,17 +199,17 @@ AsyncAccessManager::server_is_running (const char *partial_ior,
this->final_state ();
}
- AsyncLiveListener *l = 0;
+ AccessLiveListener *l = 0;
if (this->info_->activation_mode == ImplementationRepository::PER_CLIENT)
{
- ACE_NEW (l, AsyncLiveListener (this->info_->name.c_str(),
+ ACE_NEW (l, AccessLiveListener (this->info_->name.c_str(),
this,
this->locator_.pinger(),
this->info_->server.in()));
}
else
{
- ACE_NEW (l, AsyncLiveListener (this->info_->name.c_str(),
+ ACE_NEW (l, AccessLiveListener (this->info_->name.c_str(),
this,
this->locator_.pinger()));
}
@@ -308,7 +308,7 @@ AsyncAccessManager::send_start_request (void)
}
AsyncAccessManager *
-AsyncAccessManager::add_ref (void)
+AsyncAccessManager::_add_ref (void)
{
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, 0);
++this->refcount_;
@@ -317,7 +317,7 @@ AsyncAccessManager::add_ref (void)
}
void
-AsyncAccessManager::remove_ref (void)
+AsyncAccessManager::_remove_ref (void)
{
int count = 0;
{
@@ -333,127 +333,9 @@ AsyncAccessManager::remove_ref (void)
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
-AsyncAccessManager_ptr::AsyncAccessManager_ptr (void)
- : val_ (0)
-{
-}
-
-AsyncAccessManager_ptr::AsyncAccessManager_ptr (AsyncAccessManager *aam)
- :val_ (aam)
-{
-}
-
-AsyncAccessManager_ptr::AsyncAccessManager_ptr (const AsyncAccessManager_ptr &aam_ptr)
- :val_ (aam_ptr.clone())
-{
-}
-
-AsyncAccessManager_ptr::~AsyncAccessManager_ptr (void)
-{
- if (val_ != 0)
- {
- val_->remove_ref();
- }
-}
-
-AsyncAccessManager_ptr &
-AsyncAccessManager_ptr::operator= (const AsyncAccessManager_ptr &aam_ptr)
-{
- if (val_ != *aam_ptr)
- {
- if (val_ != 0)
- {
- val_->remove_ref();
- }
- val_ = aam_ptr.clone();
- }
- return *this;
-}
-
-AsyncAccessManager_ptr &
-AsyncAccessManager_ptr::operator= (AsyncAccessManager *aam)
-{
- if (val_ != aam)
- {
- if (val_ != 0)
- {
- val_->remove_ref();
- }
- val_ = aam;
- }
- return *this;
-}
-
-const AsyncAccessManager *
-AsyncAccessManager_ptr::operator-> () const
-{
- return val_;
-}
-
-const AsyncAccessManager *
-AsyncAccessManager_ptr::operator* () const
-{
- return val_;
-}
-
-AsyncAccessManager *
-AsyncAccessManager_ptr::operator-> ()
-{
- return val_;
-}
-
-AsyncAccessManager *
-AsyncAccessManager_ptr::operator* ()
-{
- return val_;
-}
-
-bool
-AsyncAccessManager_ptr::operator== (const AsyncAccessManager_ptr &aam_ptr) const
-{
- return val_ == *aam_ptr;
-}
-
-bool
-AsyncAccessManager_ptr::operator== (const AsyncAccessManager *aam) const
-{
- return val_ == aam;
-}
-
-AsyncAccessManager *
-AsyncAccessManager_ptr::clone (void) const
-{
- if (val_ != 0)
- {
- val_->add_ref();
- }
- return val_;
-}
-
-AsyncAccessManager *
-AsyncAccessManager_ptr::_retn (void)
-{
- AsyncAccessManager * aam = val_;
- val_ = 0;
- return aam;
-}
-
-void
-AsyncAccessManager_ptr::assign (AsyncAccessManager *aam)
-{
- if (val_ != 0)
- {
- val_->remove_ref();
- }
- val_ = aam;
-}
-
-//---------------------------------------------------------------------------
-//---------------------------------------------------------------------------
-
ActivatorReceiver::ActivatorReceiver (AsyncAccessManager *aam,
PortableServer::POA_ptr poa)
- :aam_ (aam->add_ref ()),
+ :aam_ (aam->_add_ref ()),
poa_ (PortableServer::POA::_duplicate (poa))
{
}
@@ -495,11 +377,11 @@ ActivatorReceiver::shutdown_excep (Messaging::ExceptionHolder * )
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
-AsyncLiveListener::AsyncLiveListener (const char *server,
+AccessLiveListener::AccessLiveListener (const char *server,
AsyncAccessManager *aam,
LiveCheck &pinger)
:LiveListener (server),
- aam_ (aam->add_ref ()),
+ aam_ (aam->_add_ref ()),
pinger_ (pinger),
status_ (LS_UNKNOWN),
per_client_ (false),
@@ -507,12 +389,12 @@ AsyncLiveListener::AsyncLiveListener (const char *server,
{
}
-AsyncLiveListener::AsyncLiveListener (const char *server,
+AccessLiveListener::AccessLiveListener (const char *server,
AsyncAccessManager *aam,
LiveCheck &pinger,
ImplementationRepository::ServerObject_ptr ref)
:LiveListener (server),
- aam_ (aam->add_ref ()),
+ aam_ (aam->_add_ref ()),
pinger_ (pinger),
status_ (LS_UNKNOWN),
per_client_ (true),
@@ -520,12 +402,12 @@ AsyncLiveListener::AsyncLiveListener (const char *server,
{
}
-AsyncLiveListener::~AsyncLiveListener (void)
+AccessLiveListener::~AccessLiveListener (void)
{
}
bool
-AsyncLiveListener::start (void)
+AccessLiveListener::start (void)
{
bool rtn = this->per_client_ ?
this->pinger_.add_per_client_listener (this, srv_ref_.in()) :
@@ -534,7 +416,7 @@ AsyncLiveListener::start (void)
}
bool
-AsyncLiveListener::status_changed (LiveStatus status)
+AccessLiveListener::status_changed (LiveStatus status)
{
this->status_ = status;
if (status == LS_TRANSIENT)
diff --git a/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h b/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h
index 1cfc0ea33d8..a071f88fa3a 100644
--- a/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h
+++ b/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h
@@ -22,10 +22,10 @@
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
+#include "tao/Intrusive_Ref_Count_Handle_T.h"
#include "LiveCheck.h"
class ImR_Locator_i;
-class ImR_ReplyHandler;
struct Server_Info;
@@ -87,8 +87,8 @@ class AsyncAccessManager
void notify_child_death (void);
void ping_replied (LiveStatus server);
- AsyncAccessManager *add_ref (void);
- void remove_ref (void);
+ AsyncAccessManager *_add_ref (void);
+ void _remove_ref (void);
private:
void final_state (void);
@@ -107,31 +107,7 @@ class AsyncAccessManager
TAO_SYNCH_MUTEX lock_;
};
-class AsyncAccessManager_ptr
-{
-public:
- AsyncAccessManager_ptr (void);
- AsyncAccessManager_ptr (AsyncAccessManager *aam);
- AsyncAccessManager_ptr (const AsyncAccessManager_ptr &aam_ptr);
- ~AsyncAccessManager_ptr (void);
-
- AsyncAccessManager_ptr &operator = (const AsyncAccessManager_ptr &aam_ptr);
- AsyncAccessManager_ptr &operator = (AsyncAccessManager *aam);
- const AsyncAccessManager * operator-> () const;
- const AsyncAccessManager * operator* () const;
- AsyncAccessManager * operator-> ();
- AsyncAccessManager * operator* ();
- bool operator== (const AsyncAccessManager_ptr &aam_ptr) const;
- bool operator== (const AsyncAccessManager *aam) const;
-
- AsyncAccessManager * clone (void) const;
- AsyncAccessManager * _retn (void);
-
- void assign (AsyncAccessManager *aam);
-
-private:
- AsyncAccessManager * val_;
-};
+typedef TAO_Intrusive_Ref_Count_Handle<AsyncAccessManager> AsyncAccessManager_ptr;
//----------------------------------------------------------------------------
/*
@@ -165,19 +141,19 @@ private:
/*
*/
-class AsyncLiveListener : public LiveListener
+class AccessLiveListener : public LiveListener
{
public:
- AsyncLiveListener (const char * server,
+ AccessLiveListener (const char * server,
AsyncAccessManager *aam,
LiveCheck &pinger,
ImplementationRepository::ServerObject_ptr ref);
- AsyncLiveListener (const char * server,
+ AccessLiveListener (const char * server,
AsyncAccessManager *aam,
LiveCheck &pinger);
- virtual ~AsyncLiveListener (void);
+ virtual ~AccessLiveListener (void);
bool start (void);
bool status_changed (LiveStatus status);
diff --git a/TAO/orbsvcs/ImplRepo_Service/AsyncListManager.cpp b/TAO/orbsvcs/ImplRepo_Service/AsyncListManager.cpp
new file mode 100644
index 00000000000..8532e5a1b9d
--- /dev/null
+++ b/TAO/orbsvcs/ImplRepo_Service/AsyncListManager.cpp
@@ -0,0 +1,273 @@
+// -*- C++ -*-
+// $Id$
+
+#include "AsyncListManager.h"
+#include "Iterator.h"
+#include "Locator_Repository.h"
+
+#include "orbsvcs/Log_Macros.h"
+
+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+
+AsyncListManager::AsyncListManager (const Locator_Repository *repo,
+ PortableServer::POA_ptr poa,
+ LiveCheck *pinger)
+ :repo_ (repo),
+ poa_ (PortableServer::POA::_duplicate (poa)),
+ primary_ (ImplementationRepository::AMH_AdministrationResponseHandler::_nil ()),
+ secondary_ (ImplementationRepository::AMH_ServerInformationIteratorResponseHandler::_nil ()),
+ pinger_ (pinger),
+ server_list_ (0),
+ first_ (0),
+ refcount_ (1),
+ lock_ ()
+{
+
+}
+
+AsyncListManager::~AsyncListManager (void)
+{
+}
+
+PortableServer::POA_ptr
+AsyncListManager::poa (void)
+{
+ return PortableServer::POA::_duplicate (this->poa_.in());
+}
+
+void
+AsyncListManager::final_state (void)
+{
+ CORBA::ULong len = this->server_list_.length ();
+ if (this->pinger_ != 0)
+ {
+ for (CORBA::ULong i = 0; i < len; i++)
+ {
+ if (this->server_list_[i].activeStatus ==
+ ImplementationRepository::ACTIVE_MAYBE)
+ {
+ return;
+ }
+ }
+ }
+
+ bool excepted = false;
+
+ if (!CORBA::is_nil (this->primary_.in()))
+ {
+ ImplementationRepository::ServerInformationIterator_var server_iterator;
+ if (len < this->repo_->servers ().current_size())
+ {
+ try
+ {
+ ImR_AsyncIterator* imr_iter = 0;
+ ACE_NEW_THROW_EX (imr_iter,
+ ImR_AsyncIterator (len, this),
+ CORBA::NO_MEMORY ());
+
+ PortableServer::ServantBase_var tmp (imr_iter);
+
+ PortableServer::ObjectId_var id =
+ this->poa_->activate_object (imr_iter);
+ CORBA::Object_var obj = this->poa_->id_to_reference (id.in ());
+ server_iterator = ImplementationRepository::
+ ServerInformationIterator::_unchecked_narrow (obj.in ());
+ }
+ catch (CORBA::Exception& ex)
+ {
+ ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate());
+ this->primary_->list_excep (&h);
+ excepted = true;
+ }
+ }
+ else
+ {
+ server_iterator =
+ ImplementationRepository::ServerInformationIterator::_nil ();
+ }
+
+ if (!excepted)
+ {
+ try
+ {
+ this->primary_->list (this->server_list_, server_iterator.in ());
+ }
+ catch (CORBA::Exception &ex)
+ {
+ ex._tao_print_exception ("ALM:final state sending list\n");
+ ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate());
+ this->primary_->list_excep (&h);
+ }
+ }
+ this->primary_ =
+ ImplementationRepository::AMH_AdministrationResponseHandler::_nil ();
+ }
+ else if (!CORBA::is_nil (this->secondary_.in()))
+ {
+ CORBA::Boolean done = this->first_ + this->server_list_.length () >=
+ this->repo_->servers ().current_size ();
+ this->secondary_->next_n (done, this->server_list_);
+ this->secondary_ =
+ ImplementationRepository::AMH_ServerInformationIteratorResponseHandler::_nil ();
+
+ }
+}
+
+CORBA::ULong
+AsyncListManager::list
+(ImplementationRepository::AMH_ServerInformationIteratorResponseHandler_ptr _tao_rh,
+ CORBA::ULong start,
+ CORBA::ULong count)
+{
+ this->secondary_ =
+ ImplementationRepository::AMH_ServerInformationIteratorResponseHandler::_duplicate (_tao_rh);
+ this->list_i (start, count);
+ return this->first_ + this->server_list_.length ();
+}
+
+void
+AsyncListManager::list
+(ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
+ CORBA::ULong count)
+{
+ this->primary_ =
+ ImplementationRepository::AMH_AdministrationResponseHandler::_duplicate (_tao_rh);
+ this->list_i (0, count);
+}
+
+void
+AsyncListManager::list_i (CORBA::ULong start, CORBA::ULong how_many)
+{
+ this->first_ = start;
+ CORBA::ULong len = this->repo_->servers ().current_size () - start;
+ if (how_many > 0 && len > how_many)
+ {
+ len = how_many;
+ }
+ Locator_Repository::SIMap::ENTRY* entry = 0;
+ Locator_Repository::SIMap::CONST_ITERATOR it (this->repo_->servers ());
+ for (;start > 0; start--)
+ {
+ it.advance ();
+ }
+ this->server_list_.length (len);
+ for (CORBA::ULong i = 0; i < len; i++)
+ {
+ it.next (entry);
+ it.advance ();
+
+ Server_Info_Ptr info = entry->int_id_;
+
+ this->server_list_[i].server = info->name.c_str ();
+ this->server_list_[i].startup.command_line = info->cmdline.c_str ();
+ this->server_list_[i].startup.environment = info->env_vars;
+ this->server_list_[i].startup.working_directory = info->dir.c_str ();
+ this->server_list_[i].startup.activation = info->activation_mode;
+ this->server_list_[i].startup.activator = info->activator.c_str ();
+ this->server_list_[i].startup.start_limit = info->start_limit;
+ this->server_list_[i].partial_ior = info->partial_ior.c_str ();
+ this->server_list_[i].activeStatus = ImplementationRepository::ACTIVE_MAYBE;
+ if (this->pinger_ != 0)
+ {
+ ListLiveListener *l = 0;
+ ACE_NEW (l, ListLiveListener (info->name.c_str (),
+ i,
+ this,
+ *this->pinger_));
+
+ LiveListener_ptr llp(l);
+ if (!l->start())
+ {
+ this->server_list_[i].activeStatus =
+ ImplementationRepository::ACTIVE_NO;
+ }
+ }
+ }
+}
+
+
+void
+AsyncListManager::ping_replied (CORBA::ULong index, LiveStatus server)
+{
+ switch (server)
+ {
+ case LS_ALIVE:
+ case LS_LAST_TRANSIENT:
+ case LS_TIMEDOUT:
+ this->server_list_[index].activeStatus =
+ ImplementationRepository::ACTIVE_YES;
+ break;
+ case LS_DEAD:
+ this->server_list_[index].activeStatus =
+ ImplementationRepository::ACTIVE_NO;
+ break;
+ default:
+ return;
+ }
+ this->final_state();
+}
+
+AsyncListManager *
+AsyncListManager::_add_ref (void)
+{
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, 0);
+ ++this->refcount_;
+
+ return this;
+}
+
+void
+AsyncListManager::_remove_ref (void)
+{
+ int count = 0;
+ {
+ ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
+ count = --this->refcount_;
+ }
+ if (count == 0)
+ {
+ delete this;
+ }
+}
+
+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+
+ListLiveListener::ListLiveListener (const char *server,
+ CORBA::ULong index,
+ AsyncListManager *owner,
+ LiveCheck &pinger)
+ :LiveListener (server),
+ owner_ (owner->_add_ref ()),
+ pinger_ (pinger),
+ status_ (LS_UNKNOWN),
+ index_ (index)
+{
+}
+
+ListLiveListener::~ListLiveListener (void)
+{
+}
+
+bool
+ListLiveListener::start (void)
+{
+ bool rtn = this->pinger_.add_listener (this);
+ return rtn;
+}
+
+bool
+ListLiveListener::status_changed (LiveStatus status)
+{
+ this->status_ = status;
+ if (status == LS_TRANSIENT)
+ {
+ return false;
+ }
+ else
+ {
+ this->owner_->ping_replied (this->index_, status);
+ }
+ return true;
+}
diff --git a/TAO/orbsvcs/ImplRepo_Service/AsyncListManager.h b/TAO/orbsvcs/ImplRepo_Service/AsyncListManager.h
new file mode 100644
index 00000000000..c0916391307
--- /dev/null
+++ b/TAO/orbsvcs/ImplRepo_Service/AsyncListManager.h
@@ -0,0 +1,106 @@
+// -*- C++ -*-
+/*
+ * @file AsyncListManager.h
+ *
+ * $Id$
+ *
+ * @author Phil Mesnier <mesnier_p@ociweb.com>
+ */
+
+#ifndef IMR_ASYNCLISTMANAGER_H_
+#define IMR_ASYNCLISTMANAGER_H_
+
+#include "locator_export.h"
+
+#include "ImR_LocatorC.h"
+#include "ace/Vector_T.h"
+#include "ace/SString.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/Intrusive_Ref_Count_Handle_T.h"
+#include "LiveCheck.h"
+
+class Locator_Repository;
+
+//----------------------------------------------------------------------------
+/*
+ * @class AsyncListManager
+ *
+ * @brief manages active detection of multiple servers to satisfy "list -a"
+ *
+ * A client of the locator may issue a list command to be filtered to
+ * currently active servers only. To satisfy that request each server must
+ * be pinged to determine liveness. The AsyncListManager handles the
+ * callbacks for all of the ping requests as efficiently as possible.
+ */
+
+class AsyncListManager
+{
+ public:
+ AsyncListManager (const Locator_Repository *repo,
+ PortableServer::POA_ptr poa,
+ LiveCheck *pinger);
+
+ ~AsyncListManager (void);
+
+ PortableServer::POA_ptr poa (void);
+ void list (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
+ CORBA::ULong count);
+
+ CORBA::ULong list (ImplementationRepository::AMH_ServerInformationIteratorResponseHandler_ptr _tao_rh,
+ CORBA::ULong start, CORBA::ULong count);
+
+ void ping_replied (CORBA::ULong index, LiveStatus status);
+
+ AsyncListManager *_add_ref (void);
+ void _remove_ref (void);
+
+ private:
+ void list_i (CORBA::ULong start, CORBA::ULong count);
+ void final_state (void);
+
+ const Locator_Repository *repo_;
+ PortableServer::POA_var poa_;
+ ImplementationRepository::AMH_AdministrationResponseHandler_var primary_;
+ ImplementationRepository::AMH_ServerInformationIteratorResponseHandler_var secondary_;
+ LiveCheck *pinger_;
+ ImplementationRepository::ServerInformationList server_list_;
+ CORBA::ULong first_;
+ int refcount_;
+ TAO_SYNCH_MUTEX lock_;
+};
+
+typedef TAO_Intrusive_Ref_Count_Handle<AsyncListManager> AsyncListManager_ptr;
+
+//----------------------------------------------------------------------------
+/*
+ */
+
+class ListLiveListener : public LiveListener
+{
+ public:
+ ListLiveListener (const char * server,
+ CORBA::ULong index,
+ AsyncListManager *owner,
+ LiveCheck &pinger);
+
+ virtual ~ListLiveListener (void);
+ bool start (void);
+
+ bool status_changed (LiveStatus status);
+
+ private:
+ AsyncListManager_ptr owner_;
+ LiveCheck &pinger_;
+ LiveStatus status_;
+ CORBA::ULong index_;
+};
+
+
+
+
+
+#endif /* IMR_ASYNCACCESSMANGER_H_ */
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
index cee8302f9af..bf24cc46296 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
@@ -175,15 +175,8 @@ ImR_Locator_i::init_with_orb (CORBA::ORB_ptr orb, Options& opts)
Locator_Repository::SIMap::ENTRY* entry = 0;
Locator_Repository::SIMap::ITERATOR it (this->repository_->servers ());
- // Number of servers that will go into the server_list.
- CORBA::ULong n = this->repository_->servers ().current_size ();
-
- for (CORBA::ULong i = 0; i < n; i++)
+ for (;it.next (entry) != 0; it.advance ())
{
- it.next (entry);
- it.advance ();
- ACE_ASSERT (entry != 0);
-
const Server_Info& info = *(entry->int_id_);
// ImplementationRepository::ServerInformation_var imr_info =
// info.createImRServerInfo ();
@@ -437,7 +430,7 @@ ImR_Locator_i::notify_child_death
}
AsyncAccessManager_ptr aam(this->find_aam (name));
- if (*aam != 0)
+ if (!aam.is_nil())
{
aam->notify_child_death ();
}
@@ -565,7 +558,7 @@ ImR_Locator_i::activate_server_i (UpdateableServerInfo& info,
else
{
aam = this->find_aam (info->name.c_str());
- if (*aam == 0)
+ if (aam.is_nil())
{
AsyncAccessManager *aam_raw;
ACE_NEW (aam_raw, AsyncAccessManager (*info, manual_start, *this));
@@ -1011,7 +1004,7 @@ ImR_Locator_i::server_is_running
}
AsyncAccessManager_ptr aam(this->find_aam (name.c_str()));
- if (*aam != 0)
+ if (!aam.is_nil())
aam->server_is_running (partial_ior, s.in());
else
{
@@ -1058,7 +1051,7 @@ ImR_Locator_i::server_is_shutting_down
this->pinger_.remove_server (server);
{
AsyncAccessManager_ptr aam = this->find_aam (server);
- if (*aam != 0)
+ if (!aam.is_nil())
{
aam->server_is_shutting_down ();
}
@@ -1092,7 +1085,8 @@ ImR_Locator_i::find
}
else
{
- ACE_NEW_THROW_EX (imr_info, ImplementationRepository::ServerInformation,
+ ACE_NEW_THROW_EX (imr_info,
+ ImplementationRepository::ServerInformation,
CORBA::NO_MEMORY ());
imr_info->startup.activation= ImplementationRepository::NORMAL;
if (debug_ > 1)
@@ -1114,110 +1108,26 @@ void
ImR_Locator_i::list
(ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
CORBA::ULong how_many,
- CORBA::Boolean determine_active_status)
+ CORBA::Boolean active)
{
- ImplementationRepository::ServerInformationList_var server_list;
- ImplementationRepository::ServerInformationIterator_var server_iterator;
-
- if (debug_ > 1)
- ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("ImR: List servers.\n")));
-
- // Initialize the out variables, so if we return early, they will
- // not be dangling.
- server_iterator = ImplementationRepository::ServerInformationIterator::_nil ();
+ AsyncListManager *l = 0;
try
{
- ACE_NEW_THROW_EX (server_list,
- ImplementationRepository::ServerInformationList (0),
+ ACE_NEW_THROW_EX (l,
+ AsyncListManager (this->repository_.get(),
+ this->imr_poa_.in(),
+ active ? &this->pinger_ : 0),
CORBA::NO_MEMORY ());
+ AsyncListManager_ptr lister (l);
+ l->list (_tao_rh, how_many);
}
- catch (CORBA::Exception& ex)
+ catch (CORBA::Exception &ex)
{
ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate());
- _tao_rh->list_excep (&h);
+ _tao_rh->find_excep (&h);
return;
}
-
- Locator_Repository::SIMap::ENTRY* entry = 0;
- Locator_Repository::SIMap::ITERATOR it (this->repository_->servers ());
-
- // Number of servers that will go into the server_list.
- CORBA::ULong n = this->repository_->servers ().current_size ();
- if (how_many > 0 && n > how_many)
- {
- n = how_many;
- }
-
- server_list->length (n);
-
- if (debug_ > 1)
- {
- ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("ImR_Locator_i::list: Filling ServerList with %d servers\n"),
- n));
- }
-
- for (CORBA::ULong i = 0; i < n; i++)
- {
- it.next (entry);
- it.advance ();
- ACE_ASSERT (entry != 0);
-
- const Server_Info& info = *(entry->int_id_);
-
- ImplementationRepository::ServerInformation_var imr_info =
- info.createImRServerInfo ();
- if (determine_active_status)
- {
- UpdateableServerInfo updatable_info (info);
- if (this->is_alive (updatable_info))
- {
- imr_info->activeStatus = ImplementationRepository::ACTIVE_YES;
- }
- else
- {
- imr_info->activeStatus = ImplementationRepository::ACTIVE_NO;
- if (debug_ > 0)
- {
- ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("ImR: Server %s is not active\n"),
- info.name.c_str ()));
- }
- }
- }
- server_list[i] = *imr_info;
- }
-
- if (this->repository_->servers ().current_size () > n)
- {
- if (debug_ > 1)
- ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("ImR_Locator_i::list: Creating ServerInformation ")
- ACE_TEXT ("Iterator\n")));
-
- try
- {
- ImR_Iterator* imr_iter = 0;
- ACE_NEW_THROW_EX (imr_iter,
- ImR_Iterator (n, *this->repository_, this->imr_poa_.in ()),
- CORBA::NO_MEMORY ());
-
- PortableServer::ServantBase_var tmp (imr_iter);
-
- PortableServer::ObjectId_var id =
- this->imr_poa_->activate_object (imr_iter);
- CORBA::Object_var obj = this->imr_poa_->id_to_reference (id.in ());
- server_iterator = ImplementationRepository::
- ServerInformationIterator::_unchecked_narrow (obj.in ());
- }
- catch (CORBA::Exception& ex)
- {
- ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate());
- _tao_rh->list_excep (&h);
- }
- }
- _tao_rh->list (server_list.in(), server_iterator.in());
}
Activator_Info_Ptr
@@ -1434,7 +1344,7 @@ ImR_Locator_i::find_aam (const char *name)
{
if ((*i)->has_server (name))
{
- return (*i)->add_ref();
+ return (*i)->_add_ref();
}
}
return 0;
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_Service.mpc b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_Service.mpc
index cbb585df5b2..508eafcf728 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_Service.mpc
+++ b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_Service.mpc
@@ -110,6 +110,7 @@ project(ImR_Locator) : orbsvcslib, orbsvcs_output, conv_lib, avoids_minimum_corb
Activator_Info.cpp
Adapter_Activator.cpp
AsyncAccessManager.cpp
+ AsyncListManager.cpp
Forwarder.cpp
ImR_Locator_i.cpp
ImR_ResponseHandler.cpp
diff --git a/TAO/orbsvcs/ImplRepo_Service/Iterator.cpp b/TAO/orbsvcs/ImplRepo_Service/Iterator.cpp
index 7e4182e08dc..abe512064a6 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Iterator.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Iterator.cpp
@@ -12,7 +12,36 @@
#include "Iterator.h"
-ImR_Iterator::ImR_Iterator (CORBA::ULong n, Locator_Repository& repo, PortableServer::POA_ptr poa)
+
+ImR_AsyncIterator::ImR_AsyncIterator (CORBA::ULong start,
+ AsyncListManager *lister)
+ :count_ (start),
+ lister_ (lister->_add_ref ())
+{
+}
+
+void
+ImR_AsyncIterator::next_n
+ (ImplementationRepository::AMH_ServerInformationIteratorResponseHandler_ptr _tao_rh,
+ CORBA::ULong how_many)
+{
+ this->count_ = this->lister_->list (_tao_rh, this->count_, how_many);
+}
+
+void
+ImR_AsyncIterator::destroy
+ (ImplementationRepository::AMH_ServerInformationIteratorResponseHandler_ptr _tao_rh)
+{
+ PortableServer::POA_var poa = this->lister_->poa ();
+ PortableServer::ObjectId_var oid = poa->servant_to_id (this);
+ poa->deactivate_object (oid.in());
+ _tao_rh->destroy ();
+}
+
+//----------------------------------------------------------------------------
+ImR_Iterator::ImR_Iterator (CORBA::ULong n,
+ Locator_Repository& repo,
+ PortableServer::POA_ptr poa)
: repo_(repo)
, count_(n)
, poa_(poa)
diff --git a/TAO/orbsvcs/ImplRepo_Service/Iterator.h b/TAO/orbsvcs/ImplRepo_Service/Iterator.h
index db02e5f33b9..ff74eaee1ad 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Iterator.h
+++ b/TAO/orbsvcs/ImplRepo_Service/Iterator.h
@@ -15,6 +15,7 @@
#define IMR_ITERATOR_H
#include "Locator_Repository.h"
+#include "AsyncListManager.h"
#include "tao/PortableServer/PortableServer.h"
#include "ImplRepoS.h"
@@ -22,6 +23,27 @@
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+
+class ImR_AsyncIterator
+ : public POA_ImplementationRepository::AMH_ServerInformationIterator
+{
+public:
+ ImR_AsyncIterator (CORBA::ULong start,
+ AsyncListManager *lister);
+
+ virtual void next_n
+ (ImplementationRepository::AMH_ServerInformationIteratorResponseHandler_ptr _tao_rh,
+ CORBA::ULong how_many);
+
+ virtual void destroy
+ (ImplementationRepository::AMH_ServerInformationIteratorResponseHandler_ptr _tao_rh);
+
+private:
+ CORBA::ULong count_;
+ AsyncListManager_ptr lister_;
+};
+
/**
* @class ImR_Iterator
*
@@ -32,7 +54,9 @@ class ImR_Iterator
: public POA_ImplementationRepository::ServerInformationIterator
{
public:
- ImR_Iterator (CORBA::ULong n, Locator_Repository& repo, PortableServer::POA_ptr poa);
+ ImR_Iterator (CORBA::ULong start,
+ Locator_Repository& repo,
+ PortableServer::POA_ptr poa);
/// Returns the next list of up to <how_many> servers. If empty, will return
/// false.
diff --git a/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp b/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp
index 76ef51a3ebc..58bd7c99ae3 100644
--- a/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp
@@ -28,7 +28,7 @@ LiveListener::server (void) const
}
LiveListener *
-LiveListener::add_ref (void)
+LiveListener::_add_ref (void)
{
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, 0);
++this->refcount_;
@@ -36,7 +36,7 @@ LiveListener::add_ref (void)
}
void
-LiveListener::remove_ref (void)
+LiveListener::_remove_ref (void)
{
int count = 0;
{
@@ -52,124 +52,6 @@ LiveListener::remove_ref (void)
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
-LiveListener_ptr::LiveListener_ptr (void)
- : val_ (0)
-{
-}
-
-LiveListener_ptr::LiveListener_ptr (LiveListener *ll)
- :val_ (ll)
-{
-}
-
-LiveListener_ptr::LiveListener_ptr (const LiveListener_ptr &ll_ptr)
- :val_ (ll_ptr.clone())
-{
-}
-
-LiveListener_ptr::~LiveListener_ptr (void)
-{
- if (val_ != 0)
- {
- val_->remove_ref();
- }
-}
-
-LiveListener_ptr &
-LiveListener_ptr::operator= (const LiveListener_ptr &ll_ptr)
-{
- if (val_ != *ll_ptr)
- {
- if (val_ != 0)
- {
- val_->remove_ref();
- }
- val_ = ll_ptr.clone();
- }
- return *this;
-}
-
-LiveListener_ptr &
-LiveListener_ptr::operator= (LiveListener *ll)
-{
- if (val_ != ll)
- {
- if (val_ != 0)
- {
- val_->remove_ref();
- }
- val_ = ll;
- }
- return *this;
-}
-
-const LiveListener *
-LiveListener_ptr::operator-> () const
-{
- return val_;
-}
-
-const LiveListener *
-LiveListener_ptr::operator* () const
-{
- return val_;
-}
-
-LiveListener *
-LiveListener_ptr::operator-> ()
-{
- return val_;
-}
-
-LiveListener *
-LiveListener_ptr::operator* ()
-{
- return val_;
-}
-
-bool
-LiveListener_ptr::operator== (const LiveListener_ptr &ll_ptr) const
-{
- return val_ == *ll_ptr;
-}
-
-bool
-LiveListener_ptr::operator== (const LiveListener *ll) const
-{
- return val_ == ll;
-}
-
-LiveListener *
-LiveListener_ptr::clone (void) const
-{
- if (val_ != 0)
- {
- val_->add_ref();
- }
- return val_;
-}
-
-LiveListener *
-LiveListener_ptr::_retn (void)
-{
- LiveListener * ll = val_;
- val_ = 0;
- return ll;
-}
-
-void
-LiveListener_ptr::assign (LiveListener *ll)
-{
- if (val_ != 0)
- {
- val_->remove_ref();
- }
- val_ = ll;
-}
-
-//---------------------------------------------------------------------------
-//---------------------------------------------------------------------------
-
const int LiveEntry::reping_msec_[] = {10, 100, 500, 1000, 1000, 2000, 2000, 5000, 5000};
int LiveEntry::reping_limit_ = sizeof (LiveEntry::reping_msec_) / sizeof (int);
@@ -230,7 +112,7 @@ void
LiveEntry::add_listener (LiveListener *ll)
{
ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
- LiveListener_ptr llp(ll->add_ref());
+ LiveListener_ptr llp(ll->_add_ref());
this->listeners_.insert (llp);
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/LiveCheck.h b/TAO/orbsvcs/ImplRepo_Service/LiveCheck.h
index cc8b060e52b..da5195b9e79 100644
--- a/TAO/orbsvcs/ImplRepo_Service/LiveCheck.h
+++ b/TAO/orbsvcs/ImplRepo_Service/LiveCheck.h
@@ -23,6 +23,8 @@
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
+#include "tao/Intrusive_Ref_Count_Handle_T.h"
+
class LiveCheck;
//---------------------------------------------------------------------------
@@ -76,8 +78,8 @@ class Locator_Export LiveListener
/// accessor for the server name. Used by the LiveCheck to associate a listener
const char *server (void) const;
- LiveListener *add_ref (void);
- void remove_ref (void);
+ LiveListener *_add_ref (void);
+ void _remove_ref (void);
private:
ACE_CString server_;
@@ -86,32 +88,7 @@ class Locator_Export LiveListener
TAO_SYNCH_MUTEX lock_;
};
-class LiveListener_ptr
-{
-public:
- LiveListener_ptr (void);
- LiveListener_ptr (LiveListener *aam);
- LiveListener_ptr (const LiveListener_ptr &aam_ptr);
- ~LiveListener_ptr (void);
-
- LiveListener_ptr &operator = (const LiveListener_ptr &aam_ptr);
- LiveListener_ptr &operator = (LiveListener *aam);
- const LiveListener * operator-> () const;
- const LiveListener * operator* () const;
- LiveListener * operator-> ();
- LiveListener * operator* ();
- bool operator== (const LiveListener_ptr &aam_ptr) const;
- bool operator== (const LiveListener *aam) const;
-
- LiveListener * clone (void) const;
- LiveListener * _retn (void);
-
- void assign (LiveListener *aam);
-
-private:
- LiveListener * val_;
-};
-
+typedef TAO_Intrusive_Ref_Count_Handle<LiveListener> LiveListener_ptr;
//---------------------------------------------------------------------------
/*
@@ -153,7 +130,6 @@ class Locator_Export LiveEntry
ImplementationRepository::ServerObject_var ref_;
LiveStatus liveliness_;
ACE_Time_Value next_check_;
- short retry_count_;
int repings_;
int max_retry_;
bool may_ping_;
diff --git a/TAO/orbsvcs/tests/ImplRepo/ReconnectServer/run_test.pl b/TAO/orbsvcs/tests/ImplRepo/ReconnectServer/run_test.pl
index dd3a3855163..20b6c6a5dec 100755
--- a/TAO/orbsvcs/tests/ImplRepo/ReconnectServer/run_test.pl
+++ b/TAO/orbsvcs/tests/ImplRepo/ReconnectServer/run_test.pl
@@ -33,7 +33,7 @@ my $ping_ext = '';
foreach my $i (@ARGV) {
if ($i eq '-debug') {
$debug_level = '10';
- $imr_debug_level = '1';
+ $imr_debug_level = '3';
}
if ($i eq '-forwardalways') {
$delay = '5';
diff --git a/TAO/orbsvcs/tests/ImplRepo/servers_interact_on_startup/run_test.pl b/TAO/orbsvcs/tests/ImplRepo/servers_interact_on_startup/run_test.pl
index 99925e985c1..086d8a350d2 100755
--- a/TAO/orbsvcs/tests/ImplRepo/servers_interact_on_startup/run_test.pl
+++ b/TAO/orbsvcs/tests/ImplRepo/servers_interact_on_startup/run_test.pl
@@ -326,6 +326,7 @@ sub init_test
register_server_with_activator(0, 1);
if ($hide_server == 1) {
+ sleep (2);
$name = $SRV[0]->Executable();
rename ($name, "hidden") or die "Rename ($name, \"hidden\") failed: $!";
}
@@ -338,7 +339,7 @@ sub fini_test
if ($hide_server == 1) {
$name = $SRV[0]->Executable();
- rename ("hidden", "server") or die "Rename ($name, \"hidden\") failed: $!";
+ rename ("hidden", $name) or die "Rename ($name, \"hidden\") failed: $!";
}
if ($srv[1]->WaitForFileTimed ($srvstatusfile[1], $srv[1]->ProcessStartWaitInterval() + $server_reply_delay) == -1) {
@@ -348,8 +349,9 @@ sub fini_test
}
##### Shutdown servers #####
- for (my $i = 0; $i < $servers_count; $i++ ) {
- # Shutting down any server object within the server will shutdown the whole server
+ for (my $i = $servers_count - 1; $i >= 0; $i-- ) {
+ # Shutting down any server object within the server will
+ # shutdown the whole server
run_imr_util ("shutdown $obj[$i]");
if ($SRV[$i]->WaitKill ($srv[$i]->ProcessStopWaitInterval ()) == -1) {
print STDERR "ERROR: Server $i not terminated correctly\n";
@@ -421,15 +423,14 @@ sub run_list_test
run_imr_util ("start $obj[1]");
run_imr_util ("start $obj[0]");
run_imr_util ("list -a");
+ run_imr_util ("shutdown $obj[1]");
if ($restart_loc == 1) {
restart_imr_locator ();
run_imr_util ("list -a");
}
- print "sleeping (20).... ";
- sleep (20);
- print "done\n";
+ run_imr_util ("start $obj[1]");
run_imr_util ("list -a");
diff --git a/TAO/orbsvcs/tests/ImplRepo/servers_list/run_test.pl b/TAO/orbsvcs/tests/ImplRepo/servers_list/run_test.pl
index 1cc0254a984..f1df8de931c 100755
--- a/TAO/orbsvcs/tests/ImplRepo/servers_list/run_test.pl
+++ b/TAO/orbsvcs/tests/ImplRepo/servers_list/run_test.pl
@@ -91,6 +91,7 @@ my $imr_persistdat = $imr->LocalFile ($persistdat);
$IMR = $imr->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/ImplRepo_Service/tao_imr_locator");
$ACT = $act->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/ImplRepo_Service/tao_imr_activator");
$TI = $ti->CreateProcess ("$ENV{ACE_ROOT}/bin/tao_imr");
+
$CLI = $cli->CreateProcess ("client");
@SRV;
my @srv_server_cmd;
@@ -305,7 +306,7 @@ sub servers_list_test
my $result = 0;
my $start_time = time();
- $IMR->Arguments ("-d $debug_level -v 1000 -o $imr_imriorfile -orbendpoint iiop://:$port");
+ $IMR->Arguments ("-d $debug_level -ORBDebugLevel $debug_level -v 1000 -o $imr_imriorfile -orbendpoint iiop://:$port");
##### Start ImplRepo #####
$IMR_status = $IMR->Spawn ();
@@ -357,7 +358,7 @@ sub servers_list_test
if ($CLI_status != 0) {
print STDERR "ERROR: client returned $CLI_status\n";
$status = 1;
- return 1;
+# return 1;
}
$SRV[$i]->Kill ();
}