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 ACE_ENV_ARG_DECL);
00073
00074
00075 static Routing_Slip_Ptr create (
00076 TAO_Notify_EventChannelFactory & ecf,
00077 Routing_Slip_Persistence_Manager * rspm);
00078
00079 void set_rspm (Routing_Slip_Persistence_Manager * rspm);
00080
00081 void reconnect (ACE_ENV_SINGLE_ARG_DECL);
00082
00083
00084 virtual ~Routing_Slip ();
00085
00086
00087
00088
00089
00090
00091
00092 void route (TAO_Notify_ProxyConsumer* pc, bool reliable_channel ACE_ENV_ARG_DECL);
00093
00094
00095
00096
00097 void dispatch (TAO_Notify_ProxySupplier * proxy_supplier, bool filter ACE_ENV_ARG_DECL);
00098
00099
00100
00101
00102
00103 void wait_persist ();
00104
00105
00106
00107
00108
00109 void delivery_request_complete (size_t request_id);
00110
00111
00112 void at_front_of_persist_queue ();
00113
00114
00115 virtual void persist_complete ();
00116
00117
00118
00119 const TAO_Notify_Event::Ptr & event () const;
00120
00121
00122
00123 int sequence() const;
00124
00125
00126 bool should_retry () const;
00127
00128 private:
00129
00130
00131 void enter_state_transient (Routing_Slip_Guard & guard);
00132 void continue_state_transient (Routing_Slip_Guard & guard);
00133 void enter_state_reloaded (Routing_Slip_Guard & guard);
00134 void enter_state_new (Routing_Slip_Guard & guard);
00135 void continue_state_new (Routing_Slip_Guard & guard);
00136 void enter_state_complete_while_new (Routing_Slip_Guard & guard);
00137 void enter_state_saving (Routing_Slip_Guard & guard);
00138 void enter_state_saved (Routing_Slip_Guard & guard);
00139 void enter_state_updating (Routing_Slip_Guard & guard);
00140 void enter_state_changed_while_saving (Routing_Slip_Guard & guard);
00141 void continue_state_changed_while_saving (Routing_Slip_Guard & guard);
00142 void enter_state_changed (Routing_Slip_Guard & guard);
00143 void continue_state_changed (Routing_Slip_Guard & guard);
00144 void enter_state_complete (Routing_Slip_Guard & guard);
00145 void enter_state_deleting (Routing_Slip_Guard & guard);
00146 void enter_state_terminal (Routing_Slip_Guard & guard);
00147
00148 private:
00149 bool create_persistence_manager();
00150
00151
00152 Routing_Slip(const TAO_Notify_Event::Ptr& event);
00153
00154
00155 bool all_deliveries_complete () const;
00156
00157
00158 void add_to_persist_queue(Routing_Slip_Guard & guard);
00159
00160
00161 void marshal (TAO_OutputCDR & cdr);
00162
00163
00164 bool unmarshal (TAO_Notify_EventChannelFactory &ecf, TAO_InputCDR & rscdr);
00165
00166 private:
00167
00168 TAO_SYNCH_MUTEX internals_;
00169
00170 bool is_safe_;
00171
00172 ACE_SYNCH_CONDITION until_safe_;
00173
00174
00175
00176
00177 Routing_Slip_Ptr this_ptr_;
00178
00179
00180 TAO_Notify_Event::Ptr event_;
00181
00182
00183
00184 enum State
00185 {
00186 rssCREATING,
00187 rssTRANSIENT,
00188 rssRELOADED,
00189 rssNEW,
00190 rssCOMPLETE_WHILE_NEW,
00191 rssSAVING,
00192 rssSAVED,
00193 rssUPDATING,
00194 rssCHANGED_WHILE_SAVING,
00195 rssCHANGED,
00196 rssCOMPLETE,
00197 rssDELETING,
00198 rssTERMINAL
00199 } state_;
00200
00201
00202 Delivery_Request_Vec delivery_requests_;
00203
00204
00205 Delivery_Method_Vec delivery_methods_;
00206
00207
00208 size_t complete_requests_;
00209
00210
00211 Routing_Slip_Persistence_Manager * rspm_;
00212
00213 int sequence_;
00214
00215 static TAO_SYNCH_MUTEX sequence_lock_;
00216 static int routing_slip_sequence_;
00217 static size_t count_enter_transient_;
00218 static size_t count_continue_transient_;
00219 static size_t count_enter_reloaded_;
00220 static size_t count_enter_new_;
00221 static size_t count_continue_new_;
00222 static size_t count_enter_complete_while_new_;
00223 static size_t count_enter_saving_;
00224 static size_t count_enter_saved_;
00225 static size_t count_enter_updating_;
00226 static size_t count_enter_changed_while_saving_;
00227 static size_t count_continue_changed_while_saving_;
00228 static size_t count_enter_changed_;
00229 static size_t count_continue_changed_;
00230 static size_t count_enter_complete_;
00231 static size_t count_enter_deleting_;
00232 static size_t count_enter_terminal_;
00233
00234 static Routing_Slip_Queue persistent_queue_;
00235 };
00236
00237 }
00238
00239 TAO_END_VERSIONED_NAMESPACE_DECL
00240
00241 #include "ace/post.h"
00242 #endif