Skip to content

Commit c2313d0

Browse files
authored
Tuxedo v22.1.0.0.0 - Added bankapp sample application for SALT (#2507)
Signed-off-by: Diwakar Shetty <[email protected]> Reviewed-by: Avi Miller <[email protected]>
1 parent 0798490 commit c2313d0

File tree

8 files changed

+348
-1
lines changed

8 files changed

+348
-1
lines changed

OracleTuxedo/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This repository contains the container image configuration, build and sample fil
55
The following container image is available:
66

77
* [Tuxedo Core](./core) Tuxedo core including server binaries and client libraries
8+
* [Oracle Service Architecture Leveraging Tuxedo (SALT)](./salt) Sample banking application
89

910
For support and certification information, please consult the documentation for each folder.
1011

OracleTuxedo/core/dockerfiles/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The Tuxedo image uses the Oracle JDK 8 (Server JRE) container image `oracle/serv
99
## To build the Oracle Tuxedo container image
1010

1111
1. Download the latest Tuxedo Linux 64 bit installer (e.g. `tuxedo221000_64_Linux_01_x86.zip`) as instructed in [the documentation](../README.md).
12-
2. Move the installer that you downloaded in the previous step to the appropriate version directory (e.g. 21.1.0.0.0) in your local copy of the repository.
12+
2. Move the installer that you downloaded in the previous step to the appropriate version directory (e.g. OracleTuxedo/core/dockerfiles/22.1.0.0.0) in your local copy of the repository.
1313
3. Change to this directory `OracleTuxedo/core/dockerfiles` in your local copy of the repository.
1414
4. Execute ``./buildContainerImage.sh -v 22.1.0.0.0 -i tuxedo221000_64_Linux_01_x86.zip -s`` to create a container image for Tuxedo 22.1.0.
1515

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright (c) 2022 Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
# Pull Tuxedo base image (which also sets TUXDIR)
5+
FROM oracle/tuxedo:22.1.0.0.0
6+
7+
LABEL maintainer="[email protected]"
8+
9+
COPY . /u01/data/bankapp
10+
11+
USER root
12+
RUN yum -y install make && \
13+
chown oracle:oracle -R /u01/data/ && \
14+
chmod +x /u01/data/bankapp/start.sh && \
15+
chmod +x /u01/data/bankapp/stop_server.sh
16+
17+
USER oracle
18+
WORKDIR /u01/data/bankapp
19+
ENTRYPOINT ["/u01/data/bankapp/start.sh"]
+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Oracle Tuxedo SALT bankapp sample application container image
2+
3+
This sample "bankapp" application extends the Oracle Tuxedo image.
4+
5+
## Prerequisites
6+
7+
This image uses the Oracle Tuxedo core container image `oracle/tuxedo:22.1.0.0.0` as its base image. Please follow the [Oracle Tuxedo image documentation](https://github.com/oracle/docker-images/tree/main/OracleTuxedo/core) to build the base image before continuing.
8+
9+
## How to build the image
10+
11+
To build the "bankapp" sample application, run:
12+
13+
```shell
14+
docker build -t tuxedo-bankapp .
15+
```
16+
17+
## Create and run a container from the image
18+
19+
Run the following command to create a container that runs the application from the image built in the previous step:
20+
21+
```shell
22+
docker run --name tuxedo-bankapp -d -p 5955:5955 tuxedo-bankapp
23+
```
24+
25+
Run `docker logs tuxedo-bankapp` to see the logs from the running container. Add `-f` to the command to follow the logs then hit `CTRL+C` to stop following.
26+
27+
## How to test the application
28+
29+
You can test the application using the `curl` HTTP client using the following sample commands. Run these commands on the same host that's running the sample application container.
30+
31+
First, set `TUX_HOSTNAME` to use the loopback address:
32+
33+
```shell
34+
export TUX_HOSTNAME="127.0.0.1"
35+
```
36+
37+
To send an `INQUIRY` request for account ID 10000, run:
38+
39+
```shell
40+
curl -X POST -H "Content-type:application/json" http://${TUX_HOSTNAME}:5955/INQUIRY -d '{"ACCOUNT_ID":10000}'
41+
```
42+
43+
The expected output is
44+
45+
```json
46+
{
47+
"ACCOUNT_ID": 10000,
48+
"FORMNAM": "CBALANCE",
49+
"SBALANCE": "$1456.00"
50+
}
51+
```
52+
53+
To withdraw funds from account 10001, run:
54+
55+
```shell
56+
curl -X POST -H "Content-type:application/json" http://${TUX_HOSTNAME}:5955/WITHDRAWAL -d '{"ACCOUNT_ID":10001,"SAMOUNT":"10"}'
57+
```
58+
59+
The expected output is
60+
61+
```json
62+
{
63+
"ACCOUNT_ID": 10001,
64+
"STATLIN": " ",
65+
"FORMNAM": "CWITHDRAW",
66+
"SBALANCE": "$5568.00",
67+
"SAMOUNT": "$10.00"
68+
}
69+
```
70+
71+
To deposit funds into account 10001, run:
72+
73+
```shell
74+
curl -X POST -H "Content-type:application/json" http://${TUX_HOSTNAME}:5955/DEPOSIT -d '{"ACCOUNT_ID":10001,"SAMOUNT":"1"}'
75+
```
76+
77+
The expected output is
78+
79+
```json
80+
{
81+
"ACCOUNT_ID": 10001,
82+
"BALANCE": 5569,
83+
"STATLIN": "",
84+
"FORMNAM": "CDEPOSIT",
85+
"SBALANCE": "$5569.00",
86+
"SAMOUNT": "$1.00"
87+
}
88+
```
89+
90+
To transfer funds from account 10001 to 10002, run:
91+
92+
```shell
93+
curl -X POST -H "Content-type:application/json" http://${TUX_HOSTNAME}:5955/TRANSFER -d '{"ACCOUNT_ID":[10001,10002],"SAMOUNT":"1"}'
94+
```
95+
96+
The expected output is
97+
98+
```json
99+
{
100+
"ACCOUNT_ID": [10001, 10002],
101+
"STATLIN": "",
102+
"FORMNAM": "CTRANSFER",
103+
"SBALANCE": ["$5568.00", "$904.00"],
104+
"SAMOUNT": "$1.00"
105+
}
106+
```
107+
108+
To obtain the total balance for the bank associated with branch id 10, run:
109+
110+
```shell
111+
curl -X POST -H "Content-type:application/json" http://${TUX_HOSTNAME}:5955/ABAL -d '{"b_id":10}'
112+
```
113+
114+
The expected output is
115+
116+
```json
117+
{
118+
"b_id": 10,
119+
"balance": 219216,
120+
"ermsg": ""
121+
}
122+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Deployment xmlns="http://www.bea.com/Tuxedo/SALTDEPLOY/2007">
3+
<WSDF>
4+
<Import location="bankapp.wsdf"></Import>
5+
</WSDF>
6+
<WSGateway>
7+
<GWInstance id="GWWSRestful">
8+
<TLogDevice location="<APPDIR1>/GWTLOG" />
9+
<TLogName id="GW1TLOG" />
10+
<Inbound>
11+
<HTTP>
12+
<Network http="0.0.0.0:5955" />
13+
<Service name="INQUIRY">
14+
<Method name="POST" service="INQUIRY" inputbuffer="FML" />
15+
</Service>
16+
<Service name="WITHDRAWAL">
17+
<Method name="POST" service="WITHDRAWAL" inputbuffer="FML" />
18+
</Service>
19+
<Service name="DEPOSIT">
20+
<Method name="POST" service="DEPOSIT" inputbuffer="FML" />
21+
</Service>
22+
<Service name="TRANSFER">
23+
<Method name="POST" service="TRANSFER" inputbuffer="FML" />
24+
</Service>
25+
<Service name="PREPAREFAIL">
26+
<Method name="POST" service="PREPAREFAIL" inputbuffer="STRING" />
27+
</Service>
28+
<Service name="COMMITFAIL">
29+
<Method name="POST" service="COMMITFAIL" inputbuffer="STRING" />
30+
</Service>
31+
<Service name="REBOOTCOMMIT">
32+
<Method name="POST" service="REBOOTCOMMIT" inputbuffer="STRING" />
33+
</Service>
34+
<Service name="APPFAIL">
35+
<Method name="POST" service="APPFAIL" inputbuffer="STRING" />
36+
</Service>
37+
<Service name="APPTIMEOUT">
38+
<Method name="POST" service="APPTIMEOUT" inputbuffer="STRING" />
39+
</Service>
40+
<Service name="TOUPPER">
41+
<Method name="POST" service="TOUPPER" inputbuffer="STRING" />
42+
</Service>
43+
<Service name="TWOSERVICE">
44+
<Method name="POST" service="TWOSERVICE" inputbuffer="STRING" />
45+
</Service>
46+
<Service name="ABAL">
47+
<Method name="POST" service="ABAL" inputbuffer="VIEW/aud" />
48+
</Service>
49+
</HTTP>
50+
</Inbound>
51+
<Properties>
52+
</Properties>
53+
</GWInstance>
54+
</WSGateway>
55+
<System>
56+
<Certificate>
57+
<!--
58+
<PrivateKey>/scratch/dohan/tux/bankapp/certs/server.pem</PrivateKey>
59+
<TrustedCert>/scratch/dohan/tux/bankapp/certs/server.pem</TrustedCert>
60+
-->
61+
<!-- TrustedIdpCert>/u01/data/bankapp/certs/server.pem</TrustedIdpCert -->
62+
<!--
63+
<PrivateKey>/scratch/dohan/tux/bankapp/wallet.4096buser</PrivateKey>
64+
<TrustedCert>/scratch/dohan/tux/bankapp/wallet.4096buser</TrustedCert>
65+
-->
66+
<VerifyClient>false</VerifyClient>
67+
</Certificate>
68+
</System>
69+
</Deployment>
70+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Definition xmlns="http://www.bea.com/Tuxedo/WSDF/2007" name="bankapp">
3+
</Definition>
+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/bin/bash
2+
3+
# Copyright (c) 2022 Oracle and/or its affiliates.
4+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
5+
6+
cd /u01/data/bankapp/ || return 1
7+
8+
APPDIR=$(pwd)
9+
export APPDIR
10+
11+
UNAME1=$(uname -n)
12+
TUX_UID=$(id -u)
13+
TUX_GID=$(id -g)
14+
15+
16+
17+
# Get the bankapp sources and build it
18+
cp -rp "${TUXDIR}"/samples/atmi/bankapp/* "${APPDIR}/"
19+
export LD_LIBRARY_PATH="${TUXDIR}/lib:$LD_LIBRARY_PATH"
20+
make -f bankapp.mk TUXDIR="${TUXDIR}" APPDIR="${APPDIR}"
21+
22+
23+
# modify and run the environment setup script
24+
cp -p bankvar bankvar.new
25+
26+
27+
# shellcheck disable=SC2016
28+
cat << 'EOF' >> bankvar.new
29+
#
30+
# For GWWS
31+
#
32+
GWTLOGDEVICE="${APPDIR}/GWTLOG"
33+
export GWTLOGDEVICE
34+
#
35+
# Device for binary file that gives SALT all its information
36+
#
37+
SALTCONFIG="${APPDIR}/saltconfig"
38+
export SALTCONFIG
39+
#
40+
# For graceful shutdown
41+
#
42+
export SHUTDOWN_MARKER_FILE="${APPDIR}/shutdown.marker"
43+
EOF
44+
45+
46+
# shellcheck disable=SC1091
47+
source ./bankvar.new
48+
49+
50+
# clean up from any previous run
51+
tmshutdown -y &>/dev/null
52+
rm -f TLOG GWTLOG tuxconfig saltconfig bankdl1 bankdl2 bankdl3 ULOG.*
53+
rm -f "${SHUTDOWN_MARKER_FILE}"
54+
55+
56+
# Modify the Tuxedo configuration file
57+
sed -e "s;<TUXDIR1>;${TUXDIR};g" \
58+
-e "s;<APPDIR1>;${APPDIR};g" \
59+
-e "s;<user id from id(1)>;${TUX_UID};g" \
60+
-e "s;<group id from id(1)>;${TUX_GID};g" \
61+
-e "s;<SITE1's uname>;\"${UNAME1}\";g" \
62+
-e "s;^MAXACCESSERS\(\s\+\).*$;MAXACCESSERS\1100;g" \
63+
-e "s;^MAXSERVERS\(\s\+\).*$;MAXSERVERS\1100;g" \
64+
-e "s;^MAXSERVICES\(\s\+\).*$;MAXSERVICES\1500;g" \
65+
-e "s;^\(\s*\)\(ULOGPFX=.*\);\1\2\n\1MAXWSCLIENTS=15;g" \
66+
-e 's;\(bankdl3:bankdb:readwrite".*$\);\1\nGWWSGRP GRPNO=4\n OPENINFO="" TMSNAME="" LMID=SITE1;g' \
67+
-e 's;\(BALC\s\+SRVGRP=BANKB3\s\+SRVID=29.*$\);\1\
68+
TMMETADATA SRVGRP=GWWSGRP SRVID=1 CLOPT="-A -- -f bankapp.repos" \
69+
GWWS SRVGRP=GWWSGRP SRVID=2 CLOPT="-A -- -iGWWSRestful";g' \
70+
ubbshm > ubbshm.new
71+
72+
73+
# Create ENVFILE
74+
export MASKPATH=${APPDIR}
75+
./envfile
76+
77+
78+
# Modify bankapp.dep
79+
sed -e "s;<APPDIR1>;${APPDIR};g" bankapp.dep > bankapp.dep.new
80+
81+
82+
# Compile the configuration file
83+
tmloadcf -y ubbshm.new || return 1
84+
wsloadcf -y bankapp.dep.new || return 1
85+
86+
87+
# Create the bank DB and the logs
88+
./crbank || return 1
89+
./crtlog || return 1
90+
91+
92+
# Boot up the domain
93+
tmboot -y
94+
95+
96+
# Insert sample records into the bank DB
97+
./populate
98+
99+
100+
# beginning section of logs to stdout
101+
cat "${APPDIR}/ULOG*"
102+
103+
104+
# Sleep till shutdown initiated
105+
while true; do
106+
if [ -e "${SHUTDOWN_MARKER_FILE}" ] ; then
107+
exit 0
108+
fi
109+
110+
sleep 1
111+
done
112+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2022 Oracle and/or its affiliates.
4+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
5+
#
6+
# This script is used to attempt to gracefully shutdown the Tuxedo server before its pod is deleted.
7+
# It assumes that TUXDIR has been set
8+
9+
export APPDIR=/u01/data/bankapp/
10+
LOG_FILE="${APPDIR}/stop_server.log"
11+
12+
# shellcheck disable=SC1091
13+
source "${APPDIR}/bankvar.new"
14+
15+
echo "Server shutdown initiated at $(date)" >> $LOG_FILE
16+
17+
# Shutdown the domain
18+
tmshutdown -y
19+
20+
touch "${SHUTDOWN_MARKER_FILE}"

0 commit comments

Comments
 (0)