summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/ImplRepo_Service
diff options
context:
space:
mode:
authormichel_j <michel_j@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-05-23 17:58:35 +0000
committermichel_j <michel_j@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-05-23 17:58:35 +0000
commit904ae615dcd5732034d4b27f997046ef29b6b7a1 (patch)
tree356619b2ce4020f571bb845e627617e0f66a9281 /TAO/orbsvcs/ImplRepo_Service
parentece78c0620b576b32eb3e133ac53f5a2d89804c5 (diff)
downloadATCD-904ae615dcd5732034d4b27f997046ef29b6b7a1.tar.gz
ChangeLogTag: Mon May 23 12:38:31 2005 Justin Michel <michel_j@ociweb.com>
Diffstat (limited to 'TAO/orbsvcs/ImplRepo_Service')
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Activator_Options.cpp13
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp46
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Activator.idl2
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp50
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.h8
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Locator.cpp47
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp177
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h44
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Locator_Options.cpp15
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Locator_Options.h6
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Locator_Repository.cpp32
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Locator_Repository.h2
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/README.txt2
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp373
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h75
15 files changed, 500 insertions, 392 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/Activator_Options.cpp b/TAO/orbsvcs/ImplRepo_Service/Activator_Options.cpp
index 7c13173a280..463fa913844 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Activator_Options.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Activator_Options.cpp
@@ -180,9 +180,8 @@ Activator_Options::print_usage (void) const
" ('install' or 'remove' or 'install_no_imr')\n"
" -d level Sets the debug level\n"
" -o file Outputs the ImR's IOR to a file\n"
- " -l Notify the ImR Locator when a process exits\n"
- " -n name Specify a name for the Activator\n"
- " -s Runs as a service (NT Only)\n")
+ " -l Notify the ImR when a process exits\n"
+ " -n name Specify a name for the Activator\n")
);
}
@@ -221,6 +220,11 @@ Activator_Options::save_registry_options()
(LPBYTE) this->name_.c_str(), this->name_.length() + 1);
ACE_ASSERT(err == ERROR_SUCCESS);
+ DWORD tmpint = this->notify_imr_;
+ err = ACE_TEXT_RegSetValueEx(key, "NotifyImR", 0, REG_DWORD,
+ (LPBYTE) &tmpint , sizeof(tmpint));
+ ACE_ASSERT(err == ERROR_SUCCESS);
+
err = ::RegCloseKey(key);
ACE_ASSERT(err == ERROR_SUCCESS);
#endif
@@ -279,13 +283,14 @@ Activator_Options::load_registry_options ()
this->name_ = tmpstr;
}
- DWORD tmpint = this->notify_imr_;
+ DWORD tmpint = 0;
sz = sizeof(tmpint);
err = ACE_TEXT_RegQueryValueEx(key, "NotifyImR", 0, &type,
(LPBYTE) &tmpint , &sz);
if (err == ERROR_SUCCESS) {
ACE_ASSERT(type == REG_DWORD);
}
+ this->notify_imr_ = tmpint != 0;
err = ::RegCloseKey(key);
ACE_ASSERT(err == ERROR_SUCCESS);
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp
index 4f8d6ee8b9f..37eb23a1884 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp
@@ -5,11 +5,47 @@
#include "ImR_Activator_i.h"
#include "Activator_NT_Service.h"
+#include "orbsvcs/Shutdown_Utilities.h"
+
+class ImR_Activator_Shutdown : public Shutdown_Functor
+{
+public:
+ ImR_Activator_Shutdown(ImR_Activator_i& act);
+
+ void operator() (int which_signal);
+private:
+ ImR_Activator_i& act_;
+};
+
+ImR_Activator_Shutdown::ImR_Activator_Shutdown (ImR_Activator_i &act)
+ : act_(act)
+{
+}
+
+void
+ImR_Activator_Shutdown::operator() (int /*which_signal*/)
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ this->act_.shutdown(true ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR Activator: ");
+ }
+ ACE_ENDTRY;
+}
+
int
run_standalone (Activator_Options& opts)
{
ImR_Activator_i server;
+ ImR_Activator_Shutdown killer (server);
+ Service_Shutdown kill_contractor(killer);
+
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
@@ -91,7 +127,7 @@ run_service_command (Activator_Options& opts)
opts.service_command() == Activator_Options::SC_INSTALL_NO_LOCATOR)
{
const DWORD MAX_PATH_LENGTH = 4096;
- char pathname[MAX_PATH_LENGTH];
+ char pathname[MAX_PATH_LENGTH];
DWORD length = ACE_TEXT_GetModuleFileName(NULL, pathname, MAX_PATH_LENGTH);
if (length == 0 || length >= MAX_PATH_LENGTH - sizeof(" -s"))
@@ -127,19 +163,19 @@ run_service_command (Activator_Options& opts)
} else {
ACE_ERROR((LM_ERROR, "Error: Failed to install service.\n"));
}
- if (ret == 0)
+ if (ret == 0)
return 1;
}
else if (opts.service_command() == Activator_Options::SC_REMOVE)
{
int ret = SERVICE::instance ()->remove ();
ACE_DEBUG ((LM_DEBUG, "ImR Activator: Service removed.\n"));
- if (ret == 0)
+ if (ret == 0)
return 1; // If successfull, then we don't want to continue.
}
- else
+ else
{
- ACE_ERROR ((LM_ERROR, "Error: Unknown service command :%d \n",
+ ACE_ERROR ((LM_ERROR, "Error: Unknown service command :%d \n",
opts.service_command()));
return -1;
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.idl b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.idl
index 0027fc8c159..aa0fecbd401 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.idl
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.idl
@@ -11,6 +11,8 @@ module ImplementationRepository
// Tells the activator to launch a server with the given information.
void start_server(in string name, in string cmdline,
in string dir, in EnvironmentList env) raises(CannotActivate);
+
+ oneway void shutdown();
};
};
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp
index dea5e9fcbf4..74911fa6839 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp
@@ -197,7 +197,11 @@ ImR_Activator_i::init_with_orb(CORBA::ORB_ptr orb, const Activator_Options& opts
int
ImR_Activator_i::init (Activator_Options& opts ACE_ENV_ARG_DECL)
{
- ACE_ARGV av(opts.cmdline());
+ ACE_CString cmdline = opts.cmdline();
+ // Must use IOR style objrefs, because URLs sometimes get mangled when passed
+ // to ACE_Process::spawn().
+ cmdline += "-ORBUseImR 0 -ORBObjRefStyle IOR ";
+ ACE_ARGV av(cmdline.c_str());
int argc = av.argc();
CORBA::ORB_var orb =
@@ -218,6 +222,8 @@ ImR_Activator_i::fini (ACE_ENV_SINGLE_ARG_DECL)
if (debug_ > 1)
ACE_DEBUG((LM_DEBUG, "ImR Activator: Shutting down...\n"));
+ this->process_mgr_.close();
+
this->root_poa_->destroy (1, 1 ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
@@ -227,7 +233,27 @@ ImR_Activator_i::fini (ACE_ENV_SINGLE_ARG_DECL)
this->registration_token_ ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
+ }
+ ACE_CATCH(CORBA::COMM_FAILURE, ex)
+ {
+ if (debug_ > 1)
+ ACE_DEBUG((LM_DEBUG, "ImR Activator: Unable to unregister from ImR.\n"));
+ }
+ ACE_CATCH(CORBA::TRANSIENT, ex)
+ {
+ if (debug_ > 1)
+ ACE_DEBUG((LM_DEBUG, "ImR Activator: Unable to unregister from ImR.\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR Activator: fini");
+ ACE_RE_THROW;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+ ACE_TRY
+ {
this->orb_->destroy(ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
@@ -236,7 +262,7 @@ ImR_Activator_i::fini (ACE_ENV_SINGLE_ARG_DECL)
}
ACE_CATCHANY
{
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR_Activator_i::fini");
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR Activator: fini 2");
ACE_RE_THROW;
}
ACE_ENDTRY;
@@ -253,6 +279,19 @@ ImR_Activator_i::run (ACE_ENV_SINGLE_ARG_DECL)
}
void
+ImR_Activator_i::shutdown (ACE_ENV_SINGLE_ARG_DECL)
+ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ shutdown(false ACE_ENV_ARG_PARAMETER);
+}
+
+void
+ImR_Activator_i::shutdown (bool wait_for_completion ACE_ENV_ARG_DECL)
+{
+ this->orb_->shutdown(wait_for_completion ACE_ENV_ARG_PARAMETER);
+}
+
+void
ImR_Activator_i::start_server(const char* name,
const char* cmdline,
const char* dir,
@@ -273,6 +312,13 @@ ImR_Activator_i::start_server(const char* name,
// handles. This includes stdin, stdout, logs, etc.
proc_opts.handle_inheritence (0);
+ proc_opts.setenv("TAO_USE_IMR", "1");
+ if (!CORBA::is_nil (this->locator_.in ()))
+ {
+ CORBA::String_var ior = orb_->object_to_string(locator_.in());
+ proc_opts.setenv("ImplRepoServiceIOR", ior.in());
+ }
+
for (CORBA::ULong i = 0; i < env.length(); ++i) {
proc_opts.setenv (env[i].name.in(), env[i].value.in());
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.h b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.h
index dedfe744ced..7b62dc525cf 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.h
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.h
@@ -29,7 +29,7 @@
class Activator_Options;
-// ace/Functor.h doesn't provide functors for every built in integer type.
+// ace/Functor.h doesn't provide functors for every built in integer type.
// Depending on the platform and what pid_t maps to, the functors may be missing.
struct ACE_Hash_pid_t
{
@@ -70,6 +70,9 @@ public:
const ImplementationRepository::EnvironmentList & env ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::CannotActivate));
+ void shutdown(ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
/// Initialize the Server state - parsing arguments and waiting.
int init (Activator_Options& opts ACE_ENV_ARG_DECL_WITH_DEFAULTS);
@@ -79,6 +82,9 @@ public:
/// Runs the orb.
int run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
+ /// Shutdown the orb.
+ void shutdown (bool wait_for_completion ACE_ENV_ARG_DECL);
+
private:
int init_with_orb (CORBA::ORB_ptr orb, const Activator_Options& opts ACE_ENV_ARG_DECL_WITH_DEFAULTS);
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.cpp
index 86fe4313604..b8d88642125 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.cpp
@@ -3,12 +3,47 @@
#include "ImR_Locator_i.h"
#include "Locator_NT_Service.h"
#include "Locator_Options.h"
+#include "orbsvcs/Shutdown_Utilities.h"
+
+class ImR_Locator_Shutdown : public Shutdown_Functor
+{
+public:
+ ImR_Locator_Shutdown(ImR_Locator_i& imr);
+
+ void operator() (int which_signal);
+private:
+ ImR_Locator_i& imr_;
+};
+
+ImR_Locator_Shutdown::ImR_Locator_Shutdown (ImR_Locator_i &imr)
+ : imr_(imr)
+{
+}
+
+void
+ImR_Locator_Shutdown::operator() (int /*which_signal*/)
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ this->imr_.shutdown(true ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR: ");
+ }
+ ACE_ENDTRY;
+}
int
run_standalone (Options& opts)
{
ImR_Locator_i server;
+ ImR_Locator_Shutdown killer (server);
+ Service_Shutdown kill_contractor(killer);
+
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
@@ -81,7 +116,7 @@ run_service (void)
static int
run_service_command (Options& opts)
{
- if (opts.service_command() == Options::SC_NONE)
+ if (opts.service_command() == Options::SC_NONE)
return 0;
#if defined (ACE_WIN32)
@@ -90,7 +125,7 @@ run_service_command (Options& opts)
if (opts.service_command() == Options::SC_INSTALL)
{
const DWORD MAX_PATH_LENGTH = 4096;
- char pathname[MAX_PATH_LENGTH];
+ char pathname[MAX_PATH_LENGTH];
DWORD length = ACE_TEXT_GetModuleFileName(NULL, pathname, MAX_PATH_LENGTH);
if (length == 0 || length >= MAX_PATH_LENGTH - sizeof(" -s"))
@@ -111,19 +146,19 @@ run_service_command (Options& opts)
} else {
ACE_ERROR((LM_ERROR, "Error: Failed to install service. error:%d\n", errno));
}
- if (ret == 0)
+ if (ret == 0)
return 1;
}
else if (opts.service_command() == Options::SC_REMOVE)
{
int ret = SERVICE::instance ()->remove ();
ACE_DEBUG ((LM_DEBUG, "ImR: Service removed.\n"));
- if (ret == 0)
+ if (ret == 0)
return 1; // If successfull, then we don't want to continue.
}
- else
+ else
{
- ACE_ERROR ((LM_ERROR, "Error: Unknown service command :%d \n",
+ ACE_ERROR ((LM_ERROR, "Error: Unknown service command :%d \n",
opts.service_command()));
return -1;
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
index adc06001a88..4e6b302d802 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
@@ -14,6 +14,7 @@
#include "ace/ARGV.h"
#include "ace/OS_NS_sys_time.h"
+#include "ace/Vector_T.h"
static const int DEFAULT_START_LIMIT = 1;
@@ -150,7 +151,7 @@ ImR_Locator_i::init_with_orb (CORBA::ORB_ptr orb, Options& opts ACE_ENV_ARG_DECL
// The init can return 1 if there is no persistent file yet. In
// that case, we need not do anything for now.
int init_result =
- this->repository_.init (opts.repository_mode(), opts.persist_file_name());
+ this->repository_.init (opts);
if (init_result == -1)
{
ACE_ERROR_RETURN ((LM_ERROR, "Repository failed to initialize\n"), -1);
@@ -187,7 +188,7 @@ int
ImR_Locator_i::init(Options& opts ACE_ENV_ARG_DECL)
{
ACE_CString cmdline = opts.cmdline();
- cmdline += " -orbcollocation no";
+ cmdline += " -orbcollocation no -orbuseimr 0";
ACE_ARGV av(cmdline.c_str());
int argc = av.argc();
char** argv = av.argv();
@@ -226,14 +227,75 @@ ImR_Locator_i::run(ACE_ENV_SINGLE_ARG_DECL)
return 0;
}
+void
+ImR_Locator_i::shutdown(CORBA::Boolean activators, CORBA::Boolean servers ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ if (servers != 0 && this->repository_.servers().current_size() > 0)
+ {
+ // Note : shutdown is oneway, so we can't throw
+ ACE_ERROR((LM_ERROR, "ImR: Shutdown of all servers not implemented.\n"));
+ }
+ if (activators != 0 && this->repository_.activators().current_size() > 0)
+ {
+ ACE_Vector<ImplementationRepository::Activator_var> acts;
+ Locator_Repository::AIMap::ENTRY* entry = 0;
+ Locator_Repository::AIMap::ITERATOR it(this->repository_.activators());
+ for (;it.next(entry) != 0; it.advance())
+ {
+ Activator_Info_Ptr info = entry->int_id_;
+ ACE_ASSERT(! info.null());
+ connect_activator(*info);
+ if (! CORBA::is_nil(info->activator.in()))
+ acts.push_back(info->activator);
+ }
+
+ int shutdown_errs = 0;
+
+ for (size_t i = 0; i < acts.size(); ++i)
+ {
+ ACE_TRY
+ {
+ acts[i]->shutdown(ACE_ENV_SINGLE_ARG_PARAMETER);
+ acts[i] = ImplementationRepository::Activator::_nil();
+ }
+ ACE_CATCHANY
+ {
+ ++shutdown_errs;
+ if (debug_ > 1)
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR: shutdown activator");
+ }
+ }
+ ACE_ENDTRY;
+ ACE_CHECK;
+ }
+ if (debug_ > 0 && shutdown_errs > 0)
+ {
+ ACE_DEBUG((LM_DEBUG, "ImR: Some activators could not be shut down.\n"));
+ }
+ }
+ // Technically, we should wait for all the activators to unregister, but
+ // ,for now at least, it doesn't seem worth it.
+ shutdown(false ACE_ENV_ARG_PARAMETER);
+}
+
+void
+ImR_Locator_i::shutdown (bool wait_for_completion ACE_ENV_ARG_DECL)
+{
+ this->orb_->shutdown(wait_for_completion ACE_ENV_ARG_PARAMETER);
+}
+
int
ImR_Locator_i::fini (ACE_ENV_SINGLE_ARG_DECL)
{
ACE_TRY
{
- if (debug_ > 0)
+ if (debug_ > 1)
ACE_DEBUG((LM_DEBUG, "ImR: Shutting down...\n"));
+ teardown_multicast();
+
this->root_poa_->destroy (1, 1 ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
@@ -253,6 +315,16 @@ ImR_Locator_i::fini (ACE_ENV_SINGLE_ARG_DECL)
return 0;
}
+void
+ImR_Locator_i::teardown_multicast()
+{
+ ACE_Reactor* r = ior_multicast_.reactor();
+ if (r != 0) {
+ r->remove_handler(&ior_multicast_, ACE_Event_Handler::READ_MASK);
+ ior_multicast_.reactor(0);
+ }
+}
+
int
ImR_Locator_i::setup_multicast (ACE_Reactor* reactor, const char* ior)
{
@@ -302,13 +374,11 @@ ImR_Locator_i::setup_multicast (ACE_Reactor* reactor, const char* ior)
ACE_DEBUG ((LM_DEBUG, "ImR: cannot register Event handler\n"));
return -1;
}
-
- return 0;
#else /* ACE_HAS_IP_MULTICAST*/
ACE_UNUSED_ARG (reactor);
ACE_UNUSED_ARG (ior);
- return 0;
#endif /* ACE_HAS_IP_MULTICAST*/
+ return 0;
}
CORBA::Long
@@ -387,9 +457,7 @@ ACE_THROW_SPEC ((CORBA::SystemException))
ACE_ASSERT(name != 0);
if (this->debug_ > 1)
- ACE_DEBUG((LM_DEBUG,
- "ImR: Server has died <%s>.\n",
- name));
+ ACE_DEBUG((LM_DEBUG, "ImR: Server has died <%s>.\n", name));
Server_Info_Ptr info = this->repository_.get_server(name);
if (! info.null())
@@ -713,45 +781,25 @@ ImR_Locator_i::set_timeout_policy(CORBA::Object_ptr obj, const ACE_Time_Value& t
}
void
-ImR_Locator_i::register_server (const char* server,
+ImR_Locator_i::add_or_update_server (const char* server,
const ImplementationRepository::StartupOptions &options
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::AlreadyRegistered,
- ImplementationRepository::NotFound))
-{
- register_server_i(server, options, false ACE_ENV_ARG_PARAMETER);
-}
-
-void
-ImR_Locator_i::reregister_server (const char* server,
- const ImplementationRepository::StartupOptions &options
- ACE_ENV_ARG_DECL )
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::AlreadyRegistered,
- ImplementationRepository::NotFound))
-{
- register_server_i(server, options, true ACE_ENV_ARG_PARAMETER);
-}
-void
-ImR_Locator_i::register_server_i (const char* server,
- const ImplementationRepository::StartupOptions &options,
- bool allow_updates
- ACE_ENV_ARG_DECL )
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::AlreadyRegistered,
ImplementationRepository::NotFound))
{
ACE_ASSERT(server != 0);
if (this->read_only_)
{
- ACE_DEBUG((LM_DEBUG, "ImR: Cannot register server <%s> due to locked database.\n", server));
+ ACE_DEBUG((LM_DEBUG, "ImR: Cannot add/update server <%s> due to locked database.\n", server));
ACE_THROW (CORBA::NO_PERMISSION (
CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0),
CORBA::COMPLETED_NO));
}
+ if (debug_ > 0)
+ ACE_DEBUG ((LM_DEBUG, "ImR: Add/Update server <%s>.\n", server));
+
int limit = options.start_limit;
if (limit < 0)
{
@@ -776,12 +824,6 @@ ImR_Locator_i::register_server_i (const char* server,
options.activation,
limit);
}
- else if (! allow_updates)
- {
- ACE_ERROR ((LM_ERROR,
- "ImR: Server <%s> already registered.\n", server));
- ACE_THROW (ImplementationRepository::AlreadyRegistered());
- }
else
{
if (this->debug_ > 1)
@@ -799,9 +841,6 @@ ImR_Locator_i::register_server_i (const char* server,
ACE_UNUSED_ARG(err);
}
- if (debug_ > 0)
- ACE_DEBUG ((LM_DEBUG, "ImR: Add/Update server <%s>.\n", server));
-
if (this->debug_ > 1)
{
// Note : The info var may be null, so we use options.
@@ -850,6 +889,18 @@ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
{
if (this->repository_.remove_server (name) == 0)
{
+ if (this->debug_ > 1)
+ ACE_DEBUG ((LM_DEBUG, "ImR: Removing Server <%s>...\n", name));
+
+ PortableServer::POA_var poa = findPOA(name);
+ ACE_CHECK;
+ if (! CORBA::is_nil(poa.in()))
+ {
+ bool etherealize = true;
+ bool wait = false;
+ poa->destroy(etherealize, wait ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ }
if (this->debug_ > 0)
ACE_DEBUG ((LM_DEBUG, "ImR: Removed Server <%s>.\n", name));
}
@@ -862,6 +913,21 @@ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
}
}
+PortableServer::POA_ptr
+ImR_Locator_i::findPOA(const char* name)
+{
+ ACE_TRY_NEW_ENV
+ {
+ bool activate_it = false;
+ return root_poa_->find_POA(name, activate_it ACE_ENV_ARG_PARAMETER);
+ }
+ ACE_CATCHANY
+ {// Ignore
+ }
+ ACE_ENDTRY;
+ return PortableServer::POA::_nil();
+}
+
void
ImR_Locator_i::shutdown_server (const char* server ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
@@ -916,11 +982,12 @@ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
if (this->debug_ > 1)
{
ACE_DEBUG((LM_DEBUG, "ImR: Exception ignored while shutting down <%s>\n", server));
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "");
}
}
ACE_ENDTRY;
+ // Note : In most cases this has already been done in the server_is_shutting_down()
+ // operation, but it doesn't hurt to update it again.
info->reset();
int err = this->repository_.update_server(*info);
@@ -1018,23 +1085,25 @@ void
ImR_Locator_i::find (const char* server,
ImplementationRepository::ServerInformation_out imr_info
ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
+ ACE_THROW_SPEC ((CORBA::SystemException))
{
ACE_ASSERT(server != 0);
ACE_NEW_THROW_EX (imr_info, ImplementationRepository::ServerInformation, CORBA::NO_MEMORY ());
Server_Info_Ptr info = this->repository_.get_server(server);
- if (info.null())
+ if (! info.null())
{
- ACE_ERROR ((LM_ERROR, "ImR: Cannot find info for server <%s>\n", server));
- ACE_THROW(ImplementationRepository::NotFound());
- }
-
imr_info = info->createImRServerInfo(ACE_ENV_SINGLE_ARG_PARAMETER);
if (this->debug_ > 1)
ACE_DEBUG ((LM_DEBUG, "ImR: Found server %s.\n", server));
}
+ else
+ {
+ if (debug_ > 1)
+ ACE_DEBUG((LM_DEBUG, "ImR: Cannot find server <%s>\n", server));
+ }
+}
void
ImR_Locator_i::list (CORBA::ULong how_many,
@@ -1043,7 +1112,7 @@ ImR_Locator_i::list (CORBA::ULong how_many,
ACE_ENV_ARG_DECL
) ACE_THROW_SPEC ((CORBA::SystemException))
{
- if (this->debug_ > 0)
+ if (this->debug_ > 1)
ACE_DEBUG ((LM_DEBUG, "ImR: List servers.\n"));
// Initialize the out variables, so if we return early, they will
@@ -1100,7 +1169,7 @@ ImR_Locator_i::list (CORBA::ULong how_many,
CORBA::Object_var obj = this->imr_poa_->id_to_reference(id.in() ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
server_iterator = ImplementationRepository::
- ServerInformationIterator::_narrow(obj.in() ACE_ENV_ARG_PARAMETER);
+ ServerInformationIterator::_unchecked_narrow(obj.in() ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
@@ -1157,7 +1226,7 @@ ImR_Locator_i::connect_activator (Activator_Info& info)
return;
}
- if (debug_ > 0)
+ if (debug_ > 1)
ACE_DEBUG((LM_DEBUG, "ImR: Connected to activator <%s>\n", info.name.c_str()));
}
ACE_CATCHANY
@@ -1407,7 +1476,7 @@ ImR_Locator_i::is_alive_i(Server_Info& info)
if (debug_ > 1)
{
ACE_DEBUG((LM_DEBUG,
- "ImR: <%s> Unknown Local TRANSIENT. alive=false.\n", info.name.c_str()));
+ "ImR: <%s> TRANSIENT exception. alive=false.\n", info.name.c_str()));
}
info.last_ping = ACE_Time_Value::zero;
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h
index 414ee3ccec0..a9c34b6863d 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h
@@ -48,6 +48,9 @@ public:
/// Run using the orb reference created during init()
int run (ACE_ENV_SINGLE_ARG_DECL);
+ /// Shutdown the orb.
+ void shutdown (bool wait_for_completion ACE_ENV_ARG_DECL);
+
int debug() const;
// Note : See the IDL for descriptions of the operations.
@@ -70,33 +73,22 @@ public:
ACE_THROW_SPEC ((CORBA::SystemException,
ImplementationRepository::NotFound,
ImplementationRepository::CannotActivate));
- virtual void register_server (const char * name,
- const ImplementationRepository::StartupOptions &options
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::AlreadyRegistered,
- ImplementationRepository::NotFound));
- virtual void reregister_server (const char * name,
- const ImplementationRepository::StartupOptions &options
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::AlreadyRegistered,
- ImplementationRepository::NotFound ));
- virtual void remove_server (const char * name
- ACE_ENV_ARG_DECL)
+ virtual void add_or_update_server (const char * name,
+ const ImplementationRepository::StartupOptions &options ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
- virtual void shutdown_server (const char * name
- ACE_ENV_ARG_DECL)
+ virtual void remove_server (const char * name ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
- virtual void find (const char * name,
- ImplementationRepository::ServerInformation_out info
- ACE_ENV_ARG_DECL)
+ virtual void shutdown_server (const char * name ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
+ virtual void find (const char * name,
+ ImplementationRepository::ServerInformation_out info ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
virtual void list (
CORBA::ULong how_many,
ImplementationRepository::ServerInformationList_out server_list,
- ImplementationRepository::ServerInformationIterator_out server_iterator
- ACE_ENV_ARG_DECL)
+ ImplementationRepository::ServerInformationIterator_out server_iterator ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+ virtual void shutdown(CORBA::Boolean activators, CORBA::Boolean servers ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException));
// Server->Locator
@@ -138,20 +130,13 @@ private:
ImplementationRepository::NotFound,
ImplementationRepository::CannotActivate));
- void register_server_i (const char * name,
- const ImplementationRepository::StartupOptions &options,
- bool allow_updates
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::AlreadyRegistered,
- ImplementationRepository::NotFound ));
-
bool is_alive(Server_Info& info);
int is_alive_i(Server_Info& info);
// Set up the multicast related if 'm' is passed on the command
// line.
int setup_multicast (ACE_Reactor *reactor, const char *ior);
+ void teardown_multicast();
void unregister_activator_i(const char* activator);
@@ -164,6 +149,7 @@ private:
void connect_server(Server_Info& info);
+ PortableServer::POA_ptr findPOA(const char* name);
private:
// The class that handles the forwarding.
diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_Options.cpp b/TAO/orbsvcs/ImplRepo_Service/Locator_Options.cpp
index faf93fc91a7..152d21939ae 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Locator_Options.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Locator_Options.cpp
@@ -30,6 +30,7 @@ static const int DEFAULT_START_TIMEOUT = 60; // seconds
Options::Options ()
: repo_mode_ (REPO_NONE)
+, erase_repo_ (false)
, debug_ (1)
, multicast_ (false)
, service_ (false)
@@ -163,6 +164,11 @@ Options::parse_args (int &argc, char *argv[])
this->repo_mode_ = REPO_XML_FILE;
}
else if (ACE_OS::strcasecmp (shifter.get_current (),
+ ACE_TEXT ("-e")) == 0)
+ {
+ this->erase_repo_ = true;
+ }
+ else if (ACE_OS::strcasecmp (shifter.get_current (),
ACE_TEXT ("-t")) == 0)
{
shifter.consume_arg ();
@@ -241,11 +247,10 @@ Options::print_usage (void) const
" -l Lock the database\n"
" -m Turn on multicast\n"
" -o file Outputs the ImR's IOR to a file\n"
- " -s Runs as a service (NT Only)\n"
" -p file Use file for storing/loading settings\n"
" -x file Use XML file for storing/loading setting\n"
" -r Use the registry for storing/loading settings\n"
- " -t secs Server startup timeout.(Default=0)\n"
+ " -t secs Server startup timeout.(Default=60s)\n"
" -v msecs Server verification interval.(Default=10s)\n"
));
}
@@ -476,6 +481,12 @@ Options::repository_mode (void) const
}
bool
+Options::repository_erase (void) const
+{
+ return this->erase_repo_;
+}
+
+bool
Options::readonly (void) const
{
return this->readonly_;
diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_Options.h b/TAO/orbsvcs/ImplRepo_Service/Locator_Options.h
index 682b2769523..17f40bddcac 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Locator_Options.h
+++ b/TAO/orbsvcs/ImplRepo_Service/Locator_Options.h
@@ -83,6 +83,9 @@ public:
RepoMode repository_mode (void) const;
+ /// Do we wish to clear out the repository
+ bool repository_erase (void) const;
+
/// Returns the timeout value for program starting.
ACE_Time_Value startup_timeout (void) const;
@@ -107,6 +110,9 @@ private:
// xml, heap, or registry
RepoMode repo_mode_;
+ // do we clear out the repository on load
+ bool erase_repo_;
+
/// Debug level.
unsigned int debug_;
diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.cpp b/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.cpp
index 2d172e8734f..28224f3c804 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.cpp
@@ -6,6 +6,7 @@
#include "ACEXML/parser/parser/Parser.h"
#include "ACEXML/common/FileCharStream.h"
+#include "ACEXML/common/XML_Util.h"
ACE_RCSID (ImplRepo_Service, Locator_Repository, "$Id$")
@@ -216,11 +217,14 @@ static void saveAsXML(const ACE_CString& fname, Locator_Repository& repo) {
for (; siit.next(sientry); siit.advance()) {
Server_Info_Ptr& info = sientry->int_id_;
+ ACE_CString cmdline = ACEXML_escape_string(info->cmdline);
+ ACE_CString wdir = ACEXML_escape_string(info->dir);
+
ACE_OS::fprintf(fp,"\t<%s", Locator_XMLHandler::SERVER_INFO_TAG);
ACE_OS::fprintf(fp," name=\"%s\"", info->name.c_str());
ACE_OS::fprintf(fp," activator=\"%s\"", info->activator.c_str());
- ACE_OS::fprintf(fp," command_line=\"%s\"", info->cmdline.c_str());
- ACE_OS::fprintf(fp," working_dir=\"%s\"", info->dir.c_str());
+ ACE_OS::fprintf(fp," command_line=\"%s\"", cmdline.c_str());
+ ACE_OS::fprintf(fp," working_dir=\"%s\"", wdir.c_str());
ACE_CString amodestr = ImR_Utils::activationModeToString(info->activation_mode);
ACE_OS::fprintf(fp," activation_mode=\"%s\"", amodestr.c_str());
ACE_OS::fprintf(fp," start_limit=\"%d\"", info->start_limit);
@@ -232,7 +236,8 @@ static void saveAsXML(const ACE_CString& fname, Locator_Repository& repo) {
{
ACE_OS::fprintf(fp,"\t\t<%s", Locator_XMLHandler::ENVIRONMENT_TAG);
ACE_OS::fprintf(fp," name=\"%s\"", info->env_vars[i].name.in());
- ACE_OS::fprintf(fp," value=\"%s\"", info->env_vars[i].value.in());
+ ACE_CString val = ACEXML_escape_string(info->env_vars[i].value.in());
+ ACE_OS::fprintf(fp," value=\"%s\"", val.c_str());
ACE_OS::fprintf(fp,"/>\n");
}
@@ -263,10 +268,10 @@ Locator_Repository::Locator_Repository()
}
int
-Locator_Repository::init(Options::RepoMode rmode, const ACE_CString& name)
+Locator_Repository::init(const Options& opts)
{
- this->rmode_ = rmode;
- this->fname_ = name;
+ this->rmode_ = opts.repository_mode();
+ this->fname_ = opts.persist_file_name();
int err = 0;
switch (this->rmode_) {
@@ -276,6 +281,10 @@ Locator_Repository::init(Options::RepoMode rmode, const ACE_CString& name)
}
case Options::REPO_HEAP_FILE:
{
+ if (opts.repository_erase())
+ {
+ ACE_OS::unlink( this->fname_.c_str() );
+ }
ACE_Configuration_Heap* heap = new ACE_Configuration_Heap();
this->config_.reset(heap);
err = heap->open(this->fname_.c_str());
@@ -288,6 +297,13 @@ Locator_Repository::init(Options::RepoMode rmode, const ACE_CString& name)
#if defined (ACE_WIN32)
case Options::REPO_REGISTRY:
{
+ if (opts.repository_erase())
+ {
+ ACE_Configuration_Win32Registry config( HKEY_LOCAL_MACHINE );
+ ACE_Configuration_Section_Key root;
+ config.open_section( config.root_section(), "Software\\TAO", 0, root );
+ config.remove_section( root, "ImplementationRepository", 1 );
+ }
HKEY root = ACE_Configuration_Win32Registry::
resolve_key(HKEY_LOCAL_MACHINE, WIN32_REG_KEY);
this->config_.reset(new ACE_Configuration_Win32Registry(root));
@@ -297,6 +313,10 @@ Locator_Repository::init(Options::RepoMode rmode, const ACE_CString& name)
#endif
case Options::REPO_XML_FILE:
{
+ if (opts.repository_erase())
+ {
+ ACE_OS::unlink( this->fname_.c_str() );
+ }
err = loadAsXML(this->fname_, *this);
break;
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.h b/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.h
index ab23cf75dae..2ef50b5753a 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.h
+++ b/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.h
@@ -52,7 +52,7 @@ public:
Locator_Repository();
/// Initializes the Server Repository
- int init (Options::RepoMode rmode, const ACE_CString& name);
+ int init (const Options& opts);
/// Add a new server to the Repository
int add_server (const ACE_CString& name,
diff --git a/TAO/orbsvcs/ImplRepo_Service/README.txt b/TAO/orbsvcs/ImplRepo_Service/README.txt
index 35bfe25157c..f6f8082f21b 100644
--- a/TAO/orbsvcs/ImplRepo_Service/README.txt
+++ b/TAO/orbsvcs/ImplRepo_Service/README.txt
@@ -509,7 +509,7 @@ The Implementation Repository supports start and stop but not pause.
When the Activator is installed using ImR_Activator -c install, it is added
with a dependency on a locator service. If you don't wish to also install
-the locator on the same machine, then you must use the -c install_no_locator
+the locator on the same machine, then you must use the -c install_no_imr
option instead.
@subsection serviceopts Service Options
diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp
index 3be1f28e5d9..c7fbddcb83e 100644
--- a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp
@@ -128,14 +128,15 @@ TAO_IMR_i::print_usage (void)
ACE_ERROR ((LM_ERROR, "Usage: tao_imr [options] command [command-arguments]\n"
" where [options] are ORB options\n"
" where command is one of the following:\n"
- " activate Activates a server through the IR\n"
- " add Add an entry to the IR\n"
+ " start Start a server through the ImR\n"
+ " add Add an entry to the ImR\n"
" autostart Activates all AUTO_START servers\n"
" ior Creates a simplified IOR\n"
- " list List the entries in the IR\n"
- " remove Remove an entry from the IR\n"
- " shutdown Shuts down a server through the IR\n"
- " update Update an entry in the IR\n"
+ " list List the entries in the ImR\n"
+ " remove Remove an entry from the ImR\n"
+ " shutdown Shut down a server through the ImR\n"
+ " shutdown-repo Shut down the ImR\n"
+ " update Update an entry in the ImR\n"
" where [command-arguments] depend on the command\n"));
}
@@ -146,9 +147,14 @@ TAO_IMR_Op *
TAO_IMR_Op::make_op (const ACE_TCHAR *op_name)
{
if (ACE_OS::strcasecmp (op_name, ACE_TEXT ("activate")) == 0)
+ {
+ ACE_ERROR((LM_ERROR, "Warning: The activate option has been renamed to start.\n"));
+ return new TAO_IMR_Op_Activate ();
+ }
+ else if (ACE_OS::strcasecmp (op_name, ACE_TEXT ("start")) == 0)
return new TAO_IMR_Op_Activate ();
else if (ACE_OS::strcasecmp (op_name, ACE_TEXT ("add")) == 0)
- return new TAO_IMR_Op_Add ();
+ return new TAO_IMR_Op_Register (true);
else if (ACE_OS::strcasecmp (op_name, ACE_TEXT ("autostart")) == 0)
return new TAO_IMR_Op_Autostart();
else if (ACE_OS::strcasecmp (op_name, ACE_TEXT ("ior")) == 0)
@@ -159,8 +165,10 @@ TAO_IMR_Op::make_op (const ACE_TCHAR *op_name)
return new TAO_IMR_Op_Remove ();
else if (ACE_OS::strcasecmp (op_name, ACE_TEXT ("shutdown")) == 0)
return new TAO_IMR_Op_Shutdown ();
+ else if (ACE_OS::strcasecmp (op_name, ACE_TEXT ("shutdown-repo")) == 0)
+ return new TAO_IMR_Op_ShutdownRepo ();
else if (ACE_OS::strcasecmp (op_name, ACE_TEXT ("update")) == 0)
- return new TAO_IMR_Op_Update ();
+ return new TAO_IMR_Op_Register (false);
return 0;
}
@@ -234,22 +242,15 @@ TAO_IMR_Op::display_server_information (const ImplementationRepository::ServerIn
ACE_DEBUG ((LM_DEBUG, "\n"));
}
-
-TAO_IMR_Op_Add::TAO_IMR_Op_Add (void)
-: activation_ (ImplementationRepository::NORMAL)
-, retry_count_ (0)
-{
- // Nothing
-}
-
TAO_IMR_Op_List::TAO_IMR_Op_List (void)
: verbose_server_information_ (0)
{
// Nothing
}
-TAO_IMR_Op_Update::TAO_IMR_Op_Update (void)
-: set_command_line_ (false)
+TAO_IMR_Op_Register::TAO_IMR_Op_Register (bool is_add)
+: is_add_ (is_add)
+, set_command_line_ (false)
, set_environment_vars_(false)
, set_working_dir_ (false)
, set_activation_ (false)
@@ -264,11 +265,11 @@ TAO_IMR_Op_Update::TAO_IMR_Op_Update (void)
void
TAO_IMR_Op_Activate::print_usage (void)
{
- ACE_ERROR ((LM_ERROR, "Activates a server\n"
+ ACE_ERROR ((LM_ERROR, "Starts a server using its registered Activator.\n"
"\n"
- "Usage: tao_imr [options] activate <name>\n"
+ "Usage: tao_imr [options] start <name>\n"
" where [options] are ORB options\n"
- " where <name> is the POA name used by the server object\n"
+ " where <name> is the name of a registered POA.\n"
" -h Displays this\n"));
}
@@ -291,114 +292,7 @@ TAO_IMR_Op_Activate::parse (int argc, ACE_TCHAR **argv)
while ((c = get_opts ()) != -1)
switch (c)
{
- case 'h': // display help
- this->print_usage ();
- return -1;
- default:
- ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c));
- this->print_usage ();
- return -1;
- }
-
- return 0;
-}
-
-void
-TAO_IMR_Op_Add::addenv (ACE_TCHAR *opt)
-{
- CORBA::ULong length = this->environment_vars_.length ();
-
- // Increase the length of the sequence
- this->environment_vars_.length (length + 1);
- ACE_CString tokens (opt);
- int index = tokens.find ("=");
- // Insert at position length since that is our new element
- this->environment_vars_ [length].name =
- CORBA::string_dup (tokens.substr (0, index).c_str ());
- this->environment_vars_ [length].value =
- CORBA::string_dup (tokens.substr (index + 1).c_str ());
-}
-
-void
-TAO_IMR_Op_Add::print_usage (void)
-{
- ACE_ERROR ((LM_ERROR,
- "Usage: tao_imr [options] add <name> [command-arguments]\n"
- " where [options] are ORB options\n"
- " where <name> is the POA name used by the server object\n"
- " where [command-arguments] can be\n"
- " -l Activator name. Defaults to local hostname.\n"
- " -h Displays this\n"
- " -c command Startup command\n"
- " -w dir Working directory\n"
- " -e name=value Set environment variables\n"
- " -a mode Set activate mode (NORMAL|MANUAL|PER_CLIENT|AUTO_START)\n"
- " -r count Set how many times to attempt restart. (default 0)\n"));
-}
-
-int
-TAO_IMR_Op_Add::parse (int argc, ACE_TCHAR **argv)
-{
- // Check for enough arguments (we need at least one for the server name)
- if (argc < 2)
- {
- this->print_usage ();
- return -1;
- }
-
- // Skip both the program name and the "add" command
- ACE_Get_Opt get_opts (argc, argv, "hc:w:a:e:l:r:R:");
-
- this->server_name_ = argv[1];
- if (this->server_name_.length() == 0 || this->server_name_[0] == '-')
- {
- ACE_ERROR((LM_ERROR, "ERROR : name is required.\n"));
- this->print_usage ();
- return -1;
- }
-
- int c;
-
- while ((c = get_opts ()) != -1)
- {
- switch (c)
- {
- case 'c': // Command line arguments
- this->command_line_ = get_opts.opt_arg ();
- break;
- case 'e': // set environment variables
- this->addenv( get_opts.opt_arg () ) ;
- break;
- case 'w': // Working Directory
- this->working_dir_ = get_opts.opt_arg ();
- break;
- case 'a': // Activation Mode
- if (ACE_OS::strcasecmp (get_opts.opt_arg (), "NORMAL") == 0)
- this->activation_ = ImplementationRepository::NORMAL;
- else if (ACE_OS::strcasecmp (get_opts.opt_arg (), "MANUAL") == 0)
- this->activation_ = ImplementationRepository::MANUAL;
- else if (ACE_OS::strcasecmp (get_opts.opt_arg (), "PER_CLIENT") == 0)
- this->activation_ = ImplementationRepository::PER_CLIENT;
- else if (ACE_OS::strcasecmp (get_opts.opt_arg (), "AUTO_START") == 0)
- this->activation_ = ImplementationRepository::AUTO_START;
- else
- ACE_ERROR_RETURN ((LM_ERROR,
- "Unknown Activation Mode <%s>.\n",
- get_opts.opt_arg ()),
- -1);
- break;
- case 'l': /// hostname of the activator
- this->activator_ = get_opts.optarg;
- break;
- case 'r': // startup/ping Retry Count
- case 'R':
- {
- int rc = ACE_OS::atoi(get_opts.optarg);
- if (rc > 0)
- this->retry_count_ = rc;
- }
- break;
- case 'h': // display help
+ case 'h':
this->print_usage ();
return -1;
default:
@@ -406,7 +300,6 @@ TAO_IMR_Op_Add::parse (int argc, ACE_TCHAR **argv)
this->print_usage ();
return -1;
}
- }
return 0;
}
@@ -630,8 +523,59 @@ TAO_IMR_Op_Shutdown::parse (int argc, ACE_TCHAR **argv)
return 0;
}
+TAO_IMR_Op_ShutdownRepo::TAO_IMR_Op_ShutdownRepo()
+: activators_(false)
+{
+}
+
+void
+TAO_IMR_Op_ShutdownRepo::print_usage (void)
+{
+ ACE_ERROR ((LM_ERROR, "Shuts down the ImR\n"
+ "\n"
+ "Usage: tao_imr [options] shutdown-repo [-a]\n"
+ " where [options] are ORB options\n"
+ " Specify -a to also shutdown any registered ImR Activators.\n"
+ " -h Displays this\n"));
+}
+
+int
+TAO_IMR_Op_ShutdownRepo::parse (int argc, ACE_TCHAR **argv)
+{
+ // Check for enough arguments (we need at least one for the server name)
+ if (argc < 1)
+ {
+ this->print_usage ();
+ return -1;
+ }
+
+ // Skip both the program name and the "shutdown-repo" command
+ ACE_Get_Opt get_opts (argc, argv, "ha");
+
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ {
+ switch (c)
+ {
+ case 'h':
+ this->print_usage ();
+ return -1;
+ case 'a':
+ activators_ = true;
+ break;
+ default:
+ ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c));
+ this->print_usage ();
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
void
-TAO_IMR_Op_Update::addenv (ACE_TCHAR *opt)
+TAO_IMR_Op_Register::addenv (ACE_TCHAR *opt)
{
CORBA::ULong length = this->environment_vars_.length ();
// Increase the length of the sequence
@@ -646,12 +590,12 @@ TAO_IMR_Op_Update::addenv (ACE_TCHAR *opt)
}
void
-TAO_IMR_Op_Update::print_usage (void)
+TAO_IMR_Op_Register::print_usage (void)
{
ACE_ERROR ((LM_ERROR,
- "Updates a server entry\n"
+ "Adds/Updates a server entry\n"
"\n"
- "Usage: tao_imr [options] update <name> [command-arguments]\n"
+ "Usage: tao_imr [options] <add|update> <name> [command-arguments]\n"
" where [options] are ORB options\n"
" where <name> is the POA name used by the server object\n"
" where [command-arguments] can be\n"
@@ -665,7 +609,7 @@ TAO_IMR_Op_Update::print_usage (void)
}
int
-TAO_IMR_Op_Update::parse (int argc, ACE_TCHAR **argv)
+TAO_IMR_Op_Register::parse (int argc, ACE_TCHAR **argv)
{
// Check for enough arguments (we need at least one for the server name)
if (argc < 2)
@@ -782,76 +726,6 @@ TAO_IMR_Op_Activate::run (void)
}
int
-TAO_IMR_Op_Add::run (void)
-{
- ACE_ASSERT(! CORBA::is_nil(imr_));
-
- ImplementationRepository::StartupOptions startup_options;
-
- startup_options.command_line =
- CORBA::string_dup (this->command_line_.c_str ());
- startup_options.environment =
- this->environment_vars_;
- startup_options.working_directory =
- CORBA::string_dup (this->working_dir_.c_str ());
- startup_options.activation = this->activation_;
- startup_options.start_limit = this->retry_count_ + 1;
-
- if (this->activator_.length() != 0)
- {
- startup_options.activator = CORBA::string_dup (this->activator_.c_str ());
- }
- else
- {
- // else use the hostname on which tao_imr is run
- char host_name[MAXHOSTNAMELEN + 1];
- ACE_OS::hostname (host_name, MAXHOSTNAMELEN);
- startup_options.activator = CORBA::string_dup (host_name);
- }
-
- ACE_DECLARE_NEW_CORBA_ENV;
- ACE_TRY
- {
- this->imr_->register_server (this->server_name_.c_str (),
- startup_options ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
-
- ACE_DEBUG ((LM_DEBUG,
- "Successfully registered server <%s>\n",
- this->server_name_.c_str ()));
- }
- ACE_CATCH (ImplementationRepository::NotFound, ex)
- {
- ACE_ERROR ((LM_ERROR,
- "Could not register server <%s>. Activator <%s> not found.\n",
- this->server_name_.c_str (),
- this->activator_.c_str()
- ));
- return TAO_IMR_Op::ALREADY_REGISTERED;
- }
- ACE_CATCH (ImplementationRepository::AlreadyRegistered, ex)
- {
- ACE_ERROR ((LM_ERROR,
- "Server <%s> already registered.\n",
- this->server_name_.c_str ()));
- return TAO_IMR_Op::ALREADY_REGISTERED;
- }
- ACE_CATCH (CORBA::NO_PERMISSION, ex)
- {
- ACE_ERROR ((LM_ERROR, "No Permission: ImplRepo is in Locked mode\n"));
- return TAO_IMR_Op::NO_PERMISSION;
- }
- ACE_CATCHANY
- {
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Adding server");
- return TAO_IMR_Op::UNKNOWN;
- }
- ACE_ENDTRY;
-
- return TAO_IMR_Op::NORMAL;
-}
-
-int
TAO_IMR_Op_Autostart::run (void)
{
ACE_ASSERT(! CORBA::is_nil(imr_));
@@ -1106,11 +980,41 @@ TAO_IMR_Op_Shutdown::run (void)
}
int
-TAO_IMR_Op_Update::run (void)
+TAO_IMR_Op_ShutdownRepo::run (void)
+{
+ ACE_ASSERT(! CORBA::is_nil(imr_));
+
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ bool servers = false; // not implemented yet, if ever
+ this->imr_->shutdown(activators_, servers ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_DEBUG ((LM_DEBUG, "ImR shutdown initiated.\n"));
+ }
+ ACE_CATCH(CORBA::TIMEOUT, ex)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Timeout waiting for ImR shutdown.\n"));
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Shutting Down ImR");
+ return TAO_IMR_Op::UNKNOWN;
+ }
+ ACE_ENDTRY;
+
+ return TAO_IMR_Op::NORMAL;
+}
+
+int
+TAO_IMR_Op_Register::run (void)
{
ACE_ASSERT(! CORBA::is_nil(imr_));
ImplementationRepository::ServerInformation_var server_information;
+ ImplementationRepository::StartupOptions local;
+ ImplementationRepository::StartupOptions* options = NULL;
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
@@ -1119,42 +1023,51 @@ TAO_IMR_Op_Update::run (void)
server_information.out() ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
- // Conditionally update the startup options
+ if (server_name_ == server_information->server.in())
+ {
+ if (is_add_)
+ {
+ ACE_DEBUG((LM_DEBUG, "Server <%s> already registered.\n", this->server_name_.c_str()));
+ return ALREADY_REGISTERED;
+ }
+ options = &server_information->startup;
+ }
+ else
+ {
+ is_add_ = true;
+ options = &local;
+ }
+
if (this->set_command_line_)
- server_information->startup.command_line =
- CORBA::string_dup (this->command_line_.c_str ());
+ options->command_line = CORBA::string_dup (this->command_line_.c_str ());
if (this->set_environment_vars_)
- server_information->startup.environment = this->environment_vars_;
+ options->environment = this->environment_vars_;
if (this->set_working_dir_)
- server_information->startup.working_directory = CORBA::string_dup (this->working_dir_.c_str ());
+ options->working_directory = CORBA::string_dup (this->working_dir_.c_str ());
- if (this->set_activation_)
- server_information->startup.activation = this->activation_;
+ if (this->set_activation_ || is_add_)
+ options->activation = this->activation_;
- if (this->set_retry_count_)
- server_information->startup.start_limit = this->retry_count_ + 1;
+ if (this->set_retry_count_ || is_add_)
+ options->start_limit = this->retry_count_ + 1;
if (this->set_activator_)
- server_information->startup.activator = CORBA::string_dup(this->activator_.c_str());
-
- this->imr_->reregister_server (this->server_name_.c_str (),
- server_information->startup
- ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
-
- ACE_DEBUG((LM_DEBUG, "Successfully updated <%s>.\n", this->server_name_.c_str ()));
- }
- ACE_CATCH (ImplementationRepository::NotFound, ex)
{
- ACE_ERROR ((LM_ERROR, "Could not find server <%s>\n", this->server_name_.c_str ()));
- return TAO_IMR_Op::NOT_FOUND;
+ options->activator = CORBA::string_dup(this->activator_.c_str());
}
- ACE_CATCH (ImplementationRepository::AlreadyRegistered, ex)
+ else if (is_add_)
{
- ACE_ERROR ((LM_ERROR, "Can't change the Activator for <%s>.\n", this->server_name_.c_str ()));
- return TAO_IMR_Op::NORMAL;
+ char host_name[MAXHOSTNAMELEN + 1];
+ ACE_OS::hostname (host_name, MAXHOSTNAMELEN);
+ options->activator = CORBA::string_dup (host_name);
+ }
+
+ this->imr_->add_or_update_server (this->server_name_.c_str (), *options ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_DEBUG((LM_DEBUG, "Successfully registered <%s>.\n", this->server_name_.c_str ()));
}
ACE_CATCH (CORBA::NO_PERMISSION, ex)
{
diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h
index f2fe1710355..df728e7002e 100644
--- a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h
+++ b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h
@@ -135,52 +135,6 @@ protected:
ACE_CString server_name_;
};
-
-/**
- * @class TAO_IMR_Op_Add
- *
- * @brief Add Operation
- *
- * Add is used to register information about a server with the IMR.
- */
-class TAO_IMR_Op_Add : public TAO_IMR_Op
-{
-public:
- TAO_IMR_Op_Add (void);
-
- virtual int parse (int argc, ACE_TCHAR **argv);
- virtual int run (void);
-
-protected:
- /// Sets one of the environment variables
- void addenv (ACE_TCHAR *opt);
-
- /// Prints a message about the usage.
- void print_usage (void);
-
- /// POA server name.
- ACE_CString server_name_;
-
- /// Command line.
- ACE_CString command_line_;
-
- /// Environment Variables.
- ImplementationRepository::EnvironmentList environment_vars_;
-
- /// Working directory.
- ACE_CString working_dir_;
-
- /// Activation mode (0 = NORMAL, 1 = MANUAL, 2 = PER_CLIENT, 3 = AUTO_START)
- ImplementationRepository::ActivationMode activation_;
-
- /// Hostname where the activator is running.
- ACE_CString activator_;
-
- /// startup/ping Retry Count
- int retry_count_;
-};
-
-
/**
* @class TAO_IMR_Op_Autostart
*
@@ -300,24 +254,43 @@ protected:
ACE_CString server_name_;
};
+/**
+ * Shutdown the ImR and optionally any registered activators.
+ */
+class TAO_IMR_Op_ShutdownRepo : public TAO_IMR_Op
+{
+public:
+ TAO_IMR_Op_ShutdownRepo();
+ virtual int parse (int argc, ACE_TCHAR **argv);
+ virtual int run (void);
+
+protected:
+ void print_usage (void);
+
+ bool activators_;
+};
/**
- * @class TAO_IMR_Op_Update
+ * @class TAO_IMR_Op_Register
*
- * @brief Update Operation
+ * @brief Register Operation
*
- * Update is used to update the information for a server registered
+ * Register is used to update/add information for a server
* with the IMR.
*/
-class TAO_IMR_Op_Update : public TAO_IMR_Op
+class TAO_IMR_Op_Register : public TAO_IMR_Op
{
public:
- TAO_IMR_Op_Update(void);
+ TAO_IMR_Op_Register(bool is_add);
virtual int parse (int argc, ACE_TCHAR **argv);
virtual int run (void);
protected:
+
+ /// Enables pre-registration checks
+ bool is_add_;
+
/// Sets one environment variable.
void addenv (ACE_TCHAR *opt);