2 #include "tao/Invocation_Retry_State.h"
3 #include "tao/ORB_Core.h"
4 #include "tao/Client_Strategy_Factory.h"
6 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
10 void retry_limit_calc (int ex
,
11 TAO::Invocation_Retry_Params
&command_line_params
,
12 TAO::Invocation_Retry_Params
&client_factory_params
,
13 TAO::Invocation_Retry_Params
&result
)
15 #define FOEL forward_on_exception_limit_
16 if (command_line_params
.FOEL
[ex
] != result
.FOEL
[ex
])
18 result
.FOEL
[ex
] = command_line_params
.FOEL
[ex
];
20 else if (client_factory_params
.FOEL
[ex
] != result
.FOEL
[ex
])
22 result
.FOEL
[ex
] = client_factory_params
.FOEL
[ex
];
27 /// Calculate the retry parameters by giving a command line parameter
28 /// precedence over the corresponding client strategy factory parameter.
29 /// result is assumed to be passed with default values
30 void retry_params_calc (TAO::Invocation_Retry_Params
&command_line_params
,
31 TAO::Invocation_Retry_Params
&client_factory_params
,
32 TAO::Invocation_Retry_Params
&result
)
35 if (command_line_params
.init_retry_delay_
!=
36 result
.init_retry_delay_
)
37 result
.init_retry_delay_
= command_line_params
.init_retry_delay_
;
38 else if (client_factory_params
.init_retry_delay_
!=
39 result
.init_retry_delay_
)
40 result
.init_retry_delay_
= client_factory_params
.init_retry_delay_
;
42 // Retry on reply closed limit
43 if (command_line_params
.forward_on_reply_closed_limit_
!=
44 result
.forward_on_reply_closed_limit_
)
45 result
.forward_on_reply_closed_limit_
=
46 command_line_params
.forward_on_reply_closed_limit_
;
47 else if (client_factory_params
.forward_on_reply_closed_limit_
!=
48 result
.forward_on_reply_closed_limit_
)
49 result
.forward_on_reply_closed_limit_
=
50 client_factory_params
.forward_on_reply_closed_limit_
;
52 // Forward on exception limits
53 retry_limit_calc (TAO::FOE_OBJECT_NOT_EXIST
,
55 client_factory_params
,
58 retry_limit_calc (TAO::FOE_COMM_FAILURE
,
60 client_factory_params
,
63 retry_limit_calc (TAO::FOE_TRANSIENT
,
65 client_factory_params
,
68 retry_limit_calc (TAO::FOE_INV_OBJREF
,
70 client_factory_params
,
75 TAO::Invocation_Retry_State::Invocation_Retry_State (TAO_Stub
&stub
)
76 : forward_on_reply_closed_count_ (0)
77 , forward_on_exception_limit_used_ (false)
79 this->ex_count_map_
[FOE_OBJECT_NOT_EXIST
] = 0;
80 this->ex_count_map_
[FOE_COMM_FAILURE
] = 0;
81 this->ex_count_map_
[FOE_TRANSIENT
] = 0;
82 this->ex_count_map_
[FOE_INV_OBJREF
] = 0;
84 // Cast away const to avoid tedious iterator operations on the ACE_Array_Map.
85 TAO::Invocation_Retry_Params
&command_line_params
=
86 const_cast<TAO::Invocation_Retry_Params
&> (stub
.orb_core ()
87 ->orb_params ()->invocation_retry_params ());
88 TAO::Invocation_Retry_Params
&client_factory_params
=
89 const_cast<TAO::Invocation_Retry_Params
&> (stub
.orb_core ()
90 ->client_factory ()->invocation_retry_params ());
92 retry_params_calc(command_line_params
,
93 client_factory_params
,
96 for (Invocation_Retry_Params::exception_limit_map_type::const_iterator i
=
97 this->retry_params_
.forward_on_exception_limit_
.begin();
98 i
!= this->retry_params_
.forward_on_exception_limit_
.end(); ++i
)
102 forward_on_exception_limit_used_
= true;
108 TAO::Invocation_Retry_State::~Invocation_Retry_State ()
113 TAO::Invocation_Retry_State::forward_on_exception_limit_used () const
115 return forward_on_exception_limit_used_
;
119 TAO::Invocation_Retry_State::forward_on_exception_increment (const int ef
)
121 if (!this->forward_on_exception_limit_used_
)
124 int count
= this->ex_count_map_
[ef
];
125 Invocation_Retry_Params::exception_limit_map_type::const_iterator i
=
126 this->retry_params_
.forward_on_exception_limit_
.find (ef
);
127 int limit
= i
->second
;
130 this->ex_count_map_
[ef
] = count
+ 1;
138 TAO::Invocation_Retry_State::forward_on_reply_closed_increment ()
140 if (this->forward_on_reply_closed_count_
<
141 this->retry_params_
.forward_on_reply_closed_limit_
)
143 ++this->forward_on_reply_closed_count_
;
151 TAO::Invocation_Retry_State::next_profile_retry (TAO_Stub
&stub
) const
153 if (!stub
.next_profile_retry ())
155 stub
.reset_profiles ();
158 this->sleep_at_starting_profile (stub
);
162 TAO::Invocation_Retry_State::sleep_at_starting_profile (TAO_Stub
&stub
) const
164 if (stub
.at_starting_profile ())
169 TAO::Invocation_Retry_State::sleep () const
171 ACE_OS::sleep (this->retry_params_
.init_retry_delay_
);
174 TAO_END_VERSIONED_NAMESPACE_DECL