Yes, you're doing several things wrong:
1) First, you didn't fill in @machines with your machines. The previous
poster had a comment in the sample code that you needed to do this. Here's
some updated code you can run. It sets my @machines = ( 'local', 'local'
); This means it will submit the process twice to the local machine.
After you have this sample code running, you should set @machines to the
hostnames/IP addresses of the machine(s) where you want the process to
run.
2) You submitted a GET request to the QUEUE service without a WAIT option.
You need the wait option so the QUEUE GET request waits for a message to
be put on your handle's queue.
3) I added some error checking and some more prints that hopefully will
help you better understand what's going on.
use lib qw( ... ); # Path to PLSTAF
use PLSTAF;
my $name = "test";
&STAF::Register($name);
# Fill in @machineList with the hostnames/ip addresses of the machines
# where you want to submit a process start request
my @machines = ( 'local', 'local' );
# my $testList_ref = [EMAIL PROTECTED];
# foreach my $test (@$testList_ref) {
my $submittedProcesses = 0;
my $completedProcesses = 0;
my $command = "notepad";
my $processKey = "MyKey";
my $request = "START COMMAND ".STAF::WrapData($command)."RETURNSTDOUT
STDERRTOSTDOUT NOTIFY ONEND KEY $processKey";
foreach my $machine (@machines)
{
my $rc = STAF::Submit($machine, "PROCESS", $request);
if($rc != $STAF::kOk)
{
print "Error on STAF local PROCESS $request\n";
print "Expected RC: 0\n";
print "Received RC: $rc, Result: $STAF::Result\n";
exit $rc;
}
print "Process handle: $STAF::Result\n";
$submittedProcesses++;
}
do
{
# Wait to get STAF process end messages off the queue
my $rc = STAF::Submit("local", "QUEUE", "GET TYPE STAF/Process/End
WAIT");
if($rc != $STAF::kOk)
{
print "Error on STAF local PROCESS $request\n";
print "Expected RC: 0\n";
print "Received RC: $rc, Result: $STAF::Result\n";
exit $rc;
}
my $mc = STAF::STAFUnmarshall($STAF::Result);
my $rootObj = $mc->getRootObject();
print "\nQueued Message:\n",STAF::STAFFormatObject($rootObj,
$mc),"\n";
my $processEndMsg = $rootObj->{message};
# Check if this message's key is the same as the key you specified
if($processEndMsg->{key} != $processKey)
{
# Ignore since this message was not submitted by you
print "Ignoring this queued message since its key doesn't
match\n";
}
else
{
$completedProcesses++;
# Get process RC
my $processRC = $processEndMsg->{rc};
# Check if the process RC is "0" (if it ran successfull)
if($processRC == "0")
{
print "The process was successful\n";
# Print the data in the stdout/stderr file for the process
print $processEndMsg->{fileList}[0]{data};
}
else
{
print "The process was did not run successfully:
Stdout/Stderr\n";
# Print the data in the stdout/stderr file for the process
print $processEndMsg->{fileList}[0]{data};
}
}
} until $completedProcesses == $submittedProcesses;
print "\nAll $submittedProcesses processes submitted are now complete\n";
Note: You should read the available STAF documentation (e.g. STAF Perl
User's Guide at http://staf.sourceforge.net/current/STAFPerl.htm and the
STAF User's Guide at http://staf.sourceforge.net/current/STAFUG.htm) more
to get a better understanding what what this code is doing. Also, you
have to know Perl.
--------------------------------------------------------------
Sharon Lucas
IBM Austin, [EMAIL PROTECTED]
(512) 838-8347 or Tieline 678-8347
"Avijit Roy" <[EMAIL PROTECTED]>
10/16/2008 01:51 PM
To
"Edmonds, Michael" <[EMAIL PROTECTED]>,
<staf-users@lists.sourceforge.net>
cc
Subject
Re: [staf-users] Is there any way to track submitted request status
completion with basic STAF
I tried with following but didn?t get the expected result. Is there
anything wrong I am doing?
# fill in @machines
use strict;
use Data::Dumper;
use lib qw( ... ); # Path to PLSTAF
use PLSTAF;
my $name = "test";
&STAF::Register($name);
my $requests = 0;
my $command = "notepad";
my $request = "START COMMAND ".STAF::WrapData($command)."ASYNC
RETURNSTDOUT STDERRTOSTDOUT NOTIFY ONEND KEY 100";
foreach my $machine (@machines)
{
if(STAF::Submit($machine, "PROCESS", $request) == $STAF::kOk)
{
$requests++;
}
}
if($requests) # I think this test may be redundent
{
for(1 .. $requests)
{
STAF::Submit("local", "QUEUE", "GET TYPE STAF/PROCESS/END ");
my $result = $STAF::Result;
my $data;
if(STAF::STAFIsMarshalledData($result))
{
my $mc = STAF::STAFUnmarshall($result);
$data = $mc->getRootObject()->{message};
}
else
{
# take care of it
}
print Dumper($data);
# parse it out further to do real work here
}
}
After execution the result
-------------------------------------
$VAR1 = undef;
$VAR1 = undef;
$VAR1 = undef;
- Avi
From: Edmonds, Michael [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 15, 2008 4:18 PM
To: Avijit Roy; staf-users@lists.sourceforge.net
Subject: RE: [staf-users] Is there any way to track submitted request
status completion with basic STAF
that actually is even easier.
in the $request, make sure to use the "ASYNC RETURNSTDOUT STDERRTOSTDOUT
NOTIFY ONEND KEY $some_unique_identifier" keywords (ok, the *STDOUT
keywords are only if you care about the output of the process, but you can
figure that part out). The return code will be there regardless of the
output though.
that way, you don't have to send it asynchronously yourself (the Process
Service will do it for you -- STAF is so Awesome)
then make your request to the QUEUE Service with something like "GET TYPE
STAF/Process/End"
Mike
From: Avijit Roy [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 15, 2008 6:38 PM
To: Edmonds, Michael; staf-users@lists.sourceforge.net
Subject: RE: [staf-users] Is there any way to track submitted request
status completion with basic STAF
I am looking more than the process submition result here.
Suppose I submit the following request using submit2 then how to get
result back that submitted process tasks has completed on machine 1 and
machine2?
$result = $handle->submit2("Machine1", "PROCESS", $request);
$result = $handle->submit2("Machine2", "PROCESS", $request);
From: Edmonds, Michael [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 15, 2008 3:08 PM
To: Avijit Roy; staf-users@lists.sourceforge.net
Subject: RE: [staf-users] Is there any way to track submitted request
statuscompletion with basic STAF
use submit2 (
http://staf.sourceforge.net/current/STAFPerl.htm#Header_Submit2OO) with
STAF::STAFHandle::kReqQueue
then send a Synchronous request to the QUEUE service for the results of
those requests.
From: Avijit Roy [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 15, 2008 5:08 PM
To: staf-users@lists.sourceforge.net
Subject: [staf-users] Is there any way to track submitted request
statuscompletion with basic STAF
Hi,
I am trying to execute some process on 3 different machines from one of
the driver machine. The main goal is after completion the tasks on three
different machines, I want to copy the result file from those three
machines into driver machine and compute the result.
I am using STAF and PERL to do the basic prototype.
My question is after submitting the task using STAF, is there any way to
check that submitted tasks has completed or not?
Here are the following steps which I want to achieve: I am stuck on Step 5
now.
Step 1 - Registering STAF
Step 2 ? Submitting the request on Machine1
Step 3 - Submitting the request on Machine2
Step 4 - Submitting the request on Machine4
Step 5 ? I want to check Step 3, 4 and 5 tasks has completed or not
----------------------------------->? How should I do that?
Step 6 ? If completed all the tasks copy the result file from machine 1,
2, 3 to driver machine
Can anybody please suggest me how to work it out?
Thanks, Avi
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the
world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users