diff options
Diffstat (limited to 'TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server')
5 files changed, 529 insertions, 0 deletions
diff --git a/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/Makefile b/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/Makefile new file mode 100644 index 00000000000..a992f98a221 --- /dev/null +++ b/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/Makefile @@ -0,0 +1,66 @@ +#---------------------------------------------------------------------------- +# $Id$ +# +# Top-level Makefile for the ACE-ified Sun Ref. implementation +# of IIOP ORB +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +#LDLIBS = -lmtcorba -lmtunixsvc -lmtpbroker -lmtboadc -lmtnaming -lmtlifecycl -lmtfsstream +LDLIBS = -lcorba -lunixsvc -lpbroker -lboadc -lnaming -llifecycl -lfsstream + +IDL_SRC = cubit.cpp cubit_s.cpp +PROG_SRCS = svr.cpp cubit_i.cpp + +LSRC = $(IDL_SRC) $(PROG_SRCS) + +CUBIT_SVR_OBJS = cubit.o cubit_s.o svr.o cubit_i.o + +BIN = svr +BUILD = $(BIN) +VLDLIBS = $(LDLIBS:%=%$(VAR)) +VBIN = $(BIN:%=%$(VAR)) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +#enable C++ exceptions +exceptions = 1 + +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU +#include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU + +# Local modifications to variables imported by includes above. +LDFLAGS += -L$(PBHOME)/lib +CPPFLAGS += -I$(PBHOME)/include + +#CXX := purify $(CXX) + +$(IDL_SRC): cubit.idl + $(PBHOME)/bin/idlc cubit.idl + -/bin/mv cubit.C cubit.cpp + -/bin/mv cubit_s.C cubit_s.cpp + +svr: $(addprefix $(VDIR),$(CUBIT_SVR_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(PBHOME)/lib/iiop_s.o $(VLDLIBS) $(POSTLINK) + +clean: + -/bin/rm -rf *.o $(BIN) obj.* core Templates.DB .make.state + +realclean: clean + -/bin/rm -rf cubit.cpp cubit.h cubit_s.* +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/cubit.o .shobj/cubit.: cubit.cpp +.obj/cubit_s.o .shobj/cubit_s.: cubit_s.cpp + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/cubit.idl b/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/cubit.idl new file mode 100644 index 00000000000..2ed3ec01499 --- /dev/null +++ b/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/cubit.idl @@ -0,0 +1,41 @@ +// $Id$ + + interface Cubit { + octet cube_octet (in octet o); + short cube_short (in short s); + long cube_long (in long l); + + struct Many { + octet o; // + 3 bytes padding (normally) ... + long l; + short s; // + 2 bytes padding (normally) ... + }; + + Many cube_struct (in Many values); + + /* enum discrim {e_0th, e_1st, e_2nd, e_3rd, e_4th, e_5th}; + + union oneof + switch (discrim) { + // this is an easy union to interpret; no padding + // is needed between discriminant and value. + case e_0th: + octet o; + case e_1st: + short s; + case e_2nd: + long l; + case e_3rd: + Many cm; + }; + + oneof cube_union (in oneof values); */ + + oneway void please_exit (); + }; + + + interface Cubit_Factory { + Cubit create_cubit (in short priority); + }; + diff --git a/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/cubit_i.cpp b/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/cubit_i.cpp new file mode 100644 index 00000000000..e6883abba0c --- /dev/null +++ b/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/cubit_i.cpp @@ -0,0 +1,82 @@ +// $Id$ + +// @(#)cubit_i.cpp 05/14/97 +// Copyright 1994-1995 by Sun Microsystems Inc. +// All Rights Reserved +// +// TEST: hand-written Cubit Implementation +// +// Modified version of Cubit Example written by Sun Microsystems Inc. +// Modified by: Brian Mendel + +#include "pbroker/corba/orb.h" +#include "pbroker/corba/environ.h" +#include "cubit_i.h" + +ACE_RCSID(server, cubit_i, "$Id$") + +Cubit_i::Cubit_i (const char *obj_name) +{ +} + +Cubit_i::~Cubit_i (void) +{ +} + +CORBA::Octet +Cubit_i::cube_octet (CORBA::Octet o) +{ + return (CORBA::Octet) (o * o * o); +} + +CORBA::Short +Cubit_i::cube_short (CORBA::Short s) +{ + return (CORBA::Short) (s * s * s); +} + +CORBA::Long +Cubit_i::cube_long (CORBA::Long l) +{ + return (CORBA::Long) (l * l * l); +} + +Cubit::Many +Cubit_i::cube_struct (const Cubit::Many &values) +{ + Cubit::Many out_values; + out_values.o = values.o * values.o * values.o; + out_values.s = values.s * values.s * values.s; + out_values.l = values.l * values.l * values.l; + + return out_values; +} + +/*Cubit_oneof * +Cubit_i::cube_union (Cubit_oneof &values, + CORBA::Environment &env) +{ + ACE_UNUSED_ARG (env); + switch (values._disc) + { + case e_0th: + values.o = (CORBA::Octet) (values.o * values.o * values.o); + break; + case e_1st: + values.s = (CORBA::Short) (values.s * values.s * values.s); + break; + case e_2nd: + values.l = values.l * values.l * values.l; + break; + case e_3rd: + default: + values.cm.o = (CORBA::Octet) (values.cm.o * values.cm.o * values.cm.o); + values.cm.s = (CORBA::Short) (values.cm.s * values.cm.s * values.cm.s); + values.cm.l = values.cm.l * values.cm.l * values.cm.l; + } + return &values; +} */ + +void Cubit_i::please_exit (void) +{ +} diff --git a/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/cubit_i.h b/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/cubit_i.h new file mode 100644 index 00000000000..8ba58a1ccd7 --- /dev/null +++ b/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/cubit_i.h @@ -0,0 +1,52 @@ +// $Id$ + +// @(#)cubit_i.cpp 05/14/97 +// Copyright 1994-1995 by Sun Microsystems Inc. +// All Rights Reserved +// +// TEST: hand-written Cubit Implementation +// +// Modified version of Cubit Example written by Sun Microsystems Inc. +// Modified by: Brian Mendel + +/************************************************************************** +This file has been hand-crafted to work with the ORB API of the SUN's IIOP +implementation +***************************************************************************/ + +#ifndef _CUBIT_I_HH +#define _CUBIT_I_HH + +#include "cubit_s.h" + +class Cubit_i; +typedef Cubit_i *Cubit_i_ptr; +typedef Cubit_i_ptr Cubit_i_ref; + +class Cubit_i : public Cubit_base_impl +{ +public: + Cubit_i (const char *obj_name = 0); + ~Cubit_i (void); + + virtual + CORBA::Octet cube_octet (CORBA::Octet o); + + virtual + CORBA::Short cube_short (CORBA::Short s); + + virtual + CORBA::Long cube_long (CORBA::Long l); + + virtual + Cubit::Many cube_struct (const Cubit::Many &values); + + /* virtual + Cubit::oneof *cube_union (Cubit::oneof &values, + CORBA::Environment &env); */ + + virtual + void please_exit (void); +}; + +#endif // _CUBIT_I_HH diff --git a/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/svr.cpp b/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/svr.cpp new file mode 100644 index 00000000000..fbce11d56ab --- /dev/null +++ b/TAO/performance-tests/Cubit/CORBAplus/MT_Cubit/server/svr.cpp @@ -0,0 +1,288 @@ +// $Id$ + +// @(#)svr.cpp 05/14/97 +// Copyright 1994-1995 by Sun Microsystems Inc. +// All Rights Reserved +// +// TEST: simple IIOP server for "cubit.idl" interface. +// +// Starts up, builds an objref, prints its string in debug mode, +// listens for messages, responds to them. +// +// Modified version of Cubit Example written by Sun Microsystems Inc. +// Modified by: Brian Mendel + +#include "pbroker/corba/orb.h" +#include "pbroker/corba/request.h" +#include "pbroker/corba/environ.h" +#include "pbroker/unixsvc/unixsvc.h" +#include "pbroker/corba/xpsorb.h" +#include "pbroker/corba/xpsboa.h" +#include "pbroker/corba/boad/boafull.h" // will force usage of "Full" BOA API +#include "ace/Get_Opt.h" +#include "ace/Log_Msg.h" +#include "ace/Task.h" +#include "ace/ARGV.h" +#include "ace/Sched_Params.h" + +#include "cubit_i.h" + +ACE_RCSID(server, svr, "$Id$") + +// Global Variables +static CORBA::String key = (CORBA::String) "Cubit"; + + +class Cubit_Task : public ACE_Task<ACE_NULL_SYNCH> +// = TITLE +// Encapsulates an ORB for the Cubit application +{ +public: + Cubit_Task (const char* args, const char* orbname, unsigned int num_of_objs); // + + virtual int svc (void); + +protected: + Cubit_Task () {}; + +private: + char* orbname_; + char* orbargs_; + unsigned int num_of_objs_; +}; + +Cubit_Task::Cubit_Task (const char* args, const char* orbname, unsigned int num_of_objs) + : orbname_ ((char*)orbname), + orbargs_ ((char*)args), + num_of_objs_ (num_of_objs) +{} + + +int +Cubit_Task::svc (void) +{ + CORBA::Environment env; + ACE_DEBUG ((LM_DEBUG, "(%P|%t) Beginning Cubit task with args = '%s'\n", orbargs_)); + ACE_ARGV args (orbargs_); + + int argc = args.argc (); + char** argv = args.argv (); + + XpsORB_ptr orb_ptr = XpsORB::_nil(); + XpsBOA * oa_ptr = XpsBOA::_nil (); + CORBA_Object_ptr obj_ptr = CORBA_Object::_nil(); + + try { + // Initialize the ORB pointer + orb_ptr = XpsORB::init (argc, argv); + + // Initialize the Object Adapter + oa_ptr = XpsBOA::init (argc, argv); + + if (CORBA::is_nil(orb_ptr) || CORBA::is_nil(oa_ptr)) + { + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the ORB and/or the BOA\n"), + 1); + } + + // Create implementation object with user specified key. + Cubit_i_ptr *my_cubit = new Cubit_i_ptr[num_of_objs_]; + + u_int i; + for (i = 0; i < num_of_objs_; i++) + { + CORBA::String obj_str = CORBA::string_alloc (ACE_OS::strlen ((char *) key)+30); + +#if 0 + ACE_OS::sprintf (obj_str, "%s-%u-%02d", (char *) key, ACE_Thread::self (), i); +#else + ACE_OS::sprintf (obj_str, "%s%02d", (char *) key, i); +#endif + + my_cubit[i] = new Cubit_i (obj_str); + + if (my_cubit[i] == 0) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to create implementation object&d\n", + i), + 2); + + //CORBA::OctetSeq obj_key; + //obj_key.buffer = (CORBA::Octet *) obj_str; + //obj_key.length = obj_key.maximum = ACE_OS::strlen (obj_str); + + //CORBA::Object_ptr obj = 0; + + // if (oa_ptr->find (obj_key, obj) == -1) + // ACE_ERROR_RETURN ((LM_ERROR, + // " (%P|%t) Unable to locate object with key '%s', %p\n", + // key), + // 3); + + // Stringify the objref we'll be implementing, and print it + // to stdout. Someone will take that string and give it to + // some client. Then release the object. + + CORBA::String str; + + // str = orb_ptr->object_to_string (obj); + str = orb_ptr->object_to_url (my_cubit[i]); + + ACE_DEBUG ((LM_DEBUG, "listening as object '%s'\n", str)); + CORBA_string_free (str); + + oa_ptr->obj_is_ready (my_cubit[i], nil); + oa_ptr->registerAlias (my_cubit[i], obj_str); + + if (env.exception () != 0) + { + // env.print_exception ("object2string"); + return 1; + } + + ACE_OS::puts ((char *) str); + ACE_OS::fflush (stdout); + //ACE_DEBUG ((LM_DEBUG,"Object Created at: '%ul'", obj)); + CORBA::string_free (obj_str); + } + + // Handle requests for this object until we're killed, or one of the + // methods asks us to exit. + XpsEventService eventService; + eventService.mainloop(); // control will not return to this point + // orb_ptr->run (); + + // Shut down the OA -- recycles all underlying resources (e.g. file + // descriptors, etc). + + // oa_ptr->clean_shutdown (env); + + // Need to clean up and do a CORBA::release on everything we've + // created! + for (i = 0; i < num_of_objs_; i++) + { + delete my_cubit[i]; + } + + // Free resources + CORBA::release (orb_ptr); + CORBA::release (oa_ptr); + } + catch(const CORBA::SystemException& exc) + { + ACE_DEBUG ((LM_DEBUG, + "CORBA::SystemException caught: %s (minor: %d): svr.cpp\n\n", + exc._repository_id (), + exc.minor ())); + } + catch(const CORBA::UserException& exc) + { + ACE_DEBUG ((LM_DEBUG, + "CORBA::UserException caught: %s: svr.cpp\n\n", + exc._repository_id ())); + } + catch(...) + { + ACE_DEBUG ((LM_DEBUG, + "Exception caught: svr.cpp\n\n")); + } + + return 0; +} + +static char *hostname = NULL; +static int base_port = 0; + +// Parses the command line arguments and returns an error status + +static int num_of_objs = 1; + +static int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt opts (argc, argv, "h:p:n:"); + int c; + + while ((c = opts ()) != -1) + switch (c) + { + case 'h': + hostname = opts.optarg; + break; + case 'p': + base_port = ACE_OS::atoi (opts.optarg); + break; + case 'n': + num_of_objs = ACE_OS::atoi (opts.optarg); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + " -p port" + " -h my_hostname" + " -n num_objects" + "\n", argv [0]), 1); + } + + return 0; // Indicates successful parsing of command line +} + +// Standard command line parsing utilities used. + +int +main (int argc, char *argv[]) +{ + +#if 0 + parse_args (argc, argv); + + if ((hostname == NULL) || (base_port == 0)) + { + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + " -p port -h my_hostname" + "\n",argv [0]), 1); + + } +#endif + + const size_t arg_size = + strlen("rate20 -ORBport %d -ORBhost %s") + + 5 /* port number */ + + MAXHOSTNAMELEN /* hostname */ + + 1 /* zero terminator */; + + char *args1 = 0; + ACE_NEW_RETURN (args1, char[arg_size], -1); + + ::sprintf (args1, "rate20"); + Cubit_Task task1 (args1 , "internet", 1); + ACE_Sched_Priority priority; +#if defined(VXWORKS) + priority = ACE_Sched_Params::priority_max (ACE_SCHED_FIFO, ACE_SCOPE_THREAD) + 6; +#else + priority = ACE_Sched_Params::priority_max (ACE_SCHED_FIFO, ACE_SCOPE_THREAD); +#endif + ACE_DEBUG ((LM_DEBUG, "Creating servant with high priority\n")); + task1.activate (THR_BOUND, 1, 0, priority); + + + char *args2 = 0; + ACE_NEW_RETURN (args2, char[arg_size], -1); + + ::sprintf (args2, "rate10");//, base_port+1, hostname); + Cubit_Task task2 (args2 , "internet", 1); + priority = + ACE_Sched_Params::priority_min (ACE_SCHED_FIFO, ACE_SCOPE_THREAD); + ACE_DEBUG ((LM_DEBUG, "Creating servant with low priority\n")); + task2.activate (THR_BOUND, 1, 0, priority); + + ACE_Thread_Manager::instance ()->wait (); + + delete [] args1; + delete [] args2; + + return 0; +} |