Presentation is loading. Please wait.

Presentation is loading. Please wait.

Grid Initiatives for e-Science virtual communities in Europe and Latin America Elisa Ingrà

Similar presentations


Presentation on theme: "Grid Initiatives for e-Science virtual communities in Europe and Latin America Elisa Ingrà"— Presentation transcript:

1 www.gisela-grid.eu Grid Initiatives for e-Science virtual communities in Europe and Latin America Elisa Ingrà (elisa.ingra@ct.infn.it)elisa.ingra@ct.infn.it Consortium GARR Joint School for Application Porting to Science Gateways Mexico City 18-26.06.2012 Hostname-portlet Template

2 www.gisela-grid.eu Portlets Standard JSR168/286 Interaction between jsp pages and java code JSP uses <form… statements to send parameters to Java code Java code extends class GenericPortlet overriding methods: –Init, doView, doHelp, doEdit, processAction Bogotá, 06.06.2012 JSP pageJava code Application Server (Glassfish) <jsp:useBean <jsp:useBean Class Extends GenericPortlet … Class Extends GenericPortlet …

3 www.gisela-grid.eu Portlet files (root) build.xml customize.sh docroot/ WEB_INF/ css/ images/ js/ jsp_page_1.jsp … jsp_page_n.jsp Bogotá, 06.06.2012 Used by ‘ant’ to compile and deploy the portlet Define here JSP’s styles JSP image files Portlet JSP pages A script file used in order to customize your portlet

4 www.gisela-grid.eu Portlet files WEB_INF/ lib/ Job/ liferay-display.xml liferay-plugin-package.properties liferay-portlet.xml portlet.xml src/ /code.java tld/ Bogotá, 06.06.2012 Jar Library directory (local scope) Job files (Custom dir) Java source files Portlet configuration files Portlet configuration files XML structure file

5 www.gisela-grid.eu Parameters exchange (JSP->Java) Portlet modes: –VIEW – Used for normal portlet operations -> calls processAction() –EDIT – Used to configure portlet parameters -> calls doEdit() –HELP – Used to show help information -> calls doHelp() Bogotá, 06.06.2012 <form action=action="<portlet:actionURL portletMode="view"> <portlet:param name="param_name_1" value="param value 1"/> … <portlet:param name="param_name_n" value="param value n"/> … <form action=action="<portlet:actionURL portletMode="view"> <portlet:param name="param_name_1" value="param value 1"/> … <portlet:param name="param_name_n" value="param value n"/> … processAction(ActionRequest request,… doView/doHelp/doEdit(RenderRequest request,… // To obtain the parameter just set … String param_i = request.getParameter("param_name_i"); processAction(ActionRequest request,… doView/doHelp/doEdit(RenderRequest request,… // To obtain the parameter just set … String param_i = request.getParameter("param_name_i");

6 www.gisela-grid.eu Parameters exchange (Java->JSP) From Java code: Inside the JSP load values with: Bogotá, 06.06.2012 <% // To load variables from Portlet Class … %> " scope="request"/> <% // To reference a param value %> <% // To load variables from Portlet Class … %> " scope="request"/> <% // To reference a param value %> doView/doHelp/doEdit(RenderRequest request,… // To send the parameter just call … request.setAttribute("param_name_j", param_name_j); doView/doHelp/doEdit(RenderRequest request,… // To send the parameter just call … request.setAttribute("param_name_j", param_name_j);

7 www.gisela-grid.eu Portlet workflow Bogotá, 06.06.2012 JSP page doView ProcessAction ACTION/VIEW Architecture Hostname code provides two Enum types: Actions and Views For each Action a different View can be selected and easily managed by switch statements The two enumerated types used to manage the portlet behavior Between portlet methods: ‘doView and ProcessAction’. Jsp/Java Variable: ‘ PortletStatus ’ doView JSP page ProcessAction JSP page default init

8 www.gisela-grid.eu Portlet Session data Bogotá, 06.06.2012 JSP page doView ProcessAction Two objecst: actionRequest processAction() renderRequest doView() doHelp() doEdit() init ProcessAction sends parameters to RenderRequest through: ActionResponse (2 nd parameter of ProcessAction ) response.setRenderParameter("param_name_y", param_value_y); doView/doHelp/doEdit (1 st parameter) RenderResponse param_name_w= request.getParameter ("param_name_w"); Parameters to jsp and select it: request.setAttribute("JobId", inputJobId); getPortletContext().getRequestDispatcher(”/.jsp");

9 www.gisela-grid.eu hostname-portlet example Portlet to send a test job into a distributed infrastructure –Input:  Input file or a text  A human readable job identifier –Ouput  Hostname of running machine  File containing information about the running machine Portlet status –INPUT (Shows the input fields) –SUBMIT (Shows the job submission feedback) –Jsp/Java variable ‘ PortletStatus ’ Bogotá, 06.06.2012 input.jsp submit.jsp

10 www.gisela-grid.eu Hostname Action/View enums Actions –ACTION_INPUT –ACTION_SUBMIT Views (Possible portlet views) –VIEW_INPUT –VIEW_SUBMIT Bogotá, 06.06.2012 Default Action Simply forward portlet status to the doView() in: RenderParameter Default Action Simply forward portlet status to the doView() in: RenderParameter

11 www.gisela-grid.eu Hostname Action/View Actions –ACTION_INPUT –ACTION_SUBMIT Views –VIEW_INPUT –VIEW_SUBMIT Bogotá, 06.06.2012 View Select the INPUT form view input.jsp (default view mode) View Select the INPUT form view input.jsp (default view mode)

12 www.gisela-grid.eu Hostname Action/View Actions –ACTION_INPUT –ACTION_SUBMIT Views –VIEW_INPUT –VIEW_SUBMIT Bogotá, 06.06.2012 This action will submit the hostname job into the distributed infrastructure This action will submit the hostname job into the distributed infrastructure " method="post”>

13 www.gisela-grid.eu Hostname Action/View Actions –ACTION_INPUT –ACTION_SUBMIT Views –VIEW_INPUT –VIEW_SUBMIT Bogotá, 06.06.2012 Select the proper view showing the Information page that shows the job has been submitted Select the proper view showing the Information page that shows the job has been submitted

14 www.gisela-grid.eu Portlet Initialization portlet.xlm contains portlet initialization parameters init parameter name init parameter value The init() method uses to load Portlet’ default parameter values Some of the default parameters values will be used to load portlet default preferences Bogotá, 06.06.2012 public void init() throws PortletException { // Load default values from portlet.xml init_PortletVersion = getInitParameter(“init parameter name"); … public void init() throws PortletException { // Load default values from portlet.xml init_PortletVersion = getInitParameter(“init parameter name"); …

15 www.gisela-grid.eu hostname’ To make parameter management easier all values are threated as String type init_PortletVersion - Portlet version number init_bdiiHost - Information system service (ldap://...:2170) init_wmsHost - Infrastructure resource manager (wms://...:7443/glite_wms_wmproxy_server) init_pxServerHost - Hostname of Robot proxy server (myproxy.ct.infn.it not used yet) init_pxRobotId - Id of the robot certificate init_pxRobotVO - Infrastructure virtual organization init_pxRobotRole - Role of generated proxy init_pxUserProxy - Standard proxy file (instead of Robots) init_pxRobotRenewalFlag - Allows automatic job renewal mechanism init_SciGwyAppId - Science Gateway application identifier '9' for GILDA VM tester application GridEngine' User tracking database (UTDB) access credentials –init_SciGwyUserTrackingDB_Hostname –init_SciGwyUserTrackingDB_Username –init_SciGwyUserTrackingDB_Password –init_SciGwyUserTrackingDB_Database – Users should not use Direct DB access to UTDB init_JobRequirements - Application job requirements init_pilotScript - Application pilot script Bogotá, 06.06.2012

16 www.gisela-grid.eu Hostname Portlet preferences getPreferences method called by both: – doView and processAction Bogotá, 06.06.2012 private void getPreferences( ActionRequest actionRequest,RenderRequest renderRequest) { PortletPreferences prefs=null; if(null!=actionRequest) prefs = actionRequest.getPreferences(); else if(null != renderRequest) prefs = renderRequest.getPreferences(); if (null != prefs) { // The second parameter assigns a default value pref_value=prefs.getValue(" ", " "); private void getPreferences( ActionRequest actionRequest,RenderRequest renderRequest) { PortletPreferences prefs=null; if(null!=actionRequest) prefs = actionRequest.getPreferences(); else if(null != renderRequest) prefs = renderRequest.getPreferences(); if (null != prefs) { // The second parameter assigns a default value pref_value=prefs.getValue(" ", " ");

17 www.gisela-grid.eu Job Submission (1/4) // Job details String executable="/bin/sh"; // Application executable String arguments="pilot_script.sh"; // executable' arguments String outputPath="/tmp/"; // Output Path String outputFile="application.out"; // Application stdout String errorFile="application.err"; // Application stderr // InputSandbox (string with comma separated list of file names) String inputSandbox= appServerPath +"/WEB-INF/job/pilot_script.sh” +","+ ; // OutputSandbox (string with comma separated list of file names) String outputSandbox="generated_output_file"; Bogotá, 06.06.2012

18 www.gisela-grid.eu Job Submission (2/4) // Software tags String jdlRequirements[] = pref_JobRequirements.split(";"); int numRequirements=0; for(int i=0; i<jdlRequirements.length; i++) if(!jdlRequirements[i].equals("")) { jdlRequirements[numRequirements] = "JDLRequirements=("+jdlRequirements[i]+")"; numRequirements++; } // Instanciate the JSAGA object JSagaJobSubmission tmpJSaga = new JSagaJobSubmission(); tmpJSaga.setBDII(bdiiHost);// Infrastructure top BDII Bogotá, 06.06.2012

19 www.gisela-grid.eu Job Submission (3/4) // Proxy renewal flag if((pref_pxRobotRenewalFlag.toLowerCase()).equals("true")) pxRobotRenewalFlag=true; else pxRobotRenewalFlag=false; // Associate a valid proxy (Robot/UserProxy) // Specifying a path for local proxy it will be used instead if(pxUserProxy==null || pxUserProxy.equals("")) { tmpJSaga.useRobotProxy( pxRobotId,pxRobotVO,pxRobotRole,pxRobotRenewalFlag ); else tmpJSaga.setUserProxy(pxUserProxy); Bogotá, 06.06.2012

20 www.gisela-grid.eu Job Submission (4/4) tmpJSaga.setExecutable(executable); // Specify the executeable tmpJSaga.setArguments(arguments); // Specify the application' arguments tmpJSaga.setOutputPath(outputPath); // Specify the output directory tmpJSaga.setInputFiles(inputSandbox); // Setup input files (InputSandbox) tmpJSaga.setOutputFiles(outputSandbox); // Setup output files (OutputSandbox) tmpJSaga.setJobOutput(outputFile); // Specify the std-outputr file tmpJSaga.setJobError(errorFile); // Specify the std-error file if(numRequirements>0) tmpJSaga.setJDLRequirements(jdlRequirements); // Assign requirements // Submit the job // If a WMS is specified the call to Job submission changes if(wmsHost!=null && !wmsHost.equals("")) tmpJSaga.submitJobAsync(username,hostUTDB,applicationId,wmsHost,jobIdentifier ); else tmpJSaga.submitJobAsync( username,hostUTDB,applicationId,jobIdentifier ); Bogotá, 06.06.2012

21 www.gisela-grid.eu From hostname to your portlet https://gilda.ct.infn.it/wikimain/-/wiki/Main/hostname-portlet Add your application in the DB –mysql -utracking_user -pusertracking userstracking –mysql> select * from GridOperations; –mysql> insert into GridOperations (portal,description) VALUES ('liferay.com','myapp'); Extract hostname portlet form svn svn checkout http://svn.ct.infn.it/svn/liferay/trunk/gilda/mi-hostname-portlethttp://svn.ct.infn.it/svn/liferay/trunk/gilda/mi-hostname-portlet ‘ cd ’ inside the hostname-portlet directory and try to compile it with the command: ant deploy If the compilation is successful create a physical copy of the portlet directory source code –cp –r hostname-portlet -portlet Bogotá, 06.06.2012

22 www.gisela-grid.eu Custumize.sh Customize your portlet editing customize.sh script: # Author' information # Used to fill-up portlet' licence information AUTH_EMAIL=diego.scardaci@ct.infn.it AUTH_NAME='Diego Scardaci' AUTH_INSTITUTE='INFN' APP_NAME=mysample APP_VERSION=1.0 BASE_CLASS=it.infn.ct (cancellare il vecchio) #init_sciGwyAppId (Refer to UserTracking database table 'GridInteractions') UTDB_APPID=9 # # Infrastructure settings (begin) # INIT_NUMINFRASTRUCTURES=1 #------------------ #1st Infrastructure #------------------ #nameInfrastructure INI_1_NAMEINFRA='GISELA infrastructure' #acronymInfrastructure INI_1_ACRONYM='GISELA' #init_bdiiHost # specify the information system BDII in the form ldap:// : INI_1_BDIIHOST='ldap://bdii.eela.ufrj.br:2170' Bogotá, 06.06.2012

23 www.gisela-grid.eu Customize.sh #init_wmsHost # The wms host can be obtained from an UI with the gLite command line # lcg-infosites --vo eumed wms # INI_1_WMSHOST='wms://wms.eela.ufrj.br:7443/glite_wms_wmproxy_server' #init_pxServerHost INI_1_PXHOST='myproxy.ct.infn.it' #init_pxServerPort INI_1_PXPORT=8082 #init_pxServerSecure INI_1_PXSECURE=true #init_pxRobotId INI_1_ROBOTID=21873 #init_pxRobotVO INI_1_ROBOTVO=prod.vo.eu-eela.eu #init_pxRobotRole INI_1_ROBOROLE=prod.vo.eu-eela.eu #init_pxRobotRenewalFlag (true/false) INI_1_RENEWALFLAG=true PORTLET_CATEGORYNAME=GILDA Execute the script: –chmod u+x customize.sh –./customize.sh Bogotá, 06.06.2012

24 www.gisela-grid.eu Modify icon and applogo –/home/liferayadmin/liferay-plugins-sdk/portlets/mysample- portlet/docroot/icon.png –/home/liferayadmin/liferay-plugins-sdk/portlets/mysample- portlet/docroot/images/AppLogo.png Modify submit.jsp and help.jsp in /home/liferayadmin/liferay-plugins- sdk/portlets/mysample-portlet/docroot according to your application Replace pilot_script.sh in /home/liferayadmin/liferay-plugins- sdk/portlets/mysample-portlet/docroot/WEB-INF/job with the pilot_script.sh you developed for your stand-alone code Go to /home/liferayadmin/liferay-plugins-sdk/portlets/mysample- portlet/docroot/WEB-INF/src/ and modify the java file.java Modify the "submitJob" method according to your stand-alone java class Bogotá, 06.06.2012

25 www.gisela-grid.eu Create NetBeans project Open new project and select: Categories: Java web Projects: Web Appliacations with existing sources. Press 'Next' Location: Point Netbeans to locate the portlet directory through the VM shared folder. Press 'Next' Accept any suggestion and proceed Press 'Next' Add other directory places: WEB-INF Content: Select the docroot/WEB-INF directory inside the portlet directory Library folder: point it to docroot/WEB-INF/lib Then press the 'Finish' button and the project will be created Right click on the project name and click on Peferences, then Libraries Select all jars pointed by liferayadmin@ :liferay_libs/ directory Bogotá, 06.06.2012

26 www.gisela-grid.eu Create Eclipse project Download the Eclipse IDE for Java EE Developers; set the Eclipse Workspace to the "portlets" liferay-plugins- SDK directory through the VM shared folder; Select File-> New -> Dynamic Web Porject (or File -> New -> Project... -> Web -> Dynamic Web Project; Fill the Web Dynamic Web Project Wizard with the project name, the default location (only if the default one is not correct), the glassphish target runtime (if doesn't exist create a new one with the New Runtime... wizard), leave the deaflaut values for Dynamic Web module_vesion and Configuration fields and select next, change the Source foders on build path "src" to "docroot/WEB-INF/src", select next and change the Content directory to "docroot", select finish; In order to fix some library dependencies could be necessary add external Jars form the project properties view. Bogotá, 06.06.2012

27 www.gisela-grid.eu References GILDA VM –https://gilda.ct.infn.it/serviceshttps://gilda.ct.infn.it/services GILDA VM Instructions –https://gilda.ct.infn.it/wikimain/-/wiki/Main/GILDA+Liferay+Virtual+Machinehttps://gilda.ct.infn.it/wikimain/-/wiki/Main/GILDA+Liferay+Virtual+Machine hostname portlet template wiki page –https://gilda.ct.infn.it/wikimain/-/wiki/Main/hostname-portlethttps://gilda.ct.infn.it/wikimain/-/wiki/Main/hostname-portlet JQuery useful link –http://jquery.com/ HTML useful link –http://www.w3schools.com/ Bogotá, 06.06.2012

28 www.gisela-grid.eu Questions? Bogotá, 06.06.2012


Download ppt "Grid Initiatives for e-Science virtual communities in Europe and Latin America Elisa Ingrà"

Similar presentations


Ads by Google