diff options
author | kirthika <kirthika@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-07-24 18:04:34 +0000 |
---|---|---|
committer | kirthika <kirthika@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-07-24 18:04:34 +0000 |
commit | aecb84566c20bff83a2514f85d1c528150b345d7 (patch) | |
tree | 8b830848da87eb9429fb312f30148224829b12a0 | |
parent | be427e677606c38010d1a9f59ef5919c4314d7e5 (diff) | |
download | ATCD-aecb84566c20bff83a2514f85d1c528150b345d7.tar.gz |
Benchamrk test files`
-rw-r--r-- | TAO/tests/Portable_Interceptors/Benchmark/client.cpp | 207 | ||||
-rw-r--r-- | TAO/tests/Portable_Interceptors/Benchmark/interceptors.cpp | 190 | ||||
-rw-r--r-- | TAO/tests/Portable_Interceptors/Benchmark/interceptors.h | 118 | ||||
-rw-r--r-- | TAO/tests/Portable_Interceptors/Benchmark/marker.cpp | 69 | ||||
-rw-r--r-- | TAO/tests/Portable_Interceptors/Benchmark/marker.h | 33 | ||||
-rw-r--r-- | TAO/tests/Portable_Interceptors/Benchmark/server.cpp | 126 | ||||
-rw-r--r-- | TAO/tests/Portable_Interceptors/Benchmark/test.idl | 52 | ||||
-rw-r--r-- | TAO/tests/Portable_Interceptors/Benchmark/test_i.cpp | 46 | ||||
-rw-r--r-- | TAO/tests/Portable_Interceptors/Benchmark/test_i.h | 56 |
9 files changed, 897 insertions, 0 deletions
diff --git a/TAO/tests/Portable_Interceptors/Benchmark/client.cpp b/TAO/tests/Portable_Interceptors/Benchmark/client.cpp new file mode 100644 index 00000000000..008a06694f1 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Benchmark/client.cpp @@ -0,0 +1,207 @@ +// $Id$ + +#include "ace/Get_Opt.h" +#include "testC.h" +#include "interceptors.h" +#include "marker.h" + +ACE_RCSID (Benchmark, client, "$Id$") + +const char *ior = "file://test.ior"; +int niterations = 5; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "ef:i:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'e': + break; + case 'f': + ior = get_opts.optarg; + break; + case 'i': + niterations = ACE_OS::atoi (get_opts.optarg); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-v " + "\n", + argv [0]), + -1); + } + return 0; +} + +// TODO:check the sched stuff form latency test, for runningtest inrealtime mode! + +void +run_test (Test_Interceptors::Secure_Vault_ptr server, + CORBA::Environment &ACE_TRY_ENV) +{ + int i=0; + const char passwd [BUFSIZ] = "root"; + Marker marker; + ACE_Throughput_Stats throughput; + + ACE_DEBUG ((LM_DEBUG, "High res. timer calibration....")); + ACE_UINT32 gsf = ACE_High_Res_Timer::global_scale_factor (); + ACE_DEBUG ((LM_DEBUG, "done\n")); + + marker.accumulate_into (throughput, 1); + ACE_hrtime_t throughput_base = ACE_OS::gethrtime (); + for (i = 0; i < niterations ; ++i) + { + // Record current time. + ACE_hrtime_t latency_base = ACE_OS::gethrtime (); + + server->ready (ACE_TRY_ENV); + + // Grab timestamp again. + ACE_hrtime_t now = ACE_OS::gethrtime (); + + // Record statistics. + marker.sample (now - throughput_base, + now - latency_base, + 1); + + ACE_CHECK; + if (TAO_debug_level > 0 && i % 100 == 0) + ACE_DEBUG ((LM_DEBUG, "(%P|%t) iteration = %d\n", i)); + + marker.dump_stats ("Ready method ", gsf, 1); + } + throughput.dump_results ("Aggregated", gsf); + + ACE_TRY + { + marker.accumulate_into (throughput, 2); + throughput_base = ACE_OS::gethrtime (); + + for (i = 0; i < niterations ; ++i) + { + // Record current time. + ACE_hrtime_t latency_base = ACE_OS::gethrtime (); + + server->authenticate (passwd, ACE_TRY_ENV); + + // Grab timestamp again. + ACE_hrtime_t now = ACE_OS::gethrtime (); + + // Record statistics. + marker.sample (now - throughput_base, + now - latency_base, + 2); + + ACE_CHECK; + if (TAO_debug_level > 0 && i % 100 == 0) + ACE_DEBUG ((LM_DEBUG, "(%P|%t) iteration = %d\n", i)); + + marker.dump_stats ("Authenticate method ", gsf, 2); + + ACE_TRY_CHECK; + } + throughput.dump_results ("Aggregated", gsf); + } + ACE_CATCH (Test_Interceptors::Invalid, userex) + { + ACE_DEBUG ((LM_DEBUG, "Invalid passwd\n")); + } + ACE_ENDTRY; + ACE_CHECK; + + + Test_Interceptors::Secure_Vault::Record record; + record.check_num = 1; + record.amount = 1000; + CORBA::Long id = 1; + + marker.accumulate_into (throughput, 3); + throughput_base = ACE_OS::gethrtime (); + + for (i = 0; i < niterations ; ++i) + { + // Record current time. + ACE_hrtime_t latency_base = ACE_OS::gethrtime (); + + CORBA::Long result = server->update_records (id, + record, + ACE_TRY_ENV); + + + // Grab timestamp again. + ACE_hrtime_t now = ACE_OS::gethrtime (); + + // Record statistics. + marker.sample (now - throughput_base, + now - latency_base, + 3); + + ACE_CHECK; + if (TAO_debug_level > 0 && i % 100 == 0) + ACE_DEBUG ((LM_DEBUG, "(%P|%t) iteration = %d\n", i)); + + marker.dump_stats ("update records method ", gsf, 3); + ACE_CHECK; + } + throughput.dump_results ("Aggregated", gsf); + +} + +int +main (int argc, char *argv[]) +{ + ACE_TRY_NEW_ENV + { + PortableInterceptor::ClientRequestInterceptor_ptr interceptor = 0; + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "", ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + // Installing the Vault interceptor + ACE_NEW_RETURN (interceptor, + Vault_Client_Request_Interceptor (orb.in ()), + -1); + orb->_register_client_interceptor (interceptor); + + CORBA::Object_var object = + orb->string_to_object (ior, ACE_TRY_ENV); + ACE_TRY_CHECK; + + Test_Interceptors::Secure_Vault_var server = + Test_Interceptors::Secure_Vault::_narrow (object.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (CORBA::is_nil (server.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Object reference <%s> is nil\n", + ior), + 1); + } + + run_test (server.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + server->shutdown (ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Catched exception:"); + return 1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/tests/Portable_Interceptors/Benchmark/interceptors.cpp b/TAO/tests/Portable_Interceptors/Benchmark/interceptors.cpp new file mode 100644 index 00000000000..516745b5991 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Benchmark/interceptors.cpp @@ -0,0 +1,190 @@ +// $Id$ + +#include "interceptors.h" + +ACE_RCSID(Benchmark, interceptors, "$Id$") + +const CORBA::ULong request_ctx_id = 0xdead; +const CORBA::ULong reply_ctx_id = 0xbeef; + +Vault_Client_Request_Interceptor::Vault_Client_Request_Interceptor (CORBA::ORB_ptr orb) + : myname_ ("Vault_Client_Interceptor"), + orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +Vault_Client_Request_Interceptor::~Vault_Client_Request_Interceptor () +{ +} + +void +Vault_Client_Request_Interceptor::_add_ref (void) +{ + this->_incr_refcnt (); + // This is a TAO specific implementation. +} + +void +Vault_Client_Request_Interceptor::_remove_ref (void) +{ + this->_decr_refcnt (); + // This is a TAO specific implementation. +} + +char * +Vault_Client_Request_Interceptor::name (CORBA::Environment &) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return CORBA::string_dup (this->myname_); +} + +void +Vault_Client_Request_Interceptor::send_request (PortableInterceptor::ClientRequestInfo_ptr ri, + CORBA::Environment &) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + if (ACE_OS::strcmp (ri->operation (), "authenticate") == 0) + { + // MAke the context to send the context to the target + IOP::ServiceContext sc; + sc.context_id = request_ctx_id; + + const char passwd [20] = "root123"; + CORBA::ULong string_len = ACE_OS::strlen (passwd) + 1; + CORBA::Octet *buf = 0; + ACE_NEW (buf, + CORBA::Octet [string_len]); + ACE_OS::strcpy (ACE_reinterpret_cast (char *, buf), passwd); + + sc.context_data.replace (string_len, string_len, buf, 1); + + // Add this context to the service context list. + ri->add_request_service_context (sc, 0); + } + + if (ACE_OS::strcmp (ri->operation (), "update_records") == 0) + { + Dynamic::ParameterList paramlist = *(ri->arguments ()); + Test_Interceptors::Secure_Vault::Record *record; + CORBA::Long id; + paramlist[0].argument >>= id; + paramlist[1].argument >>= record; + } + +} + +void +Vault_Client_Request_Interceptor::receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (ACE_OS::strcmp (ri->operation (), "update_records") == 0) + { + CORBA::Long result; + CORBA_Any result_any = *(ri->result ()); + result_any >>= result; + } + +} + +void +Vault_Client_Request_Interceptor::receive_exception (PortableInterceptor::ClientRequestInfo_ptr ri, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + // As of now, there is no way to extract an exception from an Any in TAO. + CORBA::Exception *e = ri->_received_exception (); + + ACE_ASSERT (ACE_OS::strcmp (ri->received_exception_id (), e->_id ())== 0); + +} + + +Vault_Server_Request_Interceptor::Vault_Server_Request_Interceptor (CORBA::ORB_ptr orb) + : myname_ ("Vault_Server_Interceptor"), + orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +Vault_Server_Request_Interceptor::~Vault_Server_Request_Interceptor () +{ +} + +void +Vault_Server_Request_Interceptor::_add_ref (void) +{ + this->_incr_refcnt (); + // This is a TAO specific implementation. +} + +void +Vault_Server_Request_Interceptor::_remove_ref (void) +{ + this->_decr_refcnt (); + // This is a TAO specific implementation. +} + +char * +Vault_Server_Request_Interceptor::name (CORBA::Environment &) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return CORBA::string_dup (this->myname_); +} + +void +Vault_Server_Request_Interceptor::receive_request (PortableInterceptor::ServerRequestInfo_ptr ri, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + if (ACE_OS::strcmp (ri->operation (), "authenticate") == 0) + { + + IOP::ServiceId id = request_ctx_id; + IOP::ServiceContext *sc = ri->get_request_service_context (id); + + if (sc == 0) + ACE_THROW (CORBA::NO_MEMORY ()); + + const char *buf = ACE_reinterpret_cast (const char *, sc->context_data.get_buffer ()); + if (ACE_OS::strcmp (buf, "root123") !=0) + ACE_THROW (Test_Interceptors::Invalid ()); + } + + if (ACE_OS::strcmp (ri->operation (), "update_records") == 0) + { + Dynamic::ParameterList paramlist = *(ri->arguments ()); + Test_Interceptors::Secure_Vault::Record *record; + CORBA::Long id; + paramlist[0].argument >>= id; + paramlist[1].argument >>= record; + } + + +} + +void +Vault_Server_Request_Interceptor::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri, + CORBA::Environment &) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + if (ACE_OS::strcmp (ri->operation (), "update_records") == 0) + { + CORBA::Long result; + CORBA_Any result_any = *(ri->result ()); + result_any >>= result; + } +} + +void +Vault_Server_Request_Interceptor::send_exception (PortableInterceptor::ServerRequestInfo_ptr ri, + CORBA::Environment &) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + CORBA::Exception *e = ri->_sending_exception (); + +} diff --git a/TAO/tests/Portable_Interceptors/Benchmark/interceptors.h b/TAO/tests/Portable_Interceptors/Benchmark/interceptors.h new file mode 100644 index 00000000000..ca08000cb0b --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Benchmark/interceptors.h @@ -0,0 +1,118 @@ +// $Id$ + +#ifndef TAO_INTERCEPTORS_H +#define TAO_INTERCEPTORS_H + +//#include "tao/corba.h" +#include "testC.h" +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +// Forward Declarations + +class PortableInterceptor::ClientRequestInfo; +class PortableInterceptor::ServerRequestInfo; + +class Vault_Client_Request_Interceptor +: public PortableInterceptor::ClientRequestInterceptor//, + // public CORBA::LocalObject +{ + // = Client-side Vault interceptor. For checking interceptor visually only. +public: + Vault_Client_Request_Interceptor (CORBA::ORB_ptr orb); + // ctor. + virtual ~Vault_Client_Request_Interceptor (); + // dtor. + + virtual void _add_ref (void); + // Increment the reference count. + + virtual void _remove_ref (void); + // Decrement the reference count. + + virtual char * name (CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Canonical name of the interceptor. + + virtual void send_request (PortableInterceptor::ClientRequestInfo_ptr ri, + CORBA::Environment &ACE_TRY_ENVV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void receive_exception (PortableInterceptor::ClientRequestInfo_ptr ri, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + +private: + const char *myname_; + + CORBA::ORB_var orb_; + +}; + +class Vault_Server_Request_Interceptor +: public PortableInterceptor::ServerRequestInterceptor//, +// public CORBA::LocalObject +{ + // = Server-side Vault interceptor. For checking interceptor visually only. +public: + Vault_Server_Request_Interceptor (CORBA::ORB_ptr orb); + // cotr. + ~Vault_Server_Request_Interceptor (); + // dotr. + + virtual void _add_ref (void); + // Increment the reference count. + + virtual void _remove_ref (void); + // Decrement the reference count. + + virtual char * name (CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Canonical name of the interceptor. + + virtual void receive_request (PortableInterceptor::ServerRequestInfo_ptr ri, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_reply (PortableInterceptor::ServerRequestInfo_ptr ri, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void send_exception (PortableInterceptor::ServerRequestInfo_ptr ri, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + +private: + const char *myname_; + + CORBA::ORB_var orb_; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ +#endif /* TAO_INTERCEPTORS_H */ diff --git a/TAO/tests/Portable_Interceptors/Benchmark/marker.cpp b/TAO/tests/Portable_Interceptors/Benchmark/marker.cpp new file mode 100644 index 00000000000..dda5ff3c73b --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Benchmark/marker.cpp @@ -0,0 +1,69 @@ +// $Id$ +#include "marker.h" + +void +Marker::accumulate_into (ACE_Throughput_Stats &throughput, + int which_method) const +{ + switch (which_method) + { + case 1: // method ready + throughput.accumulate (this->throughput_method_ready_); + break; + case 2: // method authenticate + throughput.accumulate (this->throughput_method_authenticate_); + break; + case 3: // method update_records + throughput.accumulate (this->throughput_method_update_records_); + break; + default: + break; + } + +} + +void +Marker::dump_stats (const char* msg, + ACE_UINT32 gsf, + int which_method) +{ + switch (which_method) + { + case 1: // method ready + this->throughput_method_ready_.dump_results (msg, gsf); + break; + case 2: // method authentciate + this->throughput_method_authenticate_.dump_results (msg, gsf); + break; + case 3: // method update_records + this->throughput_method_update_records_.dump_results (msg, gsf); + break; + default: + break; + } +} + +void +Marker::sample (ACE_hrtime_t throughput_diff, + ACE_hrtime_t latency_diff, + int which_method) +{ + switch (which_method) + { + case 1: // method ready + this->throughput_method_ready_.sample (throughput_diff, + latency_diff); + break; + case 2: // method authentciate + this->throughput_method_authenticate_.sample (throughput_diff, + latency_diff); + break; + case 3: // method update_records + this->throughput_method_update_records_.sample (throughput_diff, + latency_diff); + break; + default: + break; + } + +} diff --git a/TAO/tests/Portable_Interceptors/Benchmark/marker.h b/TAO/tests/Portable_Interceptors/Benchmark/marker.h new file mode 100644 index 00000000000..f0edba12041 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Benchmark/marker.h @@ -0,0 +1,33 @@ +// $Id$ + +#include "ace/High_Res_Timer.h" +#include "ace/Sched_Params.h" +#include "ace/Stats.h" + +class Marker +{ + public: + + void accumulate_into (ACE_Throughput_Stats &throughput, + int which_method) const; + // Accumulate the throughput statistics into <throughput> + + void dump_stats (const char* msg, + ACE_UINT32 gsf, + int which_method); + // Print stats + + void sample (ACE_hrtime_t throughput_diff, + ACE_hrtime_t latency_diff, + int which_method); + // get the sample. + + private: + ACE_Throughput_Stats throughput_method_ready_; + // Keep throughput statistics on a per-thread basis + ACE_Throughput_Stats throughput_method_authenticate_; + // Keep throughput statistics on a per-thread basis + ACE_Throughput_Stats throughput_method_update_records_; + // Keep throughput statistics on a per-thread basis +}; + diff --git a/TAO/tests/Portable_Interceptors/Benchmark/server.cpp b/TAO/tests/Portable_Interceptors/Benchmark/server.cpp new file mode 100644 index 00000000000..9ab7f755621 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Benchmark/server.cpp @@ -0,0 +1,126 @@ +// $Id$ + +#include "ace/Get_Opt.h" +#include "test_i.h" +#include "interceptors.h" + +ACE_RCSID(Benchmark, server, "$Id$") + +const char *ior_output_file = 0; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "o:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'o': + ior_output_file = get_opts.optarg; + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-o <iorfile>" + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_TRY_NEW_ENV + { + PortableInterceptor::ServerRequestInterceptor_ptr interceptor = 0; + + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "", ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Installing the Vault interceptor + ACE_NEW_RETURN (interceptor, + Vault_Server_Request_Interceptor (orb.in ()), + -1); + orb->_register_server_interceptor (interceptor); + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA"); + if (CORBA::is_nil (poa_object.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the POA.\n"), + 1); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + Secure_Vault_i server_impl (orb.in ()); + + PortableServer::ObjectId_var id = + root_poa->activate_object (&server_impl, + ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + CORBA::Object_var test_obj = + root_poa->id_to_reference (id.in (), + ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + Test_Interceptors::Secure_Vault_var server = + Test_Interceptors::Secure_Vault::_narrow (test_obj.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (server.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Test_Interceptors::Secure_Vault: <%s>\n", ior.in ())); + + // If the ior_output_file exists, output the ior to it + if (ior_output_file != 0) + { + FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + } + + poa_manager->activate (ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (orb->run () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "orb->run"), -1); + ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); + + root_poa->destroy (1, 1, ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Catched exception:"); + return 1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/tests/Portable_Interceptors/Benchmark/test.idl b/TAO/tests/Portable_Interceptors/Benchmark/test.idl new file mode 100644 index 00000000000..77e3c3114aa --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Benchmark/test.idl @@ -0,0 +1,52 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Interceptors +// +// = FILENAME +// test.idl +// +// = DESCRIPTION +// Simple IDL file to test portable interceptor support. +// +// = AUTHORS +// Kirthika Parameswaran <kirthika@cs.wustl.edu> +// ============================================================================ + +module Test_Interceptors +{ + exception Invalid + {}; + + interface Secure_Vault + { + // = TITLE + // A test idl for checking interceptor with the aim of + // performing benchmarks. + // + // = DESCRIPTION + // A secure vault into which one can store transaction details. + + struct Record + { + long check_num; + long amount; + }; + + short ready (); + // No args/exceptions operation. + + void authenticate (in string user) + raises (Invalid); + // throws a user exception. + + long update_records (in long id, in Record val); + // Normal operation with a return val. + + oneway void shutdown (); + // shutdown the ORB + + }; +}; diff --git a/TAO/tests/Portable_Interceptors/Benchmark/test_i.cpp b/TAO/tests/Portable_Interceptors/Benchmark/test_i.cpp new file mode 100644 index 00000000000..ae5ec11be49 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Benchmark/test_i.cpp @@ -0,0 +1,46 @@ +// $Id$ + +#include "test_i.h" +#include "marker.h" + +ACE_RCSID(Benchmark, test_i, "$Id$") + +Secure_Vault_i::Secure_Vault_i (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} +// ctor + +CORBA::Short +Secure_Vault_i::ready (CORBA::Environment &) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return 1; +} + +void +Secure_Vault_i::authenticate (const char * user, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException, + Test_Interceptors::Invalid)) +{ + if (ACE_OS::strcmp (user, "root") != 0) + ACE_THROW (Test_Interceptors::Invalid ()); + +} + +CORBA::Long +Secure_Vault_i::update_records (CORBA::Long id, + const Test_Interceptors::Secure_Vault::Record & val, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +return 1; +} + +void +Secure_Vault_i::shutdown (CORBA::Environment&) + ACE_THROW_SPEC (()) +{ + this->orb_->shutdown (); +} diff --git a/TAO/tests/Portable_Interceptors/Benchmark/test_i.h b/TAO/tests/Portable_Interceptors/Benchmark/test_i.h new file mode 100644 index 00000000000..182aca69185 --- /dev/null +++ b/TAO/tests/Portable_Interceptors/Benchmark/test_i.h @@ -0,0 +1,56 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Portable_Interceptors/Benchmark +// +// = FILENAME +// test_i.h +// +// = AUTHOR +// Nanbor Wang +// +// ============================================================================ + +#ifndef TAO_INTERCEPTOR_TEST_I_H +#define TAO_INTERCEPTOR_TEST_I_H + +#include "testS.h" + +class Secure_Vault_i : public POA_Test_Interceptors::Secure_Vault +{ + // = DESCRIPTION + // Implements the Secure_Vault interface in test.idl + +public: + Secure_Vault_i (CORBA::ORB_ptr orb); + // ctor + + virtual CORBA::Short ready (CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void authenticate (const char * user, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException, + Test_Interceptors::Invalid)); + // Passwd sent in the service context list + + virtual CORBA::Long update_records (CORBA::Long id, + const Test_Interceptors::Secure_Vault::Record & val, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void shutdown (CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + + private: + CORBA::ORB_var orb_; + // The ORB pointer (for shutdown.) +}; + +#endif /* TAO_INTERCEPTOR_TEST_I_H */ |