You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Matt Reason <ma...@movielink.com> on 2003/05/15 04:12:03 UTC

Ant-Contrib foreach | parallel not working..


Hello,

I have a target I'd like to call n times.  I've set up a foreach loop
and it works great.  The only issue is it wastes time because one
execution of the target can only happen at one time.  It'd be much more
efficient to run the target in parallel.

The foreach task has a parallel option, but it seems to be ignoring the
fact that I set it to true.  Has anyone else experienced this or,
hopefully, worked around it?

Below is a rough idea the build.  Basically, I have a file with a list
of host names of severs I want to connect to and run a script on.  Since
each server is it's own 'world', it doesn't matter if they are all done
at the same time or not.(other than efficiency).

<target name="deployToServers"/>
  <loadfile property="server_deploys"
srcFile="./properties/server_deploys"/>
  <foreach 
    list="${cms_deploys}" \
    delimiter="&#x0A;" 
    param="thisServer" 
    target="executeRemoteBuildScript" 
    inheritAll="true" 
    parallel="true"/>                
</target> 

<target name="executeRemoteBuildScript">
  <echo message="*********** ${userid}@${thisServer} ***********"/>
  <sshexec 
     host="${thisServer}" 
     username="${userid}" 
     password="${ftp_password}" 
     trust="yes" 
     timeout="800" 
     command=". .profile; cd bin; ant;"/>
</target>


PS, if I do get this to work, what does the output to the screen look
like?  I bet it get's a little crazy.

Thanks in advance for any help,

Matt

Re: Ant-Contrib foreach | parallel not working..

Posted by Sebastien Blanc <Se...@alcatel.com>.
Hi !
if this is ant-contrib, u can check the foreach.java file, it is not a big
one and deliverered with the distribution.
dwled a while ago and this was a synchronous loop. dunno about now, but
check it out if this is ant-contrib u're using.
seb.

Matt Reason wrote:

> Hello,
>
> I have a target I'd like to call n times.  I've set up a foreach loop
> and it works great.  The only issue is it wastes time because one
> execution of the target can only happen at one time.  It'd be much more
> efficient to run the target in parallel.
>
> The foreach task has a parallel option, but it seems to be ignoring the
> fact that I set it to true.  Has anyone else experienced this or,
> hopefully, worked around it?
>
> Below is a rough idea the build.  Basically, I have a file with a list
> of host names of severs I want to connect to and run a script on.  Since
> each server is it's own 'world', it doesn't matter if they are all done
> at the same time or not.(other than efficiency).
>
> <target name="deployToServers"/>
>   <loadfile property="server_deploys"
> srcFile="./properties/server_deploys"/>
>   <foreach
>     list="${cms_deploys}" \
>     delimiter="&#x0A;"
>     param="thisServer"
>     target="executeRemoteBuildScript"
>     inheritAll="true"
>     parallel="true"/>
> </target>
>
> <target name="executeRemoteBuildScript">
>   <echo message="*********** ${userid}@${thisServer} ***********"/>
>   <sshexec
>      host="${thisServer}"
>      username="${userid}"
>      password="${ftp_password}"
>      trust="yes"
>      timeout="800"
>      command=". .profile; cd bin; ant;"/>
> </target>
>
> PS, if I do get this to work, what does the output to the screen look
> like?  I bet it get's a little crazy.
>
> Thanks in advance for any help,
>
> Matt
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org