1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
//$Id$
#include "POA_Holder.h"
#include "tao/debug.h"
#include "ace/Log_Msg.h"
POA_Holder::POA_Holder (void)
:priority_model_ (RTCORBA::CLIENT_PROPAGATED),
server_priority_ (0)
{
}
int
POA_Holder::init (ACE_Arg_Shifter& arg_shifter)
{
const ACE_TCHAR *current_arg = 0;
POA_name_ = arg_shifter.get_current (); // Read the name of the POA
arg_shifter.consume_arg ();
while (arg_shifter.is_anything_left ())
{
if ((current_arg = arg_shifter.get_the_parameter ("-PriorityModel")))
{
if (arg_shifter.cur_arg_strncasecmp ("CLIENT") == 0)
priority_model_ = RTCORBA::CLIENT_PROPAGATED;
else
priority_model_ = RTCORBA::SERVER_DECLARED;
arg_shifter.consume_arg ();
server_priority_ = ACE_OS::atoi (current_arg);
arg_shifter.consume_arg ();
}
else if ((current_arg = arg_shifter.get_the_parameter ("-Lanes")))
{
int lanecount = ACE_OS::atoi (current_arg);
lanes_.length (lanecount);
arg_shifter.consume_arg ();
int l_index = 0;
//parse lane values ...
while (arg_shifter.is_anything_left ())
{
if (arg_shifter.cur_arg_strncasecmp ("-Lane") == 0)
{
arg_shifter.consume_arg ();
// read priority
lanes_[l_index].lane_priority = ACE_OS::atoi (arg_shifter.get_current ());
arg_shifter.consume_arg ();
// static thread count
lanes_[l_index].static_threads = ACE_OS::atoi (arg_shifter.get_current ());
arg_shifter.consume_arg ();
// dynamic thread count
lanes_[l_index].dynamic_threads = ACE_OS::atoi (arg_shifter.get_current ());
arg_shifter.consume_arg ();
//if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG, "lane parsed - %d, %d, %d\n",
lanes_[l_index].lane_priority, lanes_[l_index].static_threads, lanes_[l_index].dynamic_threads));
l_index++;
}
else
break;
} /* while -- lane values */
} /* if -Lanes */
else if ((current_arg = arg_shifter.get_the_parameter ("-Bands")))
{
int bandcount = ACE_OS::atoi (current_arg);
bands_.length (bandcount);
arg_shifter.consume_arg ();
int b_index = 0;
//parse band values ...
while (arg_shifter.is_anything_left ())
{
if (arg_shifter.cur_arg_strncasecmp ("-Band") == 0)
{
arg_shifter.consume_arg ();
// read low
bands_[b_index].low = ACE_OS::atoi (arg_shifter.get_current ());
arg_shifter.consume_arg ();
// read high
bands_[b_index].high = ACE_OS::atoi (arg_shifter.get_current ());
arg_shifter.consume_arg ();
//if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG, "band parsed - %d, %d \n",
bands_[b_index].low, bands_[b_index].high));
b_index++;
}
else
break;
} /* while -- Band values */
} /* if -Bands */
else // something else is showing up ...
{
return 0;
}
}
return 0;
}
void
POA_Holder::activate (RTCORBA::RTORB_ptr rt_orb, PortableServer::POA_ptr parent_poa ACE_ENV_ARG_DECL)
{
/*
lanes bands priomodel
if lanes create lanespolicy
if bands create bands policy
if lanes and bands , policy_list_length = 3
else
if lanes policy_list_length = 2
else
if bands policy_list_length = 2
else
policy_list_length = 1
*/
CORBA::Policy_var priority_model_policy;
CORBA::Policy_var lanes_policy;
CORBA::Policy_var bands_policy;
// Create a priority model policy.
priority_model_policy =
rt_orb->create_priority_model_policy (priority_model_,
server_priority_
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
if (lanes_.length () != 0)
{
// Create a thread-pool.
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;
// Create the thread-pool.
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_ENV_ARG_PARAMETER);
ACE_CHECK;
// Create a thread-pool policy.
lanes_policy =
rt_orb->create_threadpool_policy (threadpool_id
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
if (bands_.length () != 0)
{
// Create a bands policy.
bands_policy =
rt_orb->create_priority_banded_connection_policy (this->bands_
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
CORBA::PolicyList poa_policy_list;
if (lanes_.length () == 0 && bands_.length () == 0)
{
poa_policy_list.length (1);
poa_policy_list[0] = priority_model_policy;
}
else if (lanes_.length () != 0 && bands_.length () == 0)
{
poa_policy_list.length (2);
poa_policy_list[0] = priority_model_policy;
poa_policy_list[1] = lanes_policy;
}
else if (lanes_.length () == 0 && bands_.length () != 0)
{
poa_policy_list.length (2);
poa_policy_list[0] = priority_model_policy;
poa_policy_list[1] = bands_policy;
}
else
{
poa_policy_list.length (3);
poa_policy_list[0] = priority_model_policy;
poa_policy_list[1] = lanes_policy;
poa_policy_list[2] = bands_policy;
}
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG, "creating POA %s\n", POA_name_.c_str ()));
// Get the POA Manager.
PortableServer::POAManager_var poa_manager =
parent_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
parent_poa->create_POA (POA_name_.c_str (),
poa_manager.in (),
poa_policy_list
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
|