-
Notifications
You must be signed in to change notification settings - Fork 0
Writing your first Hello World from a DTFA
Now that you've probably gone through writing the "Hello World" test, moving to writing the same thing from a DTFA is quite simple and only requires understanding a few simple things about how DTF handles DTFA's and allows you to control what executes on them. The first thing you have to do to use a DTFA is to request this component from the DTFC and this is done by using the tag lockcomponent to identify the exact DTFA you're looking for.
The lockcomponent tag uses the underlying attributes (if any are specified) to find an exact match for the component you're looking for. If the DTFC does not have the component required then it will return an error the DTFX and let it report the lack of the component that you were trying to lock. Here's the first part of our test where we lock the component we want and we name it DTFA1:
<?xml version="1.0" encoding="UTF-8"?>
<script xmlns="http://dtf.org/v1" name="remote_helloworld">
<info>
<author>
<name>Rodney Gomes</name>
<email>rlgomes@yahoo-inc.com</email>
</author>
<description>A simple Hello World in DTF</description>
</info>
<local>
<lockcomponent id="DTFA1"/>
</local>
</script>
At this point writing to the console on the agent is as easy as wrapping our previous log tag with the component tag and specifying the correct id for the component to execute that request on, like so:
<?xml version="1.0" encoding="UTF-8"?>
<script xmlns="http://dtf.org/v1" name="remote_helloworld">
<info>
<author>
<name>Rodney Gomes</name>
<email>rlgomes@yahoo-inc.com</email>
</author>
<description>A simple Hello World in DTF</description>
</info>
<local>
<lockcomponent id="DTFA1"/>
</local>
<component id="DTFA1">
<log>Hello World!</log>
</component>
</script>
The above test requires more than just a DTFX so you'll have to startup the following components:
First we start up the DTFC:
> ./ant.sh run_dtfc Buildfile: build.xml init: [echo] Creating log dir ./logs/19-06-2010.10.56.07 [mkdir] Created dir: /.../dtf/build/dtf/dist/logs/19-06-2010.10.56.07 run_dtfc: [java] INFO 19/06/2010 10:56:07 DebugServer - Listening at 127.0.0.1:40000 [java] INFO 19/06/2010 10:56:07 Comm - Host address [127.0.0.1] [java] INFO 19/06/2010 10:56:07 CommRMIServer - Listening at [20000] [java] INFO 19/06/2010 10:56:07 Comm - DTFC Setup.
Then we start up a DTFA and connect that to the already running DTFC:
> ./ant.sh run_dtfa Buildfile: build.xml init: [echo] Creating log dir ./logs/19-06-2010.10.57.05 [mkdir] Created dir: /.../dtf/build/dtf/dist/logs/19-06-2010.10.57.05 run_dtfa: [echo] Starting DTFA [echo] logging to ./logs/19-06-2010.10.57.05/dtfa.*.log [java] INFO 19/06/2010 10:57:06 DebugServer - Listening at 127.0.0.1:40001 [java] INFO 19/06/2010 10:57:06 Comm - Host address [127.0.0.1] [java] INFO 19/06/2010 10:57:06 CommRMIServer - Listening at [30000] [java] INFO 19/06/2010 10:57:06 Comm - DTFA Setup. [java] INFO 19/06/2010 10:57:06 CommRMIClient - Registering Connect {port=30000,dtf.debug.port=40001,dtf.os.version=2.6.32-22-generic-pae,dtf.node.user=rlgomes,dtf.tunneled=false,dtf.os.arch=i386,dtf.node.home=/home/rlgomes/yahoo/workspace/op...,dtf.node.type=dtfa,hostname=127.0.0.1,dtf.node.host=127.0.0.1,dtf.os.name=Linux} [java] INFO 19/06/2010 10:57:06 Rename - Node name set to: dtfa-0 [java] INFO 19/06/2010 10:57:06 CommRMIClient - Connected to DTFC
Now we're ready to run the test itself:
> ./ant.sh run_dtfx -Ddtf.xml.filename=tests/examples/remote_helloworld.xml Buildfile: build.xml init: [echo] Creating log dir ./logs/19-06-2010.10.57.40 [mkdir] Created dir: /.../dtf/build/dtf/dist/logs/19-06-2010.10.57.40 run_dtfx: [java] INFO 19/06/2010 10:57:40 DebugServer - Listening at 127.0.0.1:40002 [java] INFO 19/06/2010 10:57:40 Comm - Host address [127.0.0.1] [java] INFO 19/06/2010 10:57:40 CommRMIServer - Listening at [30001] [java] INFO 19/06/2010 10:57:40 Comm - DTFX Setup. [java] INFO 19/06/2010 10:57:41 CommRMIClient - Registering Connect {port=30001,dtf.debug.port=40002,dtf.os.version=2.6.32-22-generic-pae,dtf.node.user=rlgomes,dtf.tunneled=false,dtf.os.arch=i386,dtf.node.home=/home/rlgomes/yahoo/workspace/op...,dtf.node.type=dtfx,hostname=127.0.0.1,dtf.node.host=127.0.0.1,dtf.os.name=Linux} [java] INFO 19/06/2010 10:57:41 Rename - Node name set to: dtfx-1 [java] INFO 19/06/2010 10:57:41 CommRMIClient - Connected to DTFC [java] INFO 19/06/2010 10:57:41 Lockcomponent - Component locked Lock {id=dtfa-0,port=30000,dtf.debug.port=40001,dtf.os.version=2.6.32-22-generic-pae,dtf.node.user=rlgomes,dtf.tunneled=false,dtf.os.arch=i386,dtf.node.home=/home/rlgomes/yahoo/workspace/op...,dtf.node.type=dtfa,hostname=127.0.0.1,dtf.node.host=127.0.0.1,dtf.os.name=Linux} as DTFA1 [java] INFO 19/06/2010 10:57:41 DTFNode - Shutting down dtfx BUILD SUCCESSFUL Total time: 6 seconds
On the DTFA side you'll see the following appear in the logs:
[java] INFO 19/06/2010 10:57:41 SetupAgent - This agent [DTFA1] in use by [dtfx-1] [java] WARN 19/06/2010 10:57:41 Storage - Storage path does not exist [remote-storage/dtfa-0] will create. [java] INFO 19/06/2010 10:57:41 Log - Hello World! [java] INFO 19/06/2010 10:57:41 RemoteStorage - Cleaning up remote storages [java] INFO 19/06/2010 10:57:41 ReleaseAgent - This agent is no longer in use by anyone.
This test can also be found at tests/examples/remote_helloworld.xml for future reference.