summaryrefslogtreecommitdiff
path: root/TAO/tests
diff options
context:
space:
mode:
authorgokhale <asgokhale@users.noreply.github.com>1997-08-10 14:27:50 +0000
committergokhale <asgokhale@users.noreply.github.com>1997-08-10 14:27:50 +0000
commit0eb91f8d5346861908472c604bd03457aab534cf (patch)
tree3e06956ff14bb505893d41856f2bc0ef35d71192 /TAO/tests
parent5b6461dc187771cdef1d4936483b0187f14f4f21 (diff)
downloadATCD-0eb91f8d5346861908472c604bd03457aab534cf.tar.gz
Added a new Demux test code
Diffstat (limited to 'TAO/tests')
-rwxr-xr-xTAO/tests/Demux_Test/Makefile64
-rw-r--r--TAO/tests/Demux_Test/README16
-rwxr-xr-xTAO/tests/Demux_Test/client.cpp309
-rwxr-xr-xTAO/tests/Demux_Test/gen_bin6
-rwxr-xr-xTAO/tests/Demux_Test/make_all19
-rwxr-xr-xTAO/tests/Demux_Test/run_all_client37
-rwxr-xr-xTAO/tests/Demux_Test/run_all_server20
-rwxr-xr-xTAO/tests/Demux_Test/run_client17
-rwxr-xr-xTAO/tests/Demux_Test/run_server10
-rwxr-xr-xTAO/tests/Demux_Test/server.cpp313
10 files changed, 811 insertions, 0 deletions
diff --git a/TAO/tests/Demux_Test/Makefile b/TAO/tests/Demux_Test/Makefile
new file mode 100755
index 00000000000..2756ff18b2c
--- /dev/null
+++ b/TAO/tests/Demux_Test/Makefile
@@ -0,0 +1,64 @@
+#----------------------------------------------------------------------------
+# $Id$
+#
+# Top-level Makefile for the TAO_TTCP benchmark
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Local macros
+#----------------------------------------------------------------------------
+
+LDLIBS = -lTAO
+
+PROG_SRCS = client.cpp tao_demuxC.cpp tao_demuxS.cpp tao_demux_i.cpp server.cpp
+
+LSRC = $(PROG_SRCS)
+
+TAO_DEMUX_CLIENT_OBJS = client.o tao_demuxC.o
+
+TAO_DEMUX_SERVER_OBJS = server.o tao_demuxC.o tao_demuxS.o tao_demux_i.o
+
+BIN = client server
+
+BUILD = $(BIN)
+
+VLDLIBS = $(LDLIBS:%=%$(VAR))
+
+#----------------------------------------------------------------------------
+# Include macros and targets
+#----------------------------------------------------------------------------
+
+include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU
+#include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU
+
+#----------------------------------------------------------------------------
+# Local modifications to variables imported by includes above.
+#----------------------------------------------------------------------------
+
+LDFLAGS += -lTAO
+LDFLAGS += -L$(TAO_ROOT)/tao
+CPPFLAGS += -I$(TAO_ROOT) -I$(TAO_ROOT)/tao/compat
+
+ifdef quantify
+LDFLAGS += -L/pkg/purify/quantify-2.1-solaris2/ -lquantify_stubs
+endif
+
+ifdef debug
+CPPFLAGS += -DDEBUG
+endif
+
+server: $(addprefix $(VDIR),$(TAO_DEMUX_SERVER_OBJS))
+ $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS)
+
+client: $(addprefix $(VDIR),$(TAO_DEMUX_CLIENT_OBJS))
+ $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS)
+
+clean:
+ $(MAKE) realclean
+ rm -fr tao_demux* gperf* *.i client server
+
diff --git a/TAO/tests/Demux_Test/README b/TAO/tests/Demux_Test/README
new file mode 100644
index 00000000000..9f19b8363f5
--- /dev/null
+++ b/TAO/tests/Demux_Test/README
@@ -0,0 +1,16 @@
+This test directory tests various demultiplexing strategies used in
+TAO.
+
+Description of various files:
+
+make_all script that generates executables for different number
+ of objects and methods
+gen_bin generates the binary for the desired number of objects
+ and methods
+run_client runs a client
+run_server runs a server
+run_all_client runs all clients generated by the make_all
+run_all_server runs all servers generated by the make_all
+CodeGen Directory containing the code generator
+server.cpp server main program
+client.cpp client main program \ No newline at end of file
diff --git a/TAO/tests/Demux_Test/client.cpp b/TAO/tests/Demux_Test/client.cpp
new file mode 100755
index 00000000000..b45b6819b0f
--- /dev/null
+++ b/TAO/tests/Demux_Test/client.cpp
@@ -0,0 +1,309 @@
+#include <sys/types.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "tao_demuxC.h"
+#include "tao/debug.h"
+
+#include <iostream.h>
+#include <fstream.h>
+
+void print_exception (const CORBA_Exception *x,
+ const char *info,
+ FILE *stream
+ );
+
+char Usage[] = "\
+Usage: client options\n\
+options:\n\
+-l strategy: operation lookup strategy - a(active), l(linear), d (dyn hash), p (perf)\n\
+-i iter: number of iterations \n\
+-m num: number of methods \n\
+-o num: number of objects \n\
+-t type: type can be l(linear), r(random), b (best), w (worst)\n\
+";
+
+#if !defined (__cplusplus)
+typedef void (*SIG_TYP)();
+#endif
+
+#ifdef SVR4
+void
+sigpipe (int foo)
+#else
+ void
+sigpipe ()
+#endif
+{
+}
+
+static const char ior_prefix [] = "IOR:";
+static const char iiop_prefix [] = "iiop:";
+
+enum SendType{
+ LINEAR,
+ BEST,
+ WORST,
+ RANDOM
+};
+
+void do_test(tao_demux_ptr *demux, int olimit, int mlimit, SendType, int iter);
+
+int
+main (int argc, char *argv[])
+{
+
+ unsigned long addr_tmp;
+ unsigned short done = 0;
+ int c;
+
+ CORBA_ORB_ptr orb_ptr;
+ CORBA_Environment env;
+ CORBA_Object_ptr objref;
+ tao_demux_ptr *demux;
+ unsigned loop_count = 0;
+ int exit_later = 0;
+ int i;
+ int ObjectLimit = 5,
+ MethodLimit = 4;
+ int iter= 1; // number of iterations
+ SendType st = RANDOM;
+ TAO_Operation_Table_Parameters *op_params = TAO_OP_TABLE_PARAMETERS::instance();
+
+ CORBA_String str;
+ fstream iorfile;
+
+ while (!done && ((c = getopt (argc, argv, "i:l:t:m:o:")) !=
+ -1)){
+ switch(c){
+ case 'i':
+ iter = atoi (optarg);
+ break;
+ case 'l': // op table lookup strategy
+ break;
+ case 'm':
+ MethodLimit = atoi(optarg);
+ break;
+ case 'o':
+ ObjectLimit = atoi(optarg);
+ break;
+ case 't':
+ switch(*optarg){
+ case 'b':
+ st = BEST;
+ break;
+ case 'w':
+ st = WORST;
+ break;
+ case 'l':
+ st = LINEAR;
+ break;
+ case 'r':
+ default:
+ st = RANDOM;
+ break;
+ }
+ break;
+ default:
+ goto usage;
+ }
+ }
+
+ TAO_debug_level = 0;
+ //
+ // Transmitter
+ //
+ orb_ptr = CORBA_ORB_init (argc, argv, "ior", env);
+ if (env.exception () != 0) {
+ print_exception (env.exception (), "ORB initialization", stdout);
+ return 1;
+ }
+
+ str = CORBA_string_alloc (500);
+
+ // read the IOR from the file ior.txt
+ iorfile.open("./ior.txt", ios::in);
+
+ for (;!iorfile.eof ();){
+ memset(str, '\0', 500);
+ iorfile >> ((char *)str);
+ if (iorfile.good ())
+ loop_count++;
+ }
+ iorfile.close();
+
+ ACE_DEBUG ((LM_DEBUG, "Total of %d object references read\n", loop_count));
+ demux = new tao_demux_ptr [loop_count];
+ for (i=0; i < loop_count; i++){
+ demux[i] = 0;
+ }
+
+ // read the IOR from the file ior.txt
+ iorfile.open("./ior.txt", ios::in);
+
+ for (i=0; i < loop_count; i++){
+ ACE_OS::memset (str, '\0', 500);
+ iorfile >> ((char *)str);
+ objref = orb_ptr->string_to_object(str, env);
+ if (env.exception() != 0){
+ print_exception(env.exception(), "string2object", stdout);
+ return 1;
+ }
+
+ cout << "objref " << i << " has key = " << objref->_get_name(env) << endl;
+ if (!CORBA_is_nil(objref)){
+ // narrow to the desired interface type
+ demux[i] = tao_demux::_narrow (objref);
+ }
+ }
+ iorfile.close();
+ CORBA_string_free(str);
+
+
+ // send operations
+ do_test(demux, ObjectLimit, MethodLimit, st, iter);
+
+ for (i=0; i < loop_count; i++){
+ CORBA_release(demux[i]);
+ }
+ delete [] demux;
+ return(0);
+usage:
+ fprintf (stderr, Usage);
+ return 1;
+}
+
+typedef void (*method_ptr)(tao_demux_ptr);
+struct method_db {
+ method_ptr method;
+};
+
+#include "client.i"
+
+void do_test(tao_demux_ptr *demux, int olimit, int mlimit, SendType st, int iter)
+{
+ int i, j, k;
+ int loop = 0;
+ hrtime_t start, end, sum, diff;
+ fstream result;
+ CORBA_Environment env;
+
+ result.open("result.dat",ios::out|ios::app);
+#ifdef __TAO_ACTIVE__
+ result << "# ACTIVE ";
+#endif
+#ifdef __TAO_GPERF__
+ result << "# GPERF ";
+#endif
+#ifdef __TAO_LINEAR__
+ result << "# LINEAR ";
+#endif
+
+ // result << "@type xy" << endl;
+ sum = 0;
+
+ if (st == LINEAR){
+ result << " LINEAR" << endl;
+#ifdef __DEBUG__
+ cout << "Linear strategy for sending" << endl;
+#endif
+ for (k=0; k < iter; k++) {
+ // invoke the jth method on the ith object
+ for (i=0; i < olimit; i++){
+ for (j=0; j < mlimit; j++){
+ loop++;
+ start = gethrtime();
+ mtbl[j].method(demux[i]);
+ end = gethrtime();
+ diff = (end - start);
+#ifdef __DEBUG__
+ cout << "Latency for this request = " << diff/1.0e+06 << endl;
+#endif
+ sum += diff;
+ // result << loop << "\t" << diff/1.e+06 << endl;
+ }
+ }
+ }
+ } else if (st == BEST){
+ result << " BEST" << endl;
+#ifdef __DEBUG__
+ cout << "best strategy for sending" << endl;
+#endif
+ for (k=0; k < iter; k++) {
+ // invoke the jth method on the ith object
+ for (i=0; i < olimit; i++){
+ for (j=0; j < mlimit; j++){
+ loop++;
+ start = gethrtime();
+ mtbl[0].method(demux[0]);
+ end = gethrtime();
+ diff = (end - start);
+#ifdef __DEBUG__
+ cout << "Latency for this request = " << diff/1.0e+06 << endl;
+#endif
+ sum += diff;
+ // result << loop << "\t" << diff/1.e+06 << endl;
+ }
+ }
+ }
+ } else if (st == RANDOM) {
+ result << " RANDOM" << endl;
+#ifdef __DEBUG__
+ cout << "Random strategy for sending" << endl;
+#endif
+ // choose the object and method name randomly
+ srand48(time(NULL));
+ long p, q;
+ for (k=0; k < iter; k++) {
+ for (i=0; i < olimit; i++){
+ for (j=0; j < mlimit; j++){
+ loop++;
+ p = lrand48() % olimit;
+ q = lrand48() % mlimit;
+ start = gethrtime();
+#ifdef DEBUG
+ ACE_DEBUG ((LM_DEBUG, "Invoking op %s on object with key %s\n",
+ mtbl[q], demux[p]->_get_name(env)));
+#endif
+ mtbl[q].method(demux[p]);
+ end = gethrtime();
+ diff = (end - start);
+#ifdef __DEBUG__
+ cout << "Latency for this request = " << diff/1.0e+06 << endl;
+#endif
+ sum += diff;
+ // result << loop << "\t" << diff/1.e+06 << endl;
+ }
+ }
+ }
+ } else if (st == WORST){
+ result << " WORST" << endl;
+#ifdef __DEBUG__
+ cout << "worst strategy for sending" << endl;
+#endif
+ // invoke the jth method on the ith object
+ for (k=0; k < iter; k++) {
+ for (i=0; i < olimit; i++){
+ for (j=0; j < mlimit; j++){
+ loop++;
+ start = gethrtime();
+ mtbl[mlimit-1].method(demux[olimit-1]);
+ end = gethrtime();
+ diff = (end - start);
+#ifdef __DEBUG__
+ cout << "Latency for this request = " << diff/1.0e+06 << endl;
+#endif
+ sum += diff;
+ // result << loop << "\t" << diff/1.e+06 << endl;
+ }
+ }
+ }
+ }
+ result << olimit << "\t" << mlimit << "\t" << sum/(loop*1000000.0) << endl;
+ cout << olimit << "\t" << mlimit << "\t" << sum/(loop*1000000.0) << endl;
+ result.close();
+}
+
diff --git a/TAO/tests/Demux_Test/gen_bin b/TAO/tests/Demux_Test/gen_bin
new file mode 100755
index 00000000000..b0650ff4249
--- /dev/null
+++ b/TAO/tests/Demux_Test/gen_bin
@@ -0,0 +1,6 @@
+#!/bin/sh
+make clean
+./CodeGen/tao -o $1 -m $2
+make
+mv client client_${1}_${2}
+mv server server_${1}_${2}
diff --git a/TAO/tests/Demux_Test/make_all b/TAO/tests/Demux_Test/make_all
new file mode 100755
index 00000000000..4ac9b18cc3f
--- /dev/null
+++ b/TAO/tests/Demux_Test/make_all
@@ -0,0 +1,19 @@
+rm -fr server_*_* client_*_*
+gen_bin 1 1
+gen_bin 1 10
+gen_bin 1 100
+gen_bin 100 1
+gen_bin 100 10
+gen_bin 100 100
+gen_bin 200 1
+gen_bin 200 10
+gen_bin 200 100
+gen_bin 300 1
+gen_bin 300 10
+gen_bin 300 100
+gen_bin 400 1
+gen_bin 400 10
+gen_bin 400 100
+gen_bin 500 1
+gen_bin 500 10
+gen_bin 500 100
diff --git a/TAO/tests/Demux_Test/run_all_client b/TAO/tests/Demux_Test/run_all_client
new file mode 100755
index 00000000000..a5a3b61c48f
--- /dev/null
+++ b/TAO/tests/Demux_Test/run_all_client
@@ -0,0 +1,37 @@
+#!/bin/sh
+# usage: run_client <num objs> <num methods> <num iters>
+run_client 500 100 1
+sleep 5
+run_client 500 10 1
+sleep 5
+run_client 500 1 1
+sleep 5
+run_client 400 100 1
+sleep 5
+run_client 400 10 1
+sleep 5
+run_client 400 1 1
+sleep 5
+run_client 300 100 1
+sleep 5
+run_client 300 10 1
+sleep 5
+run_client 300 1 1
+sleep 5
+run_client 200 100 1
+sleep 5
+run_client 200 10 1
+sleep 5
+run_client 200 1 1
+sleep 5
+run_client 100 100 1
+sleep 5
+run_client 100 10 1
+sleep 5
+run_client 100 1 1
+sleep 5
+run_client 1 100 1
+sleep 5
+run_client 1 10 10
+sleep 5
+run_client 1 1 100
diff --git a/TAO/tests/Demux_Test/run_all_server b/TAO/tests/Demux_Test/run_all_server
new file mode 100755
index 00000000000..15b4762efcb
--- /dev/null
+++ b/TAO/tests/Demux_Test/run_all_server
@@ -0,0 +1,20 @@
+#!/bin/sh
+# usage: run_server <num objs> <num methods> <num iters>
+run_server 500 100 1
+run_server 500 10 1
+run_server 500 1 1
+run_server 400 100 1
+run_server 400 10 1
+run_server 400 1 1
+run_server 300 100 1
+run_server 300 10 1
+run_server 300 1 1
+run_server 200 100 1
+run_server 200 10 1
+run_server 200 1 1
+run_server 100 100 1
+run_server 100 10 1
+run_server 100 1 1
+run_server 1 100 1
+run_server 1 10 10
+run_server 1 1 100
diff --git a/TAO/tests/Demux_Test/run_client b/TAO/tests/Demux_Test/run_client
new file mode 100755
index 00000000000..19dab08670d
--- /dev/null
+++ b/TAO/tests/Demux_Test/run_client
@@ -0,0 +1,17 @@
+#!/bin/sh
+client_${1}_${2} -o ${1} -m ${2} -t r -i $3
+sleep 5
+client_${1}_${2} -o ${1} -m ${2} -t w -i $3
+sleep 5
+client_${1}_${2} -o ${1} -m ${2} -t r -i $3
+sleep 5
+client_${1}_${2} -o ${1} -m ${2} -t w -i $3
+sleep 5
+client_${1}_${2} -o ${1} -m ${2} -t r -i $3
+sleep 5
+client_${1}_${2} -o ${1} -m ${2} -t w -i $3
+sleep 5
+client_${1}_${2} -o ${1} -m ${2} -t r -i $3
+sleep 5
+client_${1}_${2} -o ${1} -m ${2} -t w -i $3
+sleep 5
diff --git a/TAO/tests/Demux_Test/run_server b/TAO/tests/Demux_Test/run_server
new file mode 100755
index 00000000000..7f2ac61445a
--- /dev/null
+++ b/TAO/tests/Demux_Test/run_server
@@ -0,0 +1,10 @@
+#!/bin/sh
+server_${1}_${2} -OAhost merengue -OAobjdemux linear -OAtablesize ${1} -o ${1} -m ${2} -t l -i $3
+server_${1}_${2} -OAhost merengue -OAobjdemux linear -OAtablesize ${1} -o ${1} -m ${2} -t l -i $3
+server_${1}_${2} -OAhost merengue -OAobjdemux active_demux -OAtablesize ${1} -o ${1} -m ${2} -t a -i $3
+server_${1}_${2} -OAhost merengue -OAobjdemux active_demux -OAtablesize ${1} -o ${1} -m ${2} -t a -i $3
+server_${1}_${2} -OAhost merengue -OAobjdemux user_def -o ${1} -m ${2} -t g -i $3
+server_${1}_${2} -OAhost merengue -OAobjdemux user_def -o ${1} -m ${2} -t g -i $3
+server_${1}_${2} -OAhost merengue -o ${1} -m ${2} -i $3
+server_${1}_${2} -OAhost merengue -o ${1} -m ${2} -i $3
+
diff --git a/TAO/tests/Demux_Test/server.cpp b/TAO/tests/Demux_Test/server.cpp
new file mode 100755
index 00000000000..a5fbd433e45
--- /dev/null
+++ b/TAO/tests/Demux_Test/server.cpp
@@ -0,0 +1,313 @@
+#include "tao_demux_i.h"
+
+#ifdef USE_QUANTIFY
+#include <quantify.h>
+#endif
+
+#include <iostream.h>
+#include <fstream.h>
+
+#include "ace/SString.h"
+
+void print_exception (const CORBA_Exception *x,
+ const char *info,
+ FILE *stream
+ );
+
+#if !defined (__cplusplus)
+typedef void (*SIG_TYP)();
+#endif
+
+#ifdef SVR4
+void
+sigpipe (int foo)
+#else
+ void
+sigpipe ()
+#endif
+{
+}
+
+//****************** perf hash for obj lookup *************
+// for perfect hash
+struct object_db
+{
+ char *name; // name of method
+ CORBA_Object_ptr obj; //fn pointer to obj impl
+};
+
+// include the perfect hash code for objects
+#include "gperf_object.i"
+
+// Perfect hash table class
+class TAO_Perfect_Hash_ObjTable: public TAO_Object_Table
+{
+public:
+ TAO_Perfect_Hash_ObjTable (Object_Hash *oh);
+
+ ~TAO_Perfect_Hash_ObjTable (void);
+
+ virtual int bind (const CORBA_OctetSeq &key,
+ CORBA_Object_ptr obj);
+ // Registers a CORBA_Object into the object table and associates the
+ // key with it. Returns -1 on failure, 0 on success, 1 on
+ // duplicate.
+
+ virtual int find (const CORBA_OctetSeq &key,
+ CORBA_Object_ptr &obj);
+ // Looks up an object in the object table using <{key}>. Returns
+ // non-negative integer on success, or -1 on failure.
+
+private:
+ Object_Hash *hash_;
+};
+
+TAO_Perfect_Hash_ObjTable::TAO_Perfect_Hash_ObjTable (Object_Hash *oh)
+ : hash_ (oh)
+{
+}
+
+TAO_Perfect_Hash_ObjTable::~TAO_Perfect_Hash_ObjTable (void)
+{
+}
+
+int
+TAO_Perfect_Hash_ObjTable::bind (const CORBA_OctetSeq &key, CORBA_Object_ptr obj)
+{
+ struct object_db *entry;
+
+ ACE_CString objkey ((char *)key.buffer, key.length);
+ entry = this->hash_->in_word_set (objkey.rep (), key.length);
+ if (entry != 0)
+ {
+ // now fill up the entry
+ entry->obj = obj;
+ }
+ else
+ {
+ return -1; // error
+ }
+}
+
+int
+TAO_Perfect_Hash_ObjTable::find (const CORBA_OctetSeq &key, CORBA_Object_ptr &obj)
+{
+ struct object_db *entry;
+
+ ACE_CString objkey ((char *)key.buffer, key.length);
+ entry = this->hash_->in_word_set (objkey.rep (), key.length);
+
+ if (entry != 0)
+ {
+ obj = entry->obj;
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+}
+
+//****************** perf hash for opname lookup *************
+struct method_db
+{
+ char *name; // name of method
+ TAO_Skeleton skel_ptr_; //fn pointer to obj impl
+};
+
+#include "gperf_method.i"
+
+// Perfect hash table class
+class TAO_Perfect_Hash_Op_Table: public TAO_Operation_Table
+{
+public:
+ TAO_Perfect_Hash_Op_Table (Method_Hash *mh);
+
+ ~TAO_Perfect_Hash_Op_Table (void);
+
+ virtual int find (const CORBA_String &opname,
+ TAO_Skeleton &skel_ptr);
+ // Uses <{opname}> to look up the skeleton function and pass it back
+ // in <{skelfunc}>. Returns non-negative integer on success, or -1
+ // on failure.
+
+ virtual int bind (const CORBA_String &opname,
+ const TAO_Skeleton skelptr);
+ // Associate the skeleton <{skel_ptr}> with an operation named
+ // <{opname}>. Returns -1 on failure, 0 on success, 1 on duplicate.
+private:
+ Method_Hash *hash_;
+};
+
+TAO_Perfect_Hash_Op_Table::TAO_Perfect_Hash_Op_Table (Method_Hash *mh)
+ : hash_ (mh)
+{
+}
+
+TAO_Perfect_Hash_Op_Table::~TAO_Perfect_Hash_Op_Table (void)
+{
+}
+
+int
+TAO_Perfect_Hash_Op_Table::bind (const CORBA_String &opname,
+ const TAO_Skeleton skelptr)
+{
+ return 0; // nothing to do
+}
+
+int
+TAO_Perfect_Hash_Op_Table::find (const CORBA_String &opname,
+ TAO_Skeleton &skelptr)
+{
+ method_db *entry;
+
+ entry = (method_db*) this->hash_->in_word_set (opname, ACE_OS::strlen (opname));
+ if (entry != 0)
+ {
+ skelptr = entry->skel_ptr_;
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+}
+
+//***********************************************************
+char Usage[] = "\
+Usage: server [options] \n\
+Common options:\n\
+-t demux_strategy: l(linear), g(GPERF), a (delayered active demux), d (dynamic hash)\n\
+-i iter: number of iterations to expect from client \n\
+";
+
+extern CORBA_Double TAO_Avg;
+extern CORBA_Long TAO_HowMany;
+extern CORBA_Long TAO_Loop;
+int
+main (int argc, char *const *argv)
+{
+ unsigned long addr_tmp;
+ int c;
+ unsigned short done = 0;
+ CORBA_Environment env;
+ CORBA_ORB_ptr orb_ptr;
+ CORBA_BOA_ptr oa_ptr;
+ int iter = 1;
+ TAO_OA_Parameters *params = TAO_OA_PARAMS::instance();
+ char *orb_name = "ior";
+ int idle = -1;
+ int use_ior = 0;
+ int terminationStatus = 0;
+ tao_demux_i **mymux; // array of objects implementing the "demux" interface
+ int numObjs = 5, numMethods = 4;
+ Object_Hash oh;
+ TAO_Object_Table *objt = new TAO_Perfect_Hash_ObjTable (&oh);
+ Method_Hash mh;
+ TAO_Operation_Table *optbl = new TAO_Perfect_Hash_Op_Table (&mh);
+
+ TAO_Operation_Table_Parameters *op_params =
+ TAO_OP_TABLE_PARAMETERS::instance();
+
+ fstream iorfile; // stores the object references of all the objects
+ fstream outfile;
+ CORBA_String str; // scratch area
+
+ params->userdef_lookup_strategy (objt);
+
+ orb_ptr = CORBA_ORB_init (argc, argv, orb_name, env);
+ if (env.exception () != 0) {
+ print_exception (env.exception (), "ORB init", stdout);
+ return 1;
+ }
+
+ oa_ptr = orb_ptr->BOA_init (argc, argv, "ROA");
+ if (env.exception () != 0) {
+ print_exception (env.exception (), "OA init", stdout);
+ return 1;
+ }
+
+ TAO_debug_level = 0;
+ // Now process the options other than Orbix specific options
+ while ((c = getopt (argc, argv, "ui:t:o:m:")) != -1)
+ {
+ switch (c)
+ {
+ case 't':
+ switch (*optarg)
+ {
+ case 'l':
+ op_params->lookup_strategy
+ (TAO_Operation_Table_Parameters::TAO_LINEAR);
+ break;
+ case 'a':
+ op_params->lookup_strategy
+ (TAO_Operation_Table_Parameters::TAO_ACTIVE_DEMUX);
+ break;
+ case 'g':
+ op_params->lookup_strategy
+ (TAO_Operation_Table_Parameters::TAO_PERFECT_HASH);
+ op_params->concrete_strategy (optbl);
+ break;
+ case 'd':
+ default:
+ op_params->lookup_strategy
+ (TAO_Operation_Table_Parameters::TAO_DYNAMIC_HASH);
+ break;
+ }
+ break;
+ case 'u':
+ use_ior = 1;
+ orb_name = "";
+ break;
+ case 'i':
+ iter = atoi (optarg);
+ break;
+ case 'o':
+ numObjs = atoi(optarg);
+ break;
+ case 'm':
+ numMethods = atoi(optarg);
+ break;
+ default:
+ goto usage;
+ }
+ }
+
+ TAO_Avg = 0;
+ TAO_Loop = 0;
+ TAO_HowMany = iter*numObjs*numMethods;
+
+ //
+ // Receiver
+ //
+
+ iorfile.open ("ior.txt", ios::out);
+ mymux = new tao_demux_i* [numObjs];
+
+ // instantiate objects
+#include "obj_create.i"
+ iorfile.close();
+ cout << "Server ready to handle events" << endl;
+
+#if defined (USE_QUANTIFY)
+ quantify_clear_data();
+ quantify_start_recording_data();
+#endif
+
+ ACE_Service_Config::run_reactor_event_loop();
+
+ outfile.open ("muxcost.dat", ios::out|ios::app);
+ outfile << numObjs << "\t" << numMethods << "\t" << TAO_Avg << endl;
+ outfile.close ();
+ //
+ // Shut down the OA -- recycles all underlying resources (e.g. file
+ // descriptors, etc).
+ //
+ oa_ptr->clean_shutdown (env);
+ return terminationStatus;
+usage:
+ fprintf (stderr, Usage);
+ return(1);
+}
+