summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-12-06 19:52:18 +0000
committerbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-12-06 19:52:18 +0000
commit10de98ebe478914b98649b2e8ec7c3a63f61765a (patch)
treed5165c4f0c4820c42b4f5f7d800eb5c4ef8ed3aa
parent8399f340d9169e7560858e86a1a68e466bb33b52 (diff)
downloadATCD-10de98ebe478914b98649b2e8ec7c3a63f61765a.tar.gz
Changed the storage of the hostname from a number to a string.
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImplRepo.idl2
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp249
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h14
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Repository.cpp114
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Repository.h4
-rw-r--r--TAO/orbsvcs/tests/ImplRepo/IR_Helper.cpp6
-rw-r--r--TAO/orbsvcs/tests/ImplRepo/IR_Helper.h2
-rw-r--r--TAO/orbsvcs/tests/ImplRepo/Repository_Test.cpp161
8 files changed, 331 insertions, 221 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImplRepo.idl b/TAO/orbsvcs/ImplRepo_Service/ImplRepo.idl
index a0b1c36a26d..0ade67910f4 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImplRepo.idl
+++ b/TAO/orbsvcs/ImplRepo_Service/ImplRepo.idl
@@ -30,8 +30,8 @@ interface Implementation_Repository
struct INET_Addr
{
+ string host_;
unsigned short port_;
- unsigned long host_;
};
// The location of a server
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp
index 69960df4057..27655e05d0a 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp
@@ -22,15 +22,18 @@ CORBA::Object_ptr
ImplRepo_i::activate_object (CORBA::Object_ptr obj,
CORBA::Environment &_env)
{
-// ACE_DEBUG ((LM_DEBUG, "Object is: %s\n", PortableServer::ObjectId_to_string (obj->in ())));
-
- Implementation_Repository::INET_Addr new_addr;
+ Implementation_Repository::INET_Addr *new_addr;
IIOP::Profile *new_profile = new IIOP::Profile;
IIOP_Object *new_iiop_obj = 0;
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "Activating Object: %s\n",
+ this->orb_manager_.orb ()->object_to_string (obj)));
+
TAO_TRY
{
- // Where to get the poa name from?
+ // @@ Where to get the poa name from?
new_addr = this->activate_server (0, TAO_TRY_ENV);
TAO_CHECK_ENV;
@@ -38,7 +41,7 @@ ImplRepo_i::activate_object (CORBA::Object_ptr obj,
*new_profile = iiop_obj->profile;
// @@ need to fix host also.
- new_profile->port = new_addr.port_;
+ new_profile->port = new_addr->port_;
new_iiop_obj = new IIOP_Object (iiop_obj->type_id, *new_profile);
/* ACE_DEBUG ((LM_DEBUG, "The forward_to is <%s>\n",
@@ -55,87 +58,106 @@ ImplRepo_i::activate_object (CORBA::Object_ptr obj,
}
// Starts the server <server> if it is not already started
-Implementation_Repository::INET_Addr
+Implementation_Repository::INET_Addr *
ImplRepo_i::activate_server (const char *server,
CORBA::Environment &_env)
{
+ int start = 0;
char *ping_ior;
- Implementation_Repository::INET_Addr address;
- address.port_ = 0;
- address.host_ = 0;
+ Implementation_Repository::INET_Addr *address = new Implementation_Repository::INET_Addr;
+ address->port_ = 0;
+ address->host_ = CORBA::string_dup ("");
+
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG, "Activating Server: %s\n", server));
// Find out if it is already running
+
if (this->repository_.get_ping_ior (server, ping_ior) != 0)
{
- ACE_ERROR ((LM_ERROR, "ERROR starting %s: No ping object\n", server));
+ // If we had problems getting the ping_ior, probably meant that there
+ // is no <server> registered
+ ACE_ERROR ((LM_ERROR, "Error starting %s: Cannot find object\n", server));
TAO_THROW_RETURN (Implementation_Repository::Not_Found (), address);
}
- TAO_TRY
- {
- CORBA::Object_var object =
- this->orb_manager_.orb ()->string_to_object (ping_ior, TAO_TRY_ENV);
- TAO_CHECK_ENV;
-
- Ping_Object_var ping_object = Ping_Object::_narrow (object.in(), TAO_TRY_ENV);
- TAO_CHECK_ENV;
-
- if (CORBA::is_nil (ping_object.in ()))
+ // if length is 0, then none is running yet.
+ if (strlen (ping_ior) != 0)
{
- ACE_ERROR ((LM_ERROR, "Invalid Ping Object ior: <%s>\n", ping_ior));
- TAO_THROW_RETURN (Implementation_Repository::Not_Found (), address);
- }
+ TAO_TRY
+ {
+ CORBA::Object_var object =
+ this->orb_manager_.orb ()->string_to_object (ping_ior, TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ Ping_Object_var ping_object = Ping_Object::_narrow (object.in(), TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ if (CORBA::is_nil (ping_object.in ()))
+ {
+ ACE_ERROR ((LM_ERROR, "Invalid Ping Object ior: <%s>\n", ping_ior));
+ TAO_THROW_RETURN (Implementation_Repository::Not_Found (), address);
+ }
- ping_object->ping (TAO_TRY_ENV);
- TAO_CHECK_ENV;
+ ping_object->ping (TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+ }
+ TAO_CATCHANY
+ {
+ start = 1;
+ }
+ TAO_ENDTRY;
}
- TAO_CATCHANY
- {
- // Start it up
- char *cl;
-
- int status = this->repository_.get_comm_line (server, cl);
+ else
+ start = 1;
- if (status == 0)
+ // Start it up...
+ if (start == 1)
{
- ACE_DEBUG ((LM_DEBUG, "Starting %s\n", server));
+ // Start it up
+ char *cl;
- ACE_Process_Options proc_opts;
+ int status = this->repository_.get_comm_line (server, cl);
- proc_opts.command_line (cl);
+ if (status == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Starting %s\n", server));
- ACE_Process proc;
+ ACE_Process_Options proc_opts;
- proc.spawn (proc_opts);
+ proc_opts.command_line (cl);
- delete [] cl;
- }
- else
- {
- ACE_DEBUG ((LM_ERROR, "ERROR starting %s\n", server));
- TAO_THROW_RETURN (Implementation_Repository::Cannot_Activate (), address);
- }
-
- // @@ Here is where we need to wait for the response so we
- // can find out where (host/port) the server started
- ACE_OS::sleep (3);
+ ACE_Process proc;
+
+ proc.spawn (proc_opts);
+
+ delete [] cl;
+ }
+ else
+ {
+ ACE_DEBUG ((LM_ERROR, "ERROR starting %s\n", server));
+ TAO_THROW_RETURN (Implementation_Repository::Cannot_Activate (), address);
+ }
- }
- TAO_ENDTRY;
+ // @@ Here is where we need to wait for the response so we
+ // can find out where (host/port) the server started
+ ACE_OS::sleep (3);
+ }
- unsigned long host;
+ char *host;
unsigned short port;
this->repository_.get_hostport (server, host, port);
- address.host_ = host;
- address.port_ = port;
+ address->host_ = CORBA::string_dup (host);
+ address->port_ = port;
return address;
}
// Adds an entry to the Repository about this <server>
+
void
ImplRepo_i::register_server (const char *server,
const Implementation_Repository::Process_Options &options,
@@ -145,19 +167,31 @@ ImplRepo_i::register_server (const char *server,
rec.comm_line = CORBA::string_dup (options.command_line_);
rec.env = CORBA::string_dup (options.environment_);
rec.wdir = CORBA::string_dup (options.working_directory_);
- rec.host = 0;
+ rec.host = "";
rec.port = 0;
rec.ping_ior = "";
int status = this->repository_.add (server, rec);
if (status == 1)
- {
- ACE_DEBUG ((LM_DEBUG, "Server %s Already Registered\n", server));
- TAO_THROW (Implementation_Repository::Already_Registered ());
- }
+ {
+ ACE_ERROR ((LM_ERROR, "Error: Server %s Already Registered!\n", server));
+ TAO_THROW (Implementation_Repository::Already_Registered ());
+ }
else
- ACE_DEBUG ((LM_DEBUG, "Server %s Successfully Registered\n", server));
+ {
+ ACE_DEBUG ((LM_DEBUG, "register_server: Server %s Successfully Registered\n", server));
+ if (TAO_debug_level > 0)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Server: %s\n"
+ "Command Line: %s\n"
+ "Environment: %s\n"
+ "Working Directory: %s\n\n",
+ rec.comm_line,
+ rec.env,
+ rec.wdir));
+ }
+ }
}
@@ -173,32 +207,50 @@ ImplRepo_i::reregister_server (const char *server,
rec.comm_line = CORBA::string_dup (options.command_line_);
rec.env = CORBA::string_dup (options.environment_);
rec.wdir = CORBA::string_dup (options.working_directory_);
- rec.host = 0;
+ rec.host = "";
rec.port = 0;
rec.ping_ior = "";
int status = this->repository_.update (server, rec);
ACE_DEBUG ((LM_DEBUG, "Server %s Successfully Registered\n", server));
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG, "Server: %s\n"
+ "Command Line: %s\n"
+ "Environment: %s\n"
+ "Working Directory: %s\n\n",
+ rec.comm_line,
+ rec.env,
+ rec.wdir));
}
+// Remove the server entry from the Repository
+
void
ImplRepo_i::remove_server (const char *server,
CORBA::Environment &env)
{
- this->repository_.remove (server);
+ if (this->repository_.remove (server) == 0)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG, "Successfully Removed Server\n"));
+ }
+ else
+ ACE_ERROR ((LM_ERROR, "Error: Trying to remove unknown server: %s\n", server));
}
// Register the current location of the server
-Implementation_Repository::INET_Addr
+
+Implementation_Repository::INET_Addr *
ImplRepo_i::server_is_running (const char *server,
const Implementation_Repository::INET_Addr &addr,
CORBA::Object_ptr ping,
CORBA::Environment &_env)
{
- Implementation_Repository::INET_Addr new_addr;
+ Implementation_Repository::INET_Addr *new_addr = new Implementation_Repository::INET_Addr;
+
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG, "Server is running!\n"));
@@ -206,7 +258,7 @@ ImplRepo_i::server_is_running (const char *server,
Repository::Record rec;
this->repository_.resolve (server, rec);
delete [] rec.ping_ior;
- rec.host = addr.host_;
+ rec.host = ACE::strnew (addr.host_.in ());
rec.port = addr.port_;
rec.ping_ior = ACE::strnew (this->orb_manager_.orb ()->object_to_string (ping, _env));
this->repository_.update (server, rec);
@@ -217,26 +269,54 @@ ImplRepo_i::server_is_running (const char *server,
ACE_INET_Addr my_addr = TAO_ORB_Core_instance ()->addr ();
// @@ We are assuming that we are on the same machine right now
- new_addr.host_ = addr.host_;
- new_addr.port_ = my_addr.get_port_number ();
+ new_addr->host_ = CORBA::string_dup (my_addr.get_host_name ());
+ new_addr->port_ = my_addr.get_port_number ();
if (TAO_debug_level > 0)
- ACE_DEBUG ((LM_DEBUG, "The new host/port is: %Lu:%hu\n", new_addr.host_, new_addr.port_));
+ ACE_DEBUG ((LM_DEBUG, "The new host/port is: %Lu:%hu\n", new_addr->host_, new_addr->port_));
return new_addr;
}
+
+// Remove the state information for the current server
+
void
ImplRepo_i::server_is_shutting_down (const char *server,
CORBA::Environment &_env)
{
ACE_UNUSED_ARG (_env);
- // @@ Implement
-}
+ Repository::Record rec;
+ if (this->repository_.resolve (server, rec) == 0)
+ {
+ rec.host = "";
+ rec.port = 0;
+ rec.ping_ior = "";
+
+ if (this->repository_.update (server, rec) == 0)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG, "Successfully shut down %s\n", server));
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Error updating Repository while shutting down %s\n",
+ server));
+ }
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Error shutting down %s: Does not exist in Repository\n",
+ server));
+ }
+}
// Reads the Server factory ior from a file
+
int
ImplRepo_i::read_ior (char *filename)
{
@@ -260,6 +340,8 @@ ImplRepo_i::read_ior (char *filename)
return 0;
}
+
+
int
ImplRepo_i::parse_args (void)
{
@@ -380,10 +462,10 @@ ImplRepo_i::run (CORBA::Environment& env)
return 0;
}
-CORBA::ULong
+CORBA::String
ImplRepo_i::get_forward_host (const char *server)
{
- unsigned long host;
+ char *host;
unsigned short port;
if (this->repository_.get_hostport (server, host, port) != 0)
return 0;
@@ -393,10 +475,11 @@ ImplRepo_i::get_forward_host (const char *server)
CORBA::UShort
ImplRepo_i::get_forward_port (const char *server)
{
- unsigned long host;
+ char *host;
unsigned short port;
if (this->repository_.get_hostport (server, host, port) != 0)
return 0;
+ delete host;
return port;
}
@@ -538,9 +621,6 @@ IR_Forwarder::invoke (CORBA::ServerRequest_ptr request,
// Get the POA Current object reference
CORBA::Object_var obj = this->orb_var_->resolve_initial_references ("POACurrent");
- // Narrow the object reference to a POA Current reference
- //PortableServer::Current_var poa_current = PortableServer::Current::_narrow (obj.in (), _env);
-
TAO_ORB_Core *orb_core = TAO_ORB_Core_instance ();
TAO_POA_Current *poa_current = orb_core->poa_current ();
@@ -569,7 +649,7 @@ IR_Forwarder::invoke (CORBA::ServerRequest_ptr request,
// Now FORWARD!!!
- Implementation_Repository::INET_Addr new_addr;
+ Implementation_Repository::INET_Addr *new_addr;
TAO_TRY
{
@@ -588,19 +668,16 @@ IR_Forwarder::invoke (CORBA::ServerRequest_ptr request,
IIOP_Object *iiop_obj = ACE_dynamic_cast (IIOP_Object *, forward_object->_stubobj ());
// @@ Only same host for now
- iiop_obj->profile.port = new_addr.port_;
+ iiop_obj->profile.port = new_addr->port_;
- ACE_DEBUG ((LM_DEBUG, "The forward_to is <%s>\n", this->orb_var_->object_to_string (forward_object, _env)));
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "The forward_to is <%s>\n",
+ this->orb_var_->object_to_string (forward_object, _env)));
if (!CORBA::is_nil (forward_object))
- {
- _env.exception (new PortableServer::ForwardRequest (forward_object));
- return;
- }
+ _env.exception (new PortableServer::ForwardRequest (forward_object));
else
- {
- ACE_DEBUG ((LM_DEBUG, "Forward_to reference is nil.\n"));
- return;
- }
+ ACE_ERROR ((LM_ERROR, "Error:Forward_to reference is nil.\n"));
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h
index 1766f4648ed..7faaa07536f 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h
+++ b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h
@@ -70,8 +70,8 @@ public:
virtual CORBA::Object_ptr activate_object (CORBA::Object_ptr obj,
CORBA::Environment &env);
- virtual Implementation_Repository::INET_Addr activate_server (const char * server,
- CORBA::Environment &env);
+ virtual Implementation_Repository::INET_Addr *activate_server (const char * server,
+ CORBA::Environment &env);
virtual void register_server (const char * server,
const Implementation_Repository::Process_Options &options,
@@ -85,10 +85,10 @@ public:
CORBA::Environment &env);
virtual Implementation_Repository::INET_Addr
- server_is_running (const char * server,
- const Implementation_Repository::INET_Addr &addr,
- CORBA::Object_ptr ping,
- CORBA::Environment &env);
+ *server_is_running (const char * server,
+ const Implementation_Repository::INET_Addr &addr,
+ CORBA::Object_ptr ping,
+ CORBA::Environment &env);
virtual void server_is_shutting_down (const char * server,
CORBA::Environment &env);
@@ -101,7 +101,7 @@ public:
int run (CORBA::Environment& env);
// Runs the orb.
- CORBA::ULong get_forward_host (const char *server);
+ CORBA::String get_forward_host (const char *server);
// Returns the host of the server that needs to be forwarded to.
CORBA::UShort get_forward_port (const char *server);
diff --git a/TAO/orbsvcs/ImplRepo_Service/Repository.cpp b/TAO/orbsvcs/ImplRepo_Service/Repository.cpp
index 454013f839f..dde35b28a07 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Repository.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Repository.cpp
@@ -24,12 +24,15 @@ Repository::add (const char *key, const Repository::Record &rec)
+ ACE_OS::strlen (rec.env)
+ ACE_OS::strlen (rec.wdir)
+ ACE_OS::strlen (rec.ping_ior)
+ + ACE_OS::strlen (rec.host)
+ 40],
-1);
- //Put them all in a string
+ // Put them all in a string
+ // Why use the extra space? Well, strtok doesn't like null strings
+ // because they show up as \n\n, which it skips past.
ACE_OS::sprintf (temp,
- "%s\n%s\n%s\n%lu %hu\n%s\n",
+ " %s\n %s\n %s\n %s\n %hu\n %s\n",
rec.comm_line,
rec.env,
rec.wdir,
@@ -65,97 +68,27 @@ Repository::remove (const char *key)
int
Repository::resolve (const char *key, Repository::Record &rec)
{
- char *value, *type; // Temp variables needed for resolve
- char *last, *temp ; // For fields
+ char *value = 0, *type = 0; // Temp variables needed for resolve
int retval = this->repository_.resolve (key, value, type);
- // If successful, return what we need.
- while (retval == 0) // Why a while statement? So we can break out of it.
+ if (retval == 0)
{
- temp = value;
- last = ACE_OS::strstr (temp, "\n");
- if (last != 0 && *last == '\n')
- {
- *last = '\0';
- ACE_NEW_RETURN (rec.comm_line, char [strlen (temp) + 1], -1);
-
- // Copy to the comm_line argument
- strcpy (rec.comm_line, temp);
- }
- else
- {
- retval = -1;
- break;
- }
-
- temp = last + 1;
- last = ACE_OS::strstr (temp, "\n");
- if (last != 0 && *last == '\n')
- {
- *last = '\0';
- ACE_NEW_RETURN (rec.env, char [strlen (temp) + 1], -1);
-
- // Copy to the env argument
- strcpy (rec.env, temp);
- }
- else
- {
- retval = -1;
- break;
- }
-
- temp = last + 1;
- last = ACE_OS::strstr (temp, "\n");
- if (last != 0)
- {
- *last = '\0';
- ACE_NEW_RETURN (rec.wdir, char [strlen (temp) + 1], -1);
-
- // Copy to the env argument
- strcpy (rec.wdir, temp);
- }
- else
- {
- retval = -1;
- break;
- }
-
- temp = last + 1;
- last = ACE_OS::strstr (temp, "\n");
- if (last != 0)
- {
- *last = '\0';
- ::sscanf (temp, "%lu %hu", &rec.host, &rec.port);
- }
- else
- {
- retval = -1;
- break;
- }
-
- temp = last + 1;
- last = ACE_OS::strstr (temp, "\n");
- if (last != 0)
- {
- *last = '\0';
- ACE_NEW_RETURN (rec.ping_ior, char [strlen (temp) + 1], -1);
-
- // Copy to the ping_ior argument
- strcpy (rec.ping_ior, temp);
- }
- else
- {
- retval = -1;
- break;
- }
-
- delete [] value;
- delete [] type;
-
- // Now exit out.
- break;
+ // +1 to get rid of the space
+ rec.comm_line = ACE::strnew (ACE_OS::strtok (value, "\n") + 1);
+ rec.env = ACE::strnew (ACE_OS::strtok (NULL, "\n") + 1);
+ rec.wdir = ACE::strnew (ACE_OS::strtok (NULL, "\n") + 1);
+ rec.host = ACE::strnew (ACE_OS::strtok (NULL, "\n") + 1);
+ ::sscanf (ACE_OS::strtok (NULL, "\n"), "%hu", &rec.port);
+ rec.ping_ior = ACE::strnew (ACE_OS::strtok (NULL, "\n") + 1);
+ }
+ else
+ {
+ retval = -1;
}
+ delete [] value;
+ delete [] type;
+
return retval;
}
// = Accessor methods
@@ -189,6 +122,7 @@ Repository::get_env (const char *key, char *&env)
delete [] rec.comm_line;
env = rec.env;
delete [] rec.wdir;
+ delete [] rec.host;
delete [] rec.ping_ior;
}
@@ -206,6 +140,7 @@ Repository::get_wdir (const char *key, char *&wdir)
delete [] rec.comm_line;
delete [] rec.env;
wdir = rec.wdir;
+ delete [] rec.host;
delete [] rec.ping_ior;
}
@@ -213,7 +148,7 @@ Repository::get_wdir (const char *key, char *&wdir)
}
int
-Repository::get_hostport (const char *key, unsigned long &host, unsigned short &port)
+Repository::get_hostport (const char *key, char *&host, unsigned short &port)
{
Repository::Record rec;
int retval = this->resolve (key, rec);
@@ -242,6 +177,7 @@ Repository::get_ping_ior (const char *key, char *&ping_ior)
delete [] rec.comm_line;
delete [] rec.env;
delete [] rec.wdir;
+ delete [] rec.host;
ping_ior = rec.ping_ior;
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/Repository.h b/TAO/orbsvcs/ImplRepo_Service/Repository.h
index a6da2b6909d..7e174e7ff93 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Repository.h
+++ b/TAO/orbsvcs/ImplRepo_Service/Repository.h
@@ -33,7 +33,7 @@ public:
char *comm_line;
char *env;
char *wdir;
- unsigned long host;
+ char *host;
unsigned short port;
char *ping_ior;
};
@@ -55,7 +55,7 @@ public:
int get_env (const char *key, char *&env);
int get_wdir (const char *key, char *&wdir);
int get_ping_ior (const char *key, char *&ping_ior);
- int get_hostport (const char *key, unsigned long &host, unsigned short &port);
+ int get_hostport (const char *key, char *&host, unsigned short &port);
// Dump method
void dump (void);
diff --git a/TAO/orbsvcs/tests/ImplRepo/IR_Helper.cpp b/TAO/orbsvcs/tests/ImplRepo/IR_Helper.cpp
index 0b91a306c17..31b2873ffe9 100644
--- a/TAO/orbsvcs/tests/ImplRepo/IR_Helper.cpp
+++ b/TAO/orbsvcs/tests/ImplRepo/IR_Helper.cpp
@@ -37,13 +37,11 @@ IR_Helper::IR_Helper (char *server_name,
ping_ (new Ping_i (debug)),
implrepo_ (0),
ir_key_ (0),
+ ir_addr_ (0),
poa_ (poa),
orb_ (orb),
debug_ (debug)
{
- // Initialize ir_addr_
- this->ir_addr_.host_ = 0;
- this->ir_addr_.port_ = 0;
TAO_TRY
{
@@ -167,9 +165,11 @@ IR_Helper::notify_startup (CORBA_Environment &_env)
ACE_INET_Addr my_addr = TAO_ORB_Core_instance ()->addr ();
Implementation_Repository::INET_Addr my_ir_addr;
my_ir_addr.port_ = my_addr.get_port_number ();
+ my_ir_addr.host_ = CORBA::string_dup (my_addr.get_host_name ());
TAO_TRY
{
+ delete this->ir_addr_;
this->ir_addr_ = this->implrepo_->server_is_running (this->name_,
my_ir_addr,
this->ping_ptr_,
diff --git a/TAO/orbsvcs/tests/ImplRepo/IR_Helper.h b/TAO/orbsvcs/tests/ImplRepo/IR_Helper.h
index 4b39b296238..03e4f66d4e8 100644
--- a/TAO/orbsvcs/tests/ImplRepo/IR_Helper.h
+++ b/TAO/orbsvcs/tests/ImplRepo/IR_Helper.h
@@ -60,7 +60,7 @@ private:
char *name_;
char *ir_key_;
- Implementation_Repository::INET_Addr ir_addr_;
+ Implementation_Repository::INET_Addr *ir_addr_;
POA_Ping_Object *ping_;
CORBA::Object_ptr ping_ptr_;
diff --git a/TAO/orbsvcs/tests/ImplRepo/Repository_Test.cpp b/TAO/orbsvcs/tests/ImplRepo/Repository_Test.cpp
index 383af59b51b..82a02a79067 100644
--- a/TAO/orbsvcs/tests/ImplRepo/Repository_Test.cpp
+++ b/TAO/orbsvcs/tests/ImplRepo/Repository_Test.cpp
@@ -4,66 +4,163 @@
#include <iostream.h>
#include "../../ImplRepo_Service/Repository.h"
+const char *NAME_VALUE = "server";
+const char *COMM_LINE_VALUE = "server -i";
+const char *ENV_VALUE = "null environment";
+const char *HOST_VALUE = "maxixe.cs.wustl.edu";
+const int PORT_VALUE = 20000;
+const char *PING_IOR_VALUE = "iiop://maxixe/ping";
+const char *WDIR_VALUE = ".";
+
// Just tests the functionality of the Repository
int main (int argc, char *argv[])
{
+ int test_success = 1;
Repository rep;
Repository::Record new_rec, rec;
- new_rec.comm_line = "cl value";
- new_rec.env = "env value";
- new_rec.host = 100;
- new_rec.port = 1;
- new_rec.ping_ior = "ping_ior value";
- new_rec.wdir = "wdir value";
+ new_rec.comm_line = ACE::strnew (COMM_LINE_VALUE);
+ new_rec.env = ACE::strnew (ENV_VALUE);
+ new_rec.host = ACE::strnew (HOST_VALUE);
+ new_rec.port = PORT_VALUE;
+ new_rec.ping_ior = ACE::strnew (PING_IOR_VALUE);
+ new_rec.wdir = ACE::strnew (WDIR_VALUE);
+ ACE_DEBUG ((LM_DEBUG, "=Adding Record to Repository\n"));
+
// Add our one record
- int result = rep.add ("simple", new_rec);
- cout << "Registration: " << result << endl;
+ int result = rep.add (NAME_VALUE, new_rec);
if (result == 1) // We need to get rid of it
{
- rep.remove ("simple");
- result = rep.add ("simple", new_rec);
- cout << "2nd Registration: " << result << endl;
+ ACE_DEBUG ((LM_DEBUG, "New Record already registered, updating\n"));
+ rep.update (NAME_VALUE, new_rec);
}
+ ACE_DEBUG ((LM_DEBUG, "=Performing Resolve Test\n"));
+
// Bring it back!
- if (rep.resolve ("simple", rec) == 0)
+ if (rep.resolve (NAME_VALUE, rec) == 0)
{
- cout << "Command line: " << rec.comm_line << endl;
- cout << "Environment: " << rec.env << endl;
- cout << "Working directory: " << rec.wdir << endl;
- cout << "Host and Port: " << rec.host << ":" << rec.port << endl;
- cout << "Ping IOR: " << rec.ping_ior << endl;
-
- delete [] rec.comm_line;
- delete [] rec.env;
- delete [] rec.wdir;
- delete [] rec.ping_ior;
+ if (ACE_OS::strcmp (rec.comm_line, COMM_LINE_VALUE) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Error: comm_line compare failed: \"%s\" \"%s\"\n",
+ rec.comm_line,
+ COMM_LINE_VALUE));
+ test_success = 0;
+ }
+
+ if (ACE_OS::strcmp (rec.env, ENV_VALUE) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Error: env compare failed: \"%s\" \"%s\"\n",
+ rec.env,
+ ENV_VALUE));
+ test_success = 0;
+ }
+
+ if (ACE_OS::strcmp (rec.wdir, WDIR_VALUE) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Error: wdir compare failed: \"%s\" \"%s\"\n",
+ rec.wdir,
+ WDIR_VALUE));
+ test_success = 0;
+ }
+
+ if (ACE_OS::strcmp (rec.host, HOST_VALUE) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Error: host compare failed: \"%s\" \"%s\"\n",
+ rec.host,
+ HOST_VALUE));
+ test_success = 0;
+ }
+
+ if (rec.port != PORT_VALUE)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Error: port compare failed: \"%hu\" \"%hu\"\n",
+ rec.port,
+ PORT_VALUE));
+ test_success = 0;
+ }
+
+ if (ACE_OS::strcmp (rec.ping_ior, PING_IOR_VALUE) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Error: ping_ior compare failed: \"%s\" \"%s\"\n",
+ rec.ping_ior,
+ PING_IOR_VALUE));
+ test_success = 0;
+ }
}
// Try some of the single accessors
char *cl, *env, *ping_ior;
- if (rep.get_comm_line ("simple", cl) == 0
- && rep.get_env ("simple", env) == 0
- && rep.get_ping_ior ("simple", ping_ior) == 0)
+ ACE_DEBUG ((LM_DEBUG, "=Performing Single Accessor Test\n"));
+
+ if (rep.get_comm_line (NAME_VALUE, cl) == 0
+ && rep.get_env (NAME_VALUE, env) == 0
+ && rep.get_ping_ior (NAME_VALUE, ping_ior) == 0)
{
- cout << "Command line: " << cl << endl;
- cout << "Environment: " << env << endl;
- cout << "Ping IOR: " << ping_ior << endl;
+ if (ACE_OS::strcmp (cl, COMM_LINE_VALUE) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Error: comm_line compare failed: \"%s\" \"%s\"\n",
+ cl,
+ COMM_LINE_VALUE));
+ test_success = 0;
+ }
+
+ if (ACE_OS::strcmp (env, ENV_VALUE) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Error: env compare failed: \"%s\" \"%s\"\n",
+ env,
+ ENV_VALUE));
+ test_success = 0;
+ }
+
+ if (ACE_OS::strcmp (ping_ior, PING_IOR_VALUE) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Error: ping_ior compare failed: \"%s\" \"%s\"\n",
+ ping_ior,
+ PING_IOR_VALUE));
+ test_success = 0;
+ }
delete [] cl;
delete [] env;
delete [] ping_ior;
}
- // So what happens when we try to reregister?
- cout << "Re-Registration: " << rep.add ("simple", new_rec) << endl;
+ ACE_DEBUG ((LM_DEBUG, "=Performing Reregister Test\n"));
+
+ if (rep.add (NAME_VALUE, new_rec) != 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Error: Reregistration not detected\n"));
+ test_success = 0;
+ }
+
+ ACE_DEBUG ((LM_DEBUG, "=Cleaning up\n"));
- //rep.remove ("simple");
- return 0;
+ if (rep.remove (NAME_VALUE) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Error: Could not remove record\n"));
+ test_success = 0;
+ }
+
+ if (test_success == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Tests were successful\n"));
+ return 0;
+ }
+ else
+ return -1;
}