Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • This three-tiered architecture is depicted above. The figure greatly simplifies most portal systems described in [33] but serves as a conceptual illustration. The portal interface consists of Web interfaces that work with remote services through the service tier. The portal (presentation) layer not only must manage user information but also maintains “client stubs” that interact with a usually remote service tier. In the figure, the top-most horizontal thread illustrates a typical three-tiered scenario from e-business, in which the portal contacts the remote database through a client-server system. The server in turn contacts the database. The middle thread indicates a second user portal scenario in which a “portal client stub” accesses a Grid service through a standard Grid protocol. This service (such as a resource broker accessed through GRAM) in turn spawns a job on a High Performance Computer (HPC) system. The final thread illustrates portal access to Grid specific data and information services such as the Storage Resource Broker (SRB) [44] [45]. This architecture has been widely adopted, and from this we conclude that computing portal architectures are well established, with a range of standard services for accessing the Grid through such systems as the Java [46] and Perl [47] CoG kits.
  • IRIS_Portals_Pierce.ppt

    1. 1. Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University [email_address]
    2. 2. Useful Links <ul><li>These slides are available from here: </li></ul><ul><ul><li> </li></ul></ul><ul><li>General portlet tutorial information is available from here: </li></ul><ul><ul><li> </li></ul></ul><ul><li>Grid portlets are available from here: </li></ul><ul><ul><li> </li></ul></ul>
    3. 3. Outline <ul><li>Globus toolkit review </li></ul><ul><li>Computational Portals and Portlets </li></ul><ul><li>Building Grid Portlets with the Java CoG Kit </li></ul>
    4. 4. Purpose of Talk <ul><li>I am not affiliated with Globus and do not develop Globus Web Services. </li></ul><ul><ul><li>I just use Globus services as-is. </li></ul></ul><ul><ul><li>My slides are from this point of view. </li></ul></ul><ul><li>My emphasis is on building Web Portals from portlets as clients to Grid services using the Java COG kit. </li></ul><ul><li>The Java CoG kit project is lead by Gregor von Laszewski at Argonne National Labs </li></ul><ul><li>I work with Gregor through the Open Grid Computing Environments project. </li></ul><ul><ul><li>We build portlets using the Java CoG </li></ul></ul><ul><li>I also lead portlet and Web Service development for the NASA SERVOGrid project. </li></ul><ul><ul><li>Grid services, GIS services </li></ul></ul>
    5. 5. SERVOGrid Summary <ul><li>Portlet-based portal </li></ul><ul><ul><li>With portal extensions to support secure remote portlets. </li></ul></ul><ul><li>“ Execution Grid” Web Services </li></ul><ul><ul><li>Run remote tasks using Ant job managers. </li></ul></ul><ul><ul><li>Move files around (upload, download, crossload). </li></ul></ul><ul><ul><li>Maintain persistent user session state </li></ul></ul><ul><ul><ul><li>“ Context” </li></ul></ul></ul><ul><ul><li>Application metadata to describe applications. </li></ul></ul><ul><ul><ul><li>Provide data portal applications. </li></ul></ul></ul><ul><ul><li>Monitor jobs </li></ul></ul><ul><li>Data Grid Web Services </li></ul><ul><ul><li>Use Geographical Information System standards. </li></ul></ul><ul><ul><li>Web Feature Service </li></ul></ul><ul><ul><ul><li>Encodes GPS, Seismic, and Fault data archives as GML. </li></ul></ul></ul><ul><ul><ul><li>Working on high performance web services. </li></ul></ul></ul><ul><ul><li>Web Map Service </li></ul></ul><ul><ul><ul><li>Generates interactive web maps using features and other map servers. </li></ul></ul></ul><ul><ul><ul><li>Streaming video version in development. </li></ul></ul></ul><ul><ul><li>Sensor Grid Services </li></ul></ul><ul><ul><ul><li>Real time streaming GPS </li></ul></ul></ul><ul><ul><ul><li>Data mining on streams </li></ul></ul></ul><ul><li>Information Grid Services </li></ul><ul><ul><li>Extended UDDI </li></ul></ul><ul><ul><li>WS-Context for session metadata. </li></ul></ul>
    6. 6. Globus Toolkit Overview <ul><li>The Globus Toolkit provides foundations for building “ Virtual Organizations .” </li></ul><ul><li>Single Sign-On Authentication </li></ul><ul><ul><li>Log in once, access all machines on your Grid. </li></ul></ul><ul><li>Grid Security Infrastructure </li></ul><ul><ul><li>Public Key Infrastructure </li></ul></ul><ul><ul><li>Generic Security Service programming interfaces </li></ul></ul><ul><li>Secure Remote Resource Access </li></ul><ul><ul><li>Remotely execute tasks. </li></ul></ul><ul><ul><li>Interact with both shells and queuing systems. </li></ul></ul><ul><li>Secure, high performance file transfer </li></ul><ul><li>Information services for your grid resources. </li></ul>
    7. 7. Globus Toolkit 2.x <ul><li>GT 2 services implemented as Unix services. </li></ul><ul><ul><li>You quite commonly manage them through /etc/xinetd.d or similar. </li></ul></ul><ul><li>Standard services in xinetd.d: </li></ul><ul><ul><li>GRAM gatekeeper for running remote tasks. </li></ul></ul><ul><ul><li>GridFTP for file transfers </li></ul></ul><ul><ul><ul><li>Upload, download, and third party. </li></ul></ul></ul><ul><ul><li>MDS information services </li></ul></ul><ul><ul><li>MyProxy : a remote credential repository so that you don’t need to keep lots of copies of your private key. </li></ul></ul><ul><ul><ul><li>Jim Basney at NCSA is the MyProxy guy. </li></ul></ul></ul><ul><li>Support for both remote shell operations and queuing systems . </li></ul><ul><ul><li>PBS and LSF tend to be best supported. </li></ul></ul><ul><ul><li>You may be able to find others. </li></ul></ul><ul><li>Many other Globus-related tools have come and gone. </li></ul>
    8. 8. Globus Toolkit and Web Services <ul><li>Globus and others in the Global Grid Forum realized that they needed to provide more than just a bag of services </li></ul><ul><ul><li>Needed a framework for building new services. </li></ul></ul><ul><ul><li>Needed standard languages for writing service APIs </li></ul></ul><ul><ul><li>Standard messaging envelopes. </li></ul></ul><ul><ul><li>Web Services were the natural fit. </li></ul></ul><ul><li>The Open Grid Services Architecture (OGSA) outlines the basic premise of the Globus approach to Web Services. </li></ul><ul><li>Globus Toolkit 3.x was the initial implementation of these ideas. </li></ul><ul><li>But it was found to be unsustainable . </li></ul><ul><ul><li>Initial spec (“OGSI”) was too monolithic, took to long to approve, made custom extensions to WSDL, had portions that were superseded by the main stream Web Service community, and was disconnected from the general community (OASIS, W3C). </li></ul></ul><ul><ul><li>See for some discussion. </li></ul></ul><ul><li>GT 4 release (April 2005) attempts to correct these problems. </li></ul>
    9. 9. Some Globus 2 Services v. Globus 4 Web Services <ul><li>PKI X.509 certificates used for mutual authentication </li></ul><ul><li>GSI Security </li></ul><ul><ul><li>GSSAPI-based socket connections </li></ul></ul><ul><li>GRAM </li></ul><ul><ul><li>Uses Resource Specification Language (RSL) </li></ul></ul><ul><ul><li>Binds to PBS, LSF, and possibly other schedulers with third party plugins (support may vary). </li></ul></ul><ul><li>GridFTP </li></ul><ul><ul><li>Note GT 4 includes GridFTP 2.0, which is a different codebase from GridFTP 1.17 bundled in previous Globus releases. </li></ul></ul><ul><ul><li>We have reported some incompatibilities, which I think have been addressed in GT 4.0.1. </li></ul></ul><ul><li>Still PKI X.509 based mutual authentication… </li></ul><ul><li>But used now with Web Service Security: SSL and WS-Security </li></ul><ul><ul><li>Your certificates work in both GT versions. </li></ul></ul><ul><li>WS-GRAM </li></ul><ul><ul><li>Replaces RSL with XML Job Descriptors. </li></ul></ul><ul><ul><li>Uses Reliable File Transfer and GridFTP to support file staging and multiple jobs (which is a pain to install). </li></ul></ul><ul><ul><li>Binds to PBS, LSF </li></ul></ul><ul><li>Reliable File Transfer (RFT) </li></ul><ul><ul><li>Web Service-based </li></ul></ul><ul><ul><li>Uses “scheduling” techniques to do batch file transfers that don’t require persistent client connections. </li></ul></ul><ul><ul><li>Builds on GridFTP. </li></ul></ul>
    10. 10. Grid (and Web Service) Clients <ul><li>Web and Grid Services run in service hosting environments. </li></ul><ul><ul><li>Apache Axis, Globus WS container, etc. </li></ul></ul><ul><li>Clients likewise need to run in client hosting environments. </li></ul><ul><ul><li>Graphical Use Interfaces, Desktops, Web Browser Portals </li></ul></ul><ul><ul><li>But also grid and web service shells. </li></ul></ul><ul><ul><ul><li>Gridshell, HPSearch </li></ul></ul></ul><ul><li>We will focus on portals, since these are the most common and have standards. </li></ul>
    11. 11. Building Grid Portals
    12. 12. A Famous Web Portal
    13. 13. A Famous Portal, After Login
    14. 14. What to Notice <ul><li>After logging in, my colors, layouts, and content all changed. </li></ul><ul><ul><li>I get my stock list, my Bloomington weather, my news stories, etc. </li></ul></ul><ul><ul><li>I got rid of “Garfield” </li></ul></ul><ul><li>As we will see later, each of these content fragments (encircled) is managed by a thing called a portlet … </li></ul><ul><ul><li>… I don’t guarantee that this is true for Yahoo’s web site but it is true for a large class of enterprise Java portal systems. </li></ul></ul><ul><li>Portlets are the key to portal software reuse. </li></ul>
    15. 15. Let 10,000 Flowers Bloom <ul><li>Many portal projects have been launched since late ’90s. </li></ul><ul><ul><li>HotPage from SDSC, NCSA efforts, DOD, DOE Portals, NASA IPG </li></ul></ul><ul><ul><li>2002 Special Issue of Concurrency and Computation: Practice and Experience. </li></ul></ul><ul><li>The field continues to be active </li></ul><ul><ul><li>An upcoming issue of Concurrency will survey the current field. </li></ul></ul><ul><ul><li>Based on Global Grid Forum 14 Science Gateway workshop in June 2005. </li></ul></ul><ul><ul><li>GCE2005 workshop at Supercomputing 05. </li></ul></ul><ul><ul><ul><li> </li></ul></ul></ul><ul><li>Global Grid Forum’s Grid Computing Environments (GCE) Research Group </li></ul><ul><ul><li>Community forum </li></ul></ul><ul><li>How do we share and reuse all of this work? </li></ul>
    16. 16. Three-Tiered Architecture <ul><li>Three-tiered architecture is accepted standard for accessing Grid and other services </li></ul>Portal User Interface Grid Resource Broker Service Grid and Web Protocols Information and Data Services Database Service Database HPC or Compute Cluster Grid Information Services, SRB Portal Client Stub Portal Client Stub Portal Client Stub JDBC, Local, or Remote Connection
    17. 17. What Is a Portlet? <ul><li>A portlet is a piece of Java code that manages the content of one section of a web portal’s HTML. </li></ul><ul><li>It can do anything else that a Java web application can do. </li></ul><ul><ul><li>You can connect a portlet to a database, invoke a web service, download an RSS feed, etc. </li></ul></ul><ul><li>It lives in a portlet container , which creates, manages, and destroys all the portlets of the portal. </li></ul><ul><li>Portlet containers are part of portals. </li></ul><ul><ul><li>Portals must do other things like manage login, users, groups, layouts, etc. </li></ul></ul><ul><li>JSR 168 standardizes two main things: </li></ul><ul><ul><li>How the portlet container manages portlet lifecycles </li></ul></ul><ul><ul><li>How the portlets are programmed. </li></ul></ul>
    18. 18. JSR 168 Overview A General Review of JSR 168
    19. 19. What is JSR 168? <ul><li>From the portlet development point of view, it is really very simple: </li></ul><ul><ul><li>You write a java class that extends GenericPortlet . </li></ul></ul><ul><ul><li>You override/implement several methods inherited from GenericPortlet. </li></ul></ul><ul><ul><li>You use some supporting classes/interfaces </li></ul></ul><ul><ul><ul><li>Many are analogous to their servlet equivalents </li></ul></ul></ul><ul><ul><ul><li>Some (portletsession) actually seem to be trivial wrappers around servlet equivalents in Pluto. </li></ul></ul></ul><ul><li>I have a complete example in the extended slides. </li></ul><ul><ul><li>See also tutorial slides. </li></ul></ul>
    20. 20. Some Methods Place for handling any <form> actions before turning over to the display mode method (like doView). You should override this for web forms. processAction Other portlet display modes doHelp, doEdit Controls what happens immediately before the portlet is displayed in view mode. Normally you override this. doView Called when the portlet is created. Override if you need to set initial params. Init Description Method
    21. 21. Some Supporting Classes/Interfaces The request and response objects available to the processAction() method. Similar to the servlet request and response objects. ActionRequest,ActionResponse Use this to include/forward to a JSP or servlet in the same portlet app. PortletRequestDispatcher Use this to create URLs that reference the portal. PortletURL See if you are in minimized, maximized, normal state. WindowState The request and response objects available to the doView() method. Similar to the normal servlet request RenderRequest, RenderResponse Stores attribute information for a single portlet application across multiple requests. PortletSession Similar to servlet context; get context info and the RequestDispatcher from here. PortletContext Description Class
    22. 22. The Big Picture <ul><li>As a portlet developer, the previous set of classes are all you normally touch. </li></ul><ul><li>The portlet container (Pluto) is responsible for running your portlets. </li></ul><ul><ul><li>Init, invoke methods, destroy. </li></ul></ul><ul><li>Portlets have a very limited way of interacting with the container. </li></ul><ul><ul><li>It is a black box->black hole. </li></ul></ul><ul><ul><li>The API is basically one-way. </li></ul></ul>
    23. 23. A Comment on Portlet Coding <ul><li>The extended example makes some important and dubious assumptions </li></ul><ul><ul><li>Developers would want to write a GenericPortlet extension for every single portlet they develop. </li></ul></ul><ul><ul><ul><li>And write really complicated processAction() and doView() methods. </li></ul></ul></ul><ul><ul><li>Developers will like the specific JSR 168 portlet-style Model-View-Controller that it forces on them. </li></ul></ul><ul><ul><li>Developers will gladly ignore other development methodologies/frameworks like Velocity, Struts, and Java Server Faces. </li></ul></ul><ul><li>Fortunately, these other development environments can be mapped to portlet actions. </li></ul><ul><ul><li>In the OGCE project, we have developed support for Velocity portlets. </li></ul></ul><ul><ul><li>We are transitioning to Java Server Faces </li></ul></ul>
    24. 24. Some Free JSR 168 Containers Depends heavily on EJB. Interesting set of portlets but too non-portable. LifeRay I found this difficult to use, had some incompatibilities with CoG jars. ExoPortal Supports WSRP, JSF. I have not yet evaluated. StringBeans Supports WSRP; JSF support planned. I have used extensively, but prefer GridSphere. uPortal Supports JSF. I recommend. Popular container in scientific portal community. GridSphere Comments Container
    25. 25. The Java CoG Kit Gregor von Laszewski Argonne National Laboratory University of Chicago [email_address]
    26. 26. The Story So Far… <ul><li>Globus has several interesting services that can be used out of the box. </li></ul><ul><li>Portlets can be used to build portals out of reusable parts. </li></ul><ul><li>Portlets (as Java code) can also be used to invoke remote services. </li></ul><ul><li>Now we will look at how to do this for Grid applications. </li></ul>
    27. 27. CoG Kits <ul><li>CoG Kits make Grid programming simple and new technologies are easy to integrate </li></ul><ul><li>We focus on a CoG Kit for Java </li></ul><ul><ul><li>Python also available (K. Jackson, LBNL) </li></ul></ul><ul><ul><li>Availability: Java CoG Kit since 1997 </li></ul></ul><ul><li>The CoG provides two important things </li></ul><ul><ul><li>A higher level programming client programming environment than stubs. </li></ul></ul><ul><ul><li>A shield against different versions of the Globus toolkit </li></ul></ul><ul><ul><ul><li>Same high level API works with GT 2.4, GT 3.0.2, GT 3.2.0, GT 3.2.1, GT 4.0.0 </li></ul></ul></ul>
    28. 28. CoG Abstraction Layers GT2 GT3 OGSI classic GT4 WS-RF Condor Unicore Applications SSH Others Avaki SETI Nano materials Bio- Informatics Disaster Management Portals Development Support CoG Abstraction Layer CoG CoG CoG CoG CoG CoG Data and Task Management Layer CoG Gridfaces Layer CoG CoG CoG GridIDE CoG Abstraction Layer CoG CoG CoG CoG CoG CoG Data and Task Management Layer CoG Gridfaces Layer CoG CoG CoG GridIDE
    29. 29. Grid Portlet Overview <ul><li>In the tutorial examples, we look at writing JSR 168 portlets using JSP and Velocity. </li></ul><ul><li>Grid Portlets are just portlets, and portlets are just Java applications. </li></ul><ul><ul><li>Use the Java CoG to make calls from the portlet code to the desired Grid service. </li></ul></ul><ul><ul><li>Can also make non-COG calls, such as to GridPort API. </li></ul></ul><ul><li>These APIs are not be portlet-specific, since you should be able to reuse the Grid APIs from other Java clients. </li></ul><ul><ul><li>You can also build Web Services out of them. </li></ul></ul><ul><ul><li>NCSA’s OGRE (general), Trebuchet (application specific) are examples </li></ul></ul><ul><ul><li>NCSA Tupelo also makes use of COG in its metadata management services. </li></ul></ul>
    30. 30. COG and Portlets <ul><li>We use the COG to illustrate some basic portlet programming features. </li></ul><ul><li>We use the COG4 APIs in our ProxyManager, Job Submission, and GridFTP portlets </li></ul><ul><ul><li>Hides differences between Globus Toolkit versions. </li></ul></ul><ul><ul><li>Is also structured to handle task-based workflow and job composition. </li></ul></ul><ul><li>For more detailed examples, see the extended version of these slides. </li></ul>
    31. 31. Task Task Handler Service Task Specification Security Context Service Contact The class diagram is the same for all grid tasks (running jobs, modifying files, moving data). Classes also abstract toolkit provider differences. You set these as parameters: GT2, GT4, etd.
    32. 32. Setting Up Task and Specification <ul><li>Task task=new TaskImpl(“mytask”, </li></ul><ul><li>Task.JOB_SUBMISSION); </li></ul><ul><li>task.setProvider(“GT2”); </li></ul><ul><li>JobSpecification spec= </li></ul><ul><li>new JobSpecificationImpl(); </li></ul><ul><li>spec.setExecutable(“rm”); </li></ul><ul><li>spec.setBatchJob(true); </li></ul><ul><li>spec.setArguments(“-r”); </li></ul><ul><li>… </li></ul><ul><li>task.setSpecification(spec); </li></ul>
    33. 33. Setting Up the Service and Security Context <ul><li>Service service=new ServiceImpl(Service.JOB_SUBMISSION); </li></ul><ul><li>service.setProvider(“GT2”); </li></ul><ul><li>SecurityContext securityContext= </li></ul><ul><li>CoreFactory.newSecurityContext(“GT2”); </li></ul><ul><li>//Use cred object from ProxyManager </li></ul><ul><li>securityContext.setCredentials(cred); </li></ul><ul><li>service.setSecurityContext( </li></ul><ul><li>(SecurityContext)securityContext); </li></ul>
    34. 34. Set Up Service Contact and Finish <ul><li>ServiceContact serviceContact= </li></ul><ul><li>new ServiceContact(“”); </li></ul><ul><li>service.setServiceContact(serviceContact); </li></ul><ul><li>task.setService( </li></ul><ul><li>Service.JOB_SUBMISSION_SERVICE, </li></ul><ul><li>service); </li></ul><ul><li>TaskHandler handler=new GenericTaskHandler(); </li></ul><ul><li>handler.submit(task); </li></ul>
    35. 35. Summary and Future Directions <ul><li>Portlets provide a way to build reusable Web components. </li></ul><ul><li>The Java COG kit provides a nice abstraction layer for building Grid portlets. </li></ul><ul><li>Portlets can be written using JSP, Velocity, and JSF. </li></ul><ul><li>In our OGCE project, we previously concentrated on Velocity but are now moving to Java Server Faces. </li></ul><ul><ul><li>Provides a clear way to build reusable widgets, not just portlets. </li></ul></ul><ul><li>AJAX techniques (such as Google Maps) provide a very way to build interactive Web Service clients. </li></ul><ul><li>There is a larger problem: can we define a general user interface component? </li></ul><ul><ul><li>Portlets would be a subclass </li></ul></ul><ul><ul><li>But also include shells and desktop clients. </li></ul></ul><ul><li>These components would also require standard supporting services: </li></ul><ul><ul><li>Login, access control, layout management, …. </li></ul></ul>
    36. 36. Basic Portlet Programming Guide
    37. 37. In Action: Get started. <ul><li>public class JunkPortlet extends GenericPortlet { </li></ul><ul><li>public void init(){ </li></ul><ul><li>//Do any initialization. </li></ul><ul><li>} </li></ul><ul><li>//Rest of the methods on following slides go here. </li></ul><ul><li>… </li></ul><ul><li>} </li></ul>
    38. 38. Override doView() <ul><li>protected void doView( RenderRequest req , RenderResponse res ) </li></ul><ul><li>throws PortletException, IOException { </li></ul><ul><li>//Include the desired JSP or HTML page. </li></ul><ul><li>//We could also use out to write directly to the response. </li></ul><ul><li>WindowState state=req.getWindowState(); </li></ul><ul><li>if(!state.equals(WindowState.MINIMIZED)) { </li></ul><ul><li> res.setContentType(&quot;text/html&quot;); </li></ul><ul><li> PortletRequestDispatcher rd= </li></ul><ul><li>getPortletContext().getRequestDispatcher(“MyJSP.jsp”); </li></ul><ul><li> rd.include(req,res); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
    39. 39. The JSP Page <ul><li>< portlet:defineObjects /> </li></ul><ul><li><% </li></ul><ul><li>PortletSession portletSession=renderRequest.getPortletSession(); </li></ul><ul><li>portletSession.setAttribute(&quot;localattname&quot;,&quot;localattval&quot;); </li></ul><ul><li>PortletURL url=renderResponse.createActionURL(); </li></ul><ul><li>String theActionString=url.toString(); </li></ul><ul><li>%> </li></ul><ul><li>HTML Content is here. </li></ul><ul><li>A form is below. </li></ul><ul><li><form method=post action=&quot;<%= theActionString %>&quot;> </li></ul><ul><li><input type=…> </li></ul><ul><li></form> </li></ul>
    40. 40. Some Notes <ul><li>Include the <%portlet:definedObjects/%> tag, which will instantiate renderRequest, renderResponse, and portletConfig objects. </li></ul><ul><ul><li>You can then just use them, as with request, response, and other JSP implicit objects. </li></ul></ul><ul><li>The renderRequest gives you access to the PortletSession, if you want to store session variables. </li></ul><ul><ul><li>One of the trouble points. </li></ul></ul><ul><li>The renderResponse gives you access to the PortletURL object. </li></ul><ul><li>Use the PortletURL to generate a URL for the <form action> </li></ul><ul><ul><li>So that it points to portlet container and gets handled by the processAction() method, rather than going of into space. </li></ul></ul><ul><ul><li>Handle href URLs similarly. </li></ul></ul><ul><ul><li>This is one of the sticking points. </li></ul></ul>
    41. 41. Lastly, Override processAction() <ul><li>When you invoke the form on the previous JSP, the portlet container will pass the action handling to the processAction method. </li></ul><ul><li>The ActionRequest can be used to get any of the <input> parameters in a way similar to the usual HttpServletRequest. </li></ul><ul><li>When the processAction method returns, the container then invokes the appropriate do method (usually doView). </li></ul><ul><li>If you need to pass <form> parameters on to doView, add them to the ActionResponse. </li></ul><ul><ul><li>This will give them to the RenderRequest. </li></ul></ul><ul><ul><li>The example shows how to add ALL parameters. </li></ul></ul><ul><li>public void processAction (ActionRequest request, ActionResponse actionResponse) throws PortletException, { </li></ul><ul><li>//Process request parameters </li></ul><ul><li>… </li></ul><ul><li>//Add any other request params </li></ul><ul><li>// to the renderRequest </li></ul><ul><li>actionResponse.setRenderParameters(request.getParameterMap()); </li></ul><ul><li>} </li></ul>
    42. 42. Deploying Portlet Applications <ul><li>The portlet container (i.e. uPortal) runs as a distinct web application. </li></ul><ul><ul><li>That is, it has its own directory in tomcat. </li></ul></ul><ul><ul><li>Moreover, it runs as a separate context, with its own classloader, session management, etc. </li></ul></ul><ul><li>Portlet applications are deployed as distinct war files/web applications. </li></ul><ul><ul><li>You go through the container webapp to get to the portlet webapp. </li></ul></ul><ul><ul><li>Portlets in the same application share jars, classes, and runtime stuff like request and session variables. </li></ul></ul><ul><ul><li>Portlets in different portlet apps do not share anything. </li></ul></ul><ul><li>JSR 168 containers vary in the specifics of their deployment procedures. </li></ul>
    43. 43. Writing Grid Portlets Extended Example
    44. 44. Grid Portlet Overview <ul><li>Previously we looked at writing JSR 168 portlets using JSP and Velocity. </li></ul><ul><li>Grid Portlets are just portlets </li></ul><ul><ul><li>Use the Java CoG to make calls from the portlet code to the desired Grid service. </li></ul></ul><ul><ul><li>Can also make non-COG calls, such as to GridPort API. </li></ul></ul><ul><li>These APIs should not be portlet-specific, since you should be able to reuse the Grid APIs from other Java clients. </li></ul><ul><ul><li>NCSA’s OGRE (general), Trebuchet (application specific) are examples </li></ul></ul><ul><ul><li>NCSA Tupelo also makes use of COG in its metadata management services. </li></ul></ul>
    45. 45. COG and Portlets <ul><li>We will use the COG to illustrate some basic portlet programming features. </li></ul><ul><li>We use the COG4 APIs in our ProxyManager, Job Submission, and GridFTP portlets </li></ul><ul><ul><li>Hides differences between Globus Toolkit versions. </li></ul></ul><ul><ul><li>Is also structured to handle task-based workflow and job composition. </li></ul></ul><ul><li>But for in-depth COG questions, we defer to Gregor’s group. </li></ul><ul><ul><li>Available through AG session today. </li></ul></ul><ul><ul><li>Or docs available through </li></ul></ul><ul><li>OGCE is an open consortium, and there are other alternatives. </li></ul><ul><ul><li>OGRE job management builds on COG for Workflow </li></ul></ul><ul><ul><li>GridPort uses the GGF Community Scheduling Framework and higher level tools (job sequencers, for instance). </li></ul></ul><ul><ul><li>Use what you like </li></ul></ul>
    46. 46. Getting Proxy Credentials <ul><li>The key ingredient is getting proxy credentials into the portal and sharing between different portlets. </li></ul><ul><li>We use MyProxy for this </li></ul><ul><ul><li>Advantage: you don’t have to store users’ long term keys on the web server. </li></ul></ul><ul><ul><li>Disadvantage: you have to run a separate MyProxy server; users have to put keys there outside the portal. </li></ul></ul><ul><li>You must include the OGCE2 MyProxy portlet (or a variation of it) in your Grid portal to do any other Grid stuff. </li></ul><ul><li>OGCE1 also had support for grid-proxy-init. </li></ul><ul><ul><li>Would be able to add this, but you would need to manage your users’ long term keys. </li></ul></ul>
    47. 48. Proxy Manager Under the Hood <ul><li>See ogce2/indiana/extreme/ProxyManager/modules/portlet/src for templates and code. </li></ul><ul><li>Templates illustrate several Velocity scripting concepts. </li></ul><ul><ul><li>Control structures, variables </li></ul></ul><ul><li>But the action code is more interesting. </li></ul><ul><ul><li>This is where you do your Grid coding. </li></ul></ul><ul><ul><li>Use Velocity’s Context object to communicate strings back to your templates. </li></ul></ul>
    48. 49. Proxy Manager Code <ul><li>Key part here is the doGet_proxy() method. </li></ul><ul><li>Abbreviated code on the right. </li></ul><ul><li>MyProxy class: import from CoG kit. </li></ul><ul><li>GSSCredential class: standard Java security class. </li></ul><ul><li>ProxyManager class: used by us to pass credentials between portlets. </li></ul><ul><li>public void doGet_proxy() { </li></ul><ul><li>MyProxy myproxy= </li></ul><ul><li> new MyProxy(…); </li></ul><ul><li>GSSCredential proxy= </li></ul><ul><li> myproxy.get(…); </li></ul><ul><li>ProxyManager.addProxy(…); </li></ul><ul><li>} </li></ul>
    49. 50. Writing Simple Job Submission Portlets <ul><li>For portlets, you have to deal with two main Grid issues: </li></ul><ul><ul><li>Getting the credential from the proxy store. </li></ul></ul><ul><ul><li>And then using it. </li></ul></ul><ul><li>The CoG APIs provide an additional nice layer of Grid abstraction for Grid tasks. </li></ul><ul><ul><li>We will look at this for wrapping GRAM calls. </li></ul></ul><ul><li>We will assume the following: </li></ul><ul><ul><li>You have your project set up to be warred with maven. </li></ul></ul><ul><ul><li>You have chosen a development technology (like JSP + portlets or Velocity portlets). </li></ul></ul><ul><ul><li>You will be collecting the necessary input information from an HTML <form>. </li></ul></ul><ul><ul><li>You will be putting the action code in either the portlet (perhaps as a JavaBean) or Velocity action handler. </li></ul></ul><ul><ul><li>All code snippets below go in this portlet/action code. </li></ul></ul>
    50. 51. Write the Method Skeleton <ul><li>In your action code, write a method to do job submission. </li></ul><ul><ul><li>For Velocity, this maps to the “eventSubmit_” form parameter in your template. </li></ul></ul><ul><ul><li>In portlets, this code is called by your processAction method. </li></ul></ul><ul><li>You will need to pass it, minimally, the ActionRequest and ActionResponse objects. </li></ul><ul><li>public void doSubmitJob( </li></ul><ul><li>ActionRequest req, ActionResponse resp,…) { </li></ul><ul><li>//Next, get proxy </li></ul><ul><li>//Then, run command. </li></ul><ul><li>} </li></ul>
    51. 52. Get the Proxy <ul><li>Now get the proxy from the local store. </li></ul><ul><li>The ProxyManager class calls the static method getDefaultProxy to look up your credential using your portlet session. </li></ul><ul><li>You need these imports </li></ul><ul><ul><li>org.ietf.jgss.GSSCredential </li></ul></ul><ul><ul><li>xportlets.proxymanager.ProxyManager. </li></ul></ul><ul><ul><li>javax.portlet.* for everything else. </li></ul></ul><ul><li>This assumes that you have retrieved a credential from the MyProxy server. </li></ul><ul><li>public doSubmitJob( </li></ul><ul><li>ActionRequest req, ActionResponse res) { </li></ul><ul><li>//Get the proxy </li></ul><ul><li>PortletSession sess= </li></ul><ul><li> req.getPortletSession() </li></ul><ul><li>GSSCredential cred= ProxyManager.getDefaultProxy(sess); </li></ul><ul><li>//Next, run command </li></ul><ul><li>} </li></ul>
    52. 53. Run the Command <ul><li>The CoG4 interfaces now come into play. You should first understand the general CoG approach. </li></ul><ul><li>The COG4 interfaces attempt to abstract things at several layers </li></ul><ul><ul><li>Tasks: a generic Grid function </li></ul></ul><ul><ul><ul><li>Remote command execution, file operation, or information inquiry. </li></ul></ul></ul><ul><ul><ul><li>Has a specification and service </li></ul></ul></ul><ul><ul><ul><li>Is run by a handler </li></ul></ul></ul><ul><ul><li>Specification: set the type of task (job submit, etc.) and its specific parameters. </li></ul></ul><ul><ul><li>Service: sets the Globus Toolkit (or other) provider, security context, and service contact information. </li></ul></ul><ul><ul><li>TaskHandler: runs the task. </li></ul></ul><ul><li>Note this scheme is intended to shield you from programming differences of different Globus toolkits. </li></ul>
    53. 54. Making Contact with the Portal <ul><li>The remaining issue is getting information from the HTML forms to the appropriate CoG calls. </li></ul><ul><li>This is done through the PortletRequest object. </li></ul><ul><ul><li>Typically, it is actually the ActionRequest subclass. </li></ul></ul><ul><li>In your doSubmitJob() command, just use </li></ul><ul><ul><li>String param=request.getParameter(“Param-Name”); </li></ul></ul><ul><ul><li>“ Param-Name” is replaced with the input parameter name in your HTML form. </li></ul></ul><ul><ul><ul><li><input type=text name=“Param-Name” value=“rm -r *.*”> </li></ul></ul></ul><ul><li>In following code snippets, “quoted strings” are usually what you would pass in from the Web form. </li></ul>
    54. 55. An Extended Code Example: Setting Up Task and Specification <ul><li>Task task=new TaskImpl(“mytask”, </li></ul><ul><li>Task.JOB_SUBMISSION); </li></ul><ul><li>task.setProvider(“GT2”); </li></ul><ul><li>JobSpecification spec= </li></ul><ul><li>new JobSpecificationImpl(); </li></ul><ul><li>spec.setExecutable(“rm”); </li></ul><ul><li>spec.setBatchJob(true); </li></ul><ul><li>spec.setArguments(“-r”); </li></ul><ul><li>… </li></ul><ul><li>task.setSpecification(spec); </li></ul>
    55. 56. Extended Code Example: Setting Up the Service and Security Context <ul><li>Service service=new ServiceImpl(Service.JOB_SUBMISSION); </li></ul><ul><li>service.setProvider(“GT2”); </li></ul><ul><li>SecurityContext securityContext= </li></ul><ul><li>CoreFactory.newSecurityContext(“GT2”); </li></ul><ul><li>//Use cred object from ProxyManager </li></ul><ul><li>securityContext.setCredentials(cred); </li></ul><ul><li>service.setSecurityContext( </li></ul><ul><li>(SecurityContext)securityContext); </li></ul>
    56. 57. Extended Example: Set Up Service Contact and Finish <ul><li>ServiceContact serviceContact= </li></ul><ul><li>new ServiceContact(“”); </li></ul><ul><li>service.setServiceContact(serviceContact); </li></ul><ul><li>task.setService( </li></ul><ul><li>Service.JOB_SUBMISSION_SERVICE, </li></ul><ul><li>service); </li></ul><ul><li>TaskHandler handler=new GenericTaskHandler(); </li></ul><ul><li>handler.submit(task); </li></ul>
    57. 58. Monitoring Tasks <ul><li>Monitoring running tasks submitted by the COG is done through a status listener. </li></ul><ul><ul><li>Write a class that implements StatusListener interface </li></ul></ul><ul><ul><li>Create an instance of your listener and add it to the task: </li></ul></ul><ul><ul><ul><li>task.addStatusListener(myListener); </li></ul></ul></ul><ul><li>There is a small problem with doing this in a portal application </li></ul><ul><ul><li>The listener must be instantiated in the action code, along with the rest of the COG classes. </li></ul></ul><ul><ul><li>But these are lost after the action completes. </li></ul></ul><ul><li>Simple solution: store it in the PortletSession </li></ul><ul><ul><li>This will keep the listener object alive after the action completes </li></ul></ul><ul><ul><li>Get the session from the PortletRequest (more typically, its subclass, ActionRequest) </li></ul></ul><ul><ul><li>Sample code </li></ul></ul><ul><ul><ul><li>PortletSession session=request.getPortletSession(); </li></ul></ul></ul><ul><ul><ul><li>session.setAttribute(“mytask”,myListener); </li></ul></ul></ul><ul><ul><li>When you are curious about your task’s status, fetch it out of the session by name. </li></ul></ul>