1 #include "POA_Holder.h"
5 #include "ace/Arg_Shifter.h"
6 #include "ace/Log_Msg.h"
8 POA_Holder::POA_Holder ()
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"));
94 else if (0 != (current_arg
= arg_shifter
.get_the_parameter (ACE_TEXT("-Bands"))))
97 "Initializing Bands\n"));
99 int bandcount
= ACE_OS::atoi (current_arg
);
100 bands_
.length (bandcount
);
101 arg_shifter
.consume_arg ();
104 //parse band values ...
105 while (arg_shifter
.is_anything_left ())
107 if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-Band")) == 0)
109 arg_shifter
.consume_arg ();
112 bands_
[b_index
].low
= ACE_OS::atoi (arg_shifter
.get_current ());
113 arg_shifter
.consume_arg ();
116 bands_
[b_index
].high
= ACE_OS::atoi (arg_shifter
.get_current ());
117 arg_shifter
.consume_arg ();
119 //if (TAO_debug_level > 0)
120 ACE_DEBUG ((LM_DEBUG
, "band parsed - %d, %d\n",
121 bands_
[b_index
].low
, bands_
[b_index
].high
));
126 } /* while -- Band values */
127 ACE_DEBUG ((LM_DEBUG
,
128 "Bands Initialized\n"));
130 else // something else is showing up ...
132 ACE_DEBUG ((LM_DEBUG
,
133 "Finish Init POA\n"));
138 ACE_DEBUG ((LM_DEBUG
,
139 "Finish Init POA\n"));
144 POA_Holder::activate (RTCORBA::RTORB_ptr rt_orb
, PortableServer::POA_ptr parent_poa
)
146 CORBA::Policy_var priority_model_policy
;
147 CORBA::Policy_var lanes_policy
;
148 CORBA::Policy_var bands_policy
;
149 CORBA::Policy_var thread_pool_policy
;
151 // Create a priority model policy.
152 priority_model_policy
=
153 rt_orb
->create_priority_model_policy (priority_model_
,
156 if (lanes_
.length () != 0)
158 // Create a thread-pool.
159 CORBA::ULong stacksize
= 0;
160 CORBA::Boolean allow_request_buffering
= 0;
161 CORBA::ULong max_buffered_requests
= 0;
162 CORBA::ULong max_request_buffer_size
= 0;
163 CORBA::Boolean allow_borrowing
= 0;
165 // Create the thread-pool.
166 RTCORBA::ThreadpoolId threadpool_id
=
167 rt_orb
->create_threadpool_with_lanes (stacksize
,
170 allow_request_buffering
,
171 max_buffered_requests
,
172 max_request_buffer_size
);
174 // Create a thread-pool policy.
176 rt_orb
->create_threadpool_policy (threadpool_id
);
178 ACE_DEBUG ((LM_DEBUG
,
179 "Activated Lanes\n"));
184 CORBA::ULong stacksize
= 0;
185 CORBA::Boolean allow_request_buffering
= 0;
186 CORBA::ULong max_buffered_requests
= 0;
187 CORBA::ULong max_request_buffer_size
= 0;
189 RTCORBA::ThreadpoolId threadpool_id_1
=
190 rt_orb
->create_threadpool (stacksize
,
194 allow_request_buffering
,
195 max_buffered_requests
,
196 max_request_buffer_size
);
199 thread_pool_policy
= rt_orb
->create_threadpool_policy (threadpool_id_1
);
201 ACE_DEBUG ((LM_DEBUG
,
202 "Activated thread pool\n"));
205 if (bands_
.length () != 0)
207 // Create a bands policy.
209 rt_orb
->create_priority_banded_connection_policy (this->bands_
);
210 ACE_DEBUG ((LM_DEBUG
,
211 "Activated Bands\n"));
214 CORBA::PolicyList poa_policy_list
;
216 if (lanes_
.length () == 0 && bands_
.length () == 0)
220 poa_policy_list
.length (2);
221 poa_policy_list
[0] = priority_model_policy
;
222 poa_policy_list
[1] = thread_pool_policy
;
226 poa_policy_list
.length (1);
227 poa_policy_list
[0] = priority_model_policy
;
230 else if (lanes_
.length () != 0 && bands_
.length () == 0)
234 poa_policy_list
.length (3);
235 poa_policy_list
[0] = priority_model_policy
;
236 poa_policy_list
[1] = lanes_policy
;
237 poa_policy_list
[2] = thread_pool_policy
;
241 poa_policy_list
.length (2);
242 poa_policy_list
[0] = priority_model_policy
;
243 poa_policy_list
[1] = lanes_policy
;
246 else if (lanes_
.length () == 0 && bands_
.length () != 0)
250 poa_policy_list
.length (3);
251 poa_policy_list
[0] = priority_model_policy
;
252 poa_policy_list
[1] = bands_policy
;
253 poa_policy_list
[2] = thread_pool_policy
;
257 poa_policy_list
.length (2);
258 poa_policy_list
[0] = priority_model_policy
;
259 poa_policy_list
[1] = bands_policy
;
266 poa_policy_list
.length (4);
267 poa_policy_list
[0] = priority_model_policy
;
268 poa_policy_list
[1] = lanes_policy
;
269 poa_policy_list
[2] = bands_policy
;
270 poa_policy_list
[3] = thread_pool_policy
;
274 poa_policy_list
.length (3);
275 poa_policy_list
[0] = priority_model_policy
;
276 poa_policy_list
[1] = lanes_policy
;
277 poa_policy_list
[2] = bands_policy
;
281 ACE_DEBUG ((LM_DEBUG
,
282 "Initialized POA Policy\n"));
284 if (TAO_debug_level
> 0)
285 ACE_DEBUG ((LM_DEBUG
, "creating POA %C\n", POA_name_
.c_str ()));
287 // Get the POA Manager.
288 PortableServer::POAManager_var poa_manager
=
289 parent_poa
->the_POAManager ();
291 PortableServer::POA_var poa
=
292 parent_poa
->create_POA (POA_name_
.c_str (),