Advanced gLite: Distributed Applications (2)
R-GMA may be used by the jobs to inform themselves about their respective
contact addresses.
- Create a RGMA table Contacts to hold for each communication
partner id its contact address addr:
rgma -c 'create table Contacts
(id INTEGER PRIMARY KEY, addr VARCHAR(99))'
- Put scripts publish.sh and query.sh
into the input sandbox of each job:
InputSandbox = { ..., "publish.sh", "query.sh" }
- When a job starts execution, it publishes (after binding to a free port)
its contact information in table Contacts:
/bin/sh publish.sh id hostname:port
- Each job may query the contact address of communication
partner id from table
Contacts:
/bin/sh query.sh id
(Repeat query, if address has not yet been published).
The same principle may be applied in a more sophisticated form
within programs by the use of the R-GMA API.
|
# publish.sh: publish <id> and <contact>
#!/bin/sh
if [ $# -ne 2 ]; then exit 127; fi
$RGMA_HOME/bin/rgma<<EOF
set producer latest
set producer lrp 24 hours
insert into Contacts values ($1, "$2")
EOF
exit 0
# query.sh: query for <id> and print <addr>
#!/bin/sh
if [ $# -ne 1 ]; then exit 127; fi
$RGMA_HOME/bin/rgma<<EOF | tail -n4 | head -n1
| awk '{print $2}' | awk -F, '{print $1}'
set output csv
select addr from Contacts where id=$1
EOF
exit 0
|
|