summaryrefslogtreecommitdiff
path: root/TAO/docs/tutorials/Quoter/RTCORBA/docs/run.html
blob: 2006748137c76819512c513ad0d9d082b8ef0b50 (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
<!-- $Id$ -->

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Execution programs for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</title>
</head>

<body
 text = "#000000"
 link = "#000fff"
 vLink= "#ff0f0f"
 aLink = "#0000ff"
 bgColor = "#ffffff">

<hr><h2>Execution programs for the Stock Quoter Publisher/Subscriber Real-time CORBA Service</h2><hr>

<P> There are three execution programs (*.cpp files that have the main () functions) in this system:
Distributor, Broker and Admin. Each of them belongs to the corresponding project defined in the
StockQuoter.mpc file. <P>

<h3>Building the Distributor program</h3>

The Distributor.cpp file is used for this purpose. It contains the main () function and is used to generated the
Distributor execution file. The main steps in this file are described as follows: <P>

<li>Initalize the ORB.</li> <P>

<li>Parse the command-line arguments, which give the stock distributor notification rate and the stock database 
update rate.<P>

<li>Get the RootPOA.</li> <P>

<li>Activate the POAManager.</li> <P>

<li>Create a StockDistributor factory object, which will then create a StockDistributor object.</li>
<PRE>
    Stock_StockDistributorHome_i stock_distributor_home (orb.in ());
    Stock::StockDistributor_var stock_distributor = stock_distributor_home.create ();
</PRE>

<li>Register the StockDistributor servant with the Naming Service or write the object reference of the 
StockDistributor object to a file such that other projects can read it when they are bootstrapping.</li> <P>

<li>Set the initial notification rate of the StockDistributor object.</li> <P>

<li>Set the database update rate.</li> <P>

<li>Enter into the event looping.</li> <P>

<li>Cleanup the POA and ORB.</li> <P>

<hr><h3>Building the Broker program</h3>

The Broker.cpp file is used for this purpose. It contains the main () function and is used to generated the
Broker execution file. The main steps in this file are described as follows: <P>

<li>Initalize the ORB.</li> <P>

<li>Parse the command-line arguments, which give the stock name and the priority of the StockBroker object 
(actually, the priority of the StockNameConsumer object that the StockBroker object contains).</li> <P>

<li>Get the RootPOA.</li> <P>

<li>Activate the POAManager.</li> <P>

<li>Create a StockBroker factory object, which will then create a StockBroker object.</li>
<PRE>
    Stock_StockBrokerHome_i stock_broker_home (orb, stock_name, priority);
    Stock::StockBroker_var stock_broker = stock_broker_home.create ();
</PRE>

<li>Read and destringify the StockDistributor object's IOR or use Naming Service to get the object reference 
and narrow it to a StockDistributor object reference.</li> <P>

<li>Create a StockBroker factory object and use it to create a StockBroker object.</li>
<PRE>
    Stock_StockBrokerHome_i stock_broker_home (orb.in ());
    Stock::StockBroker_var stock_broker = stock_broker_home.create (stock_distributor.in (), stock_name.c_str ());
</PRE>

<li>Create a new consumer; initialize it; subscribe it with the Stock Distributor server.</li>
<PRE>
    Stock::StockNameConsumer_var consumer = stock_broker->get_consumer_notifier ();
    Stock::Cookie_var cookie = stock_distributor->subscribe_notifier (consumer, priority_level);
    consumer->cookie (cookie.in ());
</PRE>

<li>Set the cookie attribute of the consumer.</li>
<PRE>
    consumer->cookie (cookie.in ());
</PRE>

<li>Get the object reference to a StockQuoter that's been activated at the appropriate priority.</li>
<PRE>
    Stock::StockQuoter_var stock_quoter = stock_distributor->provide_quoter_info (cookie.in ());
</PRE>

<li>Stash the StockQuoter object reference away for later use.</li>
<PRE>
    stock_broker->connect_quoter_info (stock_quoter);
</PRE>

<li>Enter into the event looping.</li> <P>

<li>Cleanup the POA and ORB.</li> <P>

<hr><h3>Building the Admin program</h3>

The Admin.cpp file is used for this purpose. It contains the main () function and is used to generated
Admin execution file. The main steps in this file are described as follows: <P>

<li>Initalize the ORB.</li> <P>

<li>Parse the command-line arguments, which give the option of different operations of StockDistributor interface.</li> <P>

<li>Read and destringify the StockDistributor object's IOR or use Naming Service to get the object reference 
and narrow it to a StockDistributor object reference.</li> <P>

<li>Call the operations of StockDistributor interface:</li>
<PRE>
    start: Start the distributor.
    stop: Stop the distributor.
    rate: Change the notification rate of the distributor.
</PRE>

<li>Cleanup the ORB.</li> <P>

<hr><h3>Running the Stock Quoter Service</h3>

When executing the programs, they should be executed in the following order:

<PRE>
    Distributor
    Broker
    Admin
</PRE>

You can run more than one Broker program at the same time. Each of them should be given different stock name
that it is interested in. All the stock information is installed in the <A HREF="database.html">Stock Database</A>.
The number of stocks can easily be extended by adding items to the stock_names array of 
the Stock Database constuctor. <P>

<hr><b>Email: </b><a href="mailto:"</a<ADDRESS>shanshan.jiang@vanderbilt.edu</ADDRESS>

</body>

</html>