Thursday, July 23, 2009

Karajan and GridFTP

I owe big thanks to Mihael Hategan for some help here.

Karajan is a workflow system that is part of the Java COG Kit and also powers the Swift system. You can get it in the 4.1.5 version of the COG Kit, but this version is out of date, so it is better to get the code from the SourceForge SVN:

View it: http://cogkit.svn.sourceforge.net/viewvc/cogkit/trunk/current/src/cog/

Get it: svn co https://cogkit.svn.sourceforge.net/svnroot/cogkit/trunk/current/src/cog

Compile with ant. Here's an example script that will run gridftp on a remote host and return the file listing and metadata to your screen. Run it with $COG_INSTALL_PATH/bin/cog-workflow gridftpExample.xml:

<project>
<include file="cogkit.xml"/>

<set name="l">
<file:list dir="." host="gridftp-hg.ncsa.teragrid.org" provider="gridftp"/>
</set>
<for name="file" in="{l}">
<set names="type,permissions,size,modified">
<file:info file="{file}"/>
</set>
<print message="{file} Type:{type} Permissions:{permissions} Size:{size} Modified:{modified}"/>
</for>
</project>


Mihael actually added some of these fields on my request (they are part of the underlying code).

Karajan also has its own scripting language that is much less awkward than XML for expressing the scripts:

import("sys.k")
import("task.k")

element(niceType, [type]
if (
type == FILETYPE:FILE, "File"
type == FILETYPE:DIRECTORY, "Directory"
type == FILETYPE:SOFTLINK, "Softlink"
type == FILETYPE:DEVICE, "Device"
"Unknown"
)
)

files := file:list(dir=".",host="gridftp-hg.ncsa.teragrid.org",provider="GT2")

for(f, files,
[type, perm, size, modified] := file:info(f)
print("name: {f}, type: ", niceType(type),
" ({type}), size: {size}, modified: {modified}, permissions: {perm}")
)

No comments: