80
Developing Grid Developing Grid Portals Using Portals Using Portlets Portlets Marlon Pierce Marlon Pierce Community Grids Lab Community Grids Lab Indiana University Indiana University

Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Embed Size (px)

Citation preview

Page 1: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Developing Grid Portals Developing Grid Portals Using PortletsUsing Portlets

Marlon PierceMarlon Pierce

Community Grids LabCommunity Grids Lab

Indiana UniversityIndiana University

Page 2: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Overview of MaterialOverview of Material General remarks on portals and portlets.General remarks on portals and portlets.

• General remarks to provide context for the remainder of General remarks to provide context for the remainder of the session.the session.

OGCE Portal capabilities.OGCE Portal capabilities.• Summary of things we do in OGCE.Summary of things we do in OGCE.

JSR 168 ReviewJSR 168 Review Developing OGCE portletsDeveloping OGCE portlets

• How to develop OGCE compatible portlets.How to develop OGCE compatible portlets.• With launching points for Dennis and Gregor.With launching points for Dennis and Gregor.

Useful third party testing tool: HttpUnit.Useful third party testing tool: HttpUnit. A brief JSR 168 tutorial.A brief JSR 168 tutorial. At the risk of a low tutorial rating, I will cover At the risk of a low tutorial rating, I will cover

higher level issues. Slides on nuts and bolts higher level issues. Slides on nuts and bolts details are provided for homework.details are provided for homework.

Page 3: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Towards A Common Grid Towards A Common Grid Client Hosting Client Hosting EnvironmentEnvironment

Grid portal background and Grid portal background and emerging common emerging common

frameworksframeworks

Page 4: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

What Is a Grid Computing Portal?What Is a Grid Computing Portal? Browser based user interface for accessing grid Browser based user interface for accessing grid

and other servicesand other services• ““Live” dynamic pages available to authenticated, Live” dynamic pages available to authenticated,

authorized users. authorized users. • Use(d) Java/Perl/Python COGsUse(d) Java/Perl/Python COGs• Manage credentials, launch jobs, manage files, etc.Manage credentials, launch jobs, manage files, etc.• Hide Grid complexities like RSLHide Grid complexities like RSL• Can run from anywhereCan run from anywhere• Unlike user desktop clients, connections go through Unlike user desktop clients, connections go through

portal server, so overcome firewall/NAT issues portal server, so overcome firewall/NAT issues Combine “Science Grid” with traditional web Combine “Science Grid” with traditional web

portal capabilitiesportal capabilities• Get web pages for news feedsGet web pages for news feeds• Post and share documentsPost and share documents• Search engine interfaces, calendars, etc.Search engine interfaces, calendars, etc.• Enabled by Enabled by portletsportlets, as we will see., as we will see.

Customizable interfaces and user roles/viewsCustomizable interfaces and user roles/views

Page 5: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

What a Grid Portal Is/Is NotWhat a Grid Portal Is/Is Not It isIt is

• A tool for aggregating and managing web contentA tool for aggregating and managing web content• A user customizable view of these Web content pieces.A user customizable view of these Web content pieces.

You see what you want/can see.You see what you want/can see. But you must log in.But you must log in.

• Implemented on top of standard servicesImplemented on top of standard services Like login, authorization, customization.Like login, authorization, customization. May include collaboration, etc, that depend on login.May include collaboration, etc, that depend on login.

• A way to accomplish Grid tasks through browsers:A way to accomplish Grid tasks through browsers: Launch, monitor jobsLaunch, monitor jobs Move filesMove files Run science applications based on these services.Run science applications based on these services.

• Compatible with emerging standards and best practices Compatible with emerging standards and best practices (such as portlets, JSR 168 and WSRP).(such as portlets, JSR 168 and WSRP).

It is not (just)It is not (just)• A web pageA web page• A collection of linksA collection of links• An appletAn applet

Page 6: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Which Is the Portal?Which Is the Portal?

Page 7: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Which Is the Computing Portal?Which Is the Computing Portal? In fairness, the screenshots are not large In fairness, the screenshots are not large

enough to see, but you have to log in to enough to see, but you have to log in to the one on the right.the one on the right.• Point is that they are superficially similar to Point is that they are superficially similar to

browser users, but have many differences browser users, but have many differences under the hood.under the hood.

The screen shot on the left is of the NASA The screen shot on the left is of the NASA JPL QuakeSim project page.JPL QuakeSim project page.• http://http://quakesim.jpl.nasa.govquakesim.jpl.nasa.gov//

The screen shot on the right is the NASA The screen shot on the right is the NASA JPL QuakeSim portal.JPL QuakeSim portal.• http://www.complexity.ucs.indiana.edu:8282http://www.complexity.ucs.indiana.edu:8282• Go here to run QuakeSim earthquake Go here to run QuakeSim earthquake

simulation codes, access earthquake simulation codes, access earthquake databases, etc.databases, etc.

Page 8: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Let 10,000 Flowers BloomLet 10,000 Flowers Bloom Many portal projects have been launched Many portal projects have been launched

since late ’90s. since late ’90s. • HotPage from SDSC, NCSA efforts, DOD, DOE HotPage from SDSC, NCSA efforts, DOD, DOE

Portals, NASA IPGPortals, NASA IPG• 2002 Special Issue of Concurrency and 2002 Special Issue of Concurrency and

Computation: Practice and Experience.Computation: Practice and Experience. Continue to be important component of Continue to be important component of

many large projectsmany large projects• NEESGrid, DOE SciDAC projects, NASA, NSF, NEESGrid, DOE SciDAC projects, NASA, NSF,

many international effortsmany international efforts Global Grid Forum’s Grid Computing Global Grid Forum’s Grid Computing

Environments (GCE) Research GroupEnvironments (GCE) Research Group• Community forumCommunity forum

Page 9: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Por

tal U

ser

Inte

rfac

e Grid ResourceBroker Service

Grid and Web

Protocols

Informationand

Data Services

DatabaseService Database

HPCor

Compute Cluster

Grid InformationServices, SRB

PortalClientStub

PortalClientStub

PortalClientStub

JDBC,Local, orRemote

Connection

Three-Tiered ArchitectureThree-Tiered Architecture

Three-tiered architecture is accepted standard for Three-tiered architecture is accepted standard for accessing Grid and other servicesaccessing Grid and other services

Page 10: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Problem with PortalsProblem with Portals GCE revealed two thingsGCE revealed two things

• Everyone was doing the same thingEveryone was doing the same thing Not quite, but significant Not quite, but significant Everyone builds secure logins, remote file manipulation, command Everyone builds secure logins, remote file manipulation, command

execution, access to info servers.execution, access to info servers. Everyone would at least like support for multiple user roles Everyone would at least like support for multiple user roles

(administrators, users) and customization(administrators, users) and customization• No one could share components with other groupsNo one could share components with other groups

No well defined way of sharing UI components or making services No well defined way of sharing UI components or making services interoperate.interoperate.

No well defined interfaces to portal services.No well defined interfaces to portal services. A research opportunity!A research opportunity!

• Two levels of integration: user interfaces and servicesTwo levels of integration: user interfaces and services Our challengesOur challenges

• Stop reinventing things and provide ways for groups to reuse Stop reinventing things and provide ways for groups to reuse components.components.

• Provide a portal marketplace for competing (advanced) Provide a portal marketplace for competing (advanced) services.services.

• Provide APIs for service integrationProvide APIs for service integration

Page 11: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

A Solution based on A Solution based on componentscomponents

A software component is object defined by A software component is object defined by • A precise public interface A precise public interface • A semantics that includes a set of “standard” behaviors.A semantics that includes a set of “standard” behaviors.

A Software component architecture is:A Software component architecture is:• A a set of rules for component behavior & A a set of rules for component behavior & • A framework in which components can be easily A framework in which components can be easily

installed and interoperate.installed and interoperate. The component architecture of choice for the The component architecture of choice for the

Portal community is the one based on Portal community is the one based on portletsportlets• (Java) components that generate content, make local (Java) components that generate content, make local

and remote connections to services.and remote connections to services.• Portlet containersPortlet containers manage portlet lifecycles manage portlet lifecycles

We have now many, many components.We have now many, many components.• So don’t start from scratch. So don’t start from scratch.

Page 12: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Things to Hate About PortalsThings to Hate About Portals If you involved in portal efforts, be aware of the following:If you involved in portal efforts, be aware of the following: Browsers have Browsers have limited interactivitylimited interactivity..

• Desktop GUIs provide much better interactivity but have other Desktop GUIs provide much better interactivity but have other problems.problems.

• Applets are a solution, but they don’t interact with other parts Applets are a solution, but they don’t interact with other parts of the browser very well.of the browser very well.

• SolutionSolution: Service Oriented portals let you use services : Service Oriented portals let you use services through both portals and grid desktops.through both portals and grid desktops.

Developing Developing really useful user interfacesreally useful user interfaces to your set of to your set of services is a time consuming, non-scaling process.services is a time consuming, non-scaling process.• Get users involved early in design.Get users involved early in design.

Browsers notoriously have Browsers notoriously have incompatibleincompatible features. features.• Things don’t work the same on IE, Mozilla, Konqueror, etc.Things don’t work the same on IE, Mozilla, Konqueror, etc.• Same browsers on Macs, Windows don’t work the same.Same browsers on Macs, Windows don’t work the same.• No substitute for lots of testing.No substitute for lots of testing.

Grid portals need grids.Grid portals need grids.• Setting up grids is a fragile process.Setting up grids is a fragile process.• Plenty of dumb mistakes like setting up CA signing policies that Plenty of dumb mistakes like setting up CA signing policies that

even experts make.even experts make.• You will be blamed when things don’t go smoothly.You will be blamed when things don’t go smoothly.

Page 13: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

OGCE: Open Grid OGCE: Open Grid Computing EnvironmentsComputing Environments

Marlon PierceMarlon Pierce

Indiana UniversityIndiana University

Page 14: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

NSF NMI Project for Reusable NSF NMI Project for Reusable Portal Components: Who We ArePortal Components: Who We Are

University of ChicagoUniversity of Chicago• Gregor von LaszewskiGregor von Laszewski

Indiana UniversityIndiana University• Marlon Pierce, Dennis Gannon, Geoffrey Fox, Marlon Pierce, Dennis Gannon, Geoffrey Fox,

and Beth Plaleand Beth Plale University of MichiganUniversity of Michigan

• Charles Severance, Joseph HardinCharles Severance, Joseph Hardin NCSA/UIUCNCSA/UIUC

• Jay Alameda, Joe FutrelleJay Alameda, Joe Futrelle Texas Advanced Computing Center/San Texas Advanced Computing Center/San

Diego State UniversityDiego State University• Mary ThomasMary Thomas

Page 15: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

What Is OGCE’s Release 1What Is OGCE’s Release 1 The OGCE Portal release is based on The OGCE Portal release is based on

CHEF/Jetspeed 1.4CHEF/Jetspeed 1.4 Available for download and installation from Available for download and installation from

http://www.collab-ogce.orghttp://www.collab-ogce.org.. It comes with many pre-configured capabilities if It comes with many pre-configured capabilities if

you want a grid portal “out of the box”.you want a grid portal “out of the box”.• Except for the mysql jar.Except for the mysql jar.• You must still set up Grid services (MyProxy servers, You must still set up Grid services (MyProxy servers,

Globus, etc).Globus, etc).• Globus version compatibility through the Java CoG.Globus version compatibility through the Java CoG.

Apache Ant-based installation procedure:Apache Ant-based installation procedure:• Edit one properties file, run ant, and away you go.Edit one properties file, run ant, and away you go.

Page 16: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

PortalPortal CapabilitiesCapabilities DescriptionDescription

Grid Proxy Certificate ManagerGrid Proxy Certificate Manager Get MyProxy certs after logging in.Get MyProxy certs after logging in.

ScheduleSchedule Interactive individual and group calendarsInteractive individual and group calendars

DiscussionDiscussion Persistent topic-based discussion for groupsPersistent topic-based discussion for groups

ChatChat Live chat services and interfacesLive chat services and interfaces

Document managersDocument managers WEBDav based document system for group WEBDav based document system for group file sharingfile sharing

MDS/LDAP BrowsersMDS/LDAP Browsers Basic Globus MDS browsing and navigatingBasic Globus MDS browsing and navigating

GridContext PortletsGridContext Portlets Access context services for managing Access context services for managing metadatametadata

GRAM Job SubmissionGRAM Job Submission Run simple executables on remote hostsRun simple executables on remote hosts

GridFTPGridFTP Upload, download, crossload remote files.Upload, download, crossload remote files.

GPIR PortletsGPIR Portlets View, interact with HPC status, job, etc View, interact with HPC status, job, etc information.information.

AnabasAnabas Access to Anabas shared display appletsAccess to Anabas shared display applets

Newsgroups and citation portletsNewsgroups and citation portlets Post topics to newsgroup, manage group Post topics to newsgroup, manage group references and citations with access controlsreferences and citations with access controls

User PortletsUser Portlets

Page 17: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

PortalPortal CapabilitiesCapabilities DescriptionDescription

CoG Workflow demonstration CoG Workflow demonstration portletportlet

Set up and run task graphs using the Java Set up and run task graphs using the Java CoGCoG

Job Scheduling and SequencingJob Scheduling and Sequencing Schedule sequences of jobs on several hosts Schedule sequences of jobs on several hosts using Community Scheduling Framework.using Community Scheduling Framework.

Condor PortletsCondor Portlets Interact with Condor through browser.Interact with Condor through browser.

Application ManagementApplication Management Combine GridFTP and GRAM into application Combine GridFTP and GRAM into application wizard forms.wizard forms.

Newsgroup ServicesNewsgroup Services Download and install server side of the OGCE Download and install server side of the OGCE newsgroup system.newsgroup system.

OGRE Job Management ServicesOGRE Job Management Services Manage complicated grid tasks through an Manage complicated grid tasks through an extensible, Apache Ant like task list.extensible, Apache Ant like task list.

XDirectory ServicesXDirectory Services The backend for the Grid Context portletThe backend for the Grid Context portlet

More User Portlets and ServicesMore User Portlets and Services

Page 18: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Grid Portlet ExamplesGrid Portlet Examples

We’ll next overview several portal We’ll next overview several portal capabilities.capabilities.

Jetspeed/CHEF acts as a clearing Jetspeed/CHEF acts as a clearing house for portal capabilitieshouse for portal capabilities• User interface components can be User interface components can be

added in well defined ways.added in well defined ways.• First level of integrationFirst level of integration

All Grid access goes through the Java All Grid access goes through the Java COG.COG.

Page 19: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Example Capability: Portals for Example Capability: Portals for UsersUsers

The user contacts the portal The user contacts the portal server and asks it to do “grid” server and asks it to do “grid” things on behalf of the user.things on behalf of the user.

To make this possible the To make this possible the server needs a “Proxy server needs a “Proxy Certificate”Certificate”• The user has previously The user has previously

stored a proxy cert in a secure stored a proxy cert in a secure MyProxy Server stored with a MyProxy Server stored with a temporary password.temporary password.

• User give the portal server User give the portal server the password and the portal the password and the portal server contacts the proxy server contacts the proxy server and loads the proxy.server and loads the proxy.

• The portal server will hold the The portal server will hold the proxy for the user for a “short proxy for the user for a “short amount of time” in the user’s amount of time” in the user’s session state.session state.

Portal Server

1. Load myProxyCertificate!

User “Beth”

MyProxyServer

2. Give meBeth’s proxycertificate

I amBeth’sProxy

3.COG

MyProxyPortlet

Page 20: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Example Capability: Grid Context Example Capability: Grid Context ServiceService

User’s want to be able to use the portal to User’s want to be able to use the portal to keep track of lots of thingskeep track of lots of things• Application and experiment recordsApplication and experiment records

File metadata, execution parameters, workflow File metadata, execution parameters, workflow scriptsscripts

• ““Favorite” servicesFavorite” services Useful directory services, indexes, links to important Useful directory services, indexes, links to important

resourcesresources

• Notes and annotationsNotes and annotations ““Scientific Notebooks”Scientific Notebooks”

Page 21: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Portlet Interfaces to Grid ContextPortlet Interfaces to Grid Context A Remote Service Directory A Remote Service Directory

InterfaceInterface• Holds references and Holds references and

metadata about application metadata about application services.services.

User selects interface to User selects interface to application service from the application service from the directory browser.directory browser.

Examples: (near completion)Examples: (near completion)• Select a link to a Dagman Select a link to a Dagman

document and invoke the document and invoke the Condor service on the script. Condor service on the script.

• Same for GridAnt/Ogre or BPEL Same for GridAnt/Ogre or BPEL workflow script.workflow script.

• Factory services for any grid Factory services for any grid apps that have interactive apps that have interactive user interfaces.user interfaces.

Portal Server

Portal Server

RemoteGridApplicationService

RemoteService

DirectoryService

Page 22: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University
Page 23: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Example Capability: Topic Based Example Capability: Topic Based Messaging SystemsMessaging Systems

XML metadata system based on XML metadata system based on messages.messages.

NewsgroupsNewsgroups• Topic based message posting and Topic based message posting and

administrationadministration Citation/reference browsersCitation/reference browsers

• Topic based, export/import bibtexTopic based, export/import bibtex Portlets sit atop JMS-based message Portlets sit atop JMS-based message

systemsystem• NaradaBrokering, used in JMS mode.NaradaBrokering, used in JMS mode.

Page 24: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

User Privileges for Group ChannelsUser Privileges for Group Channels

Users request access to specific Users request access to specific topics/channels.topics/channels.• Granted by administrator for that topicGranted by administrator for that topic

Can requestCan request• Read/write by browserRead/write by browser• Read/write by email (newsgroups)Read/write by email (newsgroups)• Receive/don’t receive attachments.Receive/don’t receive attachments.

Topic admin can edit these requests.Topic admin can edit these requests. Super admins can manage administrators Super admins can manage administrators

to topicsto topics

Page 25: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

GPIR DataGPIR Data Load - aggregated CPULoad - aggregated CPU Downtime data for a Downtime data for a

machinemachine• Jobs: aggregated queueJobs: aggregated queue

MOTDMOTD Nodes: job usage for Nodes: job usage for

each machine nodeeach machine node NWS: based on VO and NWS: based on VO and

Click modelClick model Grid MonitoringGrid Monitoring

• Based on TACC GMS Based on TACC GMS SystemSystem

• Custom providersCustom providers• Plans to include MDS3.0 Plans to include MDS3.0

and INCA data uderwayand INCA data uderway

Expanding to include: Expanding to include: • queuing systemqueuing system• application profilesapplication profiles• performance dataperformance data• Application profilesApplication profiles• Doc linksDoc links

Model allows generic Model allows generic inclusion of any XML inclusion of any XML data from any data from any recognized sourcerecognized source• Need schemaNeed schema• Need queryNeed query

Page 26: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Grid Portal Information Repository Grid Portal Information Repository (GPIR 1.1)(GPIR 1.1)

Page 27: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

GPIR ComponentsGPIR Components Web Services Ingestor Web Services Ingestor

• Web Services Ingestor and clientsWeb Services Ingestor and clients• XML Schemas - can be changedXML Schemas - can be changed

Data RepositoryData Repository• Local CacheLocal Cache• Archival --> PostgreSQLArchival --> PostgreSQL

Web Service QueryWeb Service Query• retrieve data – XML Queriesretrieve data – XML Queries• Retrieving current snapshot and archived dataRetrieving current snapshot and archived data

ClientsClients• GridPort servicesGridPort services• Portal/Web Interface (Portlets, servlets, JSP)Portal/Web Interface (Portlets, servlets, JSP)• Command lineCommand line• Any that speak web servicesAny that speak web services

Page 28: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

What’s Next for the OGCE?What’s Next for the OGCE? JSR 168 Compatible Grid portlet release at JSR 168 Compatible Grid portlet release at

Supercomputing.Supercomputing.• Basic capabilities: MyProxy, GridFTP, GRAM, GPIR, based Basic capabilities: MyProxy, GridFTP, GRAM, GPIR, based

on CoG 4.on CoG 4.• Working in uPortal, GridSphere, Jetspeed2, ….Working in uPortal, GridSphere, Jetspeed2, ….

Join (all of) us at SC2004 for a portals BOF.Join (all of) us at SC2004 for a portals BOF. Solutions JSR 168 limitations that work in multiple Solutions JSR 168 limitations that work in multiple

JSR 168 containers.JSR 168 containers. Grid-compatible WSRP portlets.Grid-compatible WSRP portlets.

• Compatible with Sakai/CHEF 1.2 capabilities.Compatible with Sakai/CHEF 1.2 capabilities. Backward compatibility bridges to previous Backward compatibility bridges to previous

portlets.portlets. Fancy new capabilities available in separate Fancy new capabilities available in separate

downloads.downloads.

Page 29: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

A JSR 168 OverviewA JSR 168 Overview

A review of the latest portlet A review of the latest portlet developments.developments.

Page 30: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

What is JSR 168?What is JSR 168? Defines a standard for vendor container-Defines a standard for vendor container-

independent portlet components.independent portlet components. Many implementations:Many implementations:

• Gridsphere, uPortal, WebSphere, Jetspeed2, ….Gridsphere, uPortal, WebSphere, Jetspeed2, …. From the portlet development point of view, it From the portlet development point of view, it

is really very simple:is really very simple:• You write a java class that extends GenericPortlet.You write a java class that extends GenericPortlet.• You override/implement several methods inherited You override/implement several methods inherited

from GenericPortlet.from GenericPortlet.• You use some supporting classes/interfacesYou use some supporting classes/interfaces

Many are analogous to their servlet equivalents Many are analogous to their servlet equivalents Some (portletsession) actually seem to be trivial Some (portletsession) actually seem to be trivial

wrappers around servlet equivalents in Pluto.wrappers around servlet equivalents in Pluto.

Page 31: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Some TerminologySome TerminologyTermTerm DefinitionDefinition

PortletPortlet Java code that manages a piece of Java code that manages a piece of web content and which may web content and which may invoke remote services.invoke remote services.

Portlet Portlet ContainerContainer

Manages the lifecycle of the Manages the lifecycle of the portlets (inits, invokes,destroys).portlets (inits, invokes,destroys).

PortalPortal Displays the portal content Displays the portal content provided by the container. The provided by the container. The portal is responsible for the actual portal is responsible for the actual layout.layout.

Portlet Portlet ApplicationApplication

A webapp containing a group of A webapp containing a group of related portlets, content, related portlets, content, supporting jars, etc.supporting jars, etc.

Page 32: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Some Generic Portlet MethodsSome Generic Portlet Methods

MethodMethod DescriptionDescriptionInitInit Called when the portlet is created. Called when the portlet is created.

Override if you need to set initial Override if you need to set initial params.params.

doViewdoView Controls what happens immediately Controls what happens immediately before the portlet is displayed in view before the portlet is displayed in view mode. Normally you override this.mode. Normally you override this.

doHelp, doEditdoHelp, doEdit Other portlet display modesOther portlet display modes

processActionprocessAction Place for handling any <form> actions Place for handling any <form> actions before turning over to the display mode before turning over to the display mode method (like doView). You should method (like doView). You should override this for web forms.override this for web forms.

Page 33: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Supporting Classes/InterfacesSupporting Classes/InterfacesClassClass DescriptionDescription

PortletContextPortletContext Similar to servlet context; get context info Similar to servlet context; get context info and the RequestDispatcher from here.and the RequestDispatcher from here.

PortletSessionPortletSession Stores attribute information for a single Stores attribute information for a single portlet application across multiple requests. portlet application across multiple requests.

RenderRequest, RenderRequest, RenderResponseRenderResponse

The request and response objects available The request and response objects available to the doView() method. Similar to the to the doView() method. Similar to the normal servlet requestnormal servlet request

ActionRequest,ActiActionRequest,ActionResponseonResponse

The request and response objects available The request and response objects available to the processAction() method. Similar to the to the processAction() method. Similar to the servlet request and response objects.servlet request and response objects.

PortletURLPortletURL Use this to create URLs that reference the Use this to create URLs that reference the portal.portal.

PortletRequestDisPortletRequestDispatcherpatcher

Use this to include/forward to a JSP or servlet Use this to include/forward to a JSP or servlet in the same portlet app.in the same portlet app.

WindowStateWindowState See if you are in minimized, maximized, See if you are in minimized, maximized, normal state.normal state.

Page 34: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

The Infamous Big PictureThe Infamous Big Picture As a portlet developer, the previous set of classes are As a portlet developer, the previous set of classes are

all you normally touch.all you normally touch. The portlet container (such as Pluto or Gridsphere) is The portlet container (such as Pluto or Gridsphere) is

responsible for running your portlets.responsible for running your portlets.• Init, invoke methods, destroy. Init, invoke methods, destroy.

Portlets have a very limited way of interacting with the Portlets have a very limited way of interacting with the container.container.• It is a black box.It is a black box.• The API is basically one-way.The API is basically one-way.

Page 35: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Deploying Portlet ApplicationsDeploying Portlet Applications The portlet container (i.e. uPortal) runs The portlet container (i.e. uPortal) runs

as a distinct web application.as a distinct web application.• That is, it has its own directory in tomcat.That is, it has its own directory in tomcat.• Moreover, it runs as a separate context, Moreover, it runs as a separate context,

with its own classloader, session with its own classloader, session management, etc.management, etc.

Portlet applications are deployed as Portlet applications are deployed as distinct war files/web applications.distinct war files/web applications.• You go through the container webapp to get You go through the container webapp to get

to the portlet webapp.to the portlet webapp.• Portlets in the same application share jars, Portlets in the same application share jars,

classes, and runtime stuff like request and classes, and runtime stuff like request and session variables.session variables.

• Portlets in different portlet apps do not Portlets in different portlet apps do not share anything.share anything.

Page 36: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

A Critique of JSR 168A Critique of JSR 168 There is no way to share data/objects between portlet There is no way to share data/objects between portlet

applications.applications.• So all grid portlets would have to be in the same portlet app.So all grid portlets would have to be in the same portlet app.

There is no way to extend the portlet API to add such services.There is no way to extend the portlet API to add such services. There is a lack of general purpose portlets.There is a lack of general purpose portlets.

• Right now, you make specific extensions to GenericPortlet for each Right now, you make specific extensions to GenericPortlet for each portlet you develop.portlet you develop.

JSR 168’s MVC approach is incompatible with Turbine, Struts, JSR 168’s MVC approach is incompatible with Turbine, Struts, ….….• The issue is managing <form action=“”> and href URLs.The issue is managing <form action=“”> and href URLs.• No fundamental problem, but this is a gap that must be filled. No fundamental problem, but this is a gap that must be filled. • JSF Portlets are the exception.JSF Portlets are the exception.

No defined way to integrate with portal-specific services (i.e. No defined way to integrate with portal-specific services (i.e. logins).logins).

No inter-portlet communication.No inter-portlet communication. Despite these problems, JSR168 (and WSRP) are the best Despite these problems, JSR168 (and WSRP) are the best

available standards.available standards. • They are compatible.They are compatible.• WSRP overcomes many of the JSR 168 limitations.WSRP overcomes many of the JSR 168 limitations.• But more work needs to be done to make WSRP ready for Grid But more work needs to be done to make WSRP ready for Grid

portals (Web Service security).portals (Web Service security).

Page 37: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Writing Basic OGCE Writing Basic OGCE Portlet TemplatesPortlet Templates

Developing Portlets for OGCE Developing Portlets for OGCE Release 1Release 1

Page 38: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Writing a Velocity PortletWriting a Velocity Portlet

Imagine the following simplistic scenario:Imagine the following simplistic scenario:• I have a web form that helps a user submit a I have a web form that helps a user submit a

job to a supercomputer.job to a supercomputer.• I only need one input form to generate the I only need one input form to generate the

input file, pick a host computer, etc.input file, pick a host computer, etc. The output file is written back to the user’s The output file is written back to the user’s

home directory, so he or she can gridftp it home directory, so he or she can gridftp it later.later.

Before we can do this, we first need a bit Before we can do this, we first need a bit of background on programming portlets.of background on programming portlets.

Page 39: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Velocity Portlet ExampleVelocity Portlet Example

Before handling the Grid execution, Before handling the Grid execution, we will first construct a dummy form.we will first construct a dummy form.

We will use Velocity templates.We will use Velocity templates.• Jetspeed has better support and Jetspeed has better support and

documentation for Velocity.documentation for Velocity.• Most of the portlets in the release use Most of the portlets in the release use

this.this. We will examine a JSP example later.We will examine a JSP example later.

Page 40: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Create the TemplateCreate the Template Open a new file in Open a new file in

nmi/WEB-INF/templates/vmnmi/WEB-INF/templates/vm/portlets/html./portlets/html.

Give it a name, Give it a name, myTestApp.vmmyTestApp.vm

Write the Velocity templateWrite the Velocity template Write an xreg file (see next Write an xreg file (see next

slide).slide). Restart Tomcat.Restart Tomcat. Customize your display to Customize your display to

show the new portal.show the new portal. So far, so good.So far, so good.

<h3> Enter the command <h3> Enter the command you want to execute</h3>you want to execute</h3>

<form method="post"><form method="post"><table><table> <tr><tr>

<td> Command <td> Command Name:</td>Name:</td>

<td> <input type="text" <td> <input type="text" name="runCommnad" name="runCommnad" value="">value="">

</td></td> </tr></tr></table></table></form></form>

Page 41: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Sample JSP Portlet TemplateSample JSP Portlet Template<?xml version="1.0" encoding="UTF-8"?><?xml version="1.0" encoding="UTF-8"?><registry><registry><portlet-entry name="myScienceApp" hidden="false" type="ref"<portlet-entry name="myScienceApp" hidden="false" type="ref" parent="CustomizerVelocity" application="false">parent="CustomizerVelocity" application="false"> <meta-info><meta-info> <title>Sample Proxy Form</title><title>Sample Proxy Form</title> <description>Sample Proxy Form</description><description>Sample Proxy Form</description> </meta-info></meta-info>

<classname>org.apache.jetspeed.portal.portlets.VelocityPortlet</clas<classname>org.apache.jetspeed.portal.portlets.VelocityPortlet</classname>sname>

<parameter name="template" value="myScienceApp" <parameter name="template" value="myScienceApp" hidden="true"hidden="true"

cachedOnName="true" cachedOnValue="true"/>cachedOnName="true" cachedOnValue="true"/> <parameter name="action" value="portlets.myScienceAppAction"<parameter name="action" value="portlets.myScienceAppAction" hidden="true" cachedOnName="true" hidden="true" cachedOnName="true"

cachedOnValue="true"/>cachedOnValue="true"/> <media-type ref="html"/><media-type ref="html"/> <url cachedOnURL="true"/><url cachedOnURL="true"/> </portlet-entry></portlet-entry></registry></registry>

Page 42: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Specifying The TemplateSpecifying The Template

The parts in red The parts in red (template and (template and action) point to action) point to things that you things that you must write.must write.

The line below is The line below is used to name the used to name the VM template in the VM template in the XREG.XREG.• Points to Points to

myScienceApp.vmmyScienceApp.vm

<parameter<parameter

name="template" name="template" value="myScienceAppvalue="myScienceApp" "

hidden="true" hidden="true" cachedOnName="truecachedOnName="true””

cachedOnValue="truecachedOnValue="true"/>"/>

Page 43: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Actions in TemplatesActions in Templates Note our velocity template is just HTML (at this Note our velocity template is just HTML (at this

point) with a form action.point) with a form action.• The action implementation is specified in the XREG file.The action implementation is specified in the XREG file.• MyScienceAppAction.java is the code that does the work MyScienceAppAction.java is the code that does the work

when you click the button.when you click the button. Jetspeed action managers are responsible for Jetspeed action managers are responsible for

calling your actions.calling your actions.• You just need to write the java code, put it in the right You just need to write the java code, put it in the right

place, and connect it to a Velocity template in the XREG place, and connect it to a Velocity template in the XREG file.file.

• Jetspeed will take care of the invocation.Jetspeed will take care of the invocation.

Page 44: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Writing An ActionWriting An Action

A portlet action is just a java class.A portlet action is just a java class. It should extend VelocityPortletActionIt should extend VelocityPortletAction You should implement the You should implement the

buildNormalContext() method.buildNormalContext() method.• This method is called by default when you This method is called by default when you

invoke an HTML form action.invoke an HTML form action.• This can do anything you want (i.e. make calls This can do anything you want (i.e. make calls

to Grid services through the Java COG).to Grid services through the Java COG).• You can also implement other action methods.You can also implement other action methods.

Page 45: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Getting StartedGetting Started Let’s give our simple Let’s give our simple

portlet an action.portlet an action. To do this, we first To do this, we first

modify the modify the • Don’t forget to Don’t forget to

shutdown tomcat first.shutdown tomcat first. We then write the We then write the

action and compile it action and compile it into into nmi/WEB-INF/classes.nmi/WEB-INF/classes.• See next slideSee next slide• Set classpath correctly!Set classpath correctly!

Restart the server.Restart the server.

<parameter name="action" <parameter name="action" value="portlets.mySciencevalue="portlets.myScienceApAction"ApAction"

hidden="true" hidden="true" cachedOnName="true" cachedOnName="true"

cachedOnValue="true"/>cachedOnValue="true"/>

Page 46: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

A Minimal Action: A Minimal Action: myScienceAppAction.javamyScienceAppAction.java

package org.apache.jetspeed.modules.actions.portlets;package org.apache.jetspeed.modules.actions.portlets;//Import Turbine packages.//Import Turbine packages.import org.apache.turbine.util.RunData;import org.apache.turbine.util.RunData;

//Import Velocity packages//Import Velocity packagesimport org.apache.velocity.context.Context;import org.apache.velocity.context.Context;

//Import Jetspeed packages.//Import Jetspeed packages.import import

org.apache.jetspeed.modules.actions.portlets.VelocityPortletAction;org.apache.jetspeed.modules.actions.portlets.VelocityPortletAction;import org.apache.jetspeed.portal.Portlet;import org.apache.jetspeed.portal.Portlet;

public class myScienceAppAction extends VelocityPortletAction {public class myScienceAppAction extends VelocityPortletAction { public void public void buildNormalContext(buildNormalContext(VelocityPortlet portlet, VelocityPortlet portlet,

Context acontext, Context acontext, RunData rundata) RunData rundata) {{//Real action code goes here.//Real action code goes here.

System.out.println("buildNormalContext called");System.out.println("buildNormalContext called"); }}}}

Page 47: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Some Miscellaneous NotesSome Miscellaneous Notes This action is automatically called whenever This action is automatically called whenever

the JSP template’s form action is invoked.the JSP template’s form action is invoked. In the portal release, the In the portal release, the

chef-1.0.7/modules/nmi-lib directory chef-1.0.7/modules/nmi-lib directory contains all the jars needed to compile this contains all the jars needed to compile this code.code.• You can use our ant build scripts as templates You can use our ant build scripts as templates

for writing your own.for writing your own. The portlet actions’s system.out.println() is The portlet actions’s system.out.println() is

written to catalina.out.written to catalina.out. If you prefer, you can use Jetspeed’s logger, If you prefer, you can use Jetspeed’s logger,

which writes to nmi/WEB-INF/log.which writes to nmi/WEB-INF/log.

Page 48: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

RunData, Requests, and RunData, Requests, and SessionsSessions

The method buildNormalContext includes The method buildNormalContext includes an object called an object called RunDataRunData in its arg list. in its arg list.

RunData is your access point to all HTTP RunData is your access point to all HTTP request, response, and session data.request, response, and session data.• HttpSession session=rundata.getSession();HttpSession session=rundata.getSession();• HttpServletRequest req=rundata.getRequest();HttpServletRequest req=rundata.getRequest();

From here, you can do standard java.net.* From here, you can do standard java.net.* development.development.• I am not planning to cover this, but we can I am not planning to cover this, but we can

discuss.discuss.

Page 49: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Connecting Multiple TemplatesConnecting Multiple Templates

In reality, a single web form is not enough In reality, a single web form is not enough to set up a complicated input file, select a to set up a complicated input file, select a host and execute a job.host and execute a job.• These may be spread over multiple linked These may be spread over multiple linked

forms.forms. Form actions in templates must be Form actions in templates must be

handled a bit differently.handled a bit differently. <form action=“SomeOtherPage”><form action=“SomeOtherPage”>

• This can’t point to a template, since it is not This can’t point to a template, since it is not directly accessible (in WEB-INF).directly accessible (in WEB-INF).

• Jetspeed actions handle this.Jetspeed actions handle this.

Page 50: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Redirecting to Another PageRedirecting to Another Page Setting up and Setting up and

running applications running applications from a portal typically from a portal typically requires many requires many successive HTML successive HTML forms.forms.

So we need to see So we need to see how to do this with how to do this with Jetspeed.Jetspeed.

Let’s call this Let’s call this myScienceApp2.vm myScienceApp2.vm and place it in the and place it in the same place as same place as myScienceApp.vm.myScienceApp.vm.

myScienceApp myScienceApp2

myScienceAppAction

Request Response

Page 51: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

First, Modify myScienceApp.vmFirst, Modify myScienceApp.vm Use the Use the

eventSubmit_{actieventSubmit_{action} construction.on} construction.

This action will be This action will be tied to a specific tied to a specific method in method in myScienceAppActimyScienceAppAction.java.on.java.

<h3> Enter the command you <h3> Enter the command you want to execute</h3>want to execute</h3>

<form method="post"><form method="post"><table><table> <tr><tr> <td>Command Name:</td><td>Command Name:</td>

<td><input type="text" <td><input type="text" name="runCommnad" name="runCommnad" value=""></td>value=""></td>

</tr></tr></table></table><input type="submit" <input type="submit"

name="name="eventSubmit_doGet_ceventSubmit_doGet_command"ommand" value="Click to value="Click to Select Host">Select Host">

</form></form>

Page 52: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Next, Modify Your Action CodeNext, Modify Your Action Code Add the following method to Add the following method to

myScienceAppAction.java.myScienceAppAction.java. Your method name should Your method name should

follow the pattern given in the follow the pattern given in the form.form.

This particular action runs This particular action runs setTemplate(), which loads setTemplate(), which loads the indicated Velocity the indicated Velocity template. template.

When you click a form, When you click a form, Jetspeed will look for all Jetspeed will look for all methods matching methods matching eventSubmit’s pattern.eventSubmit’s pattern.

If it finds them, it executes If it finds them, it executes them.them.

If not, buildNormalContext() is If not, buildNormalContext() is the default.the default.

public void public void doGet_command( RundoGet_command( RunData runData, Context Data runData, Context aContext ) {aContext ) {setTemplate(runData, setTemplate(runData, "myVelocityApp2");"myVelocityApp2");

}}

Page 53: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Write the Destination TemplateWrite the Destination Template The following is an The following is an

example of example of myScienceApp2.vm. myScienceApp2.vm.

Note the eventSubmit.Note the eventSubmit. Both of our templates use Both of our templates use

the same action.the same action. We can add a method We can add a method

doGet_host to doGet_host to myScienceAppAction.java myScienceAppAction.java to handle host events.to handle host events.

You can buildYou can build• Once=anomalyOnce=anomaly• Twice=infinitely Twice=infinitely

reproducible patternreproducible pattern

<form method="post"><form method="post">BigIron: <input type=radio BigIron: <input type=radio

name=host name=host value="BigIron">value="BigIron">

<br><br>IronBird: <input type=radio IronBird: <input type=radio

name=host name=host value="IronBird">value="IronBird">

<input type="submit" <input type="submit" name="name="eventSubmit_doGeeventSubmit_doGet_hostt_host" value="Click to " value="Click to Run">Run">

</form></form>

Page 54: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Grid PortletsGrid Portlets There is nothing fundamentally special about Grid portletsThere is nothing fundamentally special about Grid portlets

• Just implement your portlet action with Java COG calls.Just implement your portlet action with Java COG calls. We handle all access to the Grid through the Java COG kit.We handle all access to the Grid through the Java COG kit.

• Hides differences between Globus toolkit versions.Hides differences between Globus toolkit versions.• Currently a higher level programming API for the COG is under Currently a higher level programming API for the COG is under

development as part of NMI.development as part of NMI.• GVL is one of our PIs, so we all have vested interest in this.GVL is one of our PIs, so we all have vested interest in this.

Basic procedure:Basic procedure:• Proxy credentials acquired through MyProxy client portlet.Proxy credentials acquired through MyProxy client portlet.• Modify your action java class (myScienceAppAction.java)Modify your action java class (myScienceAppAction.java)• Use convenience methods to get local GSSCredential from Use convenience methods to get local GSSCredential from

memory.memory.• Use GSSCredential in COG calls to Grid resources.Use GSSCredential in COG calls to Grid resources.• Develop Velocity user interfaces to collect necessary info from Develop Velocity user interfaces to collect necessary info from

users.users.

Page 55: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Example Code: Fetching Example Code: Fetching CredentialsCredentials

The OGCE provides The OGCE provides a convenience a convenience class class ProxyManagerProxyManager for for storing/fetching storing/fetching proxy creds.proxy creds.• Assumes you have Assumes you have

logged in to the logged in to the proxy portlet.proxy portlet.

HttpSession session HttpSession session = = runData.getSessionrunData.getSession();();

GSSCrendential cred GSSCrendential cred = = ProxyManager.getProxyManager.getDefaultProxy(sessiDefaultProxy(session);on);

Page 56: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Using the CoG Portlet InterfacesUsing the CoG Portlet Interfaces

From here, you can develop portlet From here, you can develop portlet actions using the Java CoG kit.actions using the Java CoG kit.

Gregor will discuss new interfaces in Gregor will discuss new interfaces in the next session.the next session.

Page 57: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Portal Testing with Portal Testing with HTTPUnitHTTPUnit

Marcus Christie and Marlon Marcus Christie and Marlon PiercePierce

Page 58: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Types of Unit TestingTypes of Unit Testing

JUnit is a great way for testing code JUnit is a great way for testing code functionality.functionality.

But how do you test portals and portlets?But how do you test portals and portlets?• Portal interfaces need to be tested by simulated Portal interfaces need to be tested by simulated

users.users. Button clicks, link clicks, form interactions, etc.Button clicks, link clicks, form interactions, etc.

For the NMI OGCE project, we have adopted For the NMI OGCE project, we have adopted HttpUnit for this.HttpUnit for this.• http://httpunit.sourceforge.net/http://httpunit.sourceforge.net/

Page 59: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Unique Challenges for Testing Unique Challenges for Testing Grid PortalsGrid Portals

Fluid GUIFluid GUI Much setup required for Grid PortalMuch setup required for Grid Portal

• Portal accountPortal account• Grid Software, accountsGrid Software, accounts• Reliance on external servicesReliance on external services

Broken HTMLBroken HTML Infinite set of user operationsInfinite set of user operations

• Use Cases + Simple Error HandlingUse Cases + Simple Error Handling

Page 60: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

HTTPUnit FeaturesHTTPUnit Features Extension of JunitExtension of Junit

• Integrates easily with Ant <junit> taskIntegrates easily with Ant <junit> task Fairly high level APIFairly high level API Browser emulation (cookies, JavaScript, Browser emulation (cookies, JavaScript,

etc.)etc.) Includes a sloppy/quirky HTML parser Includes a sloppy/quirky HTML parser

(NekoHTML)(NekoHTML)

Page 61: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Setting Up Your TestSetting Up Your Test The code on the The code on the

right shows the right shows the boilerplate to boilerplate to put at the start put at the start of your test.of your test.

We will fill in We will fill in the rest of the the rest of the test in the test in the following slides.following slides.

package xportlets.tests;package xportlets.tests; import import

com.meterware.httpunit.*;com.meterware.httpunit.*; import junit.framework.*;import junit.framework.*; public class XPortletTestCase public class XPortletTestCase

extends TestCase {extends TestCase { ........ public void setUp() throws public void setUp() throws

Exception {Exception { super.setUp();super.setUp(); }} //Rest of the test//Rest of the test }}

Page 62: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Testing a Login FormTesting a Login Form The code shows how to The code shows how to

actually write a simple actually write a simple form test.form test.

Create a Create a WebConversation object.WebConversation object.

Use WebResponse to Use WebResponse to work programmatically work programmatically with the HTML.with the HTML.

Use WebForm to invoke Use WebForm to invoke HTML <forms>HTML <forms>

Assertions are used to Assertions are used to test the content of the test the content of the returned page.returned page.

public WebConversation xPortletAuth() public WebConversation xPortletAuth() throws Exception {throws Exception {

WebConversation wc = new WebConversation wc = new WebConversation();WebConversation();

WebResponse resp = WebResponse resp = wc.getResponse(url);wc.getResponse(url);

WebForm form = resp.getForms()[0];WebForm form = resp.getForms()[0];form.setParameter("username", form.setParameter("username", username);username);

form.setParameter("password", form.setParameter("password", password);password);

form.submit();form.submit(); WebResponse resp2 = WebResponse resp2 =

wc.getCurrentPage();wc.getCurrentPage(); String page = resp2.getText();String page = resp2.getText(); assertTrue("Failed to log in", assertTrue("Failed to log in",

page.indexOf("Welcome to page.indexOf("Welcome to

your workspace") != -1);your workspace") != -1); return wc;return wc; }}

Page 63: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Simulating Button ClicksSimulating Button Clicks Create SubmitButton Create SubmitButton

objects to simulate objects to simulate button clicks.button clicks.• ““myButton” is the name myButton” is the name

of the submit button in of the submit button in the HTML <form>the HTML <form>

Calling click() causes Calling click() causes the form action to take the form action to take place.place.

Get the new page Get the new page from the from the WebConversation WebConversation object.object.

public void testSimplePing() throws public void testSimplePing() throws Exception {Exception {

WebConversation wc = WebConversation wc = xPortletAuthProxy();xPortletAuthProxy();

WebResponse resp = WebResponse resp = wc.getCurrentPage();wc.getCurrentPage();

WebForm form = resp.getForms()[3];WebForm form = resp.getForms()[3]; form.setParameter("service", form.setParameter("service",

"rainier.extreme.indiana.edu");"rainier.extreme.indiana.edu"); SubmitButton addServiceBtn = SubmitButton addServiceBtn =

form.getSubmitButton(“myButton");form.getSubmitButton(“myButton"); assertNotNull(“myButton",assertNotNull(“myButton", addServiceBtn);addServiceBtn); addServiceBtn.click();addServiceBtn.click(); WebResponse resp2 = WebResponse resp2 =

wc.getCurrentPage();wc.getCurrentPage(); WebForm form2 = resp2.getForms()WebForm form2 = resp2.getForms()

[3];[3];}}

Page 64: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Running HttpUnit with AntRunning HttpUnit with Ant After you have developed a suite of tests, After you have developed a suite of tests,

you can automate your portal tests using you can automate your portal tests using Ant’s optional JUnit task.Ant’s optional JUnit task.

Even better, you can combine this with the Even better, you can combine this with the <junitreport> task that will generate nice <junitreport> task that will generate nice HTML report forms.HTML report forms.

First, you will need to put these jars in ant’s First, you will need to put these jars in ant’s lib directory.lib directory.• httpunit.jarhttpunit.jar• junit.jarjunit.jar

Page 65: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

An Example Unit Test TargetAn Example Unit Test Target Let’s say all of your tests Let’s say all of your tests

fit the pattern fit the pattern Test*.class.Test*.class.

Then run a <batchtest> Then run a <batchtest> to run all of them at to run all of them at once.once.• Will run all testsWill run all tests• Won’t exit on failed test.Won’t exit on failed test.

Use errorProperty and Use errorProperty and failureProperty to catch failureProperty to catch these states.these states.

Specify an XML formatter Specify an XML formatter for pretty output (next).for pretty output (next).

<junit printsummary="true”<junit printsummary="true”

errorProperty="test.faileerrorProperty="test.failed" d" failureProperty="test.failfailureProperty="test.failed">ed">

<formatter type="xml"/><formatter type="xml"/> <batchtest <batchtest

todir="$todir="${report.dir}">{report.dir}">

<fileset dir="classes" <fileset dir="classes" includes="**/includes="**/Test*.class"/>Test*.class"/>

</batchtest></batchtest></junit></junit>

Page 66: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Generating HTML dashboardsGenerating HTML dashboards The <junitreport> The <junitreport>

target can be used to target can be used to convert the report convert the report outputs from outputs from <junit>.<junit>.

Use <report> to Use <report> to generate HTML.generate HTML.

Finally the <fail> Finally the <fail> message checks if message checks if any tests failed. any tests failed. • See previous target.See previous target.

<junitreport todir="$<junitreport todir="${report.dir}">{report.dir}">

<fileset dir="$<fileset dir="${report.dir}">{report.dir}">

<include <include name="TEST*.xml"/>name="TEST*.xml"/>

</fileset></fileset> <report format="frames" <report format="frames"

todir="$todir="${html.report.dir}"/>{html.report.dir}"/>

</junitreport></junitreport><fail message=“Tests <fail message=“Tests

failed." if="test.failed"/>failed." if="test.failed"/>

Page 67: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Example Report DashboardExample Report Dashboard

List of Test Classes

Test Results for OneOf the Test Cases

Page 68: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Some Drawbacks to HTTPUnitSome Drawbacks to HTTPUnit Tests are tied to page structures.Tests are tied to page structures.

• If you change your page (say, reordering links If you change your page (say, reordering links or forms), you will break your tests.or forms), you will break your tests.

Tests also depend on Tests also depend on Test assertions typically depend on the Test assertions typically depend on the

content of the page.content of the page.• If content changes, tests may break.If content changes, tests may break.• Checking content is not completely sufficient Checking content is not completely sufficient

for testing Grid portals.for testing Grid portals.

Page 69: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Additional CapabilitiesAdditional Capabilities

Page 70: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Capability: Community Capability: Community Scheduling Framework PortletsScheduling Framework Portlets

CSF Use Case CSF Use Case Researcher submits job through User PortalResearcher submits job through User Portal User Portal uses GridPort toUser Portal uses GridPort to

• authenticate userauthenticate user• optionally make advanced reservation to visualization systemoptionally make advanced reservation to visualization system• submit job to CSFsubmit job to CSF

CSF selects compute cluster with best fit and forwards jobCSF selects compute cluster with best fit and forwards job Gridport sends results to visualization systemGridport sends results to visualization system

User Workstation

User PortalGridPort

CSF

VisualizationSystem

Bandera

Blanco

Buda

Page 71: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Capability: Job Sequencer PortletsCapability: Job Sequencer Portlets

Portal

User uses Portal to generate XML description of sequence.

" xsi:schemaLocation="http://grids.tacc.utexas.edu/schemas/sequencer/jobSequenceC:\DOCUME~1\Maytal\Desktop\Maytal\Work\GP-IR\GP-IRX~1\motd.xsd">

< <Status>New</Status> <Step> <Status>Unscheduled</Status> <Type>CSFJob</Type> <Parameter name="jobFactoryServiceHandle">http://129.116.218.36:15080/ogsa/services/metascheduler/JobFactoryService</Parameter> <Parameter name="queue">normal</Parameter> <Parameter name="executable">pam</Parameter> <Parameter name="arguments">-g 1 mpichp4_wrapper /home/monitor/mpi_jobs/mpimd_5</Parameter> <Parameter name="directory">/home/monitor/mpi_jobs</Parameter> <Parameter name="count">4</Parameter> <Parameter name="stdIn">/dev/null</Parameter> <Parameter name="stdOut">/home/monitor/mpi_jobs/tomislavSequencerJobOut</Parameter> <Parameter name="stdErr">/home/monitor/mpi_jobs/tomislavSequencerJobErr</Parameter> </Step> <Step> <Status></Status> <Type>GridFTP</Type> <Parameter name="fromHost">[Previous]</Parameter> <Parameter name="toHost">blanco.tacc.utexas.edu:2811</Parameter> <Parameter name="fromFileFullName">/home/monitor/mpi_jobs/tomislavSequencerJobOut</Parameter> <Parameter name="toFileFullName">/home/monitor/mpi_jobs/tomislavSequencerJobOutCopied</">/home/monitor/mpi_jobs/tomislavSequencerJobErr</Parameter> <Parameter name="toFileFullName">/home/monitor/mpi_jobs/tomislavSequencerJobErrCopied</Parameter> </Step></JobSequence>

Currently, sequence steps can consist of

File Transfers and Job Submissions to the

CSF meta scheduler

GPIR

The XML is then decomposed and persisted to GPIR where the status

information of each step in the sequence and of the sequence as a whole can be

stored

Sequencer

GridPort returns a Sequence ID to the

Portal immediately and then begins executing

the Sequence to completion or to error. Status information can be obtained at any time with the Sequence ID

Page 72: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

O.G.R.E.—A Job Management Engine

• O.G.R.E. = Open Grid Computing Environments

Runtime Engine

• What Ant lacked, but we needed:• Broader conditional execution,

• Ant: based on write-once String properties.

• A general “loop” structure for Task execution.

• Data-communication between Tasks (and with their containers).

• Specialized tasks

• File reading and writing

• Local and remote file management (gridftp)

• Web service related tasks

• Event- and process-monitoring-tasks

Page 73: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

XDirectory: A Grid Context ServiceXDirectory: A Grid Context Service

XDirectory is itself a Grid Service that is access by the XDirectory is itself a Grid Service that is access by the portal.portal.• An index over a relational databaseAn index over a relational database• Each node is either a “directory node” or a leaf.Each node is either a “directory node” or a leaf.• Leaf nodes are xml elements which contain metadata as well Leaf nodes are xml elements which contain metadata as well

as html annotations.as html annotations.

Page 74: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

JavaCOG

Example Capability: File Example Capability: File ManagementManagement

Grid FTP portlet– Allow Grid FTP portlet– Allow User to manage User to manage remote file spacesremote file spaces• Uses stored proxy for Uses stored proxy for

authenticationauthentication• Upload and download Upload and download

filesfiles• Third party file transferThird party file transfer

Request that GridFTP Request that GridFTP server A send a file to server A send a file to GridFTP server BGridFTP server B

Does not involve traffic Does not involve traffic through portal serverthrough portal server

Portal Server

User “Beth”

GridFTPServer A GridFTP

Server B

GridFTPportlet

Page 75: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

JSR 168 TutorialJSR 168 Tutorial

Details on Writing portletsDetails on Writing portlets

Page 76: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

In Action: Get started.In Action: Get started.public class JunkPortlet extends public class JunkPortlet extends

GenericPortlet {GenericPortlet {

public void init(){public void init(){

//Do any initialization.//Do any initialization.

}}

//Rest of the methods on following //Rest of the methods on following slides go here.slides go here.

……

}}

Page 77: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Override doView()Override doView() protected void doView( protected void doView( RenderRequest reqRenderRequest req, , RenderResponse RenderResponse

resres) ) throws PortletException, IOException {throws PortletException, IOException {//Include the desired JSP or HTML page.//Include the desired JSP or HTML page.//We could also use out to write directly to the response.//We could also use out to write directly to the response.WindowState state=req.getWindowState();WindowState state=req.getWindowState();if(!state.equals(WindowState.MINIMIZED)) {if(!state.equals(WindowState.MINIMIZED)) { res.setContentType("text/html");res.setContentType("text/html"); PortletRequestDispatcherPortletRequestDispatcher rd= rd=

getPortletContext().getRequestDispatcher(“MyJSP.jsp”);getPortletContext().getRequestDispatcher(“MyJSP.jsp”); rd.include(req,res);rd.include(req,res);}}

}}

Page 78: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

The JSP PageThe JSP Page<<portlet:defineObjectsportlet:defineObjects/>/><%<%PortletSession PortletSession

portletSession=renderRequest.getPortletSession();portletSession=renderRequest.getPortletSession();portletSession.setAttribute("localattname","localattvalportletSession.setAttribute("localattname","localattval

");");PortletURL url=renderResponse.createActionURL();PortletURL url=renderResponse.createActionURL();String theActionString=url.toString();String theActionString=url.toString();%>%>HTML Content is here. HTML Content is here. A form is below.A form is below.<form method=post action="<%=<form method=post action="<%=theActionStringtheActionString

%>">%>"><input type=…><input type=…></form></form>

Page 79: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Some NotesSome Notes Include the <%portlet:definedObjects/%> tag, which will Include the <%portlet:definedObjects/%> tag, which will

instantiate renderRequest, renderResponse, and instantiate renderRequest, renderResponse, and portletConfig objects.portletConfig objects.• You can then just use them, as with request, response, and You can then just use them, as with request, response, and

other JSP implicit objects.other JSP implicit objects. The renderRequest gives you access to the PortletSession, The renderRequest gives you access to the PortletSession,

if you want to store session variables.if you want to store session variables.• One of the trouble points.One of the trouble points.

The renderResponse gives you access to the PortletURL The renderResponse gives you access to the PortletURL object.object.

Use the PortletURL to generate a URL for the <form Use the PortletURL to generate a URL for the <form action>action>• So that it points to portlet container and gets handled by the So that it points to portlet container and gets handled by the

processAction() method, rather than going of into space.processAction() method, rather than going of into space.• Handle href URLs similarly.Handle href URLs similarly.• This is one of the sticking points. This is one of the sticking points.

Page 80: Developing Grid Portals Using Portlets Marlon Pierce Community Grids Lab Indiana University

Lastly, Override processAction()Lastly, Override processAction() When you invoke the form on the When you invoke the form on the

previous JSP, the portlet container previous JSP, the portlet container will pass the action handling to will pass the action handling to the processAction method.the processAction method.

The ActionRequest can be used to The ActionRequest can be used to get any of the <input> get any of the <input> parameters in a way similar to the parameters in a way similar to the usual HttpServletRequest.usual HttpServletRequest.

When the processAction method When the processAction method returns, the container then returns, the container then invokes the appropriate do invokes the appropriate do method (usually doView).method (usually doView).

If you need to pass <form> If you need to pass <form> parameters on to doView, add parameters on to doView, add them to the ActionResponse.them to the ActionResponse.• This will give them to the This will give them to the

RenderRequest.RenderRequest.• The example shows how to add The example shows how to add

ALL parameters.ALL parameters.

public void processAction public void processAction (ActionRequest request, (ActionRequest request, ActionResponse ActionResponse actionResponse) throws actionResponse) throws PortletException, PortletException, java.io.IOException {java.io.IOException {//Process request //Process request parameters parameters ……//Add any other request //Add any other request paramsparams// to the renderRequest// to the renderRequest

actionResponse.setRenderPactionResponse.setRenderParameters(request.getParaarameters(request.getParameterMap());meterMap());

}}