summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-08-11 04:58:02 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-08-11 04:58:02 +0000
commitca2d0e4039fa5f3ff74f24e5b5af233aa7662d31 (patch)
tree2bfcc06b147af620e7ff3b9987336d72a2495f18
parent33544f48146519ae133c92af2e225bcfa404e765 (diff)
downloadATCD-ca2d0e4039fa5f3ff74f24e5b5af233aa7662d31.tar.gz
Updated the Banded Connections test to work with RT thread pools.
-rw-r--r--TAO/tests/RTCORBA/Banded_Connections/client.cpp200
-rwxr-xr-xTAO/tests/RTCORBA/Banded_Connections/run_test.pl32
-rw-r--r--TAO/tests/RTCORBA/Banded_Connections/server.cpp366
-rw-r--r--TAO/tests/RTCORBA/Banded_Connections/test.idl9
4 files changed, 277 insertions, 330 deletions
diff --git a/TAO/tests/RTCORBA/Banded_Connections/client.cpp b/TAO/tests/RTCORBA/Banded_Connections/client.cpp
index a23e257a1f7..4561eb961c5 100644
--- a/TAO/tests/RTCORBA/Banded_Connections/client.cpp
+++ b/TAO/tests/RTCORBA/Banded_Connections/client.cpp
@@ -7,15 +7,12 @@
const char *ior1 = "file://test1.ior";
const char *ior2 = "file://test2.ior";
-CORBA::Short client_priority1 = -1;
-CORBA::Short client_priority2 = -1;
-CORBA::Short client_priority3 = -1;
int
parse_args (int argc, char *argv[])
{
- ACE_Get_Opt get_opts (argc, argv, "n:o:a:b:c:");
- int c, result;
+ ACE_Get_Opt get_opts (argc, argv, "n:o:");
+ int c;
while ((c = get_opts ()) != -1)
switch (c)
@@ -26,35 +23,6 @@ parse_args (int argc, char *argv[])
case 'o':
ior2 = get_opts.optarg;
break;
- case 'a':
- result = ::sscanf (get_opts.optarg,
- "%hd",
- &client_priority1);
- if (result == 0 || result == EOF)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to process <-a> option"),
- -1);
- break;
-
- case 'b':
- result = ::sscanf (get_opts.optarg,
- "%hd",
- &client_priority2);
- if (result == 0 || result == EOF)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to process <-b> option"),
- -1);
- break;
-
- case 'c':
- result = ::sscanf (get_opts.optarg,
- "%hd",
- &client_priority3);
- if (result == 0 || result == EOF)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to process <-c> option"),
- -1);
- break;
case '?':
default:
@@ -62,35 +30,12 @@ parse_args (int argc, char *argv[])
"usage: %s "
"-n <ior> "
"-o <ior> "
- "-a <client_priority1>"
- "-b <client_priority2>"
- "-c <client_priority3>"
"\n",
argv [0]),
-1);
}
- if (client_priority1 < 0
- || client_priority2 < 0
- || client_priority3 < 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Valid client priorities must be"
- " specified.\nSee README file for more info\n"),
- -1);
-
- return 0;
-}
-
-int
-check_for_nil (CORBA::Object_ptr obj, const char *msg)
-{
- if (CORBA::is_nil (obj))
- ACE_ERROR_RETURN ((LM_ERROR,
- "ERROR: Object reference <%s> is nil\n",
- msg),
- -1);
- else
- return 0;
+ return 0;
}
CORBA::Short
@@ -106,9 +51,6 @@ get_server_priority (Test_ptr server,
RTCORBA::PriorityModelPolicy::_narrow (policy.in (), ACE_TRY_ENV);
ACE_CHECK_RETURN (-1);
- if (check_for_nil (priority_policy.in (), "PriorityModelPolicy") == -1)
- return -1;
-
RTCORBA::PriorityModel priority_model =
priority_policy->priority_model (ACE_TRY_ENV);
ACE_CHECK_RETURN (-1);
@@ -128,11 +70,12 @@ invocation_exception_test (Test_ptr obj,
{
ACE_TRY
{
- obj->test_method (priority,
+ obj->test_method (1,
+ priority,
ACE_TRY_ENV);
ACE_TRY_CHECK;
- ACE_DEBUG ((LM_DEBUG, "Test Succeeded: no exception caught\n"));
+ ACE_DEBUG ((LM_DEBUG, "ERROR: no exception caught\n"));
}
ACE_CATCH (CORBA::INV_POLICY, ex)
{
@@ -141,7 +84,7 @@ invocation_exception_test (Test_ptr obj,
}
ACE_CATCHANY
{
- ACE_DEBUG ((LM_DEBUG, "Test failed: unexpected exception caught\n"));
+ ACE_DEBUG ((LM_DEBUG, "Error: unexpected exception caught\n"));
ACE_RE_THROW;
}
ACE_ENDTRY;
@@ -168,70 +111,66 @@ main (int argc, char *argv[])
return 0;
}
- // Initialize the ORB, resolve references and parse arguments.
-
- // ORB.
CORBA::ORB_var orb =
- CORBA::ORB_init (argc, argv, "", ACE_TRY_ENV);
+ CORBA::ORB_init (argc,
+ argv,
+ "",
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
// Parse arguments.
- if (parse_args (argc, argv) != 0)
- return 1;
+ int result =
+ parse_args (argc,
+ argv);
+ if (result != 0)
+ return result;
// RTORB.
CORBA::Object_var object =
- orb->resolve_initial_references ("RTORB", ACE_TRY_ENV);
+ orb->resolve_initial_references ("RTORB",
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
+
RTCORBA::RTORB_var rt_orb =
RTCORBA::RTORB::_narrow (object.in (),
ACE_TRY_ENV);
ACE_TRY_CHECK;
- if (check_for_nil (rt_orb.in (), "RTORB") == -1)
- return 1;
// RTCurrent.
object =
- orb->resolve_initial_references ("RTCurrent", ACE_TRY_ENV);
+ orb->resolve_initial_references ("RTCurrent",
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
+
RTCORBA::Current_var current =
- RTCORBA::Current::_narrow (object.in (), ACE_TRY_ENV);
+ RTCORBA::Current::_narrow (object.in (),
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
// Test object 1 (with CLIENT_PROPAGATED priority model).
object =
- orb->string_to_object (ior1, ACE_TRY_ENV);
+ orb->string_to_object (ior1,
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
Test_var client_propagated_obj =
Test::_narrow (object.in (), ACE_TRY_ENV);
ACE_TRY_CHECK;
- if (check_for_nil (client_propagated_obj.in (),
- "client_propagated_obj")
- == -1)
- return 1;
// Test object 2 (with SERVER_DECLARED priority model).
- object = orb->string_to_object (ior2, ACE_TRY_ENV);
+ object = orb->string_to_object (ior2,
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
Test_var server_declared_obj =
Test::_narrow (object.in (), ACE_TRY_ENV);
ACE_TRY_CHECK;
- if (check_for_nil (server_declared_obj.in (),
- "server_declared_obj")
- == -1)
- return 1;
- // Set client thread's priority.
- current->the_priority (client_priority1, ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- // Test 4: Attempt to set priority bands that do not match
- // server resource configuration on the <client_propagated_obj>.
+ // Test: Attempt to set priority bands that do not match server
+ // resource configuration on the <client_propagated_obj>.
// Should get INV_POLICY exception.
ACE_DEBUG ((LM_DEBUG,
- "\n Test 4\n"));
+ "\n<---Test--->: Client bands do not match server lanes\n\n"));
RTCORBA::PriorityBands false_bands;
false_bands.length (2);
@@ -242,9 +181,8 @@ main (int argc, char *argv[])
CORBA::PolicyList policies;
policies.length (1);
policies[0] =
- rt_orb->create_priority_banded_connection_policy
- (false_bands,
- ACE_TRY_ENV);
+ rt_orb->create_priority_banded_connection_policy (false_bands,
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
object =
@@ -256,24 +194,24 @@ main (int argc, char *argv[])
client_propagated_obj =
Test::_narrow (object.in (), ACE_TRY_ENV);
ACE_TRY_CHECK;
- if (check_for_nil (client_propagated_obj.in (),
- "client_propagated_obj")
- == -1)
- return 1;
invocation_exception_test (client_propagated_obj.in (),
- client_priority1,
+ 0,
ACE_TRY_ENV);
ACE_TRY_CHECK;
// Now set the priority bands that match server resource
// configuration on the <client_propagated_obj>.
- CORBA::Policy_var policy =
+ policies[0] =
server_declared_obj->_get_policy (RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE,
ACE_TRY_ENV);
ACE_TRY_CHECK;
- policies[0] = policy;
+ RTCORBA::PriorityBandedConnectionPolicy_var bands_policy =
+ RTCORBA::PriorityBandedConnectionPolicy::_narrow (policies[0]);
+
+ RTCORBA::PriorityBands_var bands =
+ bands_policy->priority_bands ();
object =
client_propagated_obj->_set_policy_overrides (policies,
@@ -284,52 +222,58 @@ main (int argc, char *argv[])
client_propagated_obj =
Test::_narrow (object.in (), ACE_TRY_ENV);
ACE_TRY_CHECK;
- if (check_for_nil (client_propagated_obj.in (),
- "client_propagated_obj")
- == -1)
- return 1;
- // Test 5: Make invocations on the <client_propagated_obj>,
- // changing the priority of the invoking thread.
+ // Test: Attempt invocation on <client_propagated_obj> with
+ // client thread priority not matching any of the bands. Should
+ // get INV_POLICY exception.
ACE_DEBUG ((LM_DEBUG,
- "\n Test 5\n"));
+ "\n<---Test--->: Client threads does not match band\n\n"));
- client_propagated_obj->test_method (client_priority1,
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- current->the_priority (client_priority2, ACE_TRY_ENV);
+ CORBA::Short client_priority =
+ bands[bands->length () - 1].high + 1;
+ current->the_priority (client_priority,
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
- client_propagated_obj->test_method (client_priority2,
- ACE_TRY_ENV);
+ invocation_exception_test (client_propagated_obj.in (),
+ client_priority,
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
- // Test 6: Attempt invocation on <client_propagated_obj> with
- // client thread priority not matching any of the bands. Should
- // get INV_POLICY exception.
+ // Test: Make invocations on the <client_propagated_obj>.
ACE_DEBUG ((LM_DEBUG,
- "\n Test 6\n"));
+ "\n<---Test--->: Invoking on client propagated object\n\n"));
- current->the_priority (client_priority3, ACE_TRY_ENV);
- ACE_TRY_CHECK;
+ for (CORBA::ULong i = 0;
+ i < bands->length ();
+ ++i)
+ {
+ CORBA::Short client_priority =
+ (bands[i].low + bands[i].high) / 2;
- invocation_exception_test (client_propagated_obj.in (),
- client_priority3,
+ // Set client thread's priority.
+ current->the_priority (client_priority,
ACE_TRY_ENV);
- ACE_TRY_CHECK;
+ ACE_TRY_CHECK;
+
+ client_propagated_obj->test_method (1,
+ client_priority,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ }
- // Test 7: Attempt invocation with the same thread priority, but
+ // Test: Attempt invocation with the same thread priority, but
// now on the <server_declared_obj>. This should succeed.
ACE_DEBUG ((LM_DEBUG,
- "\n Test 7\n"));
+ "\n<---Test--->: Invoking on server declared object\n\n"));
CORBA::Short server_priority =
get_server_priority (server_declared_obj.in (),
ACE_TRY_ENV);
ACE_TRY_CHECK;
- server_declared_obj->test_method (server_priority,
+ server_declared_obj->test_method (0,
+ server_priority,
ACE_TRY_ENV);
ACE_TRY_CHECK;
diff --git a/TAO/tests/RTCORBA/Banded_Connections/run_test.pl b/TAO/tests/RTCORBA/Banded_Connections/run_test.pl
index fd4b8fc5c2c..6d033aa45db 100755
--- a/TAO/tests/RTCORBA/Banded_Connections/run_test.pl
+++ b/TAO/tests/RTCORBA/Banded_Connections/run_test.pl
@@ -12,49 +12,25 @@ $status = 0;
$iorfile1 = PerlACE::LocalFile ("test1.ior");
$iorfile2 = PerlACE::LocalFile ("test2.ior");
-$server_conf = PerlACE::LocalFile ("server.conf");
unlink $iorfile1;
unlink $iorfile2;
-print STDERR "\n********** RTCORBA Priority Banded Connections Unit Test\n";
-
-
-# CORBA priorities 37, 45 and 50, etc. are for the SCHED_OTHER class on
-# Solaris. May need to use different values for other platforms
-# depending on their native priorities scheme, i.e., based on the
-# available range.
-
$server_args =
- "-n $iorfile1 -o $iorfile2 -b bands.unix -ORBSvcConf $server_conf "
- ."-p 37 -w 51 ";
-
-$client_args =
- "-n file://$iorfile1 -o file://$iorfile2 "
- ."-a 37 -b 45 -c 56";
+ "-b bands.unix";
if ($^O eq "MSWin32") {
$server_args =
- "-n $iorfile1 -o $iorfile2 -b bands.nt -ORBSvcConf $server_conf "
- ."-p 1 -w 7 ";
-
- $client_args =
- "-n file://$iorfile1 -o file://$iorfile2 "
- ."-a 1 -b 4 -c 6 ";
+ "-b bands.nt";
}
if ($^O eq "dec_osf") {
$server_args =
- "-n $iorfile1 -o $iorfile2 -b bands.tru64 -ORBSvcConf $server_conf "
- ."-p 20 -w 34 ";
-
- $client_args =
- "-n file://$iorfile1 -o file://$iorfile2 "
- ."-a 23 -b 28 -c 34 ";
+ "-b bands.tru64";
}
$SV = new PerlACE::Process ("server", $server_args);
-$CL = new PerlACE::Process ("client", $client_args);
+$CL = new PerlACE::Process ("client");
$SV->Spawn ();
diff --git a/TAO/tests/RTCORBA/Banded_Connections/server.cpp b/TAO/tests/RTCORBA/Banded_Connections/server.cpp
index 3776d44cdce..625e327a0e9 100644
--- a/TAO/tests/RTCORBA/Banded_Connections/server.cpp
+++ b/TAO/tests/RTCORBA/Banded_Connections/server.cpp
@@ -6,19 +6,15 @@
#include "tao/RTCORBA/RTCORBA.h"
#include "tao/RTPortableServer/RTPortableServer.h"
-#include "tao/Strategies/advanced_resource.h"
-
class Test_i : public POA_Test
{
- // = TITLE
- // An implementation for the Test interface in test.idl
- //
public:
Test_i (CORBA::ORB_ptr orb,
- RTCORBA::PriorityBands &bands);
- // ctor
+ RTCORBA::PriorityBands &bands,
+ CORBA::Environment &ACE_TRY_ENV);
- void test_method (CORBA::Short priority,
+ void test_method (CORBA::Boolean client_propagated,
+ CORBA::Short priority,
CORBA::Environment&)
ACE_THROW_SPEC ((CORBA::SystemException));
@@ -27,77 +23,100 @@ public:
private:
CORBA::ORB_var orb_;
- // The ORB
RTCORBA::PriorityBands &bands_;
- // Priority bands.
+ RTCORBA::Current_var rt_current_;
};
Test_i::Test_i (CORBA::ORB_ptr orb,
- RTCORBA::PriorityBands & bands)
+ RTCORBA::PriorityBands &bands,
+ CORBA::Environment &ACE_TRY_ENV)
: orb_ (CORBA::ORB::_duplicate (orb)),
- bands_ (bands)
-{
-}
-
-void
-Test_i::test_method (CORBA::Short priority,
- CORBA::Environment& ACE_TRY_ENV)
- ACE_THROW_SPEC ((CORBA::SystemException))
+ bands_ (bands),
+ rt_current_ ()
{
- // Use RTCurrent to find out the CORBA priority of the current
- // thread.
-
+ // We resolve and store the current for later use.
CORBA::Object_var obj =
- this->orb_->resolve_initial_references ("RTCurrent", ACE_TRY_ENV);
+ this->orb_->resolve_initial_references ("RTCurrent",
+ ACE_TRY_ENV);
ACE_CHECK;
- RTCORBA::Current_var current =
- RTCORBA::Current::_narrow (obj.in (), ACE_TRY_ENV);
+ this->rt_current_ =
+ RTCORBA::Current::_narrow (obj.in (),
+ ACE_TRY_ENV);
ACE_CHECK;
+}
- if (CORBA::is_nil (obj.in ()))
- ACE_THROW (CORBA::INTERNAL ());
-
- CORBA::Short servant_thread_priority =
- current->the_priority (ACE_TRY_ENV);
+void
+Test_i::test_method (CORBA::Boolean client_propagated,
+ CORBA::Short client_priority,
+ CORBA::Environment &ACE_TRY_ENV)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ CORBA::Short server_priority =
+ this->rt_current_->the_priority (ACE_TRY_ENV);
ACE_CHECK;
- // Print out the info.
- int index = -1;
- ACE_DEBUG ((LM_DEBUG,
- "\nObject bands: \n"));
- for (CORBA::ULong i = 0; i < this->bands_.length (); ++i)
+ // Check which policy we are dealing with.
+ if (!client_propagated)
{
+ // In this case, the client priority is simply the default
+ // priority associated with the priority propagation policy.
+ // Since we activated this servant using the default POA
+ // priority, the client priority should match what priority we
+ // get run at.
+ ACE_ASSERT (server_priority == client_priority);
+
ACE_DEBUG ((LM_DEBUG,
- "%d) %d %d\n",
- (i + 1), this->bands_[i].low, this->bands_[i].high));
-
- if (priority <= this->bands_[i].high
- && priority >= this->bands_[i].low
- && servant_thread_priority <= this->bands_[i].high
- && servant_thread_priority >= this->bands_[i].low)
- index = i + 1;
+ "Using SERVER_DECLARED policy: request processed at priority %d\n",
+ server_priority));
}
-
- ACE_DEBUG ((LM_DEBUG,
- "Object priority: %d "
- "Servant thread priority: %d\n",
- priority, servant_thread_priority));
-
- if (index == -1)
- ACE_DEBUG ((LM_DEBUG,
- "ERROR: object and thread priorities do not"
- "match the same band.\n"));
else
- ACE_DEBUG ((LM_DEBUG,
- "Band %d was used for this invocation\n", index));
+ {
+ // If we are using the CLIENT_DECLARED policy, then the bands
+ // and the client priority matters.
+ //
+ // Print out the bands.
+ int index = -1;
+ ACE_DEBUG ((LM_DEBUG,
+ "\nPriority Bands: \n"));
+ for (CORBA::ULong i = 0; i < this->bands_.length (); ++i)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "%d) %d %d\n",
+ (i + 1),
+ this->bands_[i].low,
+ this->bands_[i].high));
+
+ if (client_priority <= this->bands_[i].high &&
+ client_priority >= this->bands_[i].low &&
+ server_priority <= this->bands_[i].high &&
+ server_priority >= this->bands_[i].low)
+ index = i + 1;
+ }
+
+ ACE_DEBUG ((LM_DEBUG,
+ "Client priority: %d "
+ "Server processing request at priority: %d\n",
+ client_priority,
+ server_priority));
+
+ if (index == -1)
+ ACE_DEBUG ((LM_DEBUG,
+ "ERROR: object and thread priorities do not"
+ "match the same band.\n"));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ "Band %d was used for this invocation\n", index));
+ }
}
void
Test_i::shutdown (CORBA::Environment& ACE_TRY_ENV)
ACE_THROW_SPEC ((CORBA::SystemException))
{
- this->orb_->shutdown (0, ACE_TRY_ENV);
+ this->orb_->shutdown (0,
+ ACE_TRY_ENV);
+ ACE_CHECK;
}
//*************************************************************************
@@ -105,15 +124,13 @@ Test_i::shutdown (CORBA::Environment& ACE_TRY_ENV)
const char *bands_file = "bands";
const char *ior_output_file1 = "test1.ior";
const char *ior_output_file2 = "test2.ior";
-CORBA::Short poa_priority = -1;
-CORBA::Short wrong_priority = -1;
// Parse command-line arguments.
int
parse_args (int argc, char *argv[])
{
- ACE_Get_Opt get_opts (argc, argv, "p:w:b:o:n:");
- int c, result;
+ ACE_Get_Opt get_opts (argc, argv, "b:o:n:");
+ int c;
while ((c = get_opts ()) != -1)
switch (c)
@@ -130,26 +147,6 @@ parse_args (int argc, char *argv[])
bands_file = get_opts.optarg;
break;
- case 'p':
- result = ::sscanf (get_opts.optarg,
- "%hd",
- &poa_priority);
- if (result == 0 || result == EOF)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to process <-a> option"),
- -1);
- break;
-
- case 'w':
- result = ::sscanf (get_opts.optarg,
- "%hd",
- &wrong_priority);
- if (result == 0 || result == EOF)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to process <-c> option"),
- -1);
- break;
-
case '?':
default:
ACE_ERROR_RETURN ((LM_ERROR,
@@ -157,38 +154,33 @@ parse_args (int argc, char *argv[])
"-n <iorfile1> "
"-o <iorfile2> "
"-b <bands_file> "
- "-p <poa_priority> "
- "-w <wrong_priority> "
"\n",
argv [0]),
-1);
}
- if (poa_priority < 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Valid poa priority must be"
- " specified.\nSee README file for more info\n"),
- -1);
-
return 0;
}
int
get_priority_bands (RTCORBA::PriorityBands &bands)
{
- FILE* file = ACE_OS::fopen (bands_file, "r");
+ FILE* file =
+ ACE_OS::fopen (bands_file, "r");
if (file == 0)
return -1;
ACE_Read_Buffer reader (file, 1);
- char* string = reader.read (EOF, ' ', '\0');
+ char *string =
+ reader.read (EOF, ' ', '\0');
if (string == 0)
return -1;
- CORBA::ULong bands_length = (reader.replaced () + 1) / 2;
+ CORBA::ULong bands_length =
+ (reader.replaced () + 1) / 2;
bands.length (bands_length);
int result = 1;
@@ -229,18 +221,6 @@ get_priority_bands (RTCORBA::PriorityBands &bands)
}
int
-check_for_nil (CORBA::Object_ptr obj, const char *msg)
-{
- if (CORBA::is_nil (obj))
- ACE_ERROR_RETURN ((LM_ERROR,
- "ERROR: Object reference <%s> is nil\n",
- msg),
- -1);
- else
- return 0;
-}
-
-int
create_object (PortableServer::POA_ptr poa,
CORBA::ORB_ptr orb,
Test_i *server_impl,
@@ -249,31 +229,34 @@ create_object (PortableServer::POA_ptr poa,
{
// Register with poa.
PortableServer::ObjectId_var id;
-
- id = poa->activate_object (server_impl, ACE_TRY_ENV);
+ id = poa->activate_object (server_impl,
+ ACE_TRY_ENV);
ACE_CHECK_RETURN (-1);
CORBA::Object_var server =
- poa->id_to_reference (id.in (), ACE_TRY_ENV);
+ poa->id_to_reference (id.in (),
+ ACE_TRY_ENV);
ACE_CHECK_RETURN (-1);
// Print out the IOR.
CORBA::String_var ior =
- orb->object_to_string (server.in (), ACE_TRY_ENV);
+ orb->object_to_string (server.in (),
+ ACE_TRY_ENV);
ACE_CHECK_RETURN (-1);
- ACE_DEBUG ((LM_DEBUG, "<%s>\n\n", ior.in ()));
-
// Print ior to the file.
if (filename != 0)
{
- FILE *output_file= ACE_OS::fopen (filename, "w");
+ 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::fprintf (output_file,
+ "%s",
+ ior.in ());
ACE_OS::fclose (output_file);
}
@@ -351,37 +334,39 @@ main (int argc, char *argv[])
{
ACE_TRY_NEW_ENV
{
- // ORB.
CORBA::ORB_var orb =
- CORBA::ORB_init (argc, argv, "", ACE_TRY_ENV);
+ CORBA::ORB_init (argc,
+ argv,
+ "",
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
- // Parse arguments.
- if (parse_args (argc, argv) != 0)
- return 1;
+ int result =
+ parse_args (argc,
+ argv);
+ if (result != 0)
+ return result;
- // RTORB.
CORBA::Object_var object =
- orb->resolve_initial_references ("RTORB", ACE_TRY_ENV);
+ orb->resolve_initial_references ("RTORB",
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
+
RTCORBA::RTORB_var rt_orb =
RTCORBA::RTORB::_narrow (object.in (),
ACE_TRY_ENV);
ACE_TRY_CHECK;
- if (check_for_nil (rt_orb.in (), "RTORB") == -1)
- return 1;
// RootPOA.
object =
- orb->resolve_initial_references("RootPOA", ACE_TRY_ENV);
+ orb->resolve_initial_references ("RootPOA",
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
+
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (object.in (), ACE_TRY_ENV);
ACE_TRY_CHECK;
- if (check_for_nil (root_poa.in (), "RootPOA") == -1)
- return 1;
- // POAManager.
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager (ACE_TRY_ENV);
ACE_TRY_CHECK;
@@ -389,35 +374,63 @@ main (int argc, char *argv[])
// Obtain priority bands to be used in this test from the file
// specified by the user.
RTCORBA::PriorityBands bands;
- if (get_priority_bands (bands) == -1)
+ result = get_priority_bands (bands);
+ if (result != 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Error reading priority bands from file\n"),
- 1);
-
- // Servant.
- Test_i server_impl (orb.in (), bands);
- Test_i server_impl2 (orb.in (), bands);
+ result);
+
+ CORBA::ULong stacksize = 0;
+ CORBA::Boolean allow_request_buffering = 0;
+ CORBA::ULong max_buffered_requests = 0;
+ CORBA::ULong max_request_buffer_size = 0;
+ CORBA::Boolean allow_borrowing = 0;
+ CORBA::ULong static_threads = 1;
+ CORBA::ULong dynamic_threads = 0;
+
+ RTCORBA::ThreadpoolLanes lanes;
+ lanes.length (bands.length ());
+
+ for (CORBA::ULong i = 0;
+ i < bands.length ();
+ ++i)
+ {
+ lanes[i].lane_priority =
+ (bands[i].low + bands[i].high) / 2;
+ lanes[i].static_threads = static_threads;
+ lanes[i].dynamic_threads = dynamic_threads;
+ }
- CORBA::PolicyList poa_policy_list;
- poa_policy_list.length (1);
+ RTCORBA::ThreadpoolId threadpool_id =
+ rt_orb->create_threadpool_with_lanes (stacksize,
+ lanes,
+ allow_borrowing,
+ allow_request_buffering,
+ max_buffered_requests,
+ max_request_buffer_size,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
- // Test 2: Attempt to create a POA with priority bands that do
- // not match the resources (i.e., endpoints/lanes). Should get
- // POA::InvalidPolicy exception.
+ // Test: Attempt to create a POA with priority bands that do not
+ // match the lanes. Should get POA::InvalidPolicy exception.
ACE_DEBUG ((LM_DEBUG,
- "\n Test 2\n"));
+ "\n<---Test--->: Bands do not match lanes\n\n"));
- RTCORBA::PriorityBands false_bands;
- false_bands.length (2);
+ RTCORBA::PriorityBands false_bands (bands);
false_bands[0].low = 10000;
false_bands[0].high = 10005;
- false_bands[1].low = 26;
- false_bands[1].high = 30;
+
+ CORBA::PolicyList poa_policy_list;
+ poa_policy_list.length (2);
poa_policy_list[0] =
- rt_orb->create_priority_banded_connection_policy
- (false_bands,
- ACE_TRY_ENV);
+ rt_orb->create_priority_banded_connection_policy (false_bands,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ poa_policy_list[1] =
+ rt_orb->create_threadpool_policy (threadpool_id,
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
poa_creation_exception_test (root_poa.in (),
@@ -426,13 +439,21 @@ main (int argc, char *argv[])
ACE_TRY_ENV);
ACE_TRY_CHECK;
- // Create POA with CLIENT_PROPAGATED priority model, no bands.
+ // Create POA with CLIENT_PROPAGATED priority model, with lanes
+ // but no bands.
+ poa_policy_list.length (2);
+
poa_policy_list[0] =
rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED,
0,
ACE_TRY_ENV);
ACE_TRY_CHECK;
+ poa_policy_list[1] =
+ rt_orb->create_threadpool_policy (threadpool_id,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
PortableServer::POA_var client_propagated_poa =
root_poa->create_POA ("client_propagated_poa",
poa_manager.in (),
@@ -440,8 +461,12 @@ main (int argc, char *argv[])
ACE_TRY_ENV);
ACE_TRY_CHECK;
- // Create POA with SERVER_DECLARED priority model, with bands.
- poa_policy_list.length (2);
+ // Create POA with SERVER_DECLARED priority model, with bands
+ // and lanes.
+ poa_policy_list.length (3);
+
+ CORBA::Short poa_priority =
+ lanes[lanes.length () / 2].lane_priority;
poa_policy_list[0] =
rt_orb->create_priority_model_policy (RTCORBA::SERVER_DECLARED,
poa_priority,
@@ -449,9 +474,13 @@ main (int argc, char *argv[])
ACE_TRY_CHECK;
poa_policy_list[1] =
- rt_orb->create_priority_banded_connection_policy
- (bands,
- ACE_TRY_ENV);
+ rt_orb->create_priority_banded_connection_policy (bands,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ poa_policy_list[2] =
+ rt_orb->create_threadpool_policy (threadpool_id,
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
PortableServer::POA_var server_declared_poa =
@@ -461,47 +490,49 @@ main (int argc, char *argv[])
ACE_TRY_ENV);
ACE_TRY_CHECK;
- // Test 3: Attempt to register an object with priority that
- // doesn't match POA resources (i.e., endpoints/lanes). Should
- // get BAD_PARAM exception.
+ // Test: Attempt to register an object with priority that
+ // doesn't match lanes. Should get BAD_PARAM exception.
ACE_DEBUG ((LM_DEBUG,
- "\n Test 3\n"));
+ "\n<---Test--->: Servant priority does not match lanes\n\n"));
RTPortableServer::POA_var rt_server_declared_poa =
RTPortableServer::POA::_narrow (server_declared_poa.in (), ACE_TRY_ENV);
ACE_TRY_CHECK;
- if (check_for_nil (rt_server_declared_poa.in (), "RTPOA") == -1)
- return 1;
+ CORBA::Short wrong_priority = 10000;
object_activation_exception_test (rt_server_declared_poa.in (),
- &server_impl,
+ 0,
wrong_priority,
ACE_TRY_ENV);
ACE_TRY_CHECK;
-
- // Create object 1 and register with <client_propagated_poa>.
- int result;
- ACE_DEBUG ((LM_DEBUG, "\nActivated object one as "));
+ // Create first servant and register with <client_propagated_poa>.
+ Test_i server_impl (orb.in (),
+ bands,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
result = create_object (client_propagated_poa.in (),
orb.in (),
&server_impl,
ior_output_file1,
ACE_TRY_ENV);
ACE_TRY_CHECK;
- if (result == -1)
- return 1;
+ if (result != 0)
+ return result;
- // Create object 2 and register with <server_declared_poa>.
- ACE_DEBUG ((LM_DEBUG, "\nActivated object two as "));
+ // Create second servant and register with <server_declared_poa>.
+ Test_i server_impl2 (orb.in (),
+ bands,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
result = create_object (server_declared_poa.in (),
orb.in (),
&server_impl2,
ior_output_file2,
ACE_TRY_ENV);
ACE_TRY_CHECK;
- if (result == -1)
- return 1;
+ if (result != 0)
+ return result;
// Activate POA manager.
poa_manager->activate (ACE_TRY_ENV);
@@ -510,7 +541,8 @@ main (int argc, char *argv[])
orb->run (ACE_TRY_ENV);
ACE_TRY_CHECK;
- ACE_DEBUG ((LM_DEBUG, "\nServer ORB event loop finished\n\n"));
+ orb->destroy (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
}
ACE_CATCHANY
{
diff --git a/TAO/tests/RTCORBA/Banded_Connections/test.idl b/TAO/tests/RTCORBA/Banded_Connections/test.idl
index f7d88246a75..ae526bbfd2f 100644
--- a/TAO/tests/RTCORBA/Banded_Connections/test.idl
+++ b/TAO/tests/RTCORBA/Banded_Connections/test.idl
@@ -4,13 +4,8 @@
interface Test
{
- void test_method (in short priority);
- // Takes target object priority in effect for this invocation.
- // Prints out object priority, priority bands in effect, and the
- // priority of the server thread servicing the request. Checks that
- // object and server thread priorities match one of the
- // priority bands.
+ void test_method (in boolean client_propagated,
+ in short client_priority);
oneway void shutdown ();
- // Shut down the ORB.
};