summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-07-31 00:01:29 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-07-31 00:01:29 +0000
commit126e4526851e26ed9f42713a1ac58e8d4411456e (patch)
treebf6a07f6b0fe3e289c9083260cb3a46fc3c1dcf0
parent230d2cfd0d008aa56ce073186081a167c0b91e7e (diff)
downloadATCD-126e4526851e26ed9f42713a1ac58e8d4411456e.tar.gz
Thread Pools getting associated with POAs...
-rw-r--r--TAO/tests/RTCORBA/Thread_Pool/client.cpp4
-rwxr-xr-xTAO/tests/RTCORBA/Thread_Pool/run_test.pl129
-rw-r--r--TAO/tests/RTCORBA/Thread_Pool/server.cpp171
-rw-r--r--TAO/tests/RTCORBA/Thread_Pool/test_i.cpp39
-rw-r--r--TAO/tests/RTCORBA/Thread_Pool/test_i.h7
5 files changed, 298 insertions, 52 deletions
diff --git a/TAO/tests/RTCORBA/Thread_Pool/client.cpp b/TAO/tests/RTCORBA/Thread_Pool/client.cpp
index fc0f2a36a7e..949270513f4 100644
--- a/TAO/tests/RTCORBA/Thread_Pool/client.cpp
+++ b/TAO/tests/RTCORBA/Thread_Pool/client.cpp
@@ -1,12 +1,12 @@
// $Id$
#include "ace/Get_Opt.h"
-#include "tao/RTCORBA/RTCORBA.h"
#include "testC.h"
+#include "tao/RTCORBA/RTCORBA.h"
ACE_RCSID(Thread_Pools, client, "$Id$")
-const char *ior = "file://ior";
+const char *ior = "file://ior_1";
int iterations = 6;
int shutdown_server = 0;
diff --git a/TAO/tests/RTCORBA/Thread_Pool/run_test.pl b/TAO/tests/RTCORBA/Thread_Pool/run_test.pl
index dccaf713c70..93e04f8d77a 100755
--- a/TAO/tests/RTCORBA/Thread_Pool/run_test.pl
+++ b/TAO/tests/RTCORBA/Thread_Pool/run_test.pl
@@ -9,47 +9,142 @@ use lib '../../../../bin';
use PerlACE::Run_Test;
$status = 0;
-$iorfile = PerlACE::LocalFile ("ior");
+$iorfile_1 = PerlACE::LocalFile ("ior_1");
+$iorfile_2 = PerlACE::LocalFile ("ior_2");
+$iorfile_3 = PerlACE::LocalFile ("ior_3");
-unlink $iorfile;
+unlink $iorfile_1;
+unlink $iorfile_2;
+unlink $iorfile_3;
$SV = new PerlACE::Process ("server");
-$CL1 = new PerlACE::Process ("client");
-$CL2 = new PerlACE::Process ("client");
-$CL3 = new PerlACE::Process ("client", "-x ");
+
+$CL1_1 = new PerlACE::Process ("client", "-k file://$iorfile_1");
+$CL1_2 = new PerlACE::Process ("client", "-k file://$iorfile_1");
+$CL1_3 = new PerlACE::Process ("client", "-k file://$iorfile_1");
+
+$CL2_1 = new PerlACE::Process ("client", "-k file://$iorfile_2");
+$CL2_2 = new PerlACE::Process ("client", "-k file://$iorfile_2");
+$CL2_3 = new PerlACE::Process ("client", "-k file://$iorfile_2");
+
+$CL3_1 = new PerlACE::Process ("client", "-k file://$iorfile_3");
+$CL3_2 = new PerlACE::Process ("client", "-k file://$iorfile_3");
+$CL3_3 = new PerlACE::Process ("client", "-k file://$iorfile_3 -x");
$SV->Spawn ();
-if (PerlACE::waitforfile_timed ($iorfile, 5) == -1) {
- print STDERR "ERROR: cannot find file <$iorfile>\n";
- $SV->Kill ();
- exit 1;
+if (PerlACE::waitforfile_timed ($iorfile_1, 5) == -1 ||
+ PerlACE::waitforfile_timed ($iorfile_2, 5) == -1 ||
+ PerlACE::waitforfile_timed ($iorfile_3, 5) == -1)
+{
+ print STDERR "ERROR: cannot find file ior files: $iorfile_1; $iorfile_2; or $iorfile_3\n";
+ goto kill_server;
+}
+
+print STDERR "\n**************************************************\n";
+print STDERR "Invoking methods on servant in default thread pool\n";
+print STDERR "**************************************************\n\n";
+
+$CL1_1->Spawn ();
+$CL1_2->Spawn ();
+$CL1_3->Spawn ();
+
+$client = $CL1_1->WaitKill (120);
+
+if ($client != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1
+}
+
+$client = $CL1_2->WaitKill (30);
+
+if ($client != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1
+}
+
+$client = $CL1_3->WaitKill (30);
+
+if ($client != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1
+}
+
+if ($status != 0)
+{
+ goto kill_server;
+}
+
+print STDERR "\n**************************************************\n";
+print STDERR "Invoking methods on servant in first RT thread pool\n";
+print STDERR "***************************************************\n\n";
+
+$CL2_1->Spawn ();
+$CL2_2->Spawn ();
+$CL2_3->Spawn ();
+
+$client = $CL2_1->WaitKill (120);
+
+if ($client != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1
+}
+
+$client = $CL2_2->WaitKill (30);
+
+if ($client != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1
+}
+
+$client = $CL2_3->WaitKill (30);
+
+if ($client != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1
}
-$CL1->Spawn ();
-$CL2->Spawn ();
-$CL3->Spawn ();
+if ($status != 0)
+{
+ goto kill_server;
+}
-$client = $CL1->WaitKill (120);
+print STDERR "\n**************************************************\n";
+print STDERR "Invoking methods on servant in second RT thread pool\n";
+print STDERR "****************************************************\n\n";
+
+$CL3_1->Spawn ();
+$CL3_2->Spawn ();
+$CL3_3->Spawn ();
+
+$client = $CL3_1->WaitKill (120);
if ($client != 0) {
print STDERR "ERROR: client returned $client\n";
$status = 1
}
-$client = $CL2->WaitKill (30);
+
+$client = $CL3_2->WaitKill (30);
if ($client != 0) {
print STDERR "ERROR: client returned $client\n";
$status = 1
}
-$client = $CL3->WaitKill (30);
+$client = $CL3_3->WaitKill (30);
if ($client != 0) {
print STDERR "ERROR: client returned $client\n";
$status = 1
}
+if ($status != 0)
+{
+ goto kill_server;
+}
+
+kill_server:
+
$server = $SV->WaitKill (5);
if ($server != 0) {
@@ -57,6 +152,8 @@ if ($server != 0) {
$status = 1
}
-unlink $iorfile;
+unlink $iorfile_1;
+unlink $iorfile_2;
+unlink $iorfile_3;
exit $status
diff --git a/TAO/tests/RTCORBA/Thread_Pool/server.cpp b/TAO/tests/RTCORBA/Thread_Pool/server.cpp
index 45daea7d972..ad882fd2a58 100644
--- a/TAO/tests/RTCORBA/Thread_Pool/server.cpp
+++ b/TAO/tests/RTCORBA/Thread_Pool/server.cpp
@@ -3,13 +3,13 @@
#include "test_i.h"
#include "ace/Get_Opt.h"
#include "tao/RTCORBA/RTCORBA.h"
-#include "tao/RTPortableServer/RTPortableServer.h"
ACE_RCSID(Thread_Pools, server, "$Id$")
const char *ior_output_file = "ior";
-CORBA::ULong static_threads = 2;
-CORBA::ULong dynamic_threads = 2;
+int ior_count = 1;
+CORBA::ULong static_threads = 3;
+CORBA::ULong dynamic_threads = 3;
long nap_time = 1000;
int
@@ -55,6 +55,100 @@ parse_args (int argc, char *argv[])
}
int
+write_ior_to_file (CORBA::ORB_ptr orb,
+ test_ptr test,
+ CORBA_Environment &ACE_TRY_ENV)
+{
+ CORBA::String_var ior =
+ orb->object_to_string (test,
+ ACE_TRY_ENV);
+ ACE_CHECK;
+
+ char filename[BUFSIZ];
+ ACE_OS::sprintf (filename,
+ "%s_%d",
+ ior_output_file,
+ ior_count++);
+
+ FILE *output_file =
+ ACE_OS::fopen (filename,
+ "w");
+
+ if (output_file == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot open output file for writing IOR: %s",
+ filename),
+ -1);
+
+ ACE_OS::fprintf (output_file,
+ "%s",
+ ior.in ());
+
+ ACE_OS::fclose (output_file);
+
+ return 0;
+}
+
+int
+create_POA_and_register_servant (CORBA::Policy_ptr threadpool_policy,
+ const char *poa_name,
+ PortableServer::POAManager_ptr poa_manager,
+ PortableServer::POA_ptr root_poa,
+ CORBA::ORB_ptr orb,
+ CORBA_Environment &ACE_TRY_ENV)
+{
+ // Policies for the firstPOA to be created.
+ CORBA::PolicyList policies (2); policies.length (2);
+
+ // Implicit_activation policy.
+ policies[0] =
+ root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION,
+ ACE_TRY_ENV);
+ ACE_CHECK;
+
+ // Thread pool policy.
+ policies[1] =
+ CORBA::Policy::_duplicate (threadpool_policy);
+
+ // Create the POA under the RootPOA.
+ PortableServer::POA_var poa =
+ root_poa->create_POA (poa_name,
+ poa_manager,
+ policies,
+ ACE_TRY_ENV);
+ ACE_CHECK;
+
+ // Creation of POAs is over. Destroy the Policy objects.
+ for (CORBA::ULong i = 0;
+ i < policies.length ();
+ ++i)
+ {
+ policies[i]->destroy (ACE_TRY_ENV);
+ ACE_CHECK;
+ }
+
+ test_i *servant =
+ new test_i (orb,
+ poa.in (),
+ nap_time);
+
+ PortableServer::ServantBase_var safe_servant (servant);
+ ACE_UNUSED_ARG (safe_servant);
+
+ test_var test =
+ servant->_this (ACE_TRY_ENV);
+ ACE_CHECK;
+
+ int result =
+ write_ior_to_file (orb,
+ test.in (),
+ ACE_TRY_ENV);
+ ACE_CHECK;
+
+ return result;
+}
+
+int
main (int argc, char *argv[])
{
ACE_TRY_NEW_ENV
@@ -86,31 +180,20 @@ main (int argc, char *argv[])
return result;
test_i servant (orb.in (),
+ root_poa.in (),
nap_time);
test_var test =
servant._this (ACE_TRY_ENV);
ACE_TRY_CHECK;
- CORBA::String_var ior =
- orb->object_to_string (test.in (),
- ACE_TRY_ENV);
+ result =
+ write_ior_to_file (orb.in (),
+ test.in (),
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
- 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);
+ if (result != 0)
+ return result;
poa_manager->activate (ACE_TRY_ENV);
ACE_TRY_CHECK;
@@ -132,7 +215,7 @@ main (int argc, char *argv[])
ACE_TRY_ENV);
ACE_TRY_CHECK;
- RTCORBA::ThreadpoolId id1 =
+ RTCORBA::ThreadpoolId threadpool_id_1 =
rt_orb->create_threadpool (stacksize,
static_threads,
dynamic_threads,
@@ -142,17 +225,25 @@ main (int argc, char *argv[])
max_request_buffer_size,
ACE_TRY_ENV);
ACE_TRY_CHECK;
- ACE_UNUSED_ARG (id1);
+
+ CORBA::Policy_var threadpool_policy_1 =
+ rt_orb->create_threadpool_policy (threadpool_id_1,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
CORBA::Boolean allow_borrowing = 0;
- RTCORBA::ThreadpoolLanes lanes;
- lanes.length (1);
+ RTCORBA::ThreadpoolLanes lanes (2);
+ lanes.length (2);
lanes[0].lane_priority = default_priority;
lanes[0].static_threads = static_threads;
lanes[0].dynamic_threads = dynamic_threads;
- RTCORBA::ThreadpoolId id2 =
+ lanes[1].lane_priority = default_priority;
+ lanes[1].static_threads = static_threads * 2;
+ lanes[1].dynamic_threads = dynamic_threads * 2;
+
+ RTCORBA::ThreadpoolId threadpool_id_2 =
rt_orb->create_threadpool_with_lanes (stacksize,
lanes,
allow_borrowing,
@@ -161,7 +252,33 @@ main (int argc, char *argv[])
max_request_buffer_size,
ACE_TRY_ENV);
ACE_TRY_CHECK;
- ACE_UNUSED_ARG (id2);
+
+ CORBA::Policy_var threadpool_policy_2 =
+ rt_orb->create_threadpool_policy (threadpool_id_2,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ result =
+ create_POA_and_register_servant (threadpool_policy_1,
+ "first_poa",
+ poa_manager.in (),
+ root_poa.in (),
+ orb.in (),
+ ACE_TRY_ENV)
+ ACE_TRY_CHECK;
+ if (result != 0)
+ return result;
+
+ result =
+ create_POA_and_register_servant (threadpool_policy_2,
+ "second_poa",
+ poa_manager.in (),
+ root_poa.in (),
+ orb.in (),
+ ACE_TRY_ENV)
+ ACE_TRY_CHECK;
+ if (result != 0)
+ return result;
orb->run (ACE_TRY_ENV);
ACE_TRY_CHECK;
diff --git a/TAO/tests/RTCORBA/Thread_Pool/test_i.cpp b/TAO/tests/RTCORBA/Thread_Pool/test_i.cpp
index d058a8f6360..008edd1c767 100644
--- a/TAO/tests/RTCORBA/Thread_Pool/test_i.cpp
+++ b/TAO/tests/RTCORBA/Thread_Pool/test_i.cpp
@@ -1,13 +1,16 @@
// $Id$
#include "test_i.h"
-#include "tao/debug.h"
+#include "tao/ORB_Core.h"
+#include "tao/RTCORBA/Thread_Pool.h"
ACE_RCSID(Thread_Pools, test_i, "$Id$")
test_i::test_i (CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
long msec_sleep)
: orb_ (CORBA::ORB::_duplicate (orb)),
+ poa_ (PortableServer::POA::_duplicate (poa)),
nap_time_ ()
{
this->nap_time_.msec (msec_sleep);
@@ -16,19 +19,41 @@ test_i::test_i (CORBA::ORB_ptr orb,
CORBA::Long
test_i::method (CORBA::Long client_id,
CORBA::Long iteration,
- CORBA::Environment &)
+ CORBA::Environment &ACE_TRY_ENV)
ACE_THROW_SPEC ((CORBA::SystemException))
{
- // if (TAO_debug_level > 0)
- ACE_DEBUG ((LM_DEBUG,
- "Request in thread %t for client %d iteration %d\n",
- client_id,
- iteration));
+ // Get the ORB_Core's TSS resources.
+ TAO_ORB_Core_TSS_Resources *tss =
+ this->orb_->orb_core ()->get_tss_resources ();
+
+ /// Get the lane attribute in TSS.
+ TAO_Thread_Lane *lane =
+ (TAO_Thread_Lane *) tss->lane_;
+
+ if (lane)
+ ACE_DEBUG ((LM_DEBUG,
+ "Request in thread %t (pool id = %d; lane id = %d) for client %d iteration %d\n",
+ lane->pool ().id (),
+ lane->id (),
+ client_id,
+ iteration));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ "Request in thread %t (default pool id) for client %d iteration %d\n",
+ client_id,
+ iteration));
ACE_OS::sleep (this->nap_time_);
+
return iteration;
}
+PortableServer::POA_ptr
+test_i::_default_POA (CORBA_Environment &ACE_TRY_ENV)
+{
+ return PortableServer::POA::_duplicate (this->poa_.in ());
+}
+
void
test_i::shutdown (CORBA::Environment& ACE_TRY_ENV)
ACE_THROW_SPEC ((CORBA::SystemException))
diff --git a/TAO/tests/RTCORBA/Thread_Pool/test_i.h b/TAO/tests/RTCORBA/Thread_Pool/test_i.h
index 22810f419f4..cbf1bca61c2 100644
--- a/TAO/tests/RTCORBA/Thread_Pool/test_i.h
+++ b/TAO/tests/RTCORBA/Thread_Pool/test_i.h
@@ -15,6 +15,7 @@ class test_i : public POA_test
public:
/// Constructor.
test_i (CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
long msec_sleep);
/// Test method.
@@ -27,10 +28,16 @@ public:
void shutdown (CORBA::Environment&)
ACE_THROW_SPEC ((CORBA::SystemException));
+ /// Our POA.
+ PortableServer::POA_ptr _default_POA (CORBA_Environment &ACE_TRY_ENV);
+
private:
/// ORB.
CORBA::ORB_var orb_;
+ /// Our POA.
+ PortableServer::POA_var poa_;
+
/// Time spent in executing the upcall.
ACE_Time_Value nap_time_;
};