Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef TAO_NOTIFY_ROUTING_SLIP_H
00012 #define TAO_NOTIFY_ROUTING_SLIP_H
00013 #include "ace/pre.h"
00014
00015 #include "orbsvcs/Notify/notify_serv_export.h"
00016 #include "orbsvcs/Notify/Event.h"
00017 #include "orbsvcs/Notify/Delivery_Request.h"
00018 #include "orbsvcs/Notify/Event_Persistence_Factory.h"
00019
00020 #include "orbsvcs/Notify/Persistent_File_Allocator.h"
00021
00022 #include <ace/Vector_T.h>
00023 #include <ace/Malloc_Base.h>
00024
00025 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00026 # pragma once
00027 #endif
00028
00029 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00030
00031
00032
00033 class TAO_Notify_EventChannelFactory;
00034 class TAO_Notify_Method_Request;
00035 class TAO_Notify_ProxyConsumer;
00036 class TAO_Notify_ProxySupplier;
00037 class TAO_Notify_Method_Request_Queueable;
00038
00039 namespace TAO_Notify
00040 {
00041
00042 class Routing_Slip_Persistence_Manager;
00043
00044
00045
00046
00047
00048 typedef ACE_Vector <Delivery_Request_Ptr> Delivery_Request_Vec;
00049
00050
00051 typedef ACE_Vector <TAO_Notify_Method_Request_Queueable *> Delivery_Method_Vec;
00052
00053 class Routing_Slip;
00054
00055 typedef ACE_Strong_Bound_Ptr<Routing_Slip, TAO_SYNCH_MUTEX> Routing_Slip_Ptr;
00056
00057 class Routing_Slip_Persistence_Manager;
00058
00059 class Routing_Slip_Queue;
00060
00061
00062
00063
00064
00065
00066 class TAO_Notify_Serv_Export Routing_Slip : public Persistent_Callback
00067 {
00068 typedef ACE_Guard< TAO_SYNCH_MUTEX > Routing_Slip_Guard;
00069 public:
00070
00071 static Routing_Slip_Ptr create (const TAO_Notify_Event::Ptr& event);
00072
00073
00074 static Routing_Slip_Ptr create (
00075 TAO_Notify_EventChannelFactory & ecf,
00076 Routing_Slip_Persistence_Manager * rspm);
00077
00078 void set_rspm (Routing_Slip_Persistence_Manager * rspm);
00079
00080 void reconnect (void);
00081
00082
00083 virtual ~Routing_Slip ();
00084
00085
00086
00087
00088
00089
00090
00091 void route (TAO_Notify_ProxyConsumer* pc, bool reliable_channel);
00092
00093
00094
00095
00096 void dispatch (TAO_Notify_ProxySupplier * proxy_supplier, bool filter);
00097
00098
00099
00100
00101
00102 void wait_persist ();
00103
00104
00105
00106
00107
00108 void delivery_request_complete (size_t request_id);
00109
00110
00111 void at_front_of_persist_queue ();
00112
00113
00114 virtual void persist_complete ();
00115
00116
00117
00118 const TAO_Notify_Event::Ptr & event () const;
00119
00120
00121
00122 int sequence() const;
00123
00124
00125 bool should_retry () const;
00126
00127 private:
00128
00129
00130 void enter_state_transient (Routing_Slip_Guard & guard);
00131 void continue_state_transient (Routing_Slip_Guard & guard);
00132 void enter_state_reloaded (Routing_Slip_Guard & guard);
00133 void enter_state_new (Routing_Slip_Guard & guard);
00134 void continue_state_new (Routing_Slip_Guard & guard);
00135 void enter_state_complete_while_new (Routing_Slip_Guard & guard);
00136 void enter_state_saving (Routing_Slip_Guard & guard);
00137 void enter_state_saved (Routing_Slip_Guard & guard);
00138 void enter_state_updating (Routing_Slip_Guard & guard);
00139 void enter_state_changed_while_saving (Routing_Slip_Guard & guard);
00140 void continue_state_changed_while_saving (Routing_Slip_Guard & guard);
00141 void enter_state_changed (Routing_Slip_Guard & guard);
00142 void continue_state_changed (Routing_Slip_Guard & guard);
00143 void enter_state_complete (Routing_Slip_Guard & guard);
00144 void enter_state_deleting (Routing_Slip_Guard & guard);
00145 void enter_state_terminal (Routing_Slip_Guard & guard);
00146
00147 private:
00148 bool create_persistence_manager();
00149
00150
00151 Routing_Slip(const TAO_Notify_Event::Ptr& event);
00152
00153
00154 bool all_deliveries_complete () const;
00155
00156
00157 void add_to_persist_queue(Routing_Slip_Guard & guard);
00158
00159
00160 void marshal (TAO_OutputCDR & cdr);
00161
00162
00163 bool unmarshal (TAO_Notify_EventChannelFactory &ecf, TAO_InputCDR & rscdr);
00164
00165 private:
00166
00167 TAO_SYNCH_MUTEX internals_;
00168
00169 bool is_safe_;
00170
00171 ACE_SYNCH_CONDITION until_safe_;
00172
00173
00174
00175
00176 Routing_Slip_Ptr this_ptr_;
00177
00178
00179 TAO_Notify_Event::Ptr event_;
00180
00181
00182
00183 enum State
00184 {
00185 rssCREATING,
00186 rssTRANSIENT,
00187 rssRELOADED,
00188 rssNEW,
00189 rssCOMPLETE_WHILE_NEW,
00190 rssSAVING,
00191 rssSAVED,
00192 rssUPDATING,
00193 rssCHANGED_WHILE_SAVING,
00194 rssCHANGED,
00195 rssCOMPLETE,
00196 rssDELETING,
00197 rssTERMINAL
00198 } state_;
00199
00200
00201 Delivery_Request_Vec delivery_requests_;
00202
00203
00204 Delivery_Method_Vec delivery_methods_;
00205
00206
00207 size_t complete_requests_;
00208
00209
00210 Routing_Slip_Persistence_Manager * rspm_;
00211
00212 int sequence_;
00213
00214 static TAO_SYNCH_MUTEX sequence_lock_;
00215 static int routing_slip_sequence_;
00216 static size_t count_enter_transient_;
00217 static size_t count_continue_transient_;
00218 static size_t count_enter_reloaded_;
00219 static size_t count_enter_new_;
00220 static size_t count_continue_new_;
00221 static size_t count_enter_complete_while_new_;
00222 static size_t count_enter_saving_;
00223 static size_t count_enter_saved_;
00224 static size_t count_enter_updating_;
00225 static size_t count_enter_changed_while_saving_;
00226 static size_t count_continue_changed_while_saving_;
00227 static size_t count_enter_changed_;
00228 static size_t count_continue_changed_;
00229 static size_t count_enter_complete_;
00230 static size_t count_enter_deleting_;
00231 static size_t count_enter_terminal_;
00232
00233 static Routing_Slip_Queue persistent_queue_;
00234 };
00235
00236 }
00237
00238 TAO_END_VERSIONED_NAMESPACE_DECL
00239
00240 #include "ace/post.h"
00241 #endif