1 #include "POA_Holder.h"
5 #include "ace/Arg_Shifter.h"
6 #include "ace/Log_Msg.h"
8 POA_Holder::POA_Holder (void)
9 :priority_model_ (RTCORBA::CLIENT_PROPAGATED
),
16 POA_Holder::init (ACE_Arg_Shifter
& arg_shifter
)
21 const ACE_TCHAR
*current_arg
= 0;
23 POA_name_
= ACE_TEXT_ALWAYS_CHAR(arg_shifter
.get_current ()); // Read the name of the POA
24 arg_shifter
.consume_arg ();
26 while (arg_shifter
.is_anything_left ())
28 if (0 != (current_arg
= arg_shifter
.get_the_parameter (ACE_TEXT("-PriorityModel"))))
30 if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("CLIENT")) == 0)
31 priority_model_
= RTCORBA::CLIENT_PROPAGATED
;
33 priority_model_
= RTCORBA::SERVER_DECLARED
;
34 arg_shifter
.consume_arg ();
36 server_priority_
= ACE_OS::atoi (current_arg
);
37 arg_shifter
.consume_arg ();
39 else if (0 != (current_arg
= arg_shifter
.get_the_parameter (ACE_TEXT("-Lanes"))))
41 int lanecount
= ACE_OS::atoi (current_arg
);
42 lanes_
.length (lanecount
);
43 arg_shifter
.consume_arg ();
46 //parse lane values ...
47 while (arg_shifter
.is_anything_left ())
49 if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-Lane")) == 0)
51 arg_shifter
.consume_arg ();
54 lanes_
[l_index
].lane_priority
= ACE_OS::atoi (arg_shifter
.get_current ());
55 arg_shifter
.consume_arg ();
57 // static thread count
58 lanes_
[l_index
].static_threads
= ACE_OS::atoi (arg_shifter
.get_current ());
59 arg_shifter
.consume_arg ();
61 // dynamic thread count
62 lanes_
[l_index
].dynamic_threads
= ACE_OS::atoi (arg_shifter
.get_current ());
63 arg_shifter
.consume_arg ();
65 //if (TAO_debug_level > 0)
66 ACE_DEBUG ((LM_DEBUG
, "lane parsed - %d, %d, %d\n",
67 lanes_
[l_index
].lane_priority
, lanes_
[l_index
].static_threads
, lanes_
[l_index
].dynamic_threads
));
72 } /* while -- lane values */
75 else if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-ThreadPool")) == 0)
80 arg_shifter
.consume_arg ();
83 tp_static_threads_
= ACE_OS::atoi (arg_shifter
.get_current ());
84 arg_shifter
.consume_arg ();
86 tp_dynamic_threads_
= ACE_OS::atoi (arg_shifter
.get_current ());
87 arg_shifter
.consume_arg ();
89 tp_priority_
= ACE_OS::atoi (arg_shifter
.get_current ());
90 arg_shifter
.consume_arg ();
92 "Thread Pool Initialized\n"));
95 else if (0 != (current_arg
= arg_shifter
.get_the_parameter (ACE_TEXT("-Bands"))))
98 "Initializing Bands\n"));
100 int bandcount
= ACE_OS::atoi (current_arg
);
101 bands_
.length (bandcount
);
102 arg_shifter
.consume_arg ();
105 //parse band values ...
106 while (arg_shifter
.is_anything_left ())
108 if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-Band")) == 0)
110 arg_shifter
.consume_arg ();
113 bands_
[b_index
].low
= ACE_OS::atoi (arg_shifter
.get_current ());
114 arg_shifter
.consume_arg ();
117 bands_
[b_index
].high
= ACE_OS::atoi (arg_shifter
.get_current ());
118 arg_shifter
.consume_arg ();
120 //if (TAO_debug_level > 0)
121 ACE_DEBUG ((LM_DEBUG
, "band parsed - %d, %d\n",
122 bands_
[b_index
].low
, bands_
[b_index
].high
));
127 } /* while -- Band values */
128 ACE_DEBUG ((LM_DEBUG
,
129 "Bands Initialized\n"));
132 else // something else is showing up ...
134 ACE_DEBUG ((LM_DEBUG
,
135 "Finish Init POA\n"));
140 ACE_DEBUG ((LM_DEBUG
,
141 "Finish Init POA\n"));
146 POA_Holder::activate (RTCORBA::RTORB_ptr rt_orb
, PortableServer::POA_ptr parent_poa
)
148 CORBA::Policy_var priority_model_policy
;
149 CORBA::Policy_var lanes_policy
;
150 CORBA::Policy_var bands_policy
;
151 CORBA::Policy_var thread_pool_policy
;
153 // Create a priority model policy.
154 priority_model_policy
=
155 rt_orb
->create_priority_model_policy (priority_model_
,
158 if (lanes_
.length () != 0)
160 // Create a thread-pool.
161 CORBA::ULong stacksize
= 0;
162 CORBA::Boolean allow_request_buffering
= 0;
163 CORBA::ULong max_buffered_requests
= 0;
164 CORBA::ULong max_request_buffer_size
= 0;
165 CORBA::Boolean allow_borrowing
= 0;
167 // Create the thread-pool.
168 RTCORBA::ThreadpoolId threadpool_id
=
169 rt_orb
->create_threadpool_with_lanes (stacksize
,
172 allow_request_buffering
,
173 max_buffered_requests
,
174 max_request_buffer_size
);
176 // Create a thread-pool policy.
178 rt_orb
->create_threadpool_policy (threadpool_id
);
180 ACE_DEBUG ((LM_DEBUG
,
181 "Activated Lanes\n"));
187 CORBA::ULong stacksize
= 0;
188 CORBA::Boolean allow_request_buffering
= 0;
189 CORBA::ULong max_buffered_requests
= 0;
190 CORBA::ULong max_request_buffer_size
= 0;
192 RTCORBA::ThreadpoolId threadpool_id_1
=
193 rt_orb
->create_threadpool (stacksize
,
197 allow_request_buffering
,
198 max_buffered_requests
,
199 max_request_buffer_size
);
202 thread_pool_policy
= rt_orb
->create_threadpool_policy (threadpool_id_1
);
204 ACE_DEBUG ((LM_DEBUG
,
205 "Activated thread pool\n"));
210 if (bands_
.length () != 0)
212 // Create a bands policy.
214 rt_orb
->create_priority_banded_connection_policy (this->bands_
);
215 ACE_DEBUG ((LM_DEBUG
,
216 "Activated Bands\n"));
220 CORBA::PolicyList poa_policy_list
;
222 if (lanes_
.length () == 0 && bands_
.length () == 0)
226 poa_policy_list
.length (2);
227 poa_policy_list
[0] = priority_model_policy
;
228 poa_policy_list
[1] = thread_pool_policy
;
232 poa_policy_list
.length (1);
233 poa_policy_list
[0] = priority_model_policy
;
236 else if (lanes_
.length () != 0 && bands_
.length () == 0)
240 poa_policy_list
.length (3);
241 poa_policy_list
[0] = priority_model_policy
;
242 poa_policy_list
[1] = lanes_policy
;
243 poa_policy_list
[2] = thread_pool_policy
;
247 poa_policy_list
.length (2);
248 poa_policy_list
[0] = priority_model_policy
;
249 poa_policy_list
[1] = lanes_policy
;
252 else if (lanes_
.length () == 0 && bands_
.length () != 0)
256 poa_policy_list
.length (3);
257 poa_policy_list
[0] = priority_model_policy
;
258 poa_policy_list
[1] = bands_policy
;
259 poa_policy_list
[2] = thread_pool_policy
;
263 poa_policy_list
.length (2);
264 poa_policy_list
[0] = priority_model_policy
;
265 poa_policy_list
[1] = bands_policy
;
272 poa_policy_list
.length (4);
273 poa_policy_list
[0] = priority_model_policy
;
274 poa_policy_list
[1] = lanes_policy
;
275 poa_policy_list
[2] = bands_policy
;
276 poa_policy_list
[3] = thread_pool_policy
;
280 poa_policy_list
.length (3);
281 poa_policy_list
[0] = priority_model_policy
;
282 poa_policy_list
[1] = lanes_policy
;
283 poa_policy_list
[2] = bands_policy
;
287 ACE_DEBUG ((LM_DEBUG
,
288 "Initialized POA Policy\n"));
290 if (TAO_debug_level
> 0)
291 ACE_DEBUG ((LM_DEBUG
, "creating POA %C\n", POA_name_
.c_str ()));
293 // Get the POA Manager.
294 PortableServer::POAManager_var poa_manager
=
295 parent_poa
->the_POAManager ();
297 PortableServer::POA_var poa
=
298 parent_poa
->create_POA (POA_name_
.c_str (),