1 / 28

Using Cyberaide JavaScript to develop Ajax based Grid Apps – A Tutorial for Grid App Developers

Using Cyberaide JavaScript to develop Ajax based Grid Apps – A Tutorial for Grid App Developers. Gregor von Laszewski Fugang Wang Jun 22, 2009. Agenda. Prerequisite to use the framework for your development How to use the JavaScript API to interact with Grid

salim
Download Presentation

Using Cyberaide JavaScript to develop Ajax based Grid Apps – A Tutorial for Grid App Developers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using Cyberaide JavaScript to develop Ajax based Grid Apps – A Tutorial for Grid App Developers Gregor von Laszewski Fugang Wang Jun 22, 2009

  2. Agenda • Prerequisite to use the framework for your development • How to use the JavaScript API to interact with Grid • Authentication; job/workflow submission and status monitor; file transfer, etc. • Mashup with other useful resources • Expand the mediator functionality while reusing the architecture

  3. Prerequisite to use the framework for your development • How to use the JavaScript API to interact with Grid • Authentication; job/workflow submission and status monitor; file transfer, etc. • Mashup with other useful resources • Expand the mediator functionality while reusing the architecture

  4. Please setup the three-tier cyberaide JavaScript framework first. A full instruction can be found at: http://cyberaide.googlecode.com/svn/trunk/project/javascript/README.txt • The framework has Mediator service, Agent, and a web client[1]. Your app will be a web client while based on the Cyberaide JavaScript API. • [1] von Laszewski, G., Wang, F., Younge, A., He, X., Guo, Z., & Pierce, M. (2008). Cyberaide JavaScript: A JavaScript Commodity Grid Kit. Paper presented at the GCE08 at SC08, Austin, TX

  5. Agenda • Prerequisite to use the framework for your development • How to use the JavaScript API to interact with Grid • Authentication; job/workflow submission and status monitor; file transfer, etc. • Mashup with other useful resources • Expand the mediator functionality while reusing the architecture

  6. The usage of the Cyberaide JavaScript toolkit is shown through code snipes. The code itself is not runnable. Please setup the three-tier cyberaide JavaScript framework first as mentioned previously, and put the code snipes into your code where you want to fulfill the functionality. An Ajax Teragrid portal example developed based on the architecture and JavaScript API

  7. How to authenticate through the Cyberaidejs? // construct authenticator object for authentication using myproxy // make sure to use the attributes keys specified here. var auth = org.cyberaide.js.jsAuthenticator(url); auth.setAttribute("host", "myproxy.teragrid.org"); auth.setAttribute("port", 7512); auth.setAttribute("user", ’YOURTGUSERNAME'); auth.setAttribute("password", ’YOURPASSWORD'); // currently only 'myproxy' is supported auth.setProvider("myproxy");

  8. // construct cyberaidejs object by pointing to the Agent service's url // Your call through the JavaScript API will be conducted to this Web service // Refer to the installation instruction for the ‘url’. varurl = "../axis2/services/AgentService”; //If you followed each step, the url should be like this varcyberaidejs = new org.cyberaide.js.jsUtil(url); // authentication cyberaidejs.authenticate(auth, authResponse); // authResponse is the callback function handler

  9. /* * the authenticate callback function */ function authResponse(ret) { if(ret){ //authenticated successfully! //put your code here } else{ //authentication failed //put your code here } }

  10. How to submit a job to remote machine to execute? // define the job object //make sure to use the attributes keys specified here. varexecObj = new org.cyberaide.js.jsExecutable(); execObj.setAttribute("cmd", "/bin/ls"); execObj.setAttribute("arg", "-l"); execObj.setAttribute("rHost", 'REMOTEHOST'); execObj.setAttribute("stdout", "lsoutput"); execObj.setAttribute("provider", "GT4"); // construct cyberaidejs object by pointing to the agent service's url varcyberaidejs = new org.cyberaide.js.jsUtil(url);

  11. // construct a remote job through the executable object varstrProj = cyberaidejs.constructRemoteJob(execObj); // submit the job by specifying constructed job specification, callback function. // you must be in authenticated status and in a valid session. cyberaidejs.submit(strProj, submitResponse); // submitResponse is the callback function handler

  12. /* * callback function of submission */ function submitResponse(ret) { if(ret > 0){ //job submitted and job id returned. //your job id is 'ret', in Number format //do something here. } else { //job submission failed. //do something here. } }

  13. How to submit a workflow (in Karajan format)? // Construct cyberaidejs object by pointing to the agent service's url varcyberaidejs = new org.cyberaide.js.jsUtil(url); // Construct your Karajan workflow // varstrProj = ...; // assign the Karajan workflow to this string and submit it. // you must be in authenticated status and in a valid session. cyberaidejs.submit(strProj, submitResponse, null); // callback function could be the same as in job submission

  14. How to query job/workflow list that user submitted? // construct cyberaidejs object by pointing to the agent service's url varcyberaidejs = new org.cyberaide.js.jsUtil(url); // Invoke the list function //do this only after you have been authenticated and in a valid session. cyberaidejs.list(listResponse); // listResponse is the callback function handler

  15. /* * call back for submitted jobs listing */ function listResponse(jsonRet){ if(jsonRet != null){ varjsonRetObj = eval("(" + jsonRet + ")"); varwfids = jsonRetObj.wfids; varnumIds = wfids.length; //now you got the jobs list with 'numIds' items in an array wfids //do something here. } } // the jsonRet is in JSON format {"wfids": String[]}

  16. How to query job/workflow execution status? // construct cyberaidejs object by pointing to the agent service's url varcyberaidejs = new org.cyberaide.js.jsUtil(url); // and then query the status with its id // do this only after you have submitted some job/workflow cyberaidejs.statusQuery(wfid, statusQueryResponse); // statusQueryResponse is the callback function handler

  17. /* * callback function of status query, to display the status info */ function statusQueryResponse(jsonRet){ if(jsonRet != null){ varjsonRetObj = eval("(" + jsonRet + ")") varwfid = jsonRetObj.wfid; var status = jsonRetObj.status; //now you get the workflowid and its current status, in a 'Number' format, //representing jobs finished so far in the workflow. //do something here. } } // the jsonRet is in JSON format {"wfid":String,"status":String}

  18. How to query output fileNAME of a job/workflow? // construct cyberaidejs object by pointing to the agent service's url varcyberaidejs = new org.cyberaide.js.jsUtil(url); // call the queryOutput function // do this only after you have been authenticated and in a valid session. cyberaidejs.queryOutput(wfid, queryOutputResponse); // statusQueryResponse is the callback function handler

  19. /* * display the returned output file names appropriately and add content retrieve links */ function queryOutputResponse(jsonRet){ if(jsonRet != null){ varjsonRetObj = eval("(" + jsonRet + ")"); varwfid = jsonRetObj.wfid; varresultFiles = jsonRetObj.resultFiles; //the result output file names for job/workflow with id 'wfid' have been stored //into array 'resultFiles' //you can display the filenames or get the REAL output through getOutput() method. } return false; } // the jsonRet is in JSON format {"wfid":String,"outputFiles":String[]}

  20. How to get a specific output from a job/workflow execution? // construct cyberaidejs object by pointing to the agent service's url varcyberaidejs = new org.cyberaide.js.jsUtil(url); // call the getOutput function // do this only after you have been authenticated and in a valid session. // wfid and filename specified job/workflow id and (one of) its output filename obtained through queryOutput cyberaidejs.getOutput(wfid, filename, getOutputResponse); // getOutputResponse is the callback function handler

  21. /* * processing the returned output */ function getOutputResponse(jsonRet){ if(jsonRet != null){ varjsonRetObj = eval("(" + jsonRet + ")"); varwfid = jsonRetObj.wfid; var filename = jsonRetObj.filename; var content = jsonRetObj.content; //now you have got the output content of an output file for the job 'wfid' //your code for further processing goes herer.. } } // the jsonRet is in JSON format {"wfid":String,"outputfilename":String,"output":String}

  22. How to do file transfer through cyberaidejs? // construct cyberaidejs object if not done yet varcyberaidejs = new org.cyberaide.js.jsUtil(url); // Invoke transfer function // source and dest are all URI per gridftp supported format, like file://PATH, gsiftp://HOST:PORT/PATH/TO/FILE // when using file:///~, it represents the user's remote home directory at where the mediator service resides, // using gsiftp://HOST:PORT/PATH/TO/FILE to point to the location at other remote resources like those from Teragrid // do this only after you have been successfully authenticated and is in valid session cyberaidejs.transfer(source, dest, transferResponse);

  23. /* * the transfer callback function */ function transferResponse(ret, updateloc) { if(!ret){ //Transfered successfully! //Your code goes here } else{ //Transfer failed! //Your code goes here } }

  24. Prerequisite to use the framework for your development • How to use the JavaScript API to interact with Grid • Authentication; job/workflow submission and status monitor; file transfer, etc. • Mashup with other useful resources • Expand the mediator functionality while reusing the architecture

  25. You can develop sophisticated Grid app/portal/scientific gateway in Ajax style based on the JavaScript API. But you also can reuse the architecture and mashup useful resources in either server side or client side. • Mashup in client side. You could integrate resources from other sites in your JavaScript/DHTML code, while using the framework and API. • Mashup in server side. Due to the Cross-site restriction of JavaScript, sometime you have to mashup resources/services in server side. You could integrate them into the Agent service java code, or using other server side tools to process the resources/services and access them through your client JavaScript.

  26. Prerequisite to use the framework for your development • How to use the JavaScript API to interact with Grid • Authentication; job/workflow submission and status monitor; file transfer, etc. • Mashup with other useful resources • Expand the mediator functionality while reusing the architecture

  27. You also can expand the functionalities of the Mediator service, while using the same architecture. In this way the expanded functionalities could be easily accessed by a web client through the framework. The possible functionalities could include supporting other Grid middle ware, supporting other HPC means like CUDA, and cloud computing related technologies like VM management & Amazon EC2. Some of these activities are being conducted or planned to be researched in our lab.

  28. THANKS! For more info, please visit: http://cyberaide.org/projects/cyberaide/cyberaide-javascript laszewski@gmail.com

More Related