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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
|
Calculator Distributed Sample
=============================
This sample implements a simple calculator using SCA components. It uses
exactly the same calculator application classes as the calculator sample but
runs the application distributed across three nodes.
A node in this sample means an instance of the Tuscany SCA java runtime running
in a Java virtual machine.
The README in the samples directory (the directory above this) provides
general instructions about building and running samples. Take a look there
first.
If you just want to run it to see what happens open four command prompts and
navigate to this sample directory in each one. There is one command to be run
in each command prompt:
ant runDomain
ant runNodeB
ant runNodeC
ant runNodeA
Please run the commands in this order.
OR if you don't have ant, on Windows use
java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.LaunchDomain
java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.LaunchCalculatorNodeB
java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.LaunchCalculatorNodeC
java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.LaunchCalculatorNodeA
and on *nix do
java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.LaunchDomain
java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.LaunchCalculatorNodeB
java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.LaunchCalculatorNodeC
java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.LaunchCalculatorNodeA
The processes started on each of these command prompts can be ended by typing 'q'.
Sample Overview
---------------
The sample provides a single calculator service with a default SCA (java)
binding. NodeA exercises this interface by calling add, subtract, multiply and
divide operations.
In the case of add and subtract the runtime recognises that
it can't find these services locally and, using the remote (web services)
version of the default SCA binding, contacts the add service running in NodeB
and the subtract service running in NodeC.
On the command prompt where you started NodeA, you see the output of invoking the
calculator functions distributed over NodeB and and NodeC. On the command prompts
where you have started NodeB and NodeC, you see log messages that indicate that
the add and subtract services where called on these nodes respectively.
The sample demonstrates that the calculator application can be distributed
across multiple nodes with no change to the application or to the SCA description
files.
The domain node makes available a web application through which the contributions and
composites used in this sample can be navigated. One you have run "ant runDomain" you can
point you browser at:
http://localhost:9990/ui/workspace/
The contents of the sample are as follows:
calculator/
src/
main/
java/
calculator/
CalculatorService.java - the first component, calls +-/* as
appropriate
AddService.java - adds two numbers
AddServiceImpl.java
SubtractService.java - subtracts one number from another
SubtractServiceImpl.java
MultiplyService.java - multiplies two numbers
MultiplyServiceImpl.java
DivideService.java - divides one number by another
DivideServiceImpl.java
node/
LaunchCalculatorNodeA.java - runs an sca node configured with the
composite describing the main calculator
application. If you look inside this class
you will see that the node is configured
using a URL of the form:
http://localhost:9990/node-config/NodeA
This retrieves the information required
to configure NodeA from the domain.
Once the node has been started this launcher
then finds the calculator service and
calls the various methods.
LaunchCalculatorNodeB&C.java - These launchers start nodes B and C
which runs the add and subtract services.
Unlike NodeA though these launchers just
wait once the node has been started. They
will service incomming web service requests
as they arrive.
LaunchDomain.java - the node that provides the domain
configuration to the distributed
nodes
resources/
workspace.xml - The domain manager configuration files that
domain.composite describe the configuration of the domain's
cloud.composite contributions, composites, and nodes
cloud/ - The SCA composite files that describe
the configuration of each node
nodeA/ - the SCA assembly for nodeA's part of the
calculator application
nodeB/ - the SCA assembly for nodeB's part of the
calculator application
nodeC/ - the SCA assembly for nodeC's part of the
calculator application
test/
java/
calculator/
CalculatorDistributedTestCase.java - JUnit test case which runs all
of the separate nodes along with the domain
in a single VM for test purposes
calculator-distributed.png - a pictorial representation of the sample
.composite files
build.xml - the Ant build file
pom.xml - the Maven build file
Building And Running The Sample Using Ant
-----------------------------------------
With the binary distribution the sample can be built and run using Ant as
follows
cd calculator-distributed
ant compile
ant runDomain
ant runNodeB
ant runNodeC
ant runNodeA
You should see the following output from the four separate command prompt:
runDomain:
ted>ant runDomain
Buildfile: build.xml
runDomain:
[java] 26-Mar-2008 12:55:12 org.apache.tuscany.sca.node.launcher.DomainMana
gerLauncher main
[java] INFO: Apache Tuscany SCA Domain Manager starting...
[java] 26-Mar-2008 12:55:13 org.apache.tuscany.sca.node.launcher.NodeLaunch
erUtil collectJARFiles
[java] INFO: Runtime classpath: 147 JARs from C:\simon\tuscany\sca-java-1.2
\distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca-
1.2-incubating-SNAPSHOT\lib
[java] 26-Mar-2008 12:55:13 org.apache.tuscany.sca.node.launcher.NodeLaunch
erUtil collectJARFiles
[java] INFO: Runtime classpath: 89 JARs from C:\simon\tuscany\sca-java-1.2\
distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca-1
.2-incubating-SNAPSHOT\modules
[java] 26-Mar-2008 12:55:19 org.apache.catalina.core.StandardEngine start
[java] INFO: Starting Servlet Engine: Apache Tomcat/6.0.14
[java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.ContextConfig defau
ltWebConfig
[java] INFO: No default web.xml
[java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg
ister
[java] WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.
xsd
[java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg
ister
[java] WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_1.
xsd
[java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg
ister
[java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt
aglibrary_1_1.dtd
[java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg
ister
[java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt
aglibrary_1_2.dtd
[java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg
ister
[java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt
aglibrary_2_0.xsd
[java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg
ister
[java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt
aglibrary_2_1.xsd
[java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg
ister
[java] WARNING: Could not get url for /javax/servlet/resources/j2ee_web_ser
vices_1_1.xsd
[java] 26-Mar-2008 12:55:20 org.apache.coyote.http11.Http11Protocol init
[java] INFO: Initializing Coyote HTTP/1.1 on http-9990
[java] 26-Mar-2008 12:55:20 org.apache.coyote.http11.Http11Protocol start
[java] INFO: Starting Coyote HTTP/1.1 on http-9990
[java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/home/*
[java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/workspace/*
[java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/files/*
[java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/composite/*
[java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/cloud/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/workspace/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/contribution/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/feed/files/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/files/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/composite/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/composite-source/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/deployable/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/composite-resolved/
*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/cloud/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/cloud-source/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/composite-config/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/node-config/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/quickstart/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/processes/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/node/processes/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer
addServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:9990/ping/*
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.node.launcher.DomainMana
gerLauncher main
[java] INFO: SCA Domain Manager started.
[java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.node.launcher.DomainMana
gerLauncher main
[java] INFO: Press enter to shutdown.
runNodeB:
[java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.launcher.NodeLaunch
er main
[java] INFO: Apache Tuscany SCA Node starting...
[java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.launcher.NodeLaunch
er main
[java] INFO: SCA Node configuration: http://localhost:9990/node-config/NodeB
[java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.launcher.NodeLaunch
erUtil collectJARFiles
[java] INFO: Runtime classpath: 147 JARs from C:\simon\tuscany\sca-java-1.2
\distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca-
1.2-incubating-SNAPSHOT\lib
[java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.launcher.NodeLaunch
erUtil collectJARFiles
[java] INFO: Runtime classpath: 89 JARs from C:\simon\tuscany\sca-java-1.2\
distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca-1
.2-incubating-SNAPSHOT\modules
[java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.impl.NodeImpl <init
>
[java] INFO: Creating node: http://localhost:9990/node-config/NodeB
[java] 26-Mar-2008 12:55:45 org.apache.tuscany.sca.node.impl.NodeImpl confi
gureNode
[java] INFO: Loading contribution: file:/C:/simon/tuscany/sca-java-1.2/dist
ribution/target/apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir/tuscany-sca-1.2-i
ncubating-SNAPSHOT/samples/calculator-distributed/./src/main/resources/nodeB/
[java] 26-Mar-2008 12:55:46 org.apache.tuscany.sca.node.impl.NodeImpl confi
gureNode
[java] INFO: Loading composite: http://localhost:9990/composite-resolved/co
mposite:nodeB;http://sample;CalculatorB
[java] 26-Mar-2008 12:55:47 org.apache.tuscany.sca.node.impl.NodeImpl start
[java] INFO: Starting node: http://localhost:9990/node-config/NodeB
[java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
[java] 26-Mar-2008 12:55:53 org.apache.tuscany.sca.http.jetty.JettyServer a
ddServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:8200/AddServiceComponent
B
[java] 26-Mar-2008 12:55:53 org.apache.tuscany.sca.node.launcher.NodeLaunch
er main
[java] INFO: SCA Node started.
[java] 26-Mar-2008 12:55:53 org.apache.tuscany.sca.node.launcher.NodeLaunch
er main
[java] INFO: Press enter to shutdown.
[java] AddService - add 3.0 and 2.0
runNodeC:
[java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.launcher.NodeLaunch
er main
[java] INFO: Apache Tuscany SCA Node starting...
[java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.launcher.NodeLaunch
er main
[java] INFO: SCA Node configuration: http://localhost:9990/node-config/NodeC
[java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.launcher.NodeLaunch
erUtil collectJARFiles
[java] INFO: Runtime classpath: 147 JARs from C:\simon\tuscany\sca-java-1.2
\distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca-
1.2-incubating-SNAPSHOT\lib
[java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.launcher.NodeLaunch
erUtil collectJARFiles
[java] INFO: Runtime classpath: 89 JARs from C:\simon\tuscany\sca-java-1.2\
distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca-1
.2-incubating-SNAPSHOT\modules
[java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.impl.NodeImpl <init
>
[java] INFO: Creating node: http://localhost:9990/node-config/NodeC
[java] 26-Mar-2008 12:56:03 org.apache.tuscany.sca.node.impl.NodeImpl confi
gureNode
[java] INFO: Loading contribution: file:/C:/simon/tuscany/sca-java-1.2/dist
ribution/target/apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir/tuscany-sca-1.2-i
ncubating-SNAPSHOT/samples/calculator-distributed/./src/main/resources/nodeC/
[java] 26-Mar-2008 12:56:04 org.apache.tuscany.sca.node.impl.NodeImpl confi
gureNode
[java] INFO: Loading composite: http://localhost:9990/composite-resolved/co
mposite:nodeC;http://sample;CalculatorC
[java] 26-Mar-2008 12:56:04 org.apache.tuscany.sca.node.impl.NodeImpl start
[java] INFO: Starting node: http://localhost:9990/node-config/NodeC
[java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
[java] 26-Mar-2008 12:56:10 org.apache.tuscany.sca.http.jetty.JettyServer a
ddServletMapping
[java] INFO: Added Servlet mapping: http://L3AW203:8300/SubtractServiceComp
onentC
[java] 26-Mar-2008 12:56:10 org.apache.tuscany.sca.node.launcher.NodeLaunch
er main
[java] INFO: SCA Node started.
[java] 26-Mar-2008 12:56:10 org.apache.tuscany.sca.node.launcher.NodeLaunch
er main
[java] INFO: Press enter to shutdown.
[java] SubtractService - subtract 3.0 and 2.0
runNodeA:
[java] 26-Mar-2008 12:56:10 org.apache.tuscany.sca.node.impl.NodeImpl <init
>
[java] INFO: Creating node: http://localhost:9990/node-config/NodeA
[java] 26-Mar-2008 12:56:12 org.apache.tuscany.sca.node.impl.NodeImpl confi
gureNode
[java] INFO: Loading contribution: file:/C:/simon/tuscany/sca-java-1.2/dist
ribution/target/apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir/tuscany-sca-1.2-i
ncubating-SNAPSHOT/samples/calculator-distributed/./src/main/resources/nodeA/
[java] 26-Mar-2008 12:56:13 org.apache.tuscany.sca.node.impl.NodeImpl confi
gureNode
[java] INFO: Loading composite: http://localhost:9990/composite-resolved/co
mposite:nodeA;http://sample;CalculatorA
[java] 26-Mar-2008 12:56:14 org.apache.tuscany.sca.assembly.builder.impl.Co
mpositeBuilderImpl$1 problem
[java] WARNING: Component reference target not found, it might be a remote
service: SubtractServiceComponentC
[java] 26-Mar-2008 12:56:14 org.apache.tuscany.sca.assembly.builder.impl.Co
mpositeBuilderImpl$1 problem
[java] WARNING: Component reference target not found, it might be a remote
service: AddServiceComponentB
[java] 26-Mar-2008 12:56:14 org.apache.tuscany.sca.node.impl.NodeImpl start
[java] INFO: Starting node: http://localhost:9990/node-config/NodeA
[java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
[java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
[java] CalculatorService - add 3.0 and 2.0
[java] 3 + 2=5.0
[java] CalculatorService - subtract 3.0 and 2.0
[java] 3 - 2=1.0
[java] CalculatorService - multiply 3.0 and 2.0
[java] 3 * 2=6.0
[java] CalculatorService - divide 3.0 and 2.0
[java] 3 / 2=1.5
[java] 26-Mar-2008 12:56:20 org.apache.tuscany.sca.node.impl.NodeImpl stop
[java] INFO: Stopping node: http://localhost:9990/node-config/NodeA
Building And Running The Sample Using Maven
-------------------------------------------
With either the binary or source distributions the sample can be built and run
using Maven as follows. When running from Maven the four nodes all run within
Java virtual machine.
cd calculator-distributed
mvn
You should see the following output at the end of the test phase.
INFO: Starting node: http://localhost:9990/node-config/NodeA
CalculatorService - add 3.0 and 2.0
AddService - add 3.0 and 2.0
CalculatorService - subtract 3.0 and 2.0
SubtractService - subtract 3.0 and 2.0
CalculatorService - multiply 3.0 and 2.0
CalculatorService - divide 3.0 and 2.0
26-Mar-2008 13:00:52 org.apache.tuscany.sca.node.impl.NodeImpl stop
INFO: Stopping node: http://localhost:9990/node-config/NodeC
26-Mar-2008 13:00:52 org.apache.tuscany.sca.node.impl.NodeImpl stop
INFO: Stopping node: http://localhost:9990/node-config/NodeB
26-Mar-2008 13:00:52 org.apache.tuscany.sca.node.impl.NodeImpl stop
INFO: Stopping node: http://localhost:9990/node-config/NodeA
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.328 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
This shows that the Junit test cases have run successfully.
|