summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/EC_Multiple/EC_Multiple.h
blob: c0a492803c00f2f0a55e7b324eb948d946f55e36 (plain)
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
/* -*- C++ -*- */
// $Id$
//
// ============================================================================
//
// = DESCRIPTION
//   This test attempts to communicate several Event Channels.
//   The test hardcodes all the objects involved (consumers,
//   suppliers, proxies, etc.); the objective is to gain understanding
//   on the architecture needed to exploit locality in the Event
//   cycle, not to provide a definite solution.
//
// ============================================================================

#if !defined (EC_MULTIPLE_H)
#define EC_MULTIPLE_H

#include "ace/SString.h"
#include "orbsvcs/RtecEventChannelAdminC.h"
#include "orbsvcs/RtecEventCommS.h"
#include "orbsvcs/Channel_Clients_T.h"


class EC_Proxy
// = TITLE
//   Event Channel Proxy.
//
// = DESCRIPTION
//   This class mediates among two event channels, it connects as a
//   consumer of events with a remote event channel, and as a supplier
//   of events with the local EC.
//   As a consumer it gives a QoS designed to only accept the events
//   in which *local* consumers are interested.
//   Eventually the local EC should create this object and compute its
//   QoS in an automated manner; but this requires some way to filter
//   out the peers registered as consumers, otherwise we will get
//   loops in the QoS graph.
//   It uses exactly the same set of events in the publications list
//   when connected as a supplier.
//
// = NOTES
//   An alternative implementation would be to register with the
//   remote EC as a supplier, and then filter on the remote EC, but
//   one of the objectives is to minimize network traffic.
//   On the other hand the events will be pushed to remote consumers,
//   event though they will be dropped upon receipt (due to the TTL
//   field); IMHO this is another suggestion that the EC needs to know
//   (somehow) which consumers are truly its peers in disguise.
//
// = ALTERNATIVES
//   Check http://www.cs.wustl.edu/~coryan/Multiple_EC.html for a
//   discussion on that topic.
//
{
public:
  EC_Proxy (void);
  ~EC_Proxy (void);

  int open (RtecEventChannelAdmin::EventChannel_ptr remote_ec,
	    RtecEventChannelAdmin::EventChannel_ptr local_ec,
	    const RtecEventChannelAdmin::ConsumerQOS& subscriptions,
	    const RtecEventChannelAdmin::SupplierQOS& publications,
	    CORBA::Environment &_env);
  // Establish the connections.
  
  void disconnect_push_supplier (CORBA::Environment &);
  // The channel is disconnecting.

  void disconnect_push_consumer (CORBA::Environment &);
  // The channel is disconnecting.

  void push (const RtecEventComm::EventSet &events,
	     CORBA::Environment &);
  // This is the Consumer side behavior, it pushes the events to the
  // local event channel.

  int shutdown (CORBA::Environment&);

private:
  ACE_PushConsumer_Adapter<EC_Proxy> consumer_;
  // Our consumer personality....

  ACE_PushSupplier_Adapter<EC_Proxy> supplier_;
  // Our supplier personality....

  RtecEventChannelAdmin::ProxyPushConsumer_var consumer_proxy_;
  // We talk to the EC (as a supplier) using this proxy.

  RtecEventChannelAdmin::ProxyPushSupplier_var supplier_proxy_;
  // We talk to the EC (as a consumer) using this proxy.
};

class Test_ECP
//
// = TITLE
//   A simple test for the EC_Proxy class.
//
// = DESCRIPTION
//   This class is design to exercise several features of the EC_Proxy
//   class and the multiple EC architecture.
//   We want to create two EC, each one having a single supplier and a
//   single consumer.
//    + To test the remote facilities the consumer register for both a
//    local event and a remote one.
//    + To test the remote filtering features the remote consumer only
//    wants one of the local events, and this event is generated less
//    frequently.
//
//   This class creates the local ECP a consumer and a supplier, it
//   uses the command line to figure the 
//
{
public:
  Test_ECP (void);

  int run (int argc, char* argv[]);
  // Execute the test.

  void disconnect_push_supplier (CORBA::Environment &);
  void disconnect_push_consumer (CORBA::Environment &);
  void push (const RtecEventComm::EventSet &events,
	     CORBA::Environment &);
  // Implement the consumer and supplier upcalls.


private:
  int parse_args (int argc, char* argv[]);

  RtecEventChannelAdmin::EventChannel_ptr
    get_ec (CosNaming::NamingContext_ptr naming_context,
	    const char* ec_name,
	    CORBA::Environment &_env);

  int connect_supplier (RtecEventChannelAdmin::EventChannel_ptr local_ec,
			CORBA::Environment &_env);
  int connect_consumer (RtecEventChannelAdmin::EventChannel_ptr local_ec,
			CORBA::Environment &_env);
  int connect_ecp (RtecEventChannelAdmin::EventChannel_ptr local_ec,
		   RtecEventChannelAdmin::EventChannel_ptr remote_ec,
		   CORBA::Environment &_env);

  int shutdown (CORBA::Environment&);

private:
  ACE_PushConsumer_Adapter<Test_ECP> consumer_; 
  // Our consumer personality....

  ACE_PushSupplier_Adapter<Test_ECP> supplier_;
  // Our supplier personality....

  EC_Proxy ecp_;
  // The proxy used to connect both event channels.

  RtecEventChannelAdmin::ProxyPushConsumer_var consumer_proxy_; 
  // We talk to the EC (as a supplier) using this proxy.

  RtecEventChannelAdmin::ProxyPushSupplier_var supplier_proxy_;
  // We talk to the EC (as a consumer) using this proxy.

  RtecEventComm::EventSourceID supplier_id_;
  // Our ID as a supplier.

  char* rmt_ec_name_;
  // The name of the "remote" EC.

  char* lcl_ec_name_;
  // The name of the "local" EC.

  char* sched_name_;
  // The name of the scheduling service.

  int dyn_sched_;
  // Use a collocated dynamic scheduler.

  int event_a_;
  int event_b_;
  int event_c_;
  // We generate events <a> and <b> and receive events <a> and <c>,
  // this allows for a lot of configurations (making a == c or
  // different, etc.)

  int interval_;
  // The interval between the messages.

  int message_count_;
  // How many messages will we send...
};


#endif /* EC_MULTIPLE_H */