summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Mesnier <mesnierp@ociweb.com>2016-03-03 16:55:46 -0600
committerPhil Mesnier <mesnierp@ociweb.com>2016-03-04 10:14:59 -0600
commitf68ad1ebb25927d2b6650091f3bc23ae6888a495 (patch)
tree002a02dc67f6bed1fec3a1e8b3d8ab35538097b9
parent80f4315eb1314ccdc47052f07c882a45a60fa10b (diff)
downloadATCD-f68ad1ebb25927d2b6650091f3bc23ae6888a495.tar.gz
Bring over recent fixes and enhancements to the FaultTolerant / LoadBalancing naming service extension from OCI's TAO release.
Fixes deadlocks that could occur as a result of file access errors, such as the transient "bad file decriptor" (ebadf) error that seems to pop up fairly regularly when using NFS. Also optimized the file locking strategy to not always setting to MODIFY access state, which then required a file update on every access
-rw-r--r--ACE/ace/config-linux.h1
-rw-r--r--ACE/bin/PerlACE/Run_Test.pm4
-rw-r--r--TAO/bin/tao_other_tests.lst15
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Server.cpp28
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_PG_Object_Group_Storable.cpp3
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_PG_Object_Group_Storable.h2
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/nsgroup_svc.cpp1091
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/nsgroup_svc.h6
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp45
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp9
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Storable.cpp63
-rw-r--r--TAO/orbsvcs/tests/FT_Naming/stress_storable/Basic.cpp62
-rw-r--r--TAO/orbsvcs/tests/FT_Naming/stress_storable/Basic.h59
-rw-r--r--TAO/orbsvcs/tests/FT_Naming/stress_storable/LB_server.cpp257
-rw-r--r--TAO/orbsvcs/tests/FT_Naming/stress_storable/LB_server.h98
-rw-r--r--TAO/orbsvcs/tests/FT_Naming/stress_storable/README16
-rw-r--r--TAO/orbsvcs/tests/FT_Naming/stress_storable/Test.idl27
-rw-r--r--TAO/orbsvcs/tests/FT_Naming/stress_storable/client.cpp221
-rwxr-xr-xTAO/orbsvcs/tests/FT_Naming/stress_storable/run_test.pl210
-rw-r--r--TAO/orbsvcs/tests/FT_Naming/stress_storable/server.cpp119
-rw-r--r--TAO/orbsvcs/tests/FT_Naming/stress_storable/stress_storable.mpc34
-rw-r--r--TAO/tao/Storable_Base.cpp1
-rw-r--r--TAO/tao/Storable_Base.h16
-rw-r--r--TAO/tao/Storable_Base.inl3
-rw-r--r--TAO/tao/Storable_File_Guard.cpp99
-rw-r--r--TAO/tao/Storable_FlatFileStream.cpp362
-rw-r--r--TAO/tao/Storable_FlatFileStream.h24
27 files changed, 2191 insertions, 684 deletions
diff --git a/ACE/ace/config-linux.h b/ACE/ace/config-linux.h
index a29d6e55844..eeb6c46e447 100644
--- a/ACE/ace/config-linux.h
+++ b/ACE/ace/config-linux.h
@@ -403,6 +403,7 @@
#define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS
#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R
#define ACE_HAS_REENTRANT_FUNCTIONS
+#define ACE_HAS_MNTENT
// To support UCLIBC
#if defined (__UCLIBC__)
diff --git a/ACE/bin/PerlACE/Run_Test.pm b/ACE/bin/PerlACE/Run_Test.pm
index 3f22bc2a110..4ae912f28ea 100644
--- a/ACE/bin/PerlACE/Run_Test.pm
+++ b/ACE/bin/PerlACE/Run_Test.pm
@@ -77,7 +77,9 @@ $| = 1;
sub LocalFile ($)
{
my $file = shift;
-
+ if (File::Spec->file_name_is_absolute( $file )) {
+ return $file;
+ }
my $newfile = getcwd () . '/' . $file;
if ($^O eq "MSWin32") {
diff --git a/TAO/bin/tao_other_tests.lst b/TAO/bin/tao_other_tests.lst
index ad484c7fd0c..a71804fe68f 100644
--- a/TAO/bin/tao_other_tests.lst
+++ b/TAO/bin/tao_other_tests.lst
@@ -9,7 +9,7 @@
#
# NOTE: This file contains examples and other service level test for
# TAO's. Please do not include regular tests here.
-TAO/performance-tests/Cubit/TAO/IDL_Cubit/run_test.pl: !LynxOS !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !ST !Win32 !ACE_FOR_TAO !OpenVMS
+TAO/performance-tests/Cubit/TAO/IDL_Cubit/run_test.pl: !LynxOS !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !ST !Win32 !ACE_FOR_TAO !OpenVMS !HPUX_IA64
TAO/performance-tests/Cubit/TAO/MT_Cubit/run_test.pl: !ST !OpenBSD !Win32 !ACE_FOR_TAO !OpenVMS !CORBA_E_MICRO
TAO/performance-tests/Latency/Single_Threaded/run_test.pl -n 1000: !Win32 !ACE_FOR_TAO !OpenVMS
TAO/performance-tests/Latency/Thread_Pool/run_test.pl -n 1000: !ST !Win32 !ACE_FOR_TAO !OpenVMS
@@ -28,7 +28,7 @@ TAO/performance-tests/Sequence_Latency/Deferred/run_test.pl: !MINIMUM !CORBA_E_C
TAO/performance-tests/Sequence_Latency/Sequence_Operations_Time/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !Win32 !ACE_FOR_TAO !OpenVMS
TAO/performance-tests/Throughput/run_test.pl: !Win32 !ACE_FOR_TAO !OpenVMS
TAO/performance-tests/POA/Object_Creation_And_Registration/run_test.pl: !Win32 !ACE_FOR_TAO !OpenVMS !CORBA_E_MICRO
-TAO/performance-tests/RTCorba/Oneways/Reliable/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !Win32 !OpenVMS !LynxOS
+TAO/performance-tests/RTCorba/Oneways/Reliable/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !Win32 !OpenVMS !LynxOS !HPUX_IA64
TAO/performance-tests/Protocols/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !STATIC !Win32 !ACE_FOR_TAO !OpenVMS !LynxOS
TAO/examples/Simple/bank/run_test.pl: !NO_MESSAGING !CORBA_E_MICRO
TAO/examples/Simple/grid/run_test.pl: !NO_MESSAGING !CORBA_E_MICRO
@@ -36,7 +36,7 @@ TAO/examples/Simple/time/run_test.pl: !NO_MESSAGING !Win32 !CORBA_E_MICRO
TAO/examples/Simple/time-date/run_test.pl: !ST !STATIC !NO_MESSAGING !Win32
TAO/examples/Quoter/run_test.pl: !DISABLE_ToFix_LynxOS_PPC !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !Win32 !ACE_FOR_TAO
TAO/examples/Load_Balancing/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !ACE_FOR_TAO
-TAO/examples/AMH/Sink_Server/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !Win32 !LynxOS !ACE_FOR_TAO
+TAO/examples/AMH/Sink_Server/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !Win32 !LynxOS !ACE_FOR_TAO !HPUX_IA64
TAO/examples/OBV/Typed_Events/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO
TAO/examples/Buffered_AMI/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO
TAO/orbsvcs/tests/AVStreams/Pluggable/run_test.pl -p TCP,UDP,RTP_UDP: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !ACE_FOR_TAO
@@ -90,7 +90,7 @@ TAO/orbsvcs/tests/Event/Basic/run_test.pl: !ST !MINIMUM !CORBA_E_COMPACT !CORBA_
TAO/orbsvcs/tests/Event/Performance/run_test.pl: !ST !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !ACE_FOR_TAO
TAO/orbsvcs/tests/Event/UDP/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !ACE_FOR_TAO !NO_DIOP
TAO/orbsvcs/tests/EC_Custom_Marshal/run_test.pl: !ST !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !ACE_FOR_TAO !DISABLE_ToFix_LynxOS_x86
-TAO/orbsvcs/tests/EC_Throughput/run_test.pl: !ST !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !DISABLE_ToFix_LynxOS_x86 !ACE_FOR_TAO !LynxOS
+TAO/orbsvcs/tests/EC_Throughput/run_test.pl: !ST !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !DISABLE_ToFix_LynxOS_x86 !ACE_FOR_TAO !LynxOS !HPUX_IA64
TAO/orbsvcs/tests/EC_MT_Mcast/run_test.pl:!ST !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !ACE_FOR_TAO !LynxOS
TAO/orbsvcs/tests/Event/Mcast/RTEC_MCast_Federated/run_test.pl: !NO_MCAST !ST !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !ACE_FOR_TAO !LynxOS
TAO/orbsvcs/tests/Event/Mcast/RTEC_MCast_Federated/run_test.pl -ipv6: IPV6 !NO_MCAST !ST !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !ACE_FOR_TAO !LynxOS
@@ -147,7 +147,7 @@ TAO/orbsvcs/tests/ImplRepo/servers_list/run_test.pl: !ST !MINIMUM !CORBA_E_COMPA
TAO/orbsvcs/tests/ImplRepo/servers_list/run_test_ft.pl: !ST !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !LynxOS
TAO/orbsvcs/tests/ImplRepo/Bug_689_Regression/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO
TAO/orbsvcs/tests/ImplRepo/Bug_2604_Regression/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !LynxOS
-TAO/orbsvcs/tests/ImplRepo/Bug_4152_Regression/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !LynxOS
+TAO/orbsvcs/tests/ImplRepo/Bug_4152_Regression/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !LynxOS !OpenVMS
TAO/orbsvcs/tests/ImplRepo/ReconnectServer/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !LynxOS
TAO/orbsvcs/tests/ImplRepo/ReconnectServer/run_test.pl -forwardalways: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !LynxOS
TAO/orbsvcs/tests/ImplRepo/ReconnectServer/run_test.pl -forwardonce: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !LynxOS
@@ -163,7 +163,7 @@ TAO/orbsvcs/tests/ImplRepo/ping_interrupt/run_test.pl: !ST !MINIMUM !CORBA_E_COM
TAO/orbsvcs/tests/ImplRepo/link_poas/run_test.pl: !ST !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !LynxOS !OpenVMS
TAO/orbsvcs/tests/ImplRepo/RestartIMR/run_test.pl: !ST !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !LynxOS !OpenVMS
TAO/orbsvcs/tests/ImplRepo/RestartIMR/run_test.pl -kill_server: !ST !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !ACE_FOR_TAO !LynxOS !OpenVMS
-TAO/orbsvcs/examples/ImR/Combined_Service/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !STATIC !ST !ACE_FOR_TAO !LynxOS !WCHAR
+TAO/orbsvcs/examples/ImR/Combined_Service/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !STATIC !ST !ACE_FOR_TAO !LynxOS
TAO/orbsvcs/examples/CosEC/TypedSimple/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !NO_IFR !ACE_FOR_TAO !WCHAR
TAO/orbsvcs/tests/CosEvent/Timeout/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !ST !NO_MESSAGING !ACE_FOR_TAO !LynxOS
TAO/orbsvcs/tests/Log/Basic_Log_Test/run_test.pl: !NO_MESSAGING !ACE_FOR_TAO !CORBA_E_MICRO
@@ -212,7 +212,7 @@ TAO/orbsvcs/tests/Bug_3387_Regression/run_test.pl: !ST !NO_MESSAGING !MINIMUM !C
#HANGS'TAO/orbsvcs/tests/ImplRepo/run_test.pl airplane_ir
TAO/orbsvcs/tests/Security/Secure_Invocation/run_test.pl: SSL !STATIC !DISABLE_INTERCEPTORS !ACE_FOR_TAO !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO
TAO/orbsvcs/tests/Security/Bug_1107_Regression/run_test.pl: SSL !STATIC !DISABLE_INTERCEPTORS !ACE_FOR_TAO !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO
-TAO/orbsvcs/tests/Security/Bug_2908_Regression/run_test.pl: SSL !STATIC !DISABLE_INTERCEPTORS !ACE_FOR_TAO !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO
+TAO/orbsvcs/tests/Security/Bug_2908_Regression/run_test.pl: SSL !STATIC !DISABLE_INTERCEPTORS !ACE_FOR_TAO !FIXED_BUGS_ONLY !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO
TAO/orbsvcs/tests/Security/Big_Request/run_test.pl: SSL !STATIC !DISABLE_INTERCEPTORS !ACE_FOR_TAO !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO
TAO/orbsvcs/tests/Security/BiDirectional/run_test.pl: SSL !STATIC !DISABLE_INTERCEPTORS !ACE_FOR_TAO !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO
TAO/orbsvcs/tests/Security/Callback/run_test.pl: SSL !STATIC !DISABLE_INTERCEPTORS !ACE_FOR_TAO !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO
@@ -304,3 +304,4 @@ TAO/orbsvcs/tests/FT_Naming/Load_Balancing/run_test.pl: !Win32 !MINIMUM !CORBA_E
TAO/orbsvcs/tests/FT_Naming/Replication/run_test.pl: !Win32 !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !DISABLE_INTERCEPTORS !ACE_FOR_TAO !LynxOS !ST
TAO/orbsvcs/tests/FT_Naming/FaultTolerant/run_test.pl: !Win32 !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !DISABLE_INTERCEPTORS !ACE_FOR_TAO !LynxOS !ST
TAO/orbsvcs/tests/FT_Naming/Federation/run_test.pl: !Win32 !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !DISABLE_INTERCEPTORS !ACE_FOR_TAO !LynxOS !ST
+TAO/orbsvcs/tests/FT_Naming/stress_storable/run_test.pl: !Win32 !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !DISABLE_INTERCEPTORS !ACE_FOR_TAO !LynxOS !ST
diff --git a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Server.cpp b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Server.cpp
index 65bc7c7a9e2..199de13ec08 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Server.cpp
+++ b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Server.cpp
@@ -4,6 +4,8 @@
/**
* @file FT_Naming_Server.cpp
*
+ * $Id: FT_Naming_Server.cpp 2827 2016-02-22 23:52:38Z mesnierp $
+ *
* @author Kevin Stanley <stanleyk@ociweb.com>
*/
//=============================================================================
@@ -792,11 +794,11 @@ TAO_FT_Naming_Server::parse_args (int argc,
if (this->use_redundancy_ == 1)
{
ORBSVCS_ERROR ((LM_ERROR,
- ACE_TEXT ("INFO: Cannot run standalone with ")
- ACE_TEXT ("-r option. Using -u instead.\n")
- ACE_TEXT ("Must start a '--primary' and a '--backup' ")
- ACE_TEXT ("server to run as a Fault \n")
- ACE_TEXT ("Tolerant Naming Service. \n")));
+ ACE_TEXT ("INFO: Standalone name server ignoring ")
+ ACE_TEXT ("-r option, treating it as -u instead.\n")
+ ACE_TEXT ("Start a '--primary' and a '--backup' ")
+ ACE_TEXT ("server to run as a Fault Tolerant ")
+ ACE_TEXT ("Naming Service. \n")));
this->use_redundancy_ = 0;
}
@@ -804,21 +806,13 @@ TAO_FT_Naming_Server::parse_args (int argc,
else
{
// Only the backup should be requested to write the multi-profile IOR
- if ((this->server_role_ != TAO_FT_Naming_Server::BACKUP) &&
- (this->combined_naming_service_ior_file_name_ != 0))
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("ERROR: Must export the multi-profile ")
- ACE_TEXT ("IOR (using '-c' option) from the backup")
- ACE_TEXT (" server.\n\n")),
- -1);
-
- // Only the backup should be requested to write the multi-profile IOR
- if ((this->server_role_ == TAO_FT_Naming_Server::BACKUP) &&
+ // so fail if (role is backup) is the same as (no filename)
+ if ((this->server_role_ == TAO_FT_Naming_Server::BACKUP) ==
(this->combined_naming_service_ior_file_name_ == 0))
ORBSVCS_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("ERROR: Must export the multi-profile ")
- ACE_TEXT ("IOR (using '-c' option) from the backup")
- ACE_TEXT (" server.\n\n")),
+ ACE_TEXT ("IOR (using '-c' option) from the backup ")
+ ACE_TEXT ("server.\n\n")),
-1);
}
return 0;
diff --git a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_PG_Object_Group_Storable.cpp b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_PG_Object_Group_Storable.cpp
index 3fa33442554..38201c1a391 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_PG_Object_Group_Storable.cpp
+++ b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_PG_Object_Group_Storable.cpp
@@ -128,9 +128,8 @@ TAO::FT_PG_Object_Group_Storable::state_written (void)
}
bool
-TAO::FT_PG_Object_Group_Storable::is_obsolete (time_t stored_time)
+TAO::FT_PG_Object_Group_Storable::is_obsolete (time_t )
{
- ACE_UNUSED_ARG (stored_time);
return (!this->loaded_from_stream_) || this->stale_;
}
diff --git a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_PG_Object_Group_Storable.h b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_PG_Object_Group_Storable.h
index 05eebfd60e5..3c3586f2574 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_PG_Object_Group_Storable.h
+++ b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_PG_Object_Group_Storable.h
@@ -71,7 +71,7 @@ namespace TAO
TAO::Storable_Factory & storable_factory);
/// Destructor
- ~FT_PG_Object_Group_Storable ();
+ virtual ~FT_PG_Object_Group_Storable ();
/////////////////
// public methods
diff --git a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/nsgroup_svc.cpp b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/nsgroup_svc.cpp
index 137e152e70d..450be60c4c5 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/nsgroup_svc.cpp
+++ b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/nsgroup_svc.cpp
@@ -13,27 +13,27 @@
#include "ace/OS_NS_strings.h"
-NS_group_svc::NS_group_svc (void)
+NS_group_svc::NS_group_svc (bool quiet )
+ : quiet_ (quiet)
{
}
bool
-NS_group_svc::determine_policy_string (
- const ACE_TCHAR *policy,
- FT_Naming::LoadBalancingStrategyValue& value)
+NS_group_svc::determine_policy_string (const ACE_TCHAR *policy,
+ FT_Naming::LoadBalancingStrategyValue& value)
{
bool rc = false;
if (ACE_OS::strcasecmp (policy, ACE_TEXT_CHAR_TO_TCHAR ("round")) == 0)
- {
- value = FT_Naming::ROUND_ROBIN;
- rc = true;
- }
+ {
+ value = FT_Naming::ROUND_ROBIN;
+ rc = true;
+ }
if (ACE_OS::strcasecmp (policy, ACE_TEXT_CHAR_TO_TCHAR ("random")) == 0)
- {
- value = FT_Naming::RANDOM;
- rc = true;
- }
+ {
+ value = FT_Naming::RANDOM;
+ rc = true;
+ }
return rc;
}
@@ -42,64 +42,80 @@ int
NS_group_svc::set_orb( CORBA::ORB_ptr orb)
{
- this->orb_ = CORBA::ORB::_duplicate (orb);
+ this->orb_ = CORBA::ORB::_duplicate (orb);
- if (CORBA::is_nil (this->orb_.in ()))
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT (" (%P|%t) Unable to initialize the ")
- ACE_TEXT ("ORB.\n")),
- -1);
- return 0;
+ if (CORBA::is_nil (this->orb_.in ()))
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to ")
+ ACE_TEXT ("initialize the ORB.\n")));
+ }
+ return -1;
+ }
+ return 0;
}
int
-NS_group_svc::set_naming_manager( FT_Naming::NamingManager_ptr nm)
+NS_group_svc::set_naming_manager (FT_Naming::NamingManager_ptr nm)
{
- this->naming_manager_ = FT_Naming::NamingManager::_duplicate (nm);
+ this->naming_manager_ = FT_Naming::NamingManager::_duplicate (nm);
- if (CORBA::is_nil (this->naming_manager_.in ()))
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT (" (%P|%t) Invalid Naming Manager.\n")),
- -1);
- return 0;
+ if (CORBA::is_nil (this->naming_manager_.in ()))
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Invalid Naming Manager.\n")));
+ }
+ return -1;
+ }
+ return 0;
}
int
NS_group_svc::set_name_context( CosNaming::NamingContextExt_ptr nc)
{
- this->name_service_ = CosNaming::NamingContextExt::_duplicate (nc);
+ this->name_service_ = CosNaming::NamingContextExt::_duplicate (nc);
- if (CORBA::is_nil (this->name_service_.in ()))
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT (" (%P|%t) Invalid Name Context.\n")),
- -1);
- return 0;
+ if (CORBA::is_nil (this->name_service_.in ()))
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Invalid Name Context.\n")));
+ }
+ return -1;
+ }
+ return 0;
}
bool
-NS_group_svc::group_exist (
- const ACE_TCHAR* group_name
-)
+NS_group_svc::group_exist ( const ACE_TCHAR* group_name )
{
if (group_name == 0 )
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("group_exist args not provided\n")),
- false);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc group_exist args not provided\n")));
+ }
+ return false;
+ }
try
{
- PortableGroup::ObjectGroup_var group_var =
- this->naming_manager_->get_object_group_ref_from_name (
- ACE_TEXT_ALWAYS_CHAR (group_name));
- }
+ PortableGroup::ObjectGroup_var group_var =
+ this->naming_manager_->get_object_group_ref_from_name
+ (ACE_TEXT_ALWAYS_CHAR (group_name));
+ }
catch (const PortableGroup::ObjectGroupNotFound&)
- {
- return false;
- }
+ {
+ return false;
+ }
return true;
}
@@ -112,74 +128,87 @@ NS_group_svc::group_exist (
*/
int
-NS_group_svc::group_create (
- const ACE_TCHAR* group_name,
- const ACE_TCHAR* policy )
+NS_group_svc::group_create (const ACE_TCHAR* group_name,
+ const ACE_TCHAR* policy )
{
-
if (group_name == 0 || policy == 0 )
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("group_create args not provided\n")),
- -2);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc group_create args not provided\n")));
+ }
+ return -2;
+ }
/// Validate load balancing strategy policy string
FT_Naming::LoadBalancingStrategyValue strategy;
if (false == determine_policy_string (policy, strategy))
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("%s is not a valid policy.\n"),
- policy),
- -2);
- }
-
- try
- {
- /// Verify that the group does not already exist
- /// Group names must be unique
- if ( true == group_exist (group_name))
{
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("Group %s already exists\n"),
- group_name),
- -1);
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc %s is not a valid policy.\n"),
+ policy));
+ }
+ return -2;
}
- PortableGroup::Criteria criteria (1);
- criteria.length (1);
-
- PortableGroup::Property &property = criteria[0];
- property.nam.length (1);
-
- property.nam[0].id = CORBA::string_dup (
- "org.omg.PortableGroup.MembershipStyle");
-
- PortableGroup::MembershipStyleValue msv = PortableGroup::MEMB_APP_CTRL;
- property.val <<= msv;
-
- CORBA::Object_var obj =
- this->naming_manager_->create_object_group (
- ACE_TEXT_ALWAYS_CHAR (group_name),
- strategy,
- criteria);
-
- if (CORBA::is_nil (obj.in ()))
+ try
{
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to create group %s.\n"),
- group_name),
- -1);
- }
+ /// Verify that the group does not already exist
+ /// Group names must be unique
+ if ( true == group_exist (group_name))
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Group %s already exists\n"),
+ group_name));
+ }
+ return -1;
+ }
+
+ PortableGroup::Criteria criteria (1);
+ criteria.length (1);
+
+ PortableGroup::Property &property = criteria[0];
+ property.nam.length (1);
+
+ property.nam[0].id = CORBA::string_dup ("org.omg.PortableGroup.MembershipStyle");
+
+ PortableGroup::MembershipStyleValue msv = PortableGroup::MEMB_APP_CTRL;
+ property.val <<= msv;
+
+ CORBA::Object_var obj =
+ this->naming_manager_->create_object_group (ACE_TEXT_ALWAYS_CHAR (group_name),
+ strategy,
+ criteria);
+
+ if (CORBA::is_nil (obj.in ()))
+ {
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to create group %s.\n"),
+ group_name));
+ }
+ return -1;
+ }
+ }
- }
+ }
catch (const CORBA::Exception&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to create group %s\n"),
- group_name),
- -1);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to create group %s\n"),
+ group_name));
+ }
+ return -1;
+ }
return 0;
}
@@ -192,130 +221,165 @@ NS_group_svc::group_create (
* specified object group.
*/
int
-NS_group_svc::group_bind (
- const ACE_TCHAR* group_name,
- const ACE_TCHAR* path)
+NS_group_svc::group_bind (const ACE_TCHAR* group_name,
+ const ACE_TCHAR* path)
{
-
if (group_name == 0 || path == 0)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("group_bind args not provided\n")),
- -2);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc group_bind args not provided\n")));
+ }
+ return -2;
+ }
try
- {
-
- PortableGroup::ObjectGroup_var group_var =
- this->naming_manager_->get_object_group_ref_from_name (
- ACE_TEXT_ALWAYS_CHAR(group_name));
-
- if (CORBA::is_nil (group_var.in()))
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("Unable to get reference.\n")),
- -1);
-
- CORBA::String_var str = CORBA::string_dup( ACE_TEXT_ALWAYS_CHAR (path) );
- CosNaming::Name_var name = this->name_service_->to_name ( str.in() );
-
- this->name_service_->rebind (name.in(), group_var.in());
-
- }
- catch (const CosNaming::NamingContextExt::InvalidName& ex){
- ex._tao_print_exception ("InvalidName Exception in group_bind");
-
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\n%s is invalid\n"),
- path),
- -1);
- }
- catch (const CosNaming::NamingContext::CannotProceed&){
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nCannot proceed with %s\n"),
- path),
- -1);
- }
- catch (const CosNaming::NamingContext::NotFound&){
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to find %s\n"),
- path),
- -1);
- }
- catch (const CORBA::SystemException& ex){
-
- ex._tao_print_exception ("SystemException Exception in group_bind");
-
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to bind %s\n"),
- path),
- -1);
- }
- catch (const CORBA::Exception& ex){
-
- ex._tao_print_exception ("Exception in group_bind");
-
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to bind %s\n"),
- path),
- -1);
- }
+ {
+
+ PortableGroup::ObjectGroup_var group_var =
+ this->naming_manager_->get_object_group_ref_from_name
+ (ACE_TEXT_ALWAYS_CHAR(group_name));
+
+ if (CORBA::is_nil (group_var.in()))
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to get reference.\n")));
+ }
+ return -1;
+ }
+
+ CORBA::String_var str = CORBA::string_dup( ACE_TEXT_ALWAYS_CHAR (path) );
+ CosNaming::Name_var name = this->name_service_->to_name ( str.in() );
+
+ this->name_service_->rebind (name.in(), group_var.in());
+
+ }
+ catch (const CosNaming::NamingContextExt::InvalidName& )
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc %s is invalid\n"),
+ path));
+ }
+ return -1;
+ }
+ catch (const CosNaming::NamingContext::CannotProceed&)
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Cannot proceed with %s\n"),
+ path));
+ }
+ return -1;
+ }
+ catch (const CosNaming::NamingContext::NotFound&)
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to find %s\n"),
+ path));
+ }
+ return -1;
+ }
+ catch (const CORBA::SystemException& )
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to bind %s\n"),
+ path));
+ }
+ return -1;
+ }
+ catch (const CORBA::Exception& )
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to bind %s\n"),
+ path));
+ }
+ return -1;
+ }
return 0;
}
int
-NS_group_svc::group_unbind (const ACE_TCHAR* path){
+NS_group_svc::group_unbind (const ACE_TCHAR* path)
+{
if ( path == 0)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("group_unbind args not provided\n")),
- -2);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc group_unbind args not provided\n")));
+ }
+ return -2;
+ }
try
{
-
CORBA::String_var str = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (path));
CosNaming::Name_var name = this->name_service_->to_name ( str.in() );
this->name_service_->unbind (name.in());
+ }
+ catch (const CosNaming::NamingContext::NotFound&)
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to find %s\n"),
+ path));
+ }
+ return -1;
+ }
+ catch (const CosNaming::NamingContext::CannotProceed&)
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Cannot proceed with %s\n"),
+ path));
+ }
+ return -1;
+ }
+ catch (const CosNaming::NamingContext::InvalidName&)
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc %s is invalid\n"),
+ path));
+ }
+ return -1;
+ }
+ catch (const CORBA::SystemException& )
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to unbind %s\n"),
+ path));
+ }
+ return -1;
+ }
+ catch (const CORBA::Exception& )
+ {
- }
- catch (const CosNaming::NamingContext::NotFound&){
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to find %s\n"),
- path),
- -1);
- }
- catch (const CosNaming::NamingContext::CannotProceed&){
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nCannot proceed with %s\n"),
- path),
- -1);
- }
- catch (const CosNaming::NamingContext::InvalidName&) {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\n%s is invalid\n"),
- path),
- -1);
- }
- catch (const CORBA::SystemException& ex) {
-
- ex._tao_print_exception ("Exception in group_unbind");
-
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to unbind %s\n"),
- path),
- -1);
- }
- catch (const CORBA::Exception& ex) {
-
- ex._tao_print_exception ("Exception in group_unbind");
-
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to unbind %s\n"),
- path),
- -1);
- }
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to unbind %s\n"),
+ path));
+ }
+ return -1;
+ }
return 0;
}
@@ -335,65 +399,70 @@ NS_group_svc::group_list (void)
int rc = 0;
if (display_load_policy_group (FT_Naming::ROUND_ROBIN,
ACE_TEXT ("Round Robin")) < 0 )
- {
- rc = -1;
- }
+ {
+ rc = -1;
+ }
if (rc == 0 && display_load_policy_group (FT_Naming::RANDOM,
ACE_TEXT ("Random")) < 0 )
- {
- rc = -1;
- }
+ {
+ rc = -1;
+ }
return rc;
}
int
-NS_group_svc::display_load_policy_group(
- FT_Naming::LoadBalancingStrategyValue strategy,
- const ACE_TCHAR *display_label) {
-
- if( display_label == 0 ) {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("display_load_policy_group args ")
- ACE_TEXT ("not provided\n")),
- -2);
- }
+NS_group_svc::display_load_policy_group(FT_Naming::LoadBalancingStrategyValue strategy,
+ const ACE_TCHAR *display_label)
+{
+ if( display_label == 0 )
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc display_load_policy_group args ")
+ ACE_TEXT ("not provided\n")));
+ }
+ return -2;
+ }
try
- {
-
- FT_Naming::GroupNames_var list = this->naming_manager_->groups (strategy);
-
- ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("\n%s Load Balancing Groups\n"),
- display_label));
-
- if ( list->length () > 0 ) {
-
- for (unsigned int i = 0; i < list->length (); ++i)
- {
- CORBA::String_var s = CORBA::string_dup (list[i]);
- ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT (" %C\n"),
- s.in ()));
- }
-
- } else {
- ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("No %s Load Balancing Groups Registered\n"),
- display_label));
+ {
+ FT_Naming::GroupNames_var list = this->naming_manager_->groups (strategy);
+ if (!this->quiet_)
+ {
+ ORBSVCS_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%s Load Balancing Groups\n"),
+ display_label));
+ if ( list->length () > 0 )
+ {
+
+ for (unsigned int i = 0; i < list->length (); ++i)
+ {
+ CORBA::String_var s = CORBA::string_dup (list[i]);
+ ORBSVCS_DEBUG ((LM_DEBUG,
+ ACE_TEXT (" %C\n"),
+ s.in ()));
+ }
+ }
+ else
+ {
+ ORBSVCS_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("No %s Load Balancing Groups Registered\n"),
+ display_label));
+ }
+ }
+ }
+ catch (const CORBA::Exception& )
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to get %s group list\n"),
+ display_label));
+ }
+ return -1;
}
-
- }
- catch (const CORBA::Exception& ex)
- {
- ex._tao_print_exception ("Exception in group_list");
-
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("Unable to get %s group list\n"),
- display_label),
- -1);
- }
return 0;
}
@@ -405,47 +474,57 @@ NS_group_svc::display_load_policy_group(
* requests to object group members.
*/
int
-NS_group_svc::group_modify (
- const ACE_TCHAR* group_name,
- const ACE_TCHAR* policy)
+NS_group_svc::group_modify (const ACE_TCHAR* group_name,
+ const ACE_TCHAR* policy)
{
if (group_name == 0 || policy == 0)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("group_modify args not provided\n")),
- -2);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc group_modify args not provided\n")));
+ }
+ return -2;
+ }
/// Validate load balancing strategy policy string
FT_Naming::LoadBalancingStrategyValue strategy;
if (false == determine_policy_string (policy, strategy))
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("%s is not a valid policy.\n"),
- policy),
- -2);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc %s is not a valid policy.\n"),
+ policy));
+ }
+ return -2;
+ }
try
- {
- this->naming_manager_->set_load_balancing_strategy (
- ACE_TEXT_ALWAYS_CHAR (group_name),
- strategy );
- }
+ {
+ this->naming_manager_->set_load_balancing_strategy
+ (ACE_TEXT_ALWAYS_CHAR (group_name), strategy );
+ }
catch (const PortableGroup::ObjectGroupNotFound&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to find group %s\n"),
- group_name),
- -1);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to find group %s\n"),
+ group_name));
+ }
+ return -1;
+ }
catch (const CORBA::Exception&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to modify group %s\n"),
- group_name),
- -1);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to modify group %s\n"),
+ group_name));
+ }
+ return -1;
+ }
return 0;
}
@@ -459,31 +538,39 @@ int
NS_group_svc::group_remove (const ACE_TCHAR* group_name)
{
if (group_name == 0)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("group_remove args not provided\n")),
- -2);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc group_remove args not provided\n")));
+ }
+ return -2;
+ }
try
- {
- this->naming_manager_->delete_object_group (
- ACE_TEXT_ALWAYS_CHAR (group_name));
- }
+ {
+ this->naming_manager_->delete_object_group (ACE_TEXT_ALWAYS_CHAR (group_name));
+ }
catch (const PortableGroup::ObjectGroupNotFound&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to find group %s\n"),
- group_name),
- -1);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to find group %s\n"),
+ group_name));
+ }
+ return -1;
+ }
catch (const CORBA::Exception&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to remove group %s\n"),
- group_name),
- -1);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to remove group %s\n"),
+ group_name));
+ }
+ return -1;
+ }
return 0;
}
@@ -495,65 +582,78 @@ NS_group_svc::group_remove (const ACE_TCHAR* group_name)
* is available for selection.
*/
int
-NS_group_svc::member_add (
- const ACE_TCHAR* group_name,
- const ACE_TCHAR* location,
- const ACE_TCHAR* ior)
+NS_group_svc::member_add (const ACE_TCHAR* group_name,
+ const ACE_TCHAR* location,
+ const ACE_TCHAR* ior)
{
if (group_name == 0 || location == 0 || ior == 0 )
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("member_add args not provided\n")),
- -2);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc member_add args not provided\n")));
+ }
+ return -2;
+ }
try
- {
- PortableGroup::Location location_name;
- location_name.length (1);
- location_name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (location));
-
- PortableGroup::ObjectGroup_var group_var =
- this->naming_manager_->get_object_group_ref_from_name (
- ACE_TEXT_ALWAYS_CHAR (group_name));
-
- CORBA::Object_var ior_var =
- this->orb_->string_to_object(ACE_TEXT_ALWAYS_CHAR (ior));
-
- if (CORBA::is_nil (ior_var.in ()))
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nInvalid member IOR provided.\n")),
- -1);
- }
-
- group_var = this->naming_manager_->add_member (group_var.in(),
- location_name,
- ior_var.in());
-
- }
+ {
+ PortableGroup::Location location_name;
+ location_name.length (1);
+ location_name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (location));
+
+ PortableGroup::ObjectGroup_var group_var =
+ this->naming_manager_->get_object_group_ref_from_name
+ (ACE_TEXT_ALWAYS_CHAR (group_name));
+
+ CORBA::Object_var ior_var =
+ this->orb_->string_to_object(ACE_TEXT_ALWAYS_CHAR (ior));
+
+ if (CORBA::is_nil (ior_var.in ()))
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Invalid member IOR provided.\n")));
+ }
+ return -1;
+ }
+
+ group_var = this->naming_manager_->add_member (group_var.in(),
+ location_name,
+ ior_var.in());
+
+ }
catch (const PortableGroup::ObjectGroupNotFound&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to find group %s\n"),
- group_name),
- -1);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to find group %s\n"),
+ group_name));
+ }
+ return -1;
+ }
catch (const PortableGroup::ObjectNotAdded&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to add location %s to group %s\n"),
- location, group_name),
- -1);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to add location %s to group %s\n"),
+ location, group_name));
+ }
+ return -1;
+ }
catch (const CORBA::Exception&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to add location %s to group %s\n"),
- location, group_name),
- -1);
- }
-
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to add location %s to group %s\n"),
+ location, group_name));
+ }
+ return -1;
+ }
return 0;
}
@@ -566,46 +666,59 @@ int
NS_group_svc::member_list (const ACE_TCHAR* group_name)
{
if (group_name == 0)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("member_list args not provided\n")),
- -2);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc member_list args not provided\n")));
+ }
+ return -2;
+ }
try
- {
- PortableGroup::ObjectGroup_var group_var =
- this->naming_manager_->get_object_group_ref_from_name (
- ACE_TEXT_ALWAYS_CHAR (group_name));
-
- PortableGroup::Locations_var locations =
- this->naming_manager_->locations_of_members (group_var.in());
-
- for (unsigned int i = 0; i < locations->length(); ++i)
{
- const PortableGroup::Location & loc = locations[i];
- if (loc.length() > 0) {
- ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("%C\n"),
- loc[0].id.in()));
- }
- }
+ PortableGroup::ObjectGroup_var group_var =
+ this->naming_manager_->get_object_group_ref_from_name
+ (ACE_TEXT_ALWAYS_CHAR (group_name));
+
+ PortableGroup::Locations_var locations =
+ this->naming_manager_->locations_of_members (group_var.in());
+
+ if (!this->quiet_)
+ {
+ for (unsigned int i = 0; i < locations->length(); ++i)
+ {
+ const PortableGroup::Location & loc = locations[i];
+ if (loc.length() > 0)
+ {
+ ORBSVCS_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("%C\n"),
+ loc[0].id.in()));
+ }
+ }
+ }
- }
+ }
catch (const PortableGroup::ObjectGroupNotFound&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to find group %s\n"),
- group_name),
- -1);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to find group %s\n"),
+ group_name));
+ }
+ return -1;
+ }
catch (const CORBA::Exception&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to list members for group %s\n"),
- group_name),
- -1);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to list members for group %s\n"),
+ group_name));
+ }
+ return -1;
+ }
return 0;
}
@@ -616,16 +729,18 @@ NS_group_svc::member_list (const ACE_TCHAR* group_name)
* Removes the specified member object from the specified object group.
*/
int
-NS_group_svc::member_remove (
- const ACE_TCHAR* group_name,
- const ACE_TCHAR* location)
+NS_group_svc::member_remove (const ACE_TCHAR* group_name,
+ const ACE_TCHAR* location)
{
if (group_name == 0 || location == 0)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("member_remove args not provided\n")),
- -2);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc member_remove args not provided\n")));
+ }
+ return -2;
+ }
/**
* Remove an object at a specific location from the given
@@ -636,39 +751,48 @@ NS_group_svc::member_remove (
*/
try
- {
- PortableGroup::Location location_name;
- location_name.length (1);
- location_name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (location));
-
- PortableGroup::ObjectGroup_var group_var =
- this->naming_manager_->get_object_group_ref_from_name (
- ACE_TEXT_ALWAYS_CHAR (group_name));
-
- group_var = this->naming_manager_->remove_member (group_var.in(),
- location_name);
- }
+ {
+ PortableGroup::Location location_name;
+ location_name.length (1);
+ location_name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (location));
+
+ PortableGroup::ObjectGroup_var group_var =
+ this->naming_manager_->get_object_group_ref_from_name
+ (ACE_TEXT_ALWAYS_CHAR (group_name));
+
+ group_var = this->naming_manager_->remove_member (group_var.in(),
+ location_name);
+ }
catch (const PortableGroup::ObjectGroupNotFound&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to find group %s\n"),
- group_name),
- -1);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to find group %s\n"),
+ group_name));
+ }
+ return -1;
+ }
catch (const PortableGroup::MemberNotFound&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to find member %s\n"),
- location),
- -1);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to find member %s\n"),
+ location));
+ }
+ return -1;
+ }
catch (const CORBA::Exception&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to remove member %s\n"),
- location),
- -1);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to remove member %s\n"),
+ location));
+ }
+ return -1;
+ }
return 0;
}
@@ -680,60 +804,73 @@ NS_group_svc::member_remove (
* object group.
*/
int
-NS_group_svc::member_show (
- const ACE_TCHAR* group_name,
- const ACE_TCHAR* location)
+NS_group_svc::member_show (const ACE_TCHAR* group_name,
+ const ACE_TCHAR* location)
{
if (group_name == 0 || location == 0)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("member_show args not provided\n")),
- -2);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc member_show args not provided\n")));
+ }
+ return -2;
+ }
//Get and display IOR for the member location
try
- {
- PortableGroup::Location location_name (1);
- location_name.length (1);
- location_name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (location));
+ {
+ PortableGroup::Location location_name (1);
+ location_name.length (1);
+ location_name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (location));
- PortableGroup::ObjectGroup_var group_var =
- this->naming_manager_->get_object_group_ref_from_name (
- ACE_TEXT_ALWAYS_CHAR (group_name));
+ PortableGroup::ObjectGroup_var group_var =
+ this->naming_manager_->get_object_group_ref_from_name
+ (ACE_TEXT_ALWAYS_CHAR (group_name));
- CORBA::Object_var ior_var =
- this->naming_manager_->get_member_ref (group_var.in(), location_name);
+ CORBA::Object_var ior_var =
+ this->naming_manager_->get_member_ref (group_var.in(), location_name);
- CORBA::String_var ior_string =
- this->orb_->object_to_string (ior_var.in());
+ CORBA::String_var ior_string =
+ this->orb_->object_to_string (ior_var.in());
- ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("%C\n"),
- ior_string.in()));
+ if (!this->quiet_)
+ {
+ ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("%C\n"), ior_string.in()));
+ }
- }
+ }
catch (const PortableGroup::ObjectGroupNotFound&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to find group %s\n"),
- group_name),
- -1);
- }
+ {
+
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to find group %s\n"),
+ group_name));
+ }
+ return -1;
+ }
catch (const PortableGroup::MemberNotFound&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to find member location %s\n"),
- location),
- -1);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to find member location %s\n"),
+ location));
+ }
+ return -1;
+ }
catch (const CORBA::Exception&)
- {
- ORBSVCS_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("\nUnable to show member location %s\n"),
- location),
- -1);
- }
+ {
+ if (TAO_debug_level > 2)
+ {
+ ORBSVCS_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) NS_group_svc Unable to show member location %s\n"),
+ location));
+ }
+ return -1;
+ }
return 0;
}
diff --git a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/nsgroup_svc.h b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/nsgroup_svc.h
index a3f92299b9c..16d2e19a642 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/nsgroup_svc.h
+++ b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/nsgroup_svc.h
@@ -14,10 +14,13 @@
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
/**
* @class NS_group_svc
*
* @brief Encapsulate the NS group operations in a class.
+ *
+ *
*/
class TAO_FtNaming_Intf_Export NS_group_svc
{
@@ -26,7 +29,7 @@ public:
/**
* Constructor
*/
- NS_group_svc (void);
+ NS_group_svc (bool quiet = false);
/**
* The naming service shall provide a command line utility for creating
@@ -182,6 +185,7 @@ private:
CosNaming::NamingContextExt_var name_service_;
CORBA::ORB_var orb_;
+ bool quiet_;
};
diff --git a/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp b/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp
index cef909af7c7..2700cb8c5ed 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp
+++ b/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp
@@ -957,14 +957,27 @@ TAO_Storable_Naming_Context::list (CORBA::ULong how_many,
typedef ACE_Hash_Map_Manager<TAO_Storable_ExtId,
TAO_Storable_IntId,
ACE_Null_Mutex>::ENTRY ENTRY_DEF;
+
+ // Typedef to the type of BindingIterator servant for ease of use.
typedef TAO_Bindings_Iterator<ITER_DEF, ENTRY_DEF> ITER_SERVANT;
- CORBA::ULong n = (this->context_->current_size () > how_many) ?
- how_many :
- static_cast<CORBA::ULong> (this->context_->current_size ());
+ // A pointer to BindingIterator servant.
+ ITER_SERVANT *bind_iter = 0;
+
+ // Number of bindings that will go into the BindingList <bl>.
+ CORBA::ULong n;
+
+ // Calculate number of bindings that will go into <bl>.
+ if (this->context_->current_size () > how_many)
+ n = how_many;
+ else
+ n = static_cast<CORBA::ULong> (this->context_->current_size ());
+
+ // Use the hash map iterator to populate <bl> with bindings.
bl->length (n);
ENTRY_DEF *hash_entry = 0;
+
for (CORBA::ULong i = 0; i < n; i++)
{
hash_iter->next (hash_entry);
@@ -974,26 +987,35 @@ TAO_Storable_Naming_Context::list (CORBA::ULong how_many,
throw CORBA::NO_MEMORY();
}
+ // Now we are done with the BindingsList, and we can follow up on
+ // the BindingIterator business.
+
+ // If we do not need to pass back BindingIterator.
if (this->context_->current_size () <= how_many)
return;
else if (redundant_)
{
+ ACE_UNUSED_ARG (bind_iter);
throw CORBA::NO_IMPLEMENT ();
}
else
{
- ITER_SERVANT *bind_iter = 0;
+ // Create a BindingIterator for return.
ACE_NEW_THROW_EX (bind_iter,
ITER_SERVANT (this, hash_iter, this->poa_.in ()),
CORBA::NO_MEMORY ());
+ // Release <hash_iter> from auto pointer, and start using
+ // reference counting to control our servant.
temp.release ();
- PortableServer::ServantBase_var svt = bind_iter;
+ PortableServer::ServantBase_var iter = bind_iter;
// Increment reference count on this Naming Context, so it doesn't get
// deleted before the BindingIterator servant gets deleted.
interface_->_add_ref ();
+ // Register with the POA.
+ // Is an ACE_UINT32 enough?
char poa_id[BUFSIZ];
ACE_OS::snprintf (poa_id,
BUFSIZ,
@@ -1003,9 +1025,9 @@ TAO_Storable_Naming_Context::list (CORBA::ULong how_many,
PortableServer::ObjectId_var id =
PortableServer::string_to_ObjectId (poa_id);
- this->poa_->activate_object_with_id (id.in (), svt.in());
- CORBA::Object_var obj = this->poa_->id_to_reference (id.in ());
- bi = CosNaming::BindingIterator::_narrow (obj.in());
+ this->poa_->activate_object_with_id (id.in (),
+ bind_iter);
+ bi = bind_iter->_this ();
}
}
@@ -1015,7 +1037,9 @@ TAO_END_VERSIONED_NAMESPACE_DECL
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
-CosNaming::NamingContext_ptr TAO_Storable_Naming_Context::recreate_all (
+/* static */
+CosNaming::NamingContext_ptr
+TAO_Storable_Naming_Context::recreate_all (
CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
const char *poa_id,
@@ -1073,8 +1097,7 @@ CosNaming::NamingContext_ptr TAO_Storable_Naming_Context::recreate_all (
// around a Storable_File_Guard derived class.
gfl_.reset(pers_factory->
create_stream (file_name.c_str(),
- "crw",
- false));
+ "crw"));
if (gfl_->open() != 0)
{
delete gfl_.release();
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp
index d68c41bbaef..18b25ceb638 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp
@@ -502,7 +502,7 @@ TAO::PG_Object_Group::increment_version (void)
if (TAO_debug_level > 3)
{
ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("%T %n (%P|%t) - Setting IOGR version to %u\n"),
+ ACE_TEXT ("TAO (%P|%t) PG_Object_Group::increment_version now %u\n"),
static_cast<unsigned> (this->tagged_component_.object_group_ref_version)
));
}
@@ -868,7 +868,7 @@ TAO::PG_Object_Group::initial_populate (void)
PortableGroup::InitialNumberMembersValue initial_number_members =
this->get_initial_number_members ();
- if (((PortableGroup::InitialNumberMembersValue)this->members_.current_size ()) < initial_number_members)
+ if (this->members_.current_size () < initial_number_members)
{
this->create_members (initial_number_members);
}
@@ -880,11 +880,11 @@ TAO::PG_Object_Group::minimum_populate (void)
{
ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);
- if ( this->get_membership_style () == PortableGroup::MEMB_INF_CTRL)
+ if ( this->get_membership_style () == PortableGroup::MEMB_INF_CTRL )
{
PortableGroup::MinimumNumberMembersValue minimum_number_members =
this->get_minimum_number_members ();
- if (((PortableGroup::InitialNumberMembersValue)members_.current_size ()) < minimum_number_members)
+ if (members_.current_size () < minimum_number_members)
{
this->create_members (minimum_number_members);
}
@@ -932,4 +932,3 @@ TAO::PG_Object_Group::clear_members_map (void)
}
TAO_END_VERSIONED_NAMESPACE_DECL
-
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Storable.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Storable.cpp
index 9957b044b7c..2a62308f955 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Storable.cpp
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Storable.cpp
@@ -89,19 +89,26 @@ TAO::Object_Group_File_Guard::Object_Group_File_Guard (
}
throw CORBA::INTERNAL ();
}
+
try
{
this->init (method_type);
}
- catch (const TAO::Storable_Exception &)
+ catch (const TAO::Storable_Exception &se)
{
if (TAO_debug_level > 0)
{
ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) Object_Group_File_Guard:caught ")
- ACE_TEXT ("Storable Exception\n")));
+ ACE_TEXT ("(%P|%t) Object_Group_File_Guard::ctor caught ")
+ ACE_TEXT ("Storable Exception, file = %C\n"),
+ se.get_file_name().c_str()));
+ }
+ if (object_group_.lock_.release() == -1 && TAO_debug_level > 0)
+ {
+ ORBSVCS_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) Object_Group_File_Guard::ctor %p\n"),
+ ACE_TEXT ("lock.release")));
}
- object_group_.lock_.release();
throw CORBA::INTERNAL ();
}
catch (const CORBA::NO_MEMORY &)
@@ -109,10 +116,15 @@ TAO::Object_Group_File_Guard::Object_Group_File_Guard (
if (TAO_debug_level > 0)
{
ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) Object_Group_File_Guard:caught ")
+ ACE_TEXT ("(%P|%t) Object_Group_File_Guard::ctor caught ")
ACE_TEXT ("CORBA::NO_MEMORY Exception\n")));
}
- object_group_.lock_.release();
+ if (object_group_.lock_.release() == -1 && TAO_debug_level > 0)
+ {
+ ORBSVCS_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) Object_Group_File_Guard::ctor %p\n"),
+ ACE_TEXT ("lock.release")));
+ }
throw CORBA::INTERNAL ();
}
catch (...)
@@ -120,31 +132,44 @@ TAO::Object_Group_File_Guard::Object_Group_File_Guard (
if (TAO_debug_level > 0)
{
ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) Object_Group_File_Guard:caught ")
+ ACE_TEXT ("(%P|%t) Object_Group_File_Guard::ctor caught ")
ACE_TEXT ("Unknown Exception\n")));
}
- object_group_.lock_.release();
- throw ;
+ if (object_group_.lock_.release() == -1 && TAO_debug_level > 0)
+ {
+ ORBSVCS_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) Object_Group_File_Guard::ctor %p\n"),
+ ACE_TEXT ("lock.release")));
+ }
+ throw CORBA::INTERNAL ();
}
}
TAO::Object_Group_File_Guard::~Object_Group_File_Guard ()
{
- this->release ();
-
- // Notify if persistent store was updated.
- if (object_group_.write_occurred_)
- object_group_.state_written ();
+ try
+ {
+ this->release ();
+ // Notify if persistent store was updated.
+ if (object_group_.write_occurred_)
+ object_group_.state_written ();
- if (object_group_.lock_.release() == -1)
+ }
+ catch (const TAO::Storable_Exception &se)
{
if (TAO_debug_level > 0)
{
ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) Object_Group_File_Guard:release ")
- ACE_TEXT ("failed\n")));
+ ACE_TEXT ("(%P|%t) Object_Group_File_Guard::dtor caught ")
+ ACE_TEXT ("Storable Exception, file = %C\n"),
+ se.get_file_name().c_str()));
}
- throw CORBA::INTERNAL ();
+ }
+ if (object_group_.lock_.release() == -1 && TAO_debug_level > 0)
+ {
+ ORBSVCS_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) Object_Group_File_Guard::dtor %p\n"),
+ ACE_TEXT ("lock.release")));
}
}
@@ -604,7 +629,7 @@ TAO::PG_Object_Group_Storable::write (TAO::Storable_Base & stream)
factory_id_cdr << member->factory_id_;
stream << factory_id_cdr;
- stream << (int)member->is_primary_;
+ stream << member->is_primary_;
}
stream.flush ();
this->write_occurred_ = true;
diff --git a/TAO/orbsvcs/tests/FT_Naming/stress_storable/Basic.cpp b/TAO/orbsvcs/tests/FT_Naming/stress_storable/Basic.cpp
new file mode 100644
index 00000000000..e74fdacf2bf
--- /dev/null
+++ b/TAO/orbsvcs/tests/FT_Naming/stress_storable/Basic.cpp
@@ -0,0 +1,62 @@
+// $Id: Basic.cpp 2827 2016-02-22 23:52:38Z mesnierp $
+
+#include "Basic.h"
+#include "LB_server.h"
+#include "orbsvcs/PortableGroup/PG_Property_Set.h"
+
+Basic::Basic (CORBA::Object_ptr object_group,
+ FT_Naming::NamingManager_ptr lm,
+ CORBA::ORB_ptr orb,
+ const char *loc)
+ : object_group_name_ ("Basic Group"), orb_ (CORBA::ORB::_duplicate (orb))
+{
+ this->object_group_ = CORBA::Object::_duplicate (object_group);
+ this->nm_ = FT_Naming::NamingManager::_duplicate (lm);
+ this->location_ = CORBA::string_dup (loc);
+}
+
+char *
+Basic::get_string (void)
+{
+ return CORBA::string_dup (this->location_.in ());
+}
+
+void
+Basic::remove_member (void)
+{
+ try
+ {
+ PortableGroup::Location location (1);
+ location.length (1);
+ location[0].id = CORBA::string_dup (this->location_.in ());
+ this->object_group_ =
+ this->nm_->remove_member (this->object_group_.in (),
+ location);
+
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Removed Member at Location <%C>\n",
+ this->location_.in ()));
+
+ }
+ catch (const PortableGroup::ObjectNotFound& ex)
+ {
+ ex._tao_print_exception ("Caught exception in remove_member");
+ throw CORBA::INTERNAL ();
+ }
+ catch (const PortableGroup::MemberNotFound& ex)
+ {
+ ex._tao_print_exception ("Caught exception in remove_member");
+ throw CORBA::INTERNAL ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught while destroying member\n");
+ }
+
+}
+
+
+void
+Basic::shutdown (void)
+{
+ this->orb_->shutdown (0);
+}
diff --git a/TAO/orbsvcs/tests/FT_Naming/stress_storable/Basic.h b/TAO/orbsvcs/tests/FT_Naming/stress_storable/Basic.h
new file mode 100644
index 00000000000..469d060ca15
--- /dev/null
+++ b/TAO/orbsvcs/tests/FT_Naming/stress_storable/Basic.h
@@ -0,0 +1,59 @@
+// -*- C++ -*-
+//
+// $Id: Basic.h 2827 2016-02-22 23:52:38Z mesnierp $
+
+#ifndef BASIC_H
+#define BASIC_H
+
+#include "TestS.h"
+#include "orbsvcs/FT_NamingManagerC.h"
+#include "orbsvcs/PortableGroupC.h"
+
+#if defined (_MSC_VER)
+# pragma warning(push)
+# pragma warning (disable:4250)
+#endif /* _MSC_VER */
+
+class LB_Basic_Test;
+
+/// Implement the Test::Basic interface
+class Basic
+ : public virtual POA_Test::Basic
+{
+public:
+ /// Constructor
+ Basic (CORBA::Object_ptr object_group,
+ FT_Naming::NamingManager_ptr lm,
+ CORBA::ORB_ptr orb,
+ const char *loc);
+
+ virtual char * get_string (void);
+
+ virtual void shutdown (void);
+
+ virtual void remove_member (void);
+
+private:
+
+ const char* object_group_name_;
+
+ /// Use an ORB reference to convert strings to objects and shutdown
+ /// the application.
+ CORBA::ORB_var orb_;
+
+ /// Load Manager Reference used to delete the servant reference from the
+ /// object group.
+ FT_Naming::NamingManager_var nm_;
+
+ /// location of the servant
+ CORBA::String_var location_;
+
+ /// Object Group reference.
+ CORBA::Object_var object_group_;
+};
+
+#if defined(_MSC_VER)
+# pragma warning(pop)
+#endif /* _MSC_VER */
+
+#endif /* BASIC_H */
diff --git a/TAO/orbsvcs/tests/FT_Naming/stress_storable/LB_server.cpp b/TAO/orbsvcs/tests/FT_Naming/stress_storable/LB_server.cpp
new file mode 100644
index 00000000000..ae49690a9f0
--- /dev/null
+++ b/TAO/orbsvcs/tests/FT_Naming/stress_storable/LB_server.cpp
@@ -0,0 +1,257 @@
+// $Id: LB_server.cpp 2833 2016-02-24 22:10:33Z mesnierp $
+
+#include "LB_server.h"
+#include "Basic.h"
+
+#include "TestC.h"
+#include "ace/OS_NS_stdio.h"
+
+LB_server::LB_server (int argc, ACE_TCHAR **argv)
+ : argc_ (argc)
+ , argv_ (argv)
+ , ior_output_file_(ACE_TEXT("obj.ior"))
+{
+}
+
+int
+LB_server::destroy (void)
+{
+ try
+ {
+ this->root_poa_->destroy (1, 1);
+
+ this->orb_->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception (
+ ACE_TEXT ("Exception caught while destroying LB_server\n"));
+ return -1;
+ }
+ return 0;
+
+}
+
+CORBA::ORB_ptr
+LB_server::orb (void)
+{
+ return this->orb_.in ();
+}
+
+CORBA::Object_ptr
+LB_server::object_group (void)
+{
+ return this->object_group_.in ();
+}
+
+FT_Naming::NamingManager_ptr
+LB_server::naming_manager (void)
+{
+ return this->naming_manager_.in ();
+}
+
+int
+LB_server::write_ior_to_file (const char *ior)
+{
+ FILE *output_file =
+ ACE_OS::fopen (this->ior_output_file_, ACE_TEXT ("w"));
+
+ if (output_file == 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Cannot open output file for writing IOR:")));
+ return -1;
+ }
+
+ ACE_OS::fprintf (output_file, "%s", ior);
+ ACE_OS::fclose (output_file);
+ return 0;
+}
+
+int
+LB_server::parse_args (int argc, ACE_TCHAR *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:"));
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o':
+ this->ior_output_file_ = get_opts.opt_arg ();
+ break;
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("usage: %s ")
+ ACE_TEXT ("-o <iorfile>")
+ ACE_TEXT ("\n"),
+ argv [0]),
+ -1);
+ }
+ // Indicates successful parsing of the command line
+ return 0;
+}
+
+int
+LB_server::start_orb_and_poa (void)
+{
+ try
+ {
+ // Initialise the ORB.
+ this->orb_ = CORBA::ORB_init (this->argc_, this->argv_);
+
+ CORBA::Object_var poa_object =
+ this->orb_->resolve_initial_references("RootPOA");
+
+ if (CORBA::is_nil (poa_object.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT (" (%P|%t) Unable to initialize the POA.\n")),
+ -1);
+
+ this->root_poa_ = PortableServer::POA::_narrow (poa_object.in ());
+
+ PortableServer::POAManager_var poa_manager =
+ this->root_poa_->the_POAManager ();
+
+ poa_manager->activate ();
+
+ ACE_Time_Value timeout (10); // Wait up to 10 seconds for the naming service
+ if (name_svc_.init (this->orb_.in (), &timeout) != 0)
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ ACE_TEXT ("LB_server: Could not connect to naming ")
+ ACE_TEXT ("service.\n")),
+ -1);
+
+ CORBA::Object_var obj =
+ this->orb_->resolve_initial_references ("NamingManager");
+
+ this->naming_manager_ =
+ FT_Naming::NamingManager::_narrow (obj.in ());
+
+ if (CORBA::is_nil (this->naming_manager_.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT (" (%P|%t) Unable to get Naming ")
+ ACE_TEXT ("Manager Reference\n")),
+ -1);
+
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception (
+ ACE_TEXT ("Exception raised initialising ORB or POA"));
+ return -1;
+ }
+
+ return 0;
+
+}
+
+int
+LB_server::create_object_group (void)
+{
+ try
+ {
+ if (this->parse_args (argc_, argv_) != 0)
+ return -1;
+
+ PortableGroup::Criteria criteria (1);
+ criteria.length (1);
+
+ PortableGroup::Property &mem_style = criteria[0];
+ mem_style.nam.length (1);
+
+ // Set the membership style property
+ mem_style.nam[0].id =
+ CORBA::string_dup ("org.omg.PortableGroup.MembershipStyle");
+ PortableGroup::MembershipStyleValue msv =
+ PortableGroup::MEMB_APP_CTRL;
+ mem_style.val <<= msv;
+
+ const char *group_names[] = {"C++ Group", "FORTRAN Group", "Groovy Group",
+ "Basic Group", "Java Group", "Forth Group",
+ "COBOL Group", "Ruby Group", "Scala Group",
+ "R Group", 0};
+ for (int i = 0; group_names[i] != 0; i++)
+ {
+ try
+ {
+ this->object_group_ = this->naming_manager_->create_object_group
+ (group_names[i],
+ (i & 0xFE) ? FT_Naming::RANDOM: FT_Naming::ROUND_ROBIN,
+ criteria);
+ }
+ catch (PortableGroup::ObjectNotCreated &ex)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Caught %C creating an object group named %C\n"),
+ ex._name(), group_names[i]));
+ try
+ {
+ this->object_group_ =
+ this->naming_manager_->get_object_group_ref_from_name (group_names[i]);
+ }
+ catch (CORBA::Exception &ex)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Then caught %C trying to retrieve existing group %C\n"),
+ ex._name(), group_names[i]));
+ }
+ }
+ catch (CORBA::Exception &ex)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Caught %C creating an object group named %C\n"),
+ ex._name(), group_names[i]));
+ }
+ }
+
+ CORBA::String_var ior =
+ this->orb_->object_to_string (this->object_group_.in ());
+
+ this->write_ior_to_file (ior.in ());
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception (
+ ACE_TEXT ("Exception raised while creating object group"));
+ return -1;
+ }
+
+ return 0;
+
+}
+
+int
+LB_server::register_servant (Basic *servant, const char *loc)
+{
+ try
+ {
+ Test::Basic_var basic =
+ servant->_this ();
+
+ PortableGroup::Location location (1);
+ location.length (1);
+
+ location[0].id = CORBA::string_dup (loc);
+
+ this->object_group_ =
+ this->naming_manager_->add_member (this->object_group_.in (),
+ location,
+ basic.in ());
+ }
+ catch (const CORBA::UserException& ex)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Caught %C during add_member for loc = %C\n"),
+ ex._name (), loc));
+ }
+
+ return 0;
+}
+
+TAO_Naming_Client&
+LB_server::name_svc ()
+{
+ return name_svc_;
+}
diff --git a/TAO/orbsvcs/tests/FT_Naming/stress_storable/LB_server.h b/TAO/orbsvcs/tests/FT_Naming/stress_storable/LB_server.h
new file mode 100644
index 00000000000..0673bb4eda7
--- /dev/null
+++ b/TAO/orbsvcs/tests/FT_Naming/stress_storable/LB_server.h
@@ -0,0 +1,98 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file LB_server.h
+ *
+ * $Id: LB_server.h 2827 2016-02-22 23:52:38Z mesnierp $
+ *
+ * @author Jaiganesh Balasubramanian <jai@doc.ece.uci.edu>
+ * @author Ossama Othman <ossama@uci.edu>
+ */
+//=============================================================================
+
+
+#include "orbsvcs/FT_NamingManagerC.h"
+#include "orbsvcs/PortableGroupC.h"
+#include "tao/PortableServer/PortableServer.h"
+#include "ace/Get_Opt.h"
+#include "orbsvcs/Naming/Naming_Client.h"
+
+// Forward Declaration of the kind of servant we would like to handle
+// by the server.
+class Basic;
+
+/**
+ * @class LB_server
+ *
+ * @brief Encapsulate the test in class.
+ *
+ * TODO: Fix description
+ * This is a class used to retrieve the NamingManager reference and
+ * create the Object Group. Servants add themselves to the object
+ * group and the object group reference is published to the clients.
+ * Clients then invoke the "servant operations" on the NamingManager
+ * itself. At this point the Load Balancing cycle starts.
+ */
+class LB_server
+{
+public:
+
+ /// Constructor
+ LB_server (int argc, ACE_TCHAR **argv);
+
+ /// destroys NamingManager, ORB and POA.
+ int destroy (void);
+
+ /// start the ORB.
+ int start_orb_and_poa (void);
+
+ /// Get the NamingManager Interface.
+ int init (int argc, ACE_TCHAR **argv);
+
+ /// Create the Object Group using the Load Manager Reference.
+ int create_object_group (void);
+
+ /// register the servants with the object group.
+ int register_servant (Basic *servant, const char *loc);
+
+ /// obtain the name service facade
+ TAO_Naming_Client& name_svc ();
+
+ /// for servants to register to the initialised ORB.
+ CORBA::ORB_ptr orb (void);
+
+ /// for servants to get the reference for object_group.
+ CORBA::Object_ptr object_group (void);
+
+ /// for servants to get the reference for object_group.
+ FT_Naming::NamingManager_ptr naming_manager (void);
+
+private:
+
+ int parse_args (int, ACE_TCHAR **);
+
+private:
+
+ /// Load Manager
+ FT_Naming::NamingManager_var naming_manager_;
+
+ /// Object Group.
+ CORBA::Object_var object_group_;
+
+ /// factory id for the object group.
+ PortableGroup::GenericFactory::FactoryCreationId_var fcid_;
+
+ /// Used to force the creation of the object group only once.
+ static int called_once_;
+
+ /// write the IOR to a file so that it can be read later.
+ int write_ior_to_file (const char *);
+
+ CORBA::ORB_var orb_;
+ int argc_;
+ ACE_TCHAR **argv_;
+ PortableServer::POA_var root_poa_;
+ const ACE_TCHAR *ior_output_file_;
+ TAO_Naming_Client name_svc_;
+};
diff --git a/TAO/orbsvcs/tests/FT_Naming/stress_storable/README b/TAO/orbsvcs/tests/FT_Naming/stress_storable/README
new file mode 100644
index 00000000000..adfeaca221c
--- /dev/null
+++ b/TAO/orbsvcs/tests/FT_Naming/stress_storable/README
@@ -0,0 +1,16 @@
+$Id: README 2833 2016-02-24 22:10:33Z mesnierp $
+
+This test attempts to overwhelm a multithreaded naming server by running
+more client connections than there are server threads
+
+After an initialization phase the 'hammer' threads will start requesting
+Various group membership lists as well as periodically requesting for a
+group that doesn't exist. The default root for the persistence files is
+the current work directory. The test should also be run on nfs mounted
+storage as well as local to test the retry mechanism.
+
+Command Line Options
+-p <path> Set the path to the root of the persistence files
+-n <count> Set the number of name service threads. Default 10
+-h <count> Set the number of 'hammer' threads. Default 15
+-debug Enable verbose name service logging
diff --git a/TAO/orbsvcs/tests/FT_Naming/stress_storable/Test.idl b/TAO/orbsvcs/tests/FT_Naming/stress_storable/Test.idl
new file mode 100644
index 00000000000..a6efdd7ed9b
--- /dev/null
+++ b/TAO/orbsvcs/tests/FT_Naming/stress_storable/Test.idl
@@ -0,0 +1,27 @@
+//
+// $Id: Test.idl 2827 2016-02-22 23:52:38Z mesnierp $
+
+#include "orbsvcs/FT_NamingManager.idl"
+
+/// Put the interfaces in a module, to avoid global namespace pollution
+module Test
+{
+ typedef FT_Naming::LoadBalancingStrategyValue LoadBalancingStrategyValue;
+
+ /// A very simple interface
+ interface Basic
+ {
+ /// Return a simple string
+ string get_string ();
+
+ /// A method to shutdown the ORB
+ /**
+ * This method is used to simplify the test shutdown process
+ */
+ oneway void shutdown ();
+
+ /// A method to remove the servant from the NamingManager Object Group.
+ oneway void remove_member ();
+ };
+};
+
diff --git a/TAO/orbsvcs/tests/FT_Naming/stress_storable/client.cpp b/TAO/orbsvcs/tests/FT_Naming/stress_storable/client.cpp
new file mode 100644
index 00000000000..7dde56f4283
--- /dev/null
+++ b/TAO/orbsvcs/tests/FT_Naming/stress_storable/client.cpp
@@ -0,0 +1,221 @@
+// $Id: client.cpp 2834 2016-03-01 17:41:28Z mesnierp $
+
+#include "TestC.h"
+#include "ace/Get_Opt.h"
+#include "ace/Time_Value.h"
+#include "orbsvcs/Naming/Naming_Client.h"
+#include "orbsvcs/FT_NamingManagerC.h"
+#include "orbsvcs/Naming/FaultTolerant/nsgroup_svc.h"
+#include "ace/Task.h"
+
+
+const ACE_TCHAR *group_names[] =
+ {ACE_TEXT("C++ Group"), ACE_TEXT("FORTRAN Group"), ACE_TEXT("Groovy Group"), ACE_TEXT("Basic Group"),
+ ACE_TEXT("Java Group"), ACE_TEXT("Forth Group"), ACE_TEXT("COBOL Group"), ACE_TEXT("Ruby Group"),
+ ACE_TEXT("wrong answer dude"), ACE_TEXT("Scala Group"), ACE_TEXT("R Group"), 0};
+
+class Hammer : public ACE_Task_Base
+{
+ NS_group_svc group_svc;
+
+public:
+ Hammer (CORBA::ORB_ptr orb, FT_Naming::NamingManager_ptr nm)
+ : group_svc(true)
+ {
+ group_svc.set_orb (orb);
+ group_svc.set_naming_manager (nm);
+ }
+
+ int svc (void)
+ {
+ for (int g = 0, i = 0; i < 100; i++)
+ {
+ try {
+ group_svc.member_list (group_names[g]);
+ }
+ catch (PortableGroup::ObjectGroupNotFound) {
+ }
+ catch (CORBA::Exception &ex) {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Hammer thread %t caught %C accessing %C\n"),
+ ex._name(), group_names[g]));
+ }
+ if (group_names[++g] == 0)
+ g = 0;
+ }
+
+ return 0;
+ }
+
+};
+
+const ACE_TCHAR *ior = ACE_TEXT("file://obj.ior");
+int hammers = 10;
+
+int
+parse_args (int argc, ACE_TCHAR *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:n:"));
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'k':
+ ior = get_opts.opt_arg ();
+ break;
+ case 'n':
+ hammers = ACE_OS::atoi (get_opts.opt_arg ());
+ break;
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("usage: %s ")
+ ACE_TEXT ("-k <ior> ")
+ ACE_TEXT ("\n"),
+ argv [0]),
+ -1);
+ }
+ // Indicates successful parsing of the command line
+ return 0;
+}
+
+int
+ACE_TMAIN(int argc, ACE_TCHAR *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv);
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) - Acquiring Name Service\n")));
+
+
+ CORBA::Object_var nmobj = orb->resolve_initial_references ("NameManager");
+ FT_Naming::NamingManager_var naming_manager =
+ FT_Naming::NamingManager::_narrow (nmobj.in());
+
+ TAO_Naming_Client name_svc;
+ try {
+
+ ACE_Time_Value timeout (10); // Wait up to 10 seconds for the naming service
+ if (name_svc.init (orb.in (), &timeout) != 0)
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ ACE_TEXT ("client: Could not connect to ")
+ ACE_TEXT ("naming service.\n")),
+ 1);
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception (
+ ACE_TEXT ("Exception caught while initializing name ")
+ ACE_TEXT ("service facade:"));
+ return 1;
+ }
+
+
+ Hammer hammer (orb.in(), naming_manager.in());
+
+ CosNaming::Name name (1);
+ name.length (1);
+ name[0].id = CORBA::string_dup ("basic_name");
+
+ CORBA::Object_var tmp;
+ Test::Basic_var basic;
+
+ // Iterate enough so we get a few wrap-arounds
+ for (int i = 0; i < 15; i++)
+ {
+ if (i == 3) {
+ hammer.activate (THR_NEW_LWP | THR_JOINABLE, hammers);
+ }
+
+ try {
+
+ // Each time we invoke resolve, we get a different member
+ tmp =
+ name_svc->resolve (name);
+
+ // Narrow it to a Basic object
+ basic =
+ Test::Basic::_narrow (tmp.in ());
+
+ }
+ catch (CORBA::Exception& ex)
+ {
+ ex._tao_print_exception (ACE_TEXT ("Error resolving name.\n"));
+ }
+
+ if (CORBA::is_nil (basic.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ ACE_TEXT ("Server obj ref not obtained ")
+ ACE_TEXT ("from Load Balancing Name Service\n"),
+ ior),
+ 1);
+ }
+
+ try {
+ CORBA::String_var the_string =
+ basic->get_string ();
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) - Client request handled ")
+ ACE_TEXT ("by object at <%C>\n"),
+ the_string.in ()));
+
+ }
+ catch (CORBA::Exception& ex)
+ {
+ ex._tao_print_exception (
+ ACE_TEXT ("Error invoking get_string on Basic object.\n"));
+ return 1;
+ }
+
+ // Remove one member after we wrapped around to make sure naming manager can
+ // handle it successufully
+ if (i == 7)
+ {
+ try {
+ // Try removing a member
+ basic->remove_member ();
+ }
+ catch (CORBA::Exception& ex)
+ {
+ ex._tao_print_exception (
+ ACE_TEXT ("Error invoking get_string on Basic object.\n"));
+ return 1;
+ }
+ }
+ }
+
+ hammer.wait ();
+
+ try {
+
+ basic->shutdown ();
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) - Shutting down server\n")));
+ }
+ catch (CORBA::Exception& ex)
+ {
+ ex._tao_print_exception (
+ ACE_TEXT ("Error invoking get_string on Basic object.\n"));
+ return 1;
+ }
+ orb->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception (
+ ACE_TEXT ("Exception caught in client.cpp:"));
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/TAO/orbsvcs/tests/FT_Naming/stress_storable/run_test.pl b/TAO/orbsvcs/tests/FT_Naming/stress_storable/run_test.pl
new file mode 100755
index 00000000000..e6e6f7073fc
--- /dev/null
+++ b/TAO/orbsvcs/tests/FT_Naming/stress_storable/run_test.pl
@@ -0,0 +1,210 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+# $Id: run_test.pl 2833 2016-02-24 22:10:33Z mesnierp $
+# -*- perl -*-
+
+# This is a Perl script that runs a Naming Service test. It starts
+# all the servers and clients as necessary.
+
+use lib "$ENV{ACE_ROOT}/bin";
+use PerlACE::TestTarget;
+use Cwd;
+
+$status = 0;
+$debug_level = 0;
+
+$startdir = getcwd();
+
+my $test = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
+my $server2 = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
+my $client = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
+
+
+
+# Variables for command-line arguments to naming service executables.
+$hostname = $test->HostName ();
+
+$ns_orb_port1 = 10001 + $test->RandomPort ();
+$ns_orb_port2 = 10002 + $test->RandomPort ();
+$ns_endpoint1 = "iiop://$hostname:$ns_orb_port1";
+$ns_endpoint2 = "iiop://$hostname:$ns_orb_port2";
+
+$ns_threads = 10; #was 50
+$hammers = 15; #was 60, but that seems a little much for nightly build test.
+$persist_root = ".";
+
+if ($#ARGV >= 0) {
+ my $sn_set = 0;
+ for (my $i = 0; $i <= $#ARGV; $i++) {
+ if ($ARGV[$i] eq '-debug') {
+ $debug_level = 10;
+ }
+ elsif ($ARGV[$i] eq "-n") {
+ $i++;
+ $ns_threads = $ARGV[$i];
+ }
+ elsif ($ARGV[$i] eq "-h") {
+ $i++;
+ $hammers = $ARGV[$i];
+ }
+ elsif ($ARGV[$i] eq "-p") {
+ $i++;
+ $persist_root = $ARGV[$i];
+ }
+ }
+}
+
+
+$naming_persistence_dir = "$persist_root/NameService";
+$groups_persistence_dir = "$persist_root/Groups";
+
+# $primary_iorfile = "$naming_persistence_dir/ns_replica_primary.ior";
+$ns_iorfile = "ns.ior";
+$nm_iorfile = "nm.ior";
+$primary_logfile = "ns.log";
+
+my $test_combined_ns_iorfile = $test->LocalFile ($ns_iorfile);
+my $test_combined_nm_iorfile = $test->LocalFile ($nm_iorfile);
+my $test_primary_iorfile = $test->LocalFile ($primary_iorfile);
+my $test_primary_iorfile = $test->LocalFile ($primary_logfile);
+
+my $server_obj_group_iorfile = "obj.ior";
+
+#Files used by the server2
+my $server2_nm_iorfile = $server2->LocalFile ($nm_iorfile);
+$server2->DeleteFile($server2_nm_iorfile);
+my $server2_ns_iorfile = $server2->LocalFile ($ns_iorfile);
+$server2->DeleteFile($server2_ns_iorfile);
+my $server2_obj_group_iorfile = $server2->LocalFile ($server_obj_group_iorfile);
+$server2->DeleteFile($server_obj_group_iorfile);
+
+#Files which used by client
+my $client_ns_iorfile = $client->LocalFile ($ns_iorfile);
+my $client_nm_iorfile = $client->LocalFile ($nm_iorfile);
+
+$status = 0;
+
+print "INFO: Running the test in ", getcwd(), "\n";
+
+
+sub clean_persistence_dir($$)
+{
+ my $target = shift;
+ my $directory_name = shift;
+
+ chdir $directory_name;
+ opendir(THISDIR, ".");
+ @allfiles = grep(!/^\.\.?$/, readdir(THISDIR));
+ closedir(THISDIR);
+ foreach $tmp (@allfiles){
+ $target->DeleteFile ($tmp);
+ }
+ chdir $startdir;
+}
+
+# Make sure that the directory to use to hold the persistence data
+# exists and is cleaned out.
+sub init_persistence_directory($$)
+{
+ my $target = shift;
+ my $directory_name = shift;
+
+ if ( ! -d $directory_name ) {
+ mkdir ($directory_name, 0777);
+ } else {
+ clean_persistence_dir ($target, $directory_name);
+ }
+}
+
+my $args = "-ORBEndPoint $ns_endpoint1 " .
+ "-m 0 " .
+ "-u $naming_persistence_dir " .
+ "-v $groups_persistence_dir " .
+ "-n $ns_threads " .
+ "-o $ns_iorfile -h $nm_iorfile " .
+ "-ORBDebuglevel $debug_level -ORBVerboseLogging 1 -ORBLogFile $primary_logfile ";
+
+my $prog = "$startdir/../../../FT_Naming_Service/tao_ft_naming";
+
+print STDERR "Starting Primary: $prog $args\n";
+
+$NS1 = $test->CreateProcess ("$prog", "$args");
+
+# Clean out the primary ior file to allow us to wait for it
+$test->DeleteFile ($primary_iorfile);
+$test->DeleteFile ($primary_logfile);
+init_persistence_directory ($test, $naming_persistence_dir);
+init_persistence_directory ($test, $groups_persistence_dir);
+
+$NS1->Spawn ();
+
+if ($test->WaitForFileTimed ($ns_iorfile,
+ $test->ProcessStartWaitInterval()) == -1) {
+ print STDERR "ERROR: cannot find file <$test_primary_iorfile>\n";
+ $NS1->Kill (); $NS1->TimedWait (1);
+ exit 1;
+}
+
+$SV2 = $server2->CreateProcess ("server",
+ "-ORBInitRef NameService=file://$server2_ns_iorfile " .
+ "-ORBInitRef NamingManager=file://$server2_nm_iorfile " .
+ "-o $server2_obj_group_iorfile");
+
+$CL = $client->CreateProcess ("client",
+ "-n $hammers " .
+ "-ORBInitRef NameService=file://$client_ns_iorfile " .
+ "-ORBInitRef NameManager=file://$client_nm_iorfile ");
+
+print STDERR "\n\n======== Running the Storable Stress Test================\n";
+
+$server_status = $SV2->Spawn ();
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ exit 1;
+}
+
+sub KillServers{
+ $SV1->Kill (); $SV1->TimedWait (1);
+ $SV2->Kill (); $SV2->TimedWait (1);
+}
+
+if ($server2->WaitForFileTimed ($server_obj_group_iorfile,
+ $server2->ProcessStartWaitInterval()) == -1) {
+ print STDERR "ERROR: cannot find file <$server2_obj_group_iorfile>\n";
+ KillServers ();
+ exit 1;
+}
+
+if ($server2->GetFile ($server_obj_group_iorfile) == -1) {
+ print STDERR "ERROR: cannot retrieve file <$server2_obj_group_iorfile>\n";
+ KillServers ();
+ exit 1;
+}
+
+if ($client->PutFile ($server_obj_group_iorfile) == -1) {
+ print STDERR "ERROR: cannot set file <$client_ns_iorfile>\n";
+ KillServers ();
+ exit 1;
+}
+
+$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval() + 85);
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$server_status = $SV2->WaitKill ($server2->ProcessStopWaitInterval());
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ $status = 1;
+}
+
+$NS1->Kill ();
+
+
+exit $status;
diff --git a/TAO/orbsvcs/tests/FT_Naming/stress_storable/server.cpp b/TAO/orbsvcs/tests/FT_Naming/stress_storable/server.cpp
new file mode 100644
index 00000000000..9b85fc3ee64
--- /dev/null
+++ b/TAO/orbsvcs/tests/FT_Naming/stress_storable/server.cpp
@@ -0,0 +1,119 @@
+// $Id: server.cpp 2827 2016-02-22 23:52:38Z mesnierp $
+
+#include "LB_server.h"
+#include "Basic.h"
+
+int
+ACE_TMAIN(int argc, ACE_TCHAR *argv[])
+{
+ try
+ {
+ const char *location1 = "MyLocation 1";
+ const char *location2 = "MyLocation 2";
+ const char *location3 = "MyLocation 3";
+ const char *location4 = "MyLocation 4";
+ const char *location5 = "MyLocation 5";
+ const char *location6 = "MyLocation 6";
+
+ LB_server lb_server (argc, argv);
+
+ if (lb_server.start_orb_and_poa () != 0)
+ return 1;
+
+ if (lb_server.create_object_group () != 0)
+ return 1;
+
+ CosNaming::Name name (1);
+ name.length (1);
+ name[0].id = CORBA::string_dup ("basic_name");
+ try {
+ (lb_server.name_svc ())->rebind (name, lb_server.object_group ());
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Unable to bind object group in name service.\n");
+ return 1;
+ }
+
+ Basic *basic_servant1;
+ Basic *basic_servant2;
+ Basic *basic_servant3;
+ Basic *basic_servant4;
+ Basic *basic_servant5;
+ Basic *basic_servant6;
+
+ ACE_NEW_RETURN (basic_servant1,
+ Basic (lb_server.object_group (),
+ lb_server.naming_manager (),
+ lb_server.orb (),
+ location1),
+ 1);
+ PortableServer::ServantBase_var owner_transfer1(basic_servant1);
+
+ ACE_NEW_RETURN (basic_servant2,
+ Basic (lb_server.object_group (),
+ lb_server.naming_manager (),
+ lb_server.orb (),
+ location2),
+ 1);
+ PortableServer::ServantBase_var owner_transfer2(basic_servant2);
+
+ ACE_NEW_RETURN (basic_servant3,
+ Basic (lb_server.object_group (),
+ lb_server.naming_manager (),
+ lb_server.orb (),
+ location3),
+ 1);
+ PortableServer::ServantBase_var owner_transfer3(basic_servant3);
+
+ ACE_NEW_RETURN (basic_servant4,
+ Basic (lb_server.object_group (),
+ lb_server.naming_manager (),
+ lb_server.orb (),
+ location4),
+ 1);
+ PortableServer::ServantBase_var owner_transfer4(basic_servant4);
+
+ ACE_NEW_RETURN (basic_servant5,
+ Basic (lb_server.object_group (),
+ lb_server.naming_manager (),
+ lb_server.orb (),
+ location5),
+ 1);
+ PortableServer::ServantBase_var owner_transfer5(basic_servant5);
+
+ ACE_NEW_RETURN (basic_servant6,
+ Basic (lb_server.object_group (),
+ lb_server.naming_manager (),
+ lb_server.orb (),
+ location6),
+ 1);
+ PortableServer::ServantBase_var owner_transfer6(basic_servant6);
+
+ if (lb_server.register_servant (basic_servant1, location1) == -1
+ || lb_server.register_servant (basic_servant2, location2) == -1
+ || lb_server.register_servant (basic_servant3, location3) == -1
+ || lb_server.register_servant (basic_servant4, location4) == -1
+ || lb_server.register_servant (basic_servant5, location5) == -1
+ || lb_server.register_servant (basic_servant6, location6) == -1)
+ {
+ (void) lb_server.destroy ();
+ return 1;
+ }
+
+ lb_server.orb ()->run ();
+
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
+
+ if (lb_server.destroy () == -1)
+ return 1;
+
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("lb_server exception");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/TAO/orbsvcs/tests/FT_Naming/stress_storable/stress_storable.mpc b/TAO/orbsvcs/tests/FT_Naming/stress_storable/stress_storable.mpc
new file mode 100644
index 00000000000..ec9c034cdab
--- /dev/null
+++ b/TAO/orbsvcs/tests/FT_Naming/stress_storable/stress_storable.mpc
@@ -0,0 +1,34 @@
+// -*- MPC -*-
+// $Id: stress_storable.mpc 2827 2016-02-22 23:52:38Z mesnierp $
+
+project(*idl): taoidldefaults {
+ IDL_Files {
+ Test.idl
+ }
+ custom_only = 1
+}
+
+project(*server): ftnaming {
+ after += *idl
+ exename = server
+ Source_Files {
+ TestC.cpp
+ TestS.cpp
+ server.cpp
+ LB_server.cpp
+ Basic.cpp
+ }
+ IDL_Files {
+ }
+}
+
+project(*client): ftnaming {
+ after += *idl
+ exename = client
+ Source_Files {
+ TestC.cpp
+ client.cpp
+ }
+ IDL_Files {
+ }
+}
diff --git a/TAO/tao/Storable_Base.cpp b/TAO/tao/Storable_Base.cpp
index 3c963257a09..083199b8bf7 100644
--- a/TAO/tao/Storable_Base.cpp
+++ b/TAO/tao/Storable_Base.cpp
@@ -17,6 +17,7 @@
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
bool TAO::Storable_Base::use_backup_default = false;
+bool TAO::Storable_Base::retry_on_ebadf_default = false;
void
TAO::Storable_Base::remove (void)
diff --git a/TAO/tao/Storable_Base.h b/TAO/tao/Storable_Base.h
index 2a1244f98db..bd290a75e33 100644
--- a/TAO/tao/Storable_Base.h
+++ b/TAO/tao/Storable_Base.h
@@ -32,20 +32,25 @@ namespace TAO
{
public:
- Storable_Base (bool use_backup);
+ Storable_Base (bool use_backup, bool retry_ebadf);
virtual ~Storable_Base ();
- /// The process-wide default policy
- /// for doing a backup when close ()
+ /// The process-wide default policy for doing a backup when close ()
/// is called.
- /// The backup can then be restored if
- /// restore_backup () is called.
+ /// The backup can then be restored if restore_backup () is called.
/// The initial value for the default is false.
static bool use_backup_default;
+ /// The process-wide default policy for retring certain flock operations
+ /// if an ebadf is returned. This can happen spurously on nfs mounted
+ /// file.
+ static bool retry_on_ebadf_default;
+
bool use_backup ();
+ bool retry_on_ebadf ();
+
/// Remove the file that is assumed to not be open.
/// If backup are used, the backup will also be removed.
void remove();
@@ -124,6 +129,7 @@ namespace TAO
virtual void remove_backup () = 0;
bool use_backup_;
+ bool retry_on_ebadf_;
private:
Storable_State state_;
diff --git a/TAO/tao/Storable_Base.inl b/TAO/tao/Storable_Base.inl
index 341265c9a7e..27999dd25e9 100644
--- a/TAO/tao/Storable_Base.inl
+++ b/TAO/tao/Storable_Base.inl
@@ -15,8 +15,9 @@
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
-TAO::Storable_Base::Storable_Base (bool use_backup)
+TAO::Storable_Base::Storable_Base (bool use_backup, bool retry_ebadf)
: use_backup_ (use_backup)
+ , retry_on_ebadf_ (retry_ebadf)
, state_ (goodbit)
{
}
diff --git a/TAO/tao/Storable_File_Guard.cpp b/TAO/tao/Storable_File_Guard.cpp
index 9a3d0901f6b..248ed894c51 100644
--- a/TAO/tao/Storable_File_Guard.cpp
+++ b/TAO/tao/Storable_File_Guard.cpp
@@ -34,62 +34,24 @@ TAO::Storable_File_Guard::init_no_load(Method_Type method_type)
{
ACE_CString mode;
-
- // If backup is used then always need to open with
- // write access since if the file is corrupt then
- // will overwrite with backup file.
- if (this->use_backup_)
- {
- switch (method_type)
- {
- case CREATE_WITH_FILE:
- mode = "rw";
- break;
- case CREATE_WITHOUT_FILE:
- mode = "rwc";
- break;
- case ACCESSOR:
- mode = "rw";
- break;
- case MUTATOR:
- mode = "rw";
- break;
- }
- }
- else
+ this->rwflags_ = 0;
+ switch (method_type)
{
- switch (method_type)
- {
- case CREATE_WITH_FILE:
- mode = "r";
- break;
- case CREATE_WITHOUT_FILE:
- mode = "wc";
- break;
- case ACCESSOR:
- mode = "r";
- break;
- case MUTATOR:
- mode = "rw";
- break;
- }
+ case ACCESSOR:
+ case CREATE_WITH_FILE:
+ mode = "r";
+ this->rwflags_ = mode_read;
+ break;
+ case CREATE_WITHOUT_FILE:
+ mode = "wc";
+ this->rwflags_ = mode_write | mode_create;
+ break;
+ case MUTATOR:
+ mode = "rw";
+ this->rwflags_ = mode_read | mode_write;
+ break;
}
- // We only accept a subset of mode argument, check it
- rwflags_ = 0;
- for( unsigned int i = 0; i < mode.length (); i++ )
- {
- switch (mode[i])
- {
- case 'r': rwflags_ |= mode_read;
- break;
- case 'w': rwflags_ |= mode_write;
- break;
- case 'c': rwflags_ |= mode_create;
- break;
- default: rwflags_ = -1;
- }
- }
if( rwflags_ <= 0 )
{
errno = EINVAL;
@@ -201,8 +163,9 @@ TAO::Storable_File_Guard::release (void)
{
if ( ! closed_ )
{
-
- if (this->use_backup_ )
+ if (this->use_backup_ &&
+ (rwflags_ & mode_write) != 0 &&
+ (rwflags_ & mode_create) == 0)
{
fl_->create_backup ();
}
@@ -256,10 +219,10 @@ TAO::Storable_File_Guard::load ()
ACE_CString state_str = Storable_Base::state_as_string (ex.get_state());
TAOLIB_ERROR ((LM_ERROR,
- ACE_TEXT ("TAO: (%P|%t) ERROR: State %s ")
- ACE_TEXT ("encountered reading persistent ")
- ACE_TEXT ("state from file\n%s\n"),
- state_str.c_str (), ex.get_file_name().c_str ()));
+ ACE_TEXT ("TAO: (%P|%t) ERROR: State %s ")
+ ACE_TEXT ("encountered reading persistent ")
+ ACE_TEXT ("state from file\n%s\n"),
+ state_str.c_str (), ex.get_file_name().c_str ()));
// The following opens the backup file, and copies it
// to the primary file location.
@@ -270,8 +233,8 @@ TAO::Storable_File_Guard::load ()
{
TAOLIB_ERROR ((LM_INFO,
- ACE_TEXT ("TAO: (%P|%t) Attempting to restore ")
- ACE_TEXT ("from backup\n")));
+ ACE_TEXT ("TAO: (%P|%t) Attempting to restore ")
+ ACE_TEXT ("from backup\n")));
try
{ // Load the data from the newly restored primary.
@@ -280,20 +243,20 @@ TAO::Storable_File_Guard::load ()
catch (const Storable_Read_Exception)
{ // Still having trouble reading from the file. Time to bail.
TAOLIB_ERROR ((LM_ERROR,
- ACE_TEXT ("TAO: (%P|%t) ERROR: Unable to restore ")
- ACE_TEXT ("the state from backup.\n")));
+ ACE_TEXT ("TAO: (%P|%t) ERROR: Unable to restore ")
+ ACE_TEXT ("the state from backup.\n")));
throw;
}
TAOLIB_ERROR ((LM_INFO,
- ACE_TEXT ("TAO: (%P|%t) The state was restored ")
- ACE_TEXT ("from backup.\n")));
+ ACE_TEXT ("TAO: (%P|%t) The state was restored ")
+ ACE_TEXT ("from backup.\n")));
}
else
{
TAOLIB_ERROR ((LM_ERROR,
- ACE_TEXT ("TAO: (%P|%t) ERROR: Could not read ")
- ACE_TEXT ("backup file\n")));
- throw;
+ ACE_TEXT ("TAO: (%P|%t) ERROR: Could not read ")
+ ACE_TEXT ("backup file\n")));
+ throw;
}
}
diff --git a/TAO/tao/Storable_FlatFileStream.cpp b/TAO/tao/Storable_FlatFileStream.cpp
index 0c177d74a19..6206a375477 100644
--- a/TAO/tao/Storable_FlatFileStream.cpp
+++ b/TAO/tao/Storable_FlatFileStream.cpp
@@ -14,10 +14,15 @@
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_fcntl.h"
#include "ace/OS_NS_sys_stat.h"
+#include "ace/OS_NS_strings.h"
#include "ace/Numeric_Limits.h"
#include "ace/Truncate.h"
#include "tao/debug.h"
+#if defined (ACE_HAS_MNTENT)
+#include <mntent.h>
+#endif /* ACE_HAS_MNTENT */
+
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
namespace
@@ -96,13 +101,13 @@ namespace
{
// Nothing was read
TAOLIB_ERROR ((LM_ERROR,
- ACE_TEXT ("TAO: (%P|%t) ERROR: could not read from file\n")));
+ ACE_TEXT ("TAO: (%P|%t) ERROR: could not read from file\n")));
if (ferror (f1))
{
TAOLIB_ERROR ((LM_ERROR,
- ACE_TEXT ("(%P|%t) %p\n"),
- ACE_TEXT ("ACE_OS::fread")));
+ ACE_TEXT ("(%P|%t) handle = %d, %p\n"),
+ ACE_OS::fileno(f1), ACE_TEXT ("ACE_OS::fread")));
}
return -1;
}
@@ -119,8 +124,9 @@ namespace
TAO::Storable_FlatFileStream::Storable_FlatFileStream (const ACE_CString & file,
const char * mode,
- bool use_backup)
- : Storable_Base(use_backup)
+ bool use_backup,
+ bool retry_on_ebadf)
+ : Storable_Base(use_backup, retry_on_ebadf)
, filelock_ ()
, fl_ (0)
, file_(file)
@@ -151,6 +157,20 @@ TAO::Storable_FlatFileStream::exists ()
}
int
+TAO::Storable_FlatFileStream::reopen ()
+{
+ if (TAO_debug_level > 0)
+ {
+ TAOLIB_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("TAO (%P|%t) Storable_FlatFileStream::reopen, ")
+ ACE_TEXT (" handle = %d\n"),
+ filelock_.handle_));
+ }
+ this->close();
+ return this->open();
+}
+
+int
TAO::Storable_FlatFileStream::open()
{
// For now, three flags exist "r", "w", and "c"
@@ -165,27 +185,47 @@ TAO::Storable_FlatFileStream::open()
flags = O_WRONLY, fdmode = "w";
if( ACE_OS::strchr(mode_.c_str(), 'c') )
flags |= O_CREAT;
+
#ifndef ACE_WIN32
if( ACE_OS::flock_init (&filelock_, flags,
ACE_TEXT_CHAR_TO_TCHAR (file_.c_str()), 0666) != 0 )
TAOLIB_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("(%P|%t) Cannot open file %s for mode %s: %p\n"),
+ ACE_TEXT ("(%P|%t) Storable_FFS::open ")
+ ACE_TEXT ("Cannot open file %s for mode %s: %p\n"),
file_.c_str(), mode_.c_str(), ACE_TEXT ("ACE_OS::flock_init")),
- -1);
+ -1);
#else
if( (filelock_.handle_= ACE_OS::open (file_.c_str(), flags, 0)) == ACE_INVALID_HANDLE )
TAOLIB_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("(%P|%t) Cannot open file %s for mode %s: %p\n"),
+ ACE_TEXT ("(%P|%t) Storable_FFS::open ")
+ ACE_TEXT ("Cannot open file %s for mode %s: %p\n"),
file_.c_str(), mode_.c_str(), ACE_TEXT ("ACE_OS::open")),
- -1);
+ -1);
#endif
- this->fl_ = ACE_OS::fdopen(filelock_.handle_, ACE_TEXT_CHAR_TO_TCHAR (fdmode));
- if (this->fl_ == 0)
- TAOLIB_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("(%P|%t) Cannot open file %s for mode %s: %p\n"),
- file_.c_str(), mode_.c_str(), ACE_TEXT ("ACE_OS::fdopen")),
- -1);
- return 0;
+
+ this->fl_ = 0;
+ for (int attempts = this->retry_on_ebadf_ ? 2 : 1;
+ attempts > 0 && this->fl_ == 0;
+ attempts--)
+ {
+ this->fl_ = ACE_OS::fdopen(filelock_.handle_, ACE_TEXT_CHAR_TO_TCHAR (fdmode));
+
+ if (this->fl_ == 0)
+ {
+ if (TAO_debug_level > 0)
+ {
+ TAOLIB_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) Storable_FFS::open ")
+ ACE_TEXT ("Cannot open file %s for mode %s: %p\n"),
+ file_.c_str(), mode_.c_str(), ACE_TEXT ("ACE_OS::fdopen")));
+ }
+ if (errno != EBADF)
+ {
+ break;
+ }
+ }
+ }
+ return this->fl_ == 0 ? -1 : 0;
}
int
@@ -205,69 +245,135 @@ TAO::Storable_FlatFileStream::close()
int
TAO::Storable_FlatFileStream::flock (int whence, int start, int len)
{
+ int result = 0;
#if defined (ACE_WIN32)
ACE_UNUSED_ARG (whence);
ACE_UNUSED_ARG (start);
ACE_UNUSED_ARG (len);
#else
- if( ACE_OS::strcmp(mode_.c_str(), "r") == 0 )
+ bool shared = ACE_OS::strcmp(mode_.c_str(), "r") == 0;
+ result = -1;
+ bool retry = false;
+ for (int attempts = this->retry_on_ebadf_ ? 2 : 1;
+ attempts > 0 && result != 0;
+ attempts--)
{
- if (ACE_OS::flock_rdlock(&filelock_, whence, start, len) != 0)
- TAOLIB_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) - ")
- ACE_TEXT ("Storable_FlatFileStream::flock, ")
- ACE_TEXT ("Error trying to get a read lock for file %s\n"),
- file_.c_str ()),
- -1);
- }
-
- else
- {
- if (ACE_OS::flock_wrlock(&filelock_, whence, start, len) != 0)
- TAOLIB_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) - ")
- ACE_TEXT ("Storable_FlatFileStream::flock, ")
- ACE_TEXT ("Error trying to get a write lock for file %s\n"),
- file_.c_str ()),
- -1);
+ if (retry)
+ this->reopen();
+ retry = true;
+ result = shared ?
+ ACE_OS::flock_rdlock(&filelock_, whence, start, len) :
+ ACE_OS::flock_wrlock(&filelock_, whence, start, len);
+ if (result != 0)
+ {
+ if (TAO_debug_level > 0)
+ {
+ TAOLIB_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) - ")
+ ACE_TEXT ("Storable_FlatFileStream::flock, ")
+ ACE_TEXT ("File %C, %p\n"),
+ file_.c_str (),
+ (shared ? ACE_TEXT("rdlock") : ACE_TEXT("wrlock"))));
+ }
+ if (errno != EBADF)
+ {
+ break;
+ }
+ }
}
#endif
- return 0;
+ return result;
}
int
TAO::Storable_FlatFileStream::funlock (int whence, int start, int len)
{
+ int result = 0;
#if defined (ACE_WIN32)
ACE_UNUSED_ARG (whence);
ACE_UNUSED_ARG (start);
ACE_UNUSED_ARG (len);
#else
- if (ACE_OS::flock_unlock(&filelock_, whence, start, len) != 0)
- TAOLIB_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) - ")
- ACE_TEXT ("Storable_FlatFileStream::funlock, ")
- ACE_TEXT ("Error trying to unlock file %s\n"),
- file_.c_str ()),
- -1);
+ result = -1;
+ bool retry = false;
+ for (int attempts = this->retry_on_ebadf_ ? 2 : 1;
+ attempts > 0 && result != 0;
+ attempts--)
+ {
+ if (retry)
+ this->reopen();
+ retry = true;
+ result = ACE_OS::flock_unlock(&filelock_, whence, start, len);
+ if (result != 0)
+ {
+ if (TAO_debug_level > 0)
+ {
+ TAOLIB_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) - ")
+ ACE_TEXT ("Storable_FlatFileStream::flock, ")
+ ACE_TEXT ("File %C, %p\n"),
+ file_.c_str (),
+ ACE_TEXT("unlock")));
+ }
+ if (errno != EBADF)
+ {
+ break;
+ }
+ }
+ }
+
#endif
- return 0;
+ return result;
}
time_t
TAO::Storable_FlatFileStream::last_changed(void)
{
ACE_stat st;
- int result = filelock_.handle_ != ACE_INVALID_HANDLE ?
- ACE_OS::fstat(filelock_.handle_, &st) :
- ACE_OS::stat (file_.c_str (), &st);
+ int result = 0;
+ bool do_stat = filelock_.handle_ == ACE_INVALID_HANDLE;
+ if (!do_stat)
+ {
+ bool retry = false;
+ result = -1;
+ for (int attempts = this->retry_on_ebadf_ ? 2 : 1;
+ attempts > 0 && result != 0;
+ attempts--)
+ {
+ if (retry)
+ this->reopen();
+ retry = true;
+
+ result = ACE_OS::fstat(filelock_.handle_, &st);
+ if (result != 0)
+ {
+ if (TAO_debug_level > 0)
+ {
+ TAOLIB_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) - ")
+ ACE_TEXT ("Storable_FlatFileStream::last_changed, ")
+ ACE_TEXT ("File %C, handle %d, %p\n"),
+ file_.c_str (), filelock_.handle_, ACE_TEXT("fstat")));
+ }
+ if (errno != EBADF)
+ {
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ result = ACE_OS::stat (file_.c_str (), &st);
+ }
if (result != 0)
{
TAOLIB_ERROR ((LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) - ")
- ACE_TEXT ("Storable_FlatFileStream::last_changed, ")
- ACE_TEXT ("Error getting file information\n")));
+ ACE_TEXT ("TAO (%P|%t) - ")
+ ACE_TEXT ("Storable_FlatFileStream::last_changed, ")
+ ACE_TEXT ("Error getting file information for %C, handle %d, %p\n"),
+ this->file_.c_str(), filelock_.handle_, ACE_TEXT("fstat")));
throw Storable_Exception (this->file_);
}
@@ -277,7 +383,7 @@ TAO::Storable_FlatFileStream::last_changed(void)
void
TAO::Storable_FlatFileStream::rewind (void)
{
- return ACE_OS::rewind(this->fl_);
+ ACE_OS::rewind(this->fl_);
}
bool
@@ -385,7 +491,7 @@ TAO::Storable_Base &
TAO::Storable_FlatFileStream::operator << (const TAO_OutputCDR & cdr)
{
unsigned int const length =
- ACE_Utils::truncate_cast<unsigned int> (cdr.total_length ());
+ ACE_Utils::truncate_cast<unsigned int> (cdr.total_length ());
*this << length;
for (const ACE_Message_Block *i = cdr.begin (); i != 0; i = i->cont ())
{
@@ -417,16 +523,46 @@ TAO::Storable_FlatFileStream::backup_file_name ()
int
TAO::Storable_FlatFileStream::create_backup ()
{
- FILE * backup = ACE_OS::fopen (this->backup_file_name ().c_str (), "w");
- this->rewind();
- int result = file_copy(this->fl_, backup);
- if (result != 0)
+ if (this->fl_ == 0)
{
- TAOLIB_ERROR ((LM_ERROR,
- ACE_TEXT ("TAO: (%P|%t) ERROR: Unable to create backup ")
- ACE_TEXT ("of file\n%s\n"), file_.c_str ()));
+ return 0;
+ }
+
+ bool retry = false;
+ int result = -1;
+ for (int attempts = this->retry_on_ebadf_ ? 2 : 1;
+ attempts > 0 && result < 0;
+ attempts--)
+ {
+ if (retry)
+ this->reopen();
+ retry = true;
+ errno = 0;
+ this->rewind();
+ if (errno != 0)
+ {
+ if (errno == EBADF)
+ {
+ continue;
+ }
+ break;
+ }
+ FILE * backup = ACE_OS::fopen (this->backup_file_name ().c_str (), "w");
+ result = file_copy(this->fl_, backup);
+ if (result != 0)
+ {
+ TAOLIB_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO: (%P|%t) Storable_FlatFileStream::")
+ ACE_TEXT ("create_backup Unable to create backup ")
+ ACE_TEXT ("of file %s\n"), file_.c_str ()));
+ if (errno != EBADF)
+ {
+ ACE_OS::fclose (backup);
+ break;
+ }
+ }
+ ACE_OS::fclose (backup);
}
- ACE_OS::fclose (backup);
return result;
}
@@ -449,6 +585,12 @@ TAO::Storable_FlatFileStream::restore_backup ()
if (ACE_OS::access (backup_name.c_str (), F_OK))
return -1;
+ if (ACE_OS::strchr (this->mode_.c_str(),'w') == 0)
+ {
+ this->mode_ += 'w';
+ }
+ this->reopen ();
+
FILE * backup = ACE_OS::fopen (backup_name.c_str (),
"r");
this->rewind();
@@ -481,12 +623,105 @@ TAO::Storable_FlatFileStream::throw_on_write_error (Storable_State state)
}
}
-TAO::Storable_FlatFileFactory::Storable_FlatFileFactory(const ACE_CString & directory)
+//------------------------------------------------
+
+TAO::Storable_FlatFileFactory::Storable_FlatFileFactory(const ACE_CString & directory,
+ bool use_backup,
+ bool retry_on_ebadf)
: Storable_Factory ()
, directory_(directory)
+ , use_backup_(use_backup)
+ , retry_on_ebadf_ (retry_on_ebadf)
{
}
+TAO::Storable_FlatFileFactory::Storable_FlatFileFactory(const ACE_CString & directory,
+ bool use_backup)
+ : Storable_Factory ()
+ , directory_(directory)
+ , use_backup_(use_backup)
+ , retry_on_ebadf_ (Storable_Base::retry_on_ebadf_default)
+{
+ retry_on_ebadf_ = Storable_FlatFileFactory::is_nfs (directory);
+}
+
+bool
+TAO::Storable_FlatFileFactory::is_nfs (const ACE_CString& directory)
+{
+ bool ret = false;
+#if defined (ACE_HAS_MNTENT)
+ const char *dir = directory.c_str();
+ char rpath [PATH_MAX];
+ if (*dir != '/')
+ {
+ rpath[0] = 0;
+ if (ACE_OS::getcwd (rpath, PATH_MAX) == 0)
+ {
+ if (TAO_debug_level > 0)
+ {
+ TAOLIB_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) Storable_FFFactory::is_nfs ")
+ ACE_TEXT ("could not get full path, %p\n"),
+ ACE_TEXT ("getcwd")));
+ }
+ return ret;
+ }
+ size_t rootlen = ACE_OS::strlen(rpath);
+ if ((rootlen + directory.length() +1) > PATH_MAX)
+ {
+ if (TAO_debug_level > 0)
+ {
+ TAOLIB_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) Storable_FFFactory::is_nfs ")
+ ACE_TEXT ("combined root + supplied paths too long:")
+ ACE_TEXT ("%C + / + %C\n"), rpath, dir));
+ }
+ return ret;
+ }
+ char *pos = rpath + rootlen;
+ *pos++ = '/';
+ ACE_OS::strcpy (pos,directory.c_str());
+ dir = rpath;
+ }
+ size_t match = 0;
+ size_t dirlen = ACE_OS::strlen(dir);
+ struct mntent *ent = 0;
+ const char *fname = "/etc/mtab";
+ FILE *mt = ::setmntent(fname,"r");
+ if (mt == 0)
+ {
+ if (TAO_debug_level > 0)
+ {
+ TAOLIB_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) Storable_FFFactory::is_nfs ")
+ ACE_TEXT ("could not open %C, %p\n"),
+ fname, ACE_TEXT ("setmntent")));
+ }
+ return ret;
+ }
+ while ((ent = ::getmntent(mt)) != 0)
+ {
+ size_t len = ACE_OS::strlen(ent->mnt_dir);
+
+ if (len > dirlen || len < match)
+ {
+ continue;
+ }
+ if (len >= match &&ACE_OS::strstr (dir, ent->mnt_dir) == dir)
+ {
+ match = len;
+ ret = (ACE_OS::strcasecmp (ent->mnt_type, "nfs") == 0);
+ if (len == dirlen)
+ {
+ break; // exact match
+ }
+ }
+ }
+ ::endmntent (mt);
+#endif /* ACE_HAS_MNTENT */
+ return ret;
+}
+
TAO::Storable_FlatFileFactory::~Storable_FlatFileFactory()
{
}
@@ -500,14 +735,15 @@ TAO::Storable_FlatFileFactory::get_directory () const
TAO::Storable_Base *
TAO::Storable_FlatFileFactory::create_stream (const ACE_CString & file,
const char * mode,
- bool use_backup)
+ bool )
{
TAO::Storable_Base *stream = 0;
ACE_CString path = this->directory_ + "/" + file;
ACE_NEW_RETURN (stream,
TAO::Storable_FlatFileStream(path,
mode,
- use_backup),
+ this->use_backup_,
+ this->retry_on_ebadf_),
0);
return stream;
}
diff --git a/TAO/tao/Storable_FlatFileStream.h b/TAO/tao/Storable_FlatFileStream.h
index 9547fb22348..c0131894a86 100644
--- a/TAO/tao/Storable_FlatFileStream.h
+++ b/TAO/tao/Storable_FlatFileStream.h
@@ -4,6 +4,8 @@
/**
* @file Storable_FlatFileStream.h
*
+ * $Id: Storable_FlatFileStream.h 2827 2016-02-22 23:52:38Z mesnierp $
+ *
* @author Marina Spivak <marina@cs.wustl.edu>
* @author Byron Harris <harrisb@ociweb.com>
*/
@@ -37,8 +39,8 @@ namespace TAO
public:
Storable_FlatFileStream(const ACE_CString & file, const char * mode,
- bool use_backup =
- Storable_Base::use_backup_default);
+ bool use_backup = Storable_Base::use_backup_default,
+ bool retry_on_ebadf = Storable_Base::retry_on_ebadf_default);
virtual ~Storable_FlatFileStream();
@@ -48,6 +50,11 @@ namespace TAO
/// Open a file (the remaining methods below all require an open file)
virtual int open ();
+ /// When the locked file resides on an NFS mounted volume, occasionally
+ /// the FD of the opened file becomes stale, when that happens the handle
+ /// needs to be refreshed and the lock verified
+ virtual int reopen ();
+
/// Acquire a file lock
virtual int close ();
@@ -120,7 +127,11 @@ namespace TAO
/// @param directory Directory to contain file passed in
/// create_stream (). The directory is assumed to already exist.
- Storable_FlatFileFactory(const ACE_CString & directory);
+ Storable_FlatFileFactory(const ACE_CString & directory,
+ bool use_backup = Storable_Base::use_backup_default);
+ Storable_FlatFileFactory(const ACE_CString & directory,
+ bool use_backup,
+ bool retry_on_ebadf);
const ACE_CString & get_directory () const;
@@ -131,11 +142,12 @@ namespace TAO
/// Create the stream that can operate on a disk file
virtual Storable_Base *create_stream (const ACE_CString & file,
const char * mode,
- bool use_backup =
- Storable_Base::use_backup_default);
+ bool = false);
private:
+ static bool is_nfs (const ACE_CString &dir);
ACE_CString directory_;
-
+ bool use_backup_;
+ bool retry_on_ebadf_;
};
}