4 #include "ace/Get_Opt.h"
5 #include "orbsvcs/PortableGroup/GOA.h"
6 #include "tao/Policy_Manager.h"
7 #include "tao/DiffServPolicy/DiffServPolicy.h"
8 #include "tao/DiffServPolicy/Client_Network_Priority_Policy.h"
11 #define CLIENT_SLEEP_TIME 1000 /* in microseconds */
12 #define CLIENT_THREAD_NUMBER 32
13 #define HELLO_CALL_NUMBER 100
15 #define IPDSFIELD_DSCP_DEFAULT 0x00
16 #define IPDSFIELD_DSCP_CS1 0x08
17 #define IPDSFIELD_DSCP_CS2 0x10
18 #define IPDSFIELD_DSCP_CS3 0x18
19 #define IPDSFIELD_DSCP_CS4 0x20
20 #define IPDSFIELD_DSCP_CS5 0x28
21 #define IPDSFIELD_DSCP_CS6 0x30
22 #define IPDSFIELD_DSCP_CS7 0x38
23 #define IPDSFIELD_DSCP_AF11 0x0A
24 #define IPDSFIELD_DSCP_AF12 0x0C
25 #define IPDSFIELD_DSCP_AF13 0x0E
26 #define IPDSFIELD_DSCP_AF21 0x12
27 #define IPDSFIELD_DSCP_AF22 0x14
28 #define IPDSFIELD_DSCP_AF23 0x16
29 #define IPDSFIELD_DSCP_AF31 0x1A
30 #define IPDSFIELD_DSCP_AF32 0x1C
31 #define IPDSFIELD_DSCP_AF33 0x1E
32 #define IPDSFIELD_DSCP_AF41 0x22
33 #define IPDSFIELD_DSCP_AF42 0x24
34 #define IPDSFIELD_DSCP_AF43 0x26
35 #define IPDSFIELD_ECT_MASK 0x02
36 #define IPDSFIELD_CE_MASK 0x01
37 #define IPDSFIELD_DSCP_EF 0x2E
39 static int const dscp
[] =
41 IPDSFIELD_DSCP_DEFAULT
,
64 const ACE_TCHAR
*ior_file
= 0;
67 test_sleep (int microsec
)
69 ACE_Time_Value
tv (microsec
/ 1000000, microsec
% 1000000);
71 ACE_OS::sleep ((const ACE_Time_Value
&) tv
);
75 parse_args (int argc
, ACE_TCHAR
*argv
[])
77 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
78 const unsigned char full_success
= 0x01;
79 unsigned char success
= 0;
84 if (success
== full_success
&& c
== -1)
88 ACE_ERROR_RETURN ((LM_ERROR
,
98 ior_file
= get_opts
.opt_arg ();
105 // Indicates successful parsing of the command line
111 : public ACE_Task_Base
114 ClientThread (Test::Hello_ptr hello
, CORBA::Short calls
)
115 : hello_ (Test::Hello::_duplicate (hello
))
116 , call_count_ (calls
)
130 ACE_GUARD_RETURN (ACE_Mutex
, ace_mon
, this->mutex_
, 0);
134 if (c
>= this->call_count_
)
137 this->hello_
->say_hello (c
);
139 ACE_DEBUG ((LM_DEBUG
,
143 test_sleep (CLIENT_SLEEP_TIME
);
146 catch (const CORBA::Exception
& ex
)
148 ex
._tao_print_exception ("Exception caught in ClientThread:");
157 Test::Hello_var hello_
;
158 CORBA::Short call_count_
;
164 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
169 CORBA::ORB_init (argc
, argv
);
171 if (parse_args (argc
, argv
) != 0)
174 // create UIPMC reference
175 CORBA::Object_var miop_ref
=
176 orb
->string_to_object (ior_file
);
178 // create Hello reference
179 Test::Hello_var hello
=
180 Test::Hello::_unchecked_narrow (miop_ref
.in ());
182 if (CORBA::is_nil (hello
.in ()))
185 TAO::DiffservCodepoint request_dscp
= dscp
[12];
186 TAO::DiffservCodepoint reply_dscp
= dscp
[13];
188 CORBA::PolicyList policy_list
;
189 policy_list
.length (1);
191 CORBA::Policy_var client_network_policy
=
192 orb
->_create_policy (TAO::CLIENT_NETWORK_PRIORITY_TYPE
);
194 TAO::NetworkPriorityPolicy_var nw_priority
=
195 TAO::NetworkPriorityPolicy::_narrow (client_network_policy
.in ());
197 nw_priority
->request_diffserv_codepoint (
200 nw_priority
->reply_diffserv_codepoint (
203 nw_priority
->network_priority_model (
204 TAO::CLIENT_PROPAGATED_NETWORK_PRIORITY
);
206 policy_list
[0] = TAO::NetworkPriorityPolicy::_duplicate (nw_priority
.in ());
208 CORBA::Object_var over_ridden_object
= hello
->_set_policy_overrides (
209 policy_list
, CORBA::SET_OVERRIDE
);
211 policy_list
[0]->destroy ();
213 hello
= Test::Hello::_unchecked_narrow (over_ridden_object
.in ());
217 ClientThread
cln_thr (hello
.in (), HELLO_CALL_NUMBER
);
218 cln_thr
.activate (THR_NEW_LWP
| THR_JOINABLE
, CLIENT_THREAD_NUMBER
);
222 // shutdown the server, after 10 invocations of shutdown() we can be
223 // more or less sure that server actually received that call
224 for (int i
= 0; i
< 10; i
++)
229 catch (const CORBA::Exception
& ex
)
231 ex
._tao_print_exception ("Exception caught in client main ():");
235 ACE_DEBUG ((LM_DEBUG
,
236 "\n (%P|%t) client finished successfully..\n"));