summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Mesnier <mesnier_p@ociweb.com>2013-05-01 21:14:49 +0000
committerPhil Mesnier <mesnier_p@ociweb.com>2013-05-01 21:14:49 +0000
commit8b64a5758846f7672c94b633bff28fd9eede4b61 (patch)
treedcd72734e7511af2531bee753f0fe4da48f3e6c8
parent16ee5d71e3d5f429b8acbdc13c3f024ce2ea0b9d (diff)
downloadATCD-8b64a5758846f7672c94b633bff28fd9eede4b61.tar.gz
Wed May 1 21:06:50 UTC 2013 Phil Mesnier <mesnier_p@ociweb.com>
-rw-r--r--TAO/ChangeLog24
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp48
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp102
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/LiveCheck.h3
-rw-r--r--TAO/orbsvcs/tests/ImplRepo/servers_interact_on_startup/README16
-rwxr-xr-xTAO/orbsvcs/tests/ImplRepo/servers_interact_on_startup/run_test.pl63
6 files changed, 206 insertions, 50 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 4637326ab77..339a60c43b5 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,9 +1,29 @@
+Wed May 1 21:06:50 UTC 2013 Phil Mesnier <mesnier_p@ociweb.com>
+
+ * orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp:
+
+ Repopulate the pinger with all known servers on a restart with
+ a persistent store. This helps the list -a command return
+ accurate results. Also list -a considers all final states that
+ are not LS_DEAD to be be equivalent to alive.
+
+ * orbsvcs/ImplRepo_Service/LiveCheck.h:
+ * orbsvcs/ImplRepo_Service/LiveCheck.cpp:
+
+ Ensure that when a server is in a final state of LS_LAST_TRANSIENT
+ a new listener will be notified of that state.
+
+ * orbsvcs/tests/ImplRepo/servers_interact_on_startup/README:
+ * orbsvcs/tests/ImplRepo/servers_interact_on_startup/run_test.pl:
+
+ Add new test variants for listing and locator restarts.
+
Wed May 1 14:16:54 UTC 2013 Phil Mesnier <mesnier_p@ociweb.com>
* orbsvcs/tests/ImplRepo/servers_interact_on_startup/run_test.pl:
- Clear the result returned by the tao_imr when it is expected to return a
- non-zero value.
+ Clear the result returned by the tao_imr when it is expected to
+ return a non-zero value.
Wed May 1 13:32:09 UTC 2013 Phil Mesnier <mesnier_p@ociweb.com>
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
index 5eb152c0434..835939619a4 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
@@ -164,11 +164,40 @@ ImR_Locator_i::init_with_orb (CORBA::ORB_ptr orb, Options& opts)
ACE_ASSERT (! CORBA::is_nil (ior_table.in ()));
ior_table->set_locator (this->ins_locator_.in ());
+
// initialize the repository. This will load any values that
// may have been persisted before.
- return this->repository_->init(this->root_poa_.in (),
- this->imr_poa_.in (),
- ior);
+ int result = this->repository_->init(this->root_poa_.in (),
+ this->imr_poa_.in (),
+ ior);
+ if (result == 0)
+ {
+ 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++)
+ {
+ it.next (entry);
+ it.advance ();
+ ACE_ASSERT (entry != 0);
+
+ const Server_Info& info = *(entry->int_id_);
+ // ImplementationRepository::ServerInformation_var imr_info =
+ // info.createImRServerInfo ();
+
+ if (!this->pinger_.has_server (info.name.c_str()))
+ {
+ this->pinger_.add_server (info.name.c_str(),
+ this->ping_external_,
+ info.server.in());
+ }
+ }
+ }
+
+ return result;
}
int
@@ -1289,6 +1318,12 @@ ImR_Locator_i::connect_server (UpdateableServerInfo& info)
{
if (! CORBA::is_nil (info->server.in ()))
{
+ if (!this->pinger_.has_server (info->name.c_str()))
+ {
+ this->pinger_.add_server (info->name.c_str(),
+ this->ping_external_,
+ info->server.in());
+ }
return; // already connected
}
@@ -1323,6 +1358,11 @@ ImR_Locator_i::connect_server (UpdateableServerInfo& info)
ORBSVCS_DEBUG ((LM_DEBUG,
ACE_TEXT ("ImR: Connected to server <%C>\n"),
info->name.c_str ()));
+ this->pinger_.add_server (info->name.c_str(),
+ this->ping_external_,
+ info->server.in());
+
+
}
catch (CORBA::Exception&)
{
@@ -1435,7 +1475,7 @@ SyncListener::is_alive (void)
this->orb_->perform_work (delay);
}
this->got_it_ = false;
- return this->status_ == LS_ALIVE;
+ return this->status_ != LS_DEAD;
}
bool
diff --git a/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp b/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp
index 087d91666d8..76ef51a3ebc 100644
--- a/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp
@@ -214,7 +214,6 @@ LiveEntry::LiveEntry (LiveCheck *owner,
ref_ (ImplementationRepository::ServerObject::_duplicate (ref)),
liveliness_ (LS_UNKNOWN),
next_check_ (ACE_High_Res_Timer::gettimeofday_hr()),
- retry_count_ (0),
repings_ (0),
max_retry_ (LiveEntry::reping_limit_),
may_ping_ (may_ping),
@@ -239,9 +238,10 @@ void
LiveEntry::reset_status (void)
{
ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
- if ( this->liveliness_ == LS_ALIVE)
+ if ( this->liveliness_ == LS_ALIVE || this->liveliness_ == LS_LAST_TRANSIENT)
{
this->liveliness_ = LS_UNKNOWN;
+ this->repings_ = 0;
this->next_check_ = ACE_High_Res_Timer::gettimeofday_hr();
}
}
@@ -265,29 +265,14 @@ LiveEntry::status (void) const
}
void
-LiveEntry::status (LiveStatus l)
+LiveEntry::update_listeners (void)
{
- {
- ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
- this->liveliness_ = l;
- if (l == LS_ALIVE)
- {
- this->retry_count_ = 0;
- ACE_Time_Value now (ACE_High_Res_Timer::gettimeofday_hr());
- this->next_check_ = now + owner_->ping_interval();
- }
- }
Listen_Set remove;
-
- LiveStatus ls = this->liveliness_;
- if (ls == LS_TRANSIENT && ! this->reping_available())
- ls = LS_LAST_TRANSIENT;
-
for (Listen_Set::ITERATOR i(this->listeners_);
!i.done();
i.advance ())
{
- if ((*i)->status_changed (ls))
+ if ((*i)->status_changed (this->liveliness_))
{
remove.insert (*i);
}
@@ -302,6 +287,25 @@ LiveEntry::status (LiveStatus l)
this->listeners_.remove (*i);
}
}
+}
+
+void
+LiveEntry::status (LiveStatus l)
+{
+ {
+ ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
+ this->liveliness_ = l;
+ if (l == LS_ALIVE)
+ {
+ ACE_Time_Value now (ACE_High_Res_Timer::gettimeofday_hr());
+ this->next_check_ = now + owner_->ping_interval();
+ }
+ if (l == LS_TRANSIENT && !this->reping_available())
+ {
+ this->liveliness_ = LS_LAST_TRANSIENT;
+ }
+ }
+ this->update_listeners ();
if (this->listeners_.size() > 0)
{
@@ -328,22 +332,17 @@ LiveEntry::next_check (void) const
bool
LiveEntry::validate_ping (bool &want_reping, ACE_Time_Value& next)
{
- if (ImR_Locator_i::debug () > 2)
- {
- ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) LiveEntry::validate_ping, server = %C\n"),
- this->server_.c_str()));
- }
if (this->liveliness_ == LS_PING_AWAY ||
this->liveliness_ == LS_DEAD ||
this->listeners_.size () == 0)
{
- if (ImR_Locator_i::debug () > 2)
+ if (ImR_Locator_i::debug () > 5)
{
ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) LiveEntry::validate_ping, first test, ")
- ACE_TEXT ("status = %d, listeners = %d\n"),
- this->liveliness_, this->listeners_.size ()));
+ ACE_TEXT ("(%P|%t) LiveEntry::validate_ping, status ")
+ ACE_TEXT ("= %d, listeners = %d server %C\n"),
+ this->liveliness_, this->listeners_.size (),
+ this->server_.c_str()));
}
return false;
}
@@ -360,11 +359,13 @@ LiveEntry::validate_ping (bool &want_reping, ACE_Time_Value& next)
if (ImR_Locator_i::debug () > 2)
{
ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) LiveEntry::validate_ping, second test, ")
+ ACE_TEXT ("(%P|%t) LiveEntry::validate_ping, ")
ACE_TEXT ("status = %d, listeners = %d, ")
- ACE_TEXT ("diff = %d,%d, msec = %d\n"),
+ ACE_TEXT ("diff = %d,%d, msec = %d ")
+ ACE_TEXT ("server %C\n"),
this->liveliness_, this->listeners_.size (),
- diff.sec(), diff.usec(), msec));
+ diff.sec(), diff.usec(), msec,
+ this->server_.c_str()));
}
return false;
}
@@ -374,23 +375,43 @@ LiveEntry::validate_ping (bool &want_reping, ACE_Time_Value& next)
break;
case LS_ALIVE:
case LS_TIMEDOUT:
- this->next_check_ = now + owner_->ping_interval();
+ {
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, false);
+ this->next_check_ = now + owner_->ping_interval();
+ }
break;
case LS_TRANSIENT:
+ case LS_LAST_TRANSIENT:
{
int ms = this->next_reping ();
if (ms != -1)
{
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, false);
+ if (this->liveliness_ == LS_LAST_TRANSIENT)
+ {
+ this->liveliness_ = LS_TRANSIENT;
+ }
ACE_Time_Value next (ms / 1000, (ms % 1000) * 1000);
this->next_check_ = now + next;
}
else
{
+ if (this->liveliness_ == LS_TRANSIENT)
+ {
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, false);
+ this->liveliness_ = LS_LAST_TRANSIENT;
+ }
if (ImR_Locator_i::debug () > 2)
{
ORBSVCS_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) LiveEntry::validate_ping, ")
- ACE_TEXT ("transient, no more repings\n")));
+ ACE_TEXT ("transient, no more repings, ")
+ ACE_TEXT ("server %C\n"),
+ this->server_.c_str()));
+ }
+ if (this->listeners_.size() > 0)
+ {
+ this->update_listeners ();
}
return false;
}
@@ -414,12 +435,10 @@ LiveEntry::do_ping (PortableServer::POA_ptr poa)
this->ref_->sendc_ping (cb.in());
ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
this->liveliness_ = LS_PING_AWAY;
- this->retry_count_++;
}
catch (CORBA::Exception &)
{
this->status (LS_DEAD);
- this->retry_count_++;
}
}
@@ -568,7 +587,7 @@ LiveCheck::handle_timeout (const ACE_Time_Value &,
}
else
{
- if (ImR_Locator_i::debug () > 2)
+ if (ImR_Locator_i::debug () > 5)
{
ORBSVCS_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) LiveCheck::handle_timeout(%d)")
@@ -617,6 +636,15 @@ LiveCheck::handle_timeout (const ACE_Time_Value &,
return 0;
}
+bool
+LiveCheck::has_server (const char *server)
+{
+ ACE_CString s (server);
+ LiveEntry *entry = 0;
+ int result = entry_map_.find (s, entry);
+ return (result == 0 && entry != 0);
+}
+
void
LiveCheck::add_server (const char *server,
bool may_ping,
diff --git a/TAO/orbsvcs/ImplRepo_Service/LiveCheck.h b/TAO/orbsvcs/ImplRepo_Service/LiveCheck.h
index e975cf1a293..cc8b060e52b 100644
--- a/TAO/orbsvcs/ImplRepo_Service/LiveCheck.h
+++ b/TAO/orbsvcs/ImplRepo_Service/LiveCheck.h
@@ -138,6 +138,7 @@ class Locator_Export LiveEntry
void status (LiveStatus l);
void reset_status (void);
+ void update_listeners (void);
bool validate_ping (bool &want_reping, ACE_Time_Value &next);
void do_ping (PortableServer::POA_ptr poa);
const ACE_Time_Value &next_check (void) const;
@@ -213,6 +214,8 @@ class Locator_Export LiveCheck : public ACE_Event_Handler
int handle_timeout (const ACE_Time_Value &current_time,
const void *act = 0);
+ bool has_server (const char *server);
+
void add_server (const char *server,
bool may_ping,
ImplementationRepository::ServerObject_ptr ref);
diff --git a/TAO/orbsvcs/tests/ImplRepo/servers_interact_on_startup/README b/TAO/orbsvcs/tests/ImplRepo/servers_interact_on_startup/README
index e88d67ac7fa..ee5ec01375a 100644
--- a/TAO/orbsvcs/tests/ImplRepo/servers_interact_on_startup/README
+++ b/TAO/orbsvcs/tests/ImplRepo/servers_interact_on_startup/README
@@ -71,12 +71,20 @@ captured in ./imr_loc.log
-debuglog
All the processes write log output to individual log files
+-hide_server
+Use this along with the -imr_start option to test an error condition of a
+registered server being removed from the filesystem. The tao_imr start
+command should recover without hanging.
+
-imr_start
Use this option to run a simple test where the tao_imr start command is
uesd to launch a server.
This should not time out.
--hide_server
-Use this along with the -imr_start option to test an error condition of a
-registered server being removed from the filesystem. The tao_imr start
-command should recover without hanging.
+-list
+Use the tao_imr list command to test. May be used with or without restarting
+the locator.
+
+-restart_loc
+Use to bounce the locator process by itself mid test. Only used by the list
+test for now. \ No newline at end of file
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 5a9207033bb..99925e985c1 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
@@ -19,15 +19,18 @@ my $client_count = 2;
my $server_reply_delay = 5;
my $usage = 0;
my $use_imr_start = 0;
+my $restart_loc = 0;
+my $list_test = 0;
my $hide_server = 0;
my $expect_transient = "";
my $notify_locator = "";
-
my $debuglog = "";
my @srvlogfile = ( "", "", "" );
my @cltlogfile = ( "", "", "" );
my $actlogfile = "";
my $loclogfile = "";
+my $back_store_flag = "";
+my $back_store_file = "";
# Ping interval in milliseconds
my $verification_interval_msecs = 1000;
@@ -62,6 +65,16 @@ if ($#ARGV >= 0) {
elsif ($ARGV[$i] eq "-imr_start") {
$use_imr_start = 1;
}
+ elsif ($ARGV[$i] eq "-list") {
+ $imr_debug_level = 3;
+ $list_test = 1;
+ }
+ elsif ($ARGV[$i] eq "-restart_loc") {
+ $restart_loc = 1;
+ $back_store_flag = "--directory";
+ $back_store_file = ".";
+ $server_reply_delay = 0;
+ }
elsif ($ARGV[$i] eq "-v") {
$i++;
$verification_interval_msecs = $ARGV[$i];
@@ -217,6 +230,7 @@ sub init_test
$IMR->Arguments ("-o $imr_imriorfile $refstyle -orbendpoint iiop://:$port ".
"$forward_on_exception_arg ".
+ "$back_store_flag $back_store_file ".
"-d $imr_debug_level $imr_debug_arg ".
"-v $verification_interval_msecs");
print ">>> " . $IMR->CommandLine () . "\n";
@@ -363,13 +377,32 @@ sub fini_test
return $status;
}
+sub restart_imr_locator
+{
+ print_msg ("restarting locator");
+ my $IMR_status = $IMR->TerminateWaitKill ($imr->ProcessStopWaitInterval());
+ if ($IMR_status != 0) {
+ print STDERR "ERROR: IMR returned $IMR_status\n";
+ $status = 1;
+ }
+
+ print ">>> " . $IMR->CommandLine () . "\n";
+ $IMR_status = $IMR->Spawn ();
+
+ if ($IMR_status != 0) {
+ print STDERR "ERROR: ImplRepo Service returned $IMR_status\n";
+ return 1;
+ }
+
+ print "sleeping (5).... ";
+ sleep (5);
+ print "done\n";
+}
sub run_imr_start_test
{
init_test ();
- print_msg ("using IMR to start $obj[1]");
-
$result = run_imr_util ("start $obj[1]");
if ($hide_server == 1 && $result == 4) {
@@ -382,6 +415,27 @@ sub run_imr_start_test
return $result;
}
+sub run_list_test
+{
+ init_test ();
+ run_imr_util ("start $obj[1]");
+ run_imr_util ("start $obj[0]");
+ run_imr_util ("list -a");
+
+ if ($restart_loc == 1) {
+ restart_imr_locator ();
+ run_imr_util ("list -a");
+ }
+
+ print "sleeping (20).... ";
+ sleep (20);
+ print "done\n";
+
+ run_imr_util ("list -a");
+
+ fini_test ();
+}
+
sub run_client_activate_test
{
init_test ();
@@ -444,6 +498,9 @@ my $ret = 0;
if ($use_imr_start == 1) {
$ret = run_imr_start_test ();
}
+elsif ($list_test == 1) {
+ $ret = run_list_test ();
+}
else {
$ret = run_client_activate_test ();
}