Welcome to the guide on how to code for the MiG One-Click environment. The tour begins with a description of framework limitations, followed by the MiG One-Click job execution flow, ending with a code generation guide.
The flow of an MiG One-Click job execution differs from a normal resource as it must apply to the java applet security model and therefore can't store any files locally on the resource. This has left us with the following execution flow:
Browser (or console) contacts the MiG server.
The MiG server creates/recognize the contacting resource and responds with information necessary for the resource to load the MiG One-Click environment.
The browser (or console) then loads the MiG One-Click environment from the MiGOneclickCodebase.jar
located on the MiG server, this is done through https.
All jobs must extend the MiG.oneclick.Job class. This class provides methods for writing to stderr/stdout of the job and retrieving MiG.oneclick.File objects used for file I/O on files in the MiG homedir of the job submitter. The difference between a normal java application and a MiG One-Click job are the following:
We will now run through an HelloMiGOneClickWorld
sample which copies a file, writes the status of the filecopy to stdout and errors to stderr.
HelloMiGOneClickWorld
The following code is a simple hello world app:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | import MiG.oneclick.File; import MiG.oneclick.FileException; public class HelloMiGOneClickWorld extends MiG.oneclick.Job { public void MiG_main(String[] argv) { int i; int byte_counter; long starttime; long endtime; File in_file = null; File out_file = null; out("\n\nArgs:\n"); for (i=0; i<argv.length; i++ ) out(argv[i] + "\n"); byte_counter = 0; try { starttime = System.currentTimeMillis(); in_file = this.open_file(argv[0], File.R); if (in_file.getMode() != File.R) { throw new FileException("Could'nt open file for read: " + argv[0]); } out_file = this.open_file(argv[1], File.W); if (out_file.getMode() != File.W) throw new FileException("Could'nt open file for write: " + argv[1]); i=in_file.read(); while( i!= -1 ) { out_file.write(i); byte_counter = byte_counter + 1; i=in_file.read(); } out_file.close(); in_file.close(); endtime = System.currentTimeMillis(); out("\nCopyed " + byte_counter + " bytes."); out("\nCopy time: " + (endtime-starttime)/1000 + " seconds."); } catch (Exception e) { err("\nHelloMiGOneClickWorld CAUGHT:\n" + e.getMessage()); err(MiG.oneclick.Exception.dumpStackTrace(e)); if (in_file != null) err("\n\nin_file errors:" + in_file.getErrorMessages()); if (out_file != null) err("\n\nout_file errors:" + out_file.getErrorMessages()); } } } |
which you can download as HelloMiGOnceClickWorld.java.
The interesting parts of this code are the following lines:
HelloMiGOneClickWorld
You need to download the MiGOneclickCodebase.jar archive if you haven't done so already. It contains the entire MiG.oneclick package needed for compilation.
javac -classpath MiGOneClickCodebase.jar:. HelloMiGOneClickWorld.java
As for now all MiG One-Click binaries should have the root path $MIGHOME/jvm on the MiG server, to create this path use the web interface or use:
migmkdir.sh jvm
To upload the newly generated HelloMiGOneClickWorld.class
use the web interface or use:
migput.sh HelloMiGOneClickWorld.class jvm/
To submit a HelloMiGOneClickWorld
job create a mRSL file like this:
HelloMiGOneClickWorld infile outfile ::NOTIFY:: jabber: you@jabber.dk ::INPUTFILES:: ::OUTPUTFILES:: ::EXECUTABLES:: ::MEMORY:: 10 ::DISK:: 1 ::CPUTIME:: 100 ::PLATFORM:: ONE-CLICK ::SANDBOX:: 1
or download the above HelloMiGOneClickWorld.mRSL job specification file.
To submit the job use the web interface or use:
migsubmit.sh HelloMiGOneClickWorld.mRSL
The result of the job can be accessed through the web interface or through:
migget.sh jobid.stdout jobid.stderr jobid.status
Now there is nothing left besides digging into it, good luck.
Wiki: FrontPage
Wiki: Home
Wiki: UserTopics
Wiki: WelcomePage
Wiki: WikiSidebar