portals, portlets, and clients to grid services marlon pierce community grids lab indiana university...

58
Portals, Portlets, Portals, Portlets, and Clients to and Clients to Grid Services Grid Services Marlon Pierce Marlon Pierce Community Grids Lab Community Grids Lab Indiana University Indiana University [email protected] [email protected]

Upload: evan-cooper

Post on 13-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Portals, Portlets, and Portals, Portlets, and Clients to Grid ServicesClients to Grid Services

Marlon PierceMarlon PierceCommunity Grids LabCommunity Grids Lab

Indiana UniversityIndiana [email protected]@cs.indiana.edu

Page 2: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Useful LinksUseful Links

These slides are available from here:These slides are available from here:• http://www.servogrid.org/slide/iSERVO/http://www.servogrid.org/slide/iSERVO/

IRIS_WebServices_2005/IRIS_WebServices_2005/ General portlet tutorial information is General portlet tutorial information is

available from here:available from here:• http://www.servogrid.org/slide/iSERVO/http://www.servogrid.org/slide/iSERVO/

NMI/OGCE2TutorialMaterial/NMI/OGCE2TutorialMaterial/ Grid portlets are available from here:Grid portlets are available from here:

• http://www.collab-ogce.orghttp://www.collab-ogce.org

Page 3: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

OutlineOutline

Globus toolkit reviewGlobus toolkit review Computational Portals and PortletsComputational Portals and Portlets Building Grid Portlets with the Java Building Grid Portlets with the Java

CoG Kit CoG Kit

Page 4: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Purpose of TalkPurpose of Talk I am not affiliated with Globus and do not develop I am not affiliated with Globus and do not develop

Globus Web Services.Globus Web Services.• I just use Globus services as-is.I just use Globus services as-is.• My slides are from this point of view.My slides are from this point of view.

My emphasis is on building My emphasis is on building Web PortalsWeb Portals from portlets from portlets as clients to Grid services using the Java COG kit.as clients to Grid services using the Java COG kit.

The Java CoG kit project is lead by The Java CoG kit project is lead by Gregor von Gregor von LaszewskiLaszewski at Argonne National Labs at Argonne National Labs

I work with Gregor through the I work with Gregor through the Open Grid Computing Open Grid Computing EnvironmentsEnvironments project. project.• We build portlets using the Java CoGWe build portlets using the Java CoG

I also lead portlet and Web Service development for I also lead portlet and Web Service development for the the NASA SERVOGridNASA SERVOGrid project. project.• Grid services, GIS servicesGrid services, GIS services

Page 5: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

SERVOGrid SummarySERVOGrid Summary Portlet-based portalPortlet-based portal

• With portal extensions to With portal extensions to support secure remote support secure remote portlets.portlets.

““Execution Grid” Web Execution Grid” Web ServicesServices• Run remote tasks using Ant Run remote tasks using Ant

job managers.job managers.• Move files around (upload, Move files around (upload,

download, crossload).download, crossload).• Maintain persistent user Maintain persistent user

session statesession state ““Context”Context”

• Application metadata to Application metadata to describe applications.describe applications.

Provide data portal Provide data portal applications.applications.

• Monitor jobsMonitor jobs

Data Grid Web ServicesData Grid Web Services• Use Geographical Information Use Geographical Information

System standards.System standards.• Web Feature ServiceWeb Feature Service

Encodes GPS, Seismic, and Encodes GPS, Seismic, and Fault data archives as GML.Fault data archives as GML.

Working on high performance Working on high performance web services.web services.

• Web Map ServiceWeb Map Service Generates interactive web Generates interactive web

maps using features and other maps using features and other map servers.map servers.

Streaming video version in Streaming video version in development.development.

• Sensor Grid ServicesSensor Grid Services Real time streaming GPS Real time streaming GPS Data mining on streamsData mining on streams

Information Grid ServicesInformation Grid Services• Extended UDDIExtended UDDI• WS-Context for session WS-Context for session

metadata.metadata.

www.crisisgrid.orgquakesim.jpl.nasa.org

Page 6: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Globus Toolkit OverviewGlobus Toolkit Overview The Globus Toolkit provides foundations for The Globus Toolkit provides foundations for

building “building “Virtual OrganizationsVirtual Organizations.”.” Single Sign-On AuthenticationSingle Sign-On Authentication

• Log in once, access all machines on your Grid.Log in once, access all machines on your Grid. Grid Security InfrastructureGrid Security Infrastructure

• Public Key InfrastructurePublic Key Infrastructure• Generic Security Service programming interfacesGeneric Security Service programming interfaces

Secure Remote Resource AccessSecure Remote Resource Access• Remotely execute tasks.Remotely execute tasks.• Interact with both shells and queuing systems.Interact with both shells and queuing systems.

Secure, high performance file transferSecure, high performance file transfer Information servicesInformation services for your grid resources. for your grid resources.

Page 7: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Globus Toolkit 2.xGlobus Toolkit 2.x GT 2 services implemented as Unix services.GT 2 services implemented as Unix services.

• You quite commonly manage them through /etc/xinetd.d or You quite commonly manage them through /etc/xinetd.d or similar. similar.

Standard services in xinetd.d:Standard services in xinetd.d:• GRAMGRAM gatekeeper for running remote tasks. gatekeeper for running remote tasks.• GridFTPGridFTP for file transfers for file transfers

Upload, download, and third party.Upload, download, and third party.• MDSMDS information services information services• MyProxyMyProxy: a remote credential repository so that you don’t : a remote credential repository so that you don’t

need to keep lots of copies of your private key.need to keep lots of copies of your private key. Jim Basney at NCSA is the MyProxy guy.Jim Basney at NCSA is the MyProxy guy.

Support for both remote shell operations and Support for both remote shell operations and queuing systemsqueuing systems..• PBS and LSF tend to be best supported.PBS and LSF tend to be best supported.• You may be able to find others.You may be able to find others.

Many other Globus-related tools have come and Many other Globus-related tools have come and gone.gone.

Page 8: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Globus Toolkit and Web ServicesGlobus Toolkit and Web Services Globus and others in the Global Grid Forum realized that they Globus and others in the Global Grid Forum realized that they

needed to provide needed to provide more than just a bag of servicesmore than just a bag of services• Needed a framework for building new services.Needed a framework for building new services.• Needed standard languages for writing service APIsNeeded standard languages for writing service APIs• Standard messaging envelopes.Standard messaging envelopes.• Web Services were the natural fit.Web Services were the natural fit.

The The Open Grid Services ArchitectureOpen Grid Services Architecture (OGSA) outlines the basic (OGSA) outlines the basic premise of the Globus approach to Web Services.premise of the Globus approach to Web Services.

Globus Toolkit 3.x was the initial implementation of these Globus Toolkit 3.x was the initial implementation of these ideas.ideas.

But it was found to be But it was found to be unsustainableunsustainable..• Initial spec (“OGSI”) was too monolithic, took to long to approve, Initial spec (“OGSI”) was too monolithic, took to long to approve,

made custom extensions to WSDL, had portions that were made custom extensions to WSDL, had portions that were superseded by the main stream Web Service community, and superseded by the main stream Web Service community, and was disconnected from the general community (OASIS, W3C).was disconnected from the general community (OASIS, W3C).

• See See http://www-128.ibm.com/developerworks/library/ws-resource/ogsihttp://www-128.ibm.com/developerworks/library/ws-resource/ogsi_to_wsrf_1.0.pdf_to_wsrf_1.0.pdf for some discussion. for some discussion.

GT 4 release (April 2005) attempts to correct these problems.GT 4 release (April 2005) attempts to correct these problems.

Page 9: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Some Globus 2 Services v. Globus 4 Some Globus 2 Services v. Globus 4 Web ServicesWeb Services

PKI X.509 certificatesPKI X.509 certificates used for used for mutual authenticationmutual authentication

GSI SecurityGSI Security• GSSAPI-based socket GSSAPI-based socket

connectionsconnections GRAMGRAM

• Uses Resource Specification Uses Resource Specification Language (RSL)Language (RSL)

• Binds to PBS, LSF, and possibly Binds to PBS, LSF, and possibly other schedulers with third party other schedulers with third party plugins (support may vary).plugins (support may vary).

GridFTPGridFTP• Note GT 4 includes GridFTP 2.0, Note GT 4 includes GridFTP 2.0,

which is a different codebase which is a different codebase from GridFTP 1.17 bundled in from GridFTP 1.17 bundled in previous Globus releases. previous Globus releases.

• We have reported some We have reported some incompatibilities, which I think incompatibilities, which I think have been addressed in GT have been addressed in GT 4.0.1.4.0.1.

Still Still PKI X.509PKI X.509 based mutual based mutual authentication…authentication…

But used now with But used now with Web Service Web Service Security:Security: SSL and WS-Security SSL and WS-Security• Your certificates work in both GT Your certificates work in both GT

versions.versions. WS-GRAMWS-GRAM

• Replaces RSL with XML Job Replaces RSL with XML Job Descriptors.Descriptors.

• Uses Reliable File Transfer and Uses Reliable File Transfer and GridFTP to support file staging GridFTP to support file staging and multiple jobs (which is a and multiple jobs (which is a pain to install).pain to install).

• Binds to PBS, LSF Binds to PBS, LSF Reliable File Transfer (RFT)Reliable File Transfer (RFT)

• Web Service-basedWeb Service-based• Uses “scheduling” techniques to Uses “scheduling” techniques to

do batch file transfers that don’t do batch file transfers that don’t require persistent client require persistent client connections.connections.

• Builds on GridFTP.Builds on GridFTP.

Page 10: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Grid (and Web Service) ClientsGrid (and Web Service) Clients

Web and Grid Services run in Web and Grid Services run in service hosting service hosting environments.environments.• Apache Axis, Globus WS container, etc.Apache Axis, Globus WS container, etc.

Clients likewise need to run in Clients likewise need to run in client hosting client hosting environments.environments.• Graphical Use Interfaces, Desktops, Web Browser Graphical Use Interfaces, Desktops, Web Browser

PortalsPortals• But also grid and web service shells.But also grid and web service shells.

Gridshell, HPSearchGridshell, HPSearch

We will focus on portals, since these are the We will focus on portals, since these are the most common and have standards.most common and have standards.

Page 11: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Building Grid PortalsBuilding Grid Portals

Page 12: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

A Famous Web PortalA Famous Web Portal

Page 13: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

A Famous Portal, After LoginA Famous Portal, After Login

Page 14: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

What to NoticeWhat to Notice After logging in, my colors, layouts, and After logging in, my colors, layouts, and

content all changed.content all changed.• I get my stock list, my Bloomington weather, my I get my stock list, my Bloomington weather, my

news stories, etc.news stories, etc.• I got rid of “Garfield”I got rid of “Garfield”

As we will see later, each of these content As we will see later, each of these content fragments (encircled) is managed by a thing fragments (encircled) is managed by a thing called a called a portletportlet……• … … I don’t guarantee that this is true for Yahoo’s I don’t guarantee that this is true for Yahoo’s

web site but it is true for a large class of web site but it is true for a large class of enterprise Java portal systems.enterprise Java portal systems.

Portlets are the key to portal software reuse.Portlets are the key to portal software reuse.

Page 15: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

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

’90s. ’90s. • HotPage from SDSC, NCSA efforts, DOD, DOE Portals, NASA HotPage from SDSC, NCSA efforts, DOD, DOE Portals, NASA

IPGIPG• 2002 Special Issue of Concurrency and Computation: 2002 Special Issue of Concurrency and Computation:

Practice and Experience.Practice and Experience. The field continues to be activeThe field continues to be active

• An upcoming issue of Concurrency will survey the current An upcoming issue of Concurrency will survey the current field.field.

• Based on Global Grid Forum 14 Science Gateway workshop Based on Global Grid Forum 14 Science Gateway workshop in June 2005.in June 2005.

• GCE2005 workshopGCE2005 workshop at Supercomputing 05. at Supercomputing 05. http://www.ggf.org/ggf_events_lodging_ggf15.htmhttp://www.ggf.org/ggf_events_lodging_ggf15.htm

Global Grid Forum’s Grid Computing Environments Global Grid Forum’s Grid Computing Environments (GCE) Research Group(GCE) Research Group• Community forumCommunity forum

How do we share and reuse all of this work?How do we share and reuse all of this work?

Page 16: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

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 17: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

What Is a Portlet?What Is a Portlet? A portlet is a piece of Java code that manages the A portlet is a piece of Java code that manages the

content of one section of a web portal’s HTML.content of one section of a web portal’s HTML. It can do anything else that a Java web application It can do anything else that a Java web application

can do.can do.• You can connect a portlet to a database, invoke a web You can connect a portlet to a database, invoke a web

service, download an RSS feed, etc.service, download an RSS feed, etc. It lives in a It lives in a portlet containerportlet container, which creates, , which creates,

manages, and destroys all the portlets of the portal.manages, and destroys all the portlets of the portal. Portlet containers are part of portals.Portlet containers are part of portals.

• Portals must do other things like manage login, users, Portals must do other things like manage login, users, groups, layouts, etc.groups, layouts, etc.

JSR 168JSR 168 standardizes two main things: standardizes two main things:• How the portlet container manages portlet lifecyclesHow the portlet container manages portlet lifecycles• How the portlets are programmed.How the portlets are programmed.

Page 18: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

JSR 168 OverviewJSR 168 Overview

A General Review of JSR 168A General Review of JSR 168

Page 19: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

What is JSR 168?What is JSR 168? From the portlet development point of view, From the portlet development point of view,

it is really very simple:it is really very simple:• You write a java class that extends You write a java class that extends

GenericPortletGenericPortlet..• You override/implement several methods You override/implement several methods

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

Many are analogous to their Many are analogous to their servlet equivalentsservlet 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. I have a complete example in the extended I have a complete example in the extended

slides.slides.• See also tutorial slides.See also tutorial slides.

Page 20: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Some GenericPortlet.java MethodsSome GenericPortlet.java MethodsMethodMethod DescriptionDescription

InitInit Called when the portlet is created. Called when the portlet is created. Override if you need to set initial params.Override if you need to set initial 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 override method (like doView). You should override this for web forms.this for web forms.

Page 21: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Some Supporting Classes/InterfacesSome Supporting Classes/InterfacesClassClass DescriptionDescription

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

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

RenderRequest, RenderRequest, RenderResponseRenderResponse

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

ActionRequest,ActioActionRequest,ActionResponsenResponse

The request and response objects available to The request and response objects available to the processAction() method. Similar to the 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 portal.Use this to create URLs that reference the portal.

PortletRequestDispaPortletRequestDispatchertcher

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

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

Page 22: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

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

normally touch.normally touch. The portlet container (Pluto) is responsible for running your The portlet container (Pluto) is responsible for running your

portlets.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->black hole.It is a black box->black hole.• The API is basically one-way.The API is basically one-way.

Page 23: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

A Comment on Portlet CodingA Comment on Portlet Coding The extended example makes some important and The extended example makes some important and

dubious assumptionsdubious assumptions• Developers would want to write a GenericPortlet extension Developers would want to write a GenericPortlet extension

for every single portlet they develop.for every single portlet they develop. And write really complicated processAction() and doView() And write really complicated processAction() and doView()

methods.methods.• Developers will like the specific JSR 168 Developers will like the specific JSR 168 portlet-style Model-portlet-style Model-

View-ControllerView-Controller that it forces on them. that it forces on them.• Developers will gladly ignore other development Developers will gladly ignore other development

methodologies/frameworks like methodologies/frameworks like Velocity, Struts, and Java Velocity, Struts, and Java Server Faces.Server Faces.

Fortunately, these other development environments Fortunately, these other development environments can be mapped to portlet actions. can be mapped to portlet actions. • In the OGCE project, we have developed support for In the OGCE project, we have developed support for

Velocity portlets.Velocity portlets.• We are transitioning to Java Server FacesWe are transitioning to Java Server Faces

Page 24: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Some Free JSR 168 ContainersSome Free JSR 168 ContainersContainerContainer CommentsComments

GridSphereGridSphere Supports JSF. I recommend. Popular container in Supports JSF. I recommend. Popular container in scientific portal community.scientific portal community.

uPortaluPortal Supports WSRP; JSF support planned. I have used Supports WSRP; JSF support planned. I have used extensively, but prefer GridSphere.extensively, but prefer GridSphere.

LifeRayLifeRay Depends heavily on EJB. Interesting set of portlets Depends heavily on EJB. Interesting set of portlets but too non-portable.but too non-portable.

ExoPortalExoPortal I found this difficult to use, had some I found this difficult to use, had some incompatibilities with CoG jars. incompatibilities with CoG jars.

StringBeansStringBeans Supports WSRP, JSF. I have not yet evaluated.Supports WSRP, JSF. I have not yet evaluated.

Page 25: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

The Java CoG KitThe Java CoG Kit

Gregor von LaszewskiGregor von LaszewskiArgonne National LaboratoryArgonne National Laboratory

University of ChicagoUniversity of [email protected]@mcs.anl.govhttp://www.cogkit.orghttp://www.cogkit.org

Page 26: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

The Story So Far…The Story So Far…

Globus has several interesting Globus has several interesting services that can be used out of the services that can be used out of the box.box.

Portlets can be used to build portals Portlets can be used to build portals out of reusable parts.out of reusable parts.

Portlets (as Java code) can also be Portlets (as Java code) can also be used to invoke remote services.used to invoke remote services.

Now we will look at how to do this for Now we will look at how to do this for Grid applications.Grid applications.

Page 27: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

CoG KitsCoG Kits

CoG Kits make Grid programming simple and CoG Kits make Grid programming simple and new technologies are easy to integratenew technologies are easy to integrate

We focus on a CoG Kit for JavaWe focus on a CoG Kit for Java• Python also available (K. Jackson, LBNL)Python also available (K. Jackson, LBNL)• Availability: Java CoG Kit since 1997Availability: Java CoG Kit since 1997

The CoG provides two important thingsThe CoG provides two important things• A higher level programming client programming A higher level programming client programming

environment than stubs.environment than stubs.• A shield against different versions of the Globus A shield against different versions of the Globus

toolkittoolkit Same high level API works with GT 2.4, GT 3.0.2, GT Same high level API works with GT 2.4, GT 3.0.2, GT

3.2.0, GT 3.2.1, GT 4.0.03.2.0, GT 3.2.1, GT 4.0.0

Page 28: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

CoG Abstraction Layer

CoG CoG CoG CoG CoG

CoG Data and Task Management Layer

CoG Gridfaces Layer

CoG CoG

CoG

GridID

E

GT2GT3OGSI

classic

GT4WS-RF

Condor Unicore

Applications

SSHOthersAvakiSETI

Nanomaterials

Bio-Informatics

DisasterManagement

Portals

CoG Abstraction Layer

CoG CoG CoG CoG CoG

CoG Data and Task Management Layer

CoG Gridfaces Layer

CoG CoG

CoG

GridID

E

DevelopmentSupport

CoG Abstraction Layers CoG Abstraction Layers

Page 29: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Grid Portlet OverviewGrid Portlet Overview In the tutorial examples, we look at writing JSR 168 In the tutorial examples, we look at writing JSR 168

portlets using JSP and Velocity.portlets using JSP and Velocity. Grid Portlets are just portlets, and portlets are just Grid Portlets are just portlets, and portlets are just

Java applications.Java applications.• Use the Java CoG to make calls from the portlet code to Use the Java CoG to make calls from the portlet code to

the desired Grid service.the desired Grid service.• Can also make non-COG calls, such as to GridPort API.Can also make non-COG calls, such as to GridPort API.

These APIs are not be portlet-specific, since you These APIs are not be portlet-specific, since you should be able to reuse the Grid APIs from other should be able to reuse the Grid APIs from other Java clients.Java clients.• You can also build Web Services out of them.You can also build Web Services out of them.• NCSA’s OGRE (general), Trebuchet (application specific) NCSA’s OGRE (general), Trebuchet (application specific)

are examples are examples • NCSA Tupelo also makes use of COG in its metadata NCSA Tupelo also makes use of COG in its metadata

management services.management services.

Page 30: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

COG and PortletsCOG and Portlets We use the COG to illustrate some We use the COG to illustrate some

basic portlet programming features.basic portlet programming features. We use the COG4 APIs in our We use the COG4 APIs in our

ProxyManager, Job Submission, and ProxyManager, Job Submission, and GridFTP portletsGridFTP portlets• Hides differences between Globus Toolkit Hides differences between Globus Toolkit

versions.versions.• Is also structured to handle task-based Is also structured to handle task-based

workflow and job composition.workflow and job composition. For more detailed examples, see the For more detailed examples, see the

extended version of these slides.extended version of these slides.

Page 31: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

TaskTask

Handler

Service

TaskSpecification

SecurityContext

ServiceContact

The class diagram is thesame for all grid tasks (running jobs, modifying files, moving data).

Classes also abstract toolkit provider differences. You set these as parameters: GT2, GT4, etd.

Page 32: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Setting Up Task and SpecificationSetting Up Task and Specification

Task task=new TaskImpl(“mytask”,Task task=new TaskImpl(“mytask”,Task.JOB_SUBMISSION);Task.JOB_SUBMISSION);

task.setProvider(“GT2”);task.setProvider(“GT2”);JobSpecification spec=JobSpecification spec=

new JobSpecificationImpl();new JobSpecificationImpl();spec.setExecutable(“rm”);spec.setExecutable(“rm”);spec.setBatchJob(true);spec.setBatchJob(true);spec.setArguments(“-r”);spec.setArguments(“-r”);……task.setSpecification(spec);task.setSpecification(spec);

Page 33: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Setting Up the Service and Security Setting Up the Service and Security ContextContext

Service service=new Service service=new ServiceImpl(Service.JOB_SUBMISSION);ServiceImpl(Service.JOB_SUBMISSION);

service.setProvider(“GT2”);service.setProvider(“GT2”);

SecurityContext securityContext=SecurityContext securityContext=

CoreFactory.newSecurityContext(“GT2”);CoreFactory.newSecurityContext(“GT2”);

//Use cred object from ProxyManager//Use cred object from ProxyManager

securityContext.setCredentials(cred);securityContext.setCredentials(cred);

service.setSecurityContext(service.setSecurityContext(

(SecurityContext)securityContext);(SecurityContext)securityContext);

Page 34: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Set Up Service Contact and Set Up Service Contact and FinishFinish

ServiceContact serviceContact=ServiceContact serviceContact=

new ServiceContact(“myhost.myorg.org”);new ServiceContact(“myhost.myorg.org”);

service.setServiceContact(serviceContact);service.setServiceContact(serviceContact);

task.setService(task.setService(

Service.JOB_SUBMISSION_SERVICE,Service.JOB_SUBMISSION_SERVICE,

service);service);

TaskHandler handler=new TaskHandler handler=new GenericTaskHandler();GenericTaskHandler();

handler.submit(task);handler.submit(task);

Page 35: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Summary and Future DirectionsSummary and Future Directions Portlets provide a way to build reusable Web components.Portlets provide a way to build reusable Web components. The Java COG kit provides a nice abstraction layer for building The Java COG kit provides a nice abstraction layer for building

Grid portlets.Grid portlets. Portlets can be written using JSP, Velocity, and JSF.Portlets can be written using JSP, Velocity, and JSF. In our OGCE project, we previously concentrated on Velocity In our OGCE project, we previously concentrated on Velocity

but are now moving to Java Server Faces.but are now moving to Java Server Faces.• Provides a clear way to build reusable widgets, not just portlets.Provides a clear way to build reusable widgets, not just portlets.

AJAX techniques (such as Google Maps) provide a very way to AJAX techniques (such as Google Maps) provide a very way to build interactive Web Service clients.build interactive Web Service clients.

There is a larger problem: can we define a general user There is a larger problem: can we define a general user interface component?interface component?• Portlets would be a subclassPortlets would be a subclass• But also include shells and desktop clients.But also include shells and desktop clients.

These components would also require standard supporting These components would also require standard supporting services: services: • Login, access control, layout management, ….Login, access control, layout management, ….

Page 36: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Basic Portlet Basic Portlet Programming GuideProgramming Guide

Page 37: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

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 38: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

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

RenderResponse resRenderResponse res) ) 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 //We could also use out to write directly to the response.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.jgetPortletContext().getRequestDispatcher(“MyJSP.jsp”);sp”); rd.include(req,res);rd.include(req,res);}}

}}

Page 39: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

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

portletSession=renderRequest.getPortletSession();portletSession=renderRequest.getPortletSession();portletSession.setAttribute("localattname","localattval");portletSession.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 40: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

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

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

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

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

The renderResponse gives you access to the PortletURL object.The renderResponse gives you access to the PortletURL object. Use the PortletURL to generate a URL for the <form action>Use the PortletURL to generate a URL for the <form 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 41: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

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

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

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

When the processAction When the processAction method returns, the container method returns, the container then invokes the appropriate then invokes the appropriate do method (usually doView).do 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 The example shows how to

add ALL parameters.add 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 parameters //Process request parameters ……//Add any other request //Add any other request paramsparams// to the renderRequest// to the renderRequest

actionResponse.setRenderParactionResponse.setRenderParameters(request.getParameteameters(request.getParameterMap());rMap());

}}

Page 42: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

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

web application.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, with its own Moreover, it runs as a separate context, with its own

classloader, session management, etc.classloader, session management, etc. Portlet applications are deployed as distinct war Portlet applications are deployed as distinct war

files/web applications.files/web applications.• You go through the container webapp to get to the portlet You go through the container webapp to get to the portlet

webapp.webapp.• Portlets in the same application share jars, classes, and Portlets in the same application share jars, classes, and

runtime stuff like request and session variables.runtime stuff like request and session variables.• Portlets in different portlet apps do not share anything.Portlets in different portlet apps do not share anything.

JSR 168 containers vary in the specifics of their JSR 168 containers vary in the specifics of their deployment procedures.deployment procedures.

Page 43: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Writing Grid PortletsWriting Grid Portlets

Extended ExampleExtended Example

Page 44: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Grid Portlet OverviewGrid Portlet Overview Previously we looked at writing JSR 168 Previously we looked at writing JSR 168

portlets using JSP and Velocity.portlets using JSP and Velocity. Grid Portlets are just portletsGrid Portlets are just portlets

• Use the Java CoG to make calls from the portlet Use the Java CoG to make calls from the portlet code to the desired Grid service.code to the desired Grid service.

• Can also make non-COG calls, such as to Can also make non-COG calls, such as to GridPort API.GridPort API.

These APIs should not be portlet-specific, These APIs should not be portlet-specific, since you should be able to reuse the Grid since you should be able to reuse the Grid APIs from other Java clients.APIs from other Java clients.• NCSA’s OGRE (general), Trebuchet (application NCSA’s OGRE (general), Trebuchet (application

specific) are examples specific) are examples • NCSA Tupelo also makes use of COG in its NCSA Tupelo also makes use of COG in its

metadata management services.metadata management services.

Page 45: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

COG and PortletsCOG and Portlets We will use the COG to illustrate some basic portlet We will use the COG to illustrate some basic portlet

programming features.programming features. We use the COG4 APIs in our ProxyManager, Job We use the COG4 APIs in our ProxyManager, Job

Submission, and GridFTP portletsSubmission, and GridFTP portlets• Hides differences between Globus Toolkit versions.Hides differences between Globus Toolkit versions.• Is also structured to handle task-based workflow and job Is also structured to handle task-based workflow and job

composition.composition. But for in-depth COG questions, we defer to But for in-depth COG questions, we defer to

Gregor’s group.Gregor’s group.• Available through AG session today.Available through AG session today.• Or docs available through Or docs available through www.cogkit.orgwww.cogkit.org

OGCE is an open consortium, and there are other OGCE is an open consortium, and there are other alternatives.alternatives.• OGRE job management builds on COG for WorkflowOGRE job management builds on COG for Workflow• GridPort uses the GGF Community Scheduling Framework GridPort uses the GGF Community Scheduling Framework

and higher level tools (job sequencers, for instance).and higher level tools (job sequencers, for instance).• Use what you likeUse what you like

Page 46: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Getting Proxy CredentialsGetting Proxy Credentials The key ingredient is getting proxy credentials into The key ingredient is getting proxy credentials into

the portal and sharing between different portlets.the portal and sharing between different portlets. We use MyProxy for thisWe use MyProxy for this

• Advantage: you don’t have to store users’ long term keys Advantage: you don’t have to store users’ long term keys on the web server.on the web server.

• Disadvantage: you have to run a separate MyProxy server; Disadvantage: you have to run a separate MyProxy server; users have to put keys there outside the portal.users have to put keys there outside the portal.

You must include the OGCE2 MyProxy portlet (or a You must include the OGCE2 MyProxy portlet (or a variation of it) in your Grid portal to do any other variation of it) in your Grid portal to do any other Grid stuff.Grid stuff.

OGCE1 also had support for grid-proxy-init.OGCE1 also had support for grid-proxy-init.• Would be able to add this, but you would need to manage Would be able to add this, but you would need to manage

your users’ long term keys.your users’ long term keys.

Page 47: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu
Page 48: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Proxy Manager Under the Proxy Manager Under the HoodHood

See See ogce2/indiana/extreme/ProxyManager/modogce2/indiana/extreme/ProxyManager/modules/portlet/src for templates and code.ules/portlet/src for templates and code.

Templates illustrate several Velocity Templates illustrate several Velocity scripting concepts.scripting concepts.• Control structures, variablesControl structures, variables

But the action code is more interesting.But the action code is more interesting.• This is where you do your Grid coding.This is where you do your Grid coding.• Use Velocity’s Context object to communicate Use Velocity’s Context object to communicate

strings back to your templates.strings back to your templates.

Page 49: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Proxy Manager CodeProxy Manager Code Key part here is the Key part here is the

doGet_proxy() doGet_proxy() method.method.

Abbreviated code on Abbreviated code on the right.the right.

MyProxy class: MyProxy class: import from CoG kit.import from CoG kit.

GSSCredential class: GSSCredential class: standard Java standard Java security class.security class.

ProxyManager class: ProxyManager class: used by us to pass used by us to pass credentials between credentials between portlets.portlets.

public void public void doGet_proxy() {doGet_proxy() {

MyProxy myproxy=MyProxy myproxy=

new MyProxy(…);new MyProxy(…);

GSSCredential GSSCredential proxy=proxy=

myproxy.get(…);myproxy.get(…);

ProxyManager.addPrProxyManager.addProxy(…);oxy(…);

}}

Page 50: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Writing Simple Job Submission Writing Simple Job Submission PortletsPortlets

For portlets, you have to deal with two main Grid For portlets, you have to deal with two main Grid issues:issues:• Getting the credential from the proxy store.Getting the credential from the proxy store.• And then using it.And then using it.

The CoG APIs provide an additional nice layer of The CoG APIs provide an additional nice layer of Grid abstraction for Grid tasks.Grid abstraction for Grid tasks.• We will look at this for wrapping GRAM calls.We will look at this for wrapping GRAM calls.

We will assume the following:We will assume the following:• You have your project set up to be warred with maven.You have your project set up to be warred with maven.• You have chosen a development technology (like JSP + You have chosen a development technology (like JSP +

portlets or Velocity portlets).portlets or Velocity portlets).• You will be collecting the necessary input information from You will be collecting the necessary input information from

an HTML <form>.an HTML <form>.• You will be putting the action code in either the portlet You will be putting the action code in either the portlet

(perhaps as a JavaBean) or Velocity action handler.(perhaps as a JavaBean) or Velocity action handler.• All code snippets below go in this portlet/action code.All code snippets below go in this portlet/action code.

Page 51: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Write the Method SkeletonWrite the Method Skeleton In your action code, In your action code,

write a method to do write a method to do job submission.job submission.• For Velocity, this maps For Velocity, this maps

to the “eventSubmit_” to the “eventSubmit_” form parameter in your form parameter in your template.template.

• In portlets, this code is In portlets, this code is called by your called by your processAction method.processAction method.

You will need to pass You will need to pass it, minimally, the it, minimally, the ActionRequest and ActionRequest and ActionResponse ActionResponse objects.objects.

public void doSubmitJob(public void doSubmitJob(ActionRequest req, ActionRequest req, ActionResponse resp,ActionResponse resp,…) {…) {//Next, get proxy//Next, get proxy//Then, run command.//Then, run command.

}}

Page 52: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Get the ProxyGet the Proxy Now get the proxy from the Now get the proxy from the

local store.local store. The ProxyManager class The ProxyManager class

calls the static method calls the static method getDefaultProxy to look up getDefaultProxy to look up your credential using your your credential using your portlet session.portlet session.

You need these importsYou need these imports• org.ietf.jgss.GSSCredentialorg.ietf.jgss.GSSCredential• xportlets.proxymanager.Proxportlets.proxymanager.Pro

xyManager.xyManager.• javax.portlet.* for javax.portlet.* for

everything else.everything else. This assumes that you have This assumes that you have

retrieved a credential from retrieved a credential from the MyProxy server.the MyProxy server.

public doSubmitJob(public doSubmitJob(ActionRequest req, ActionRequest req, ActionResponse res) {ActionResponse res) {//Get the proxy//Get the proxyPortletSession sess=PortletSession sess= req.getPortletSession()req.getPortletSession()GSSCredential cred= GSSCredential cred= ProxyManager.getDefaultPrProxyManager.getDefaultProxy(sess);oxy(sess);

//Next, run command//Next, run command}}

Page 53: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Run the CommandRun the Command The CoG4 interfaces now come into play. You should The CoG4 interfaces now come into play. You should

first understand the general CoG approach.first understand the general CoG approach. The COG4 interfaces attempt to abstract things at The COG4 interfaces attempt to abstract things at

several layersseveral layers• Tasks: a generic Grid function Tasks: a generic Grid function

Remote command execution, file operation, or information Remote command execution, file operation, or information inquiry.inquiry.

Has a specification and serviceHas a specification and service Is run by a handlerIs run by a handler

• Specification: set the type of task (job submit, etc.) and its Specification: set the type of task (job submit, etc.) and its specific parameters.specific parameters.

• Service: sets the Globus Toolkit (or other) provider, security Service: sets the Globus Toolkit (or other) provider, security context, and service contact information.context, and service contact information.

• TaskHandler: runs the task.TaskHandler: runs the task. Note this scheme is intended to shield you from Note this scheme is intended to shield you from

programming differences of different Globus programming differences of different Globus toolkits.toolkits.

Page 54: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Making Contact with the PortalMaking Contact with the Portal The remaining issue is getting information from the The remaining issue is getting information from the

HTML forms to the appropriate CoG calls.HTML forms to the appropriate CoG calls. This is done through the PortletRequest object.This is done through the PortletRequest object.

• Typically, it is actually the ActionRequest subclass.Typically, it is actually the ActionRequest subclass. In your doSubmitJob() command, just useIn your doSubmitJob() command, just use

• String param=request.getParameter(“Param-Name”);String param=request.getParameter(“Param-Name”);• ““Param-Name” is replaced with the input parameter name Param-Name” is replaced with the input parameter name

in your HTML form.in your HTML form. <input type=text name=“Param-Name” value=“rm -r *.*”><input type=text name=“Param-Name” value=“rm -r *.*”>

In following code snippets, “quoted strings” are In following code snippets, “quoted strings” are usually what you would pass in from the Web form.usually what you would pass in from the Web form.

Page 55: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

An Extended Code Example: Setting An Extended Code Example: Setting Up Task and SpecificationUp Task and Specification

Task task=new TaskImpl(“mytask”,Task task=new TaskImpl(“mytask”,Task.JOB_SUBMISSION);Task.JOB_SUBMISSION);

task.setProvider(“GT2”);task.setProvider(“GT2”);JobSpecification spec=JobSpecification spec=

new JobSpecificationImpl();new JobSpecificationImpl();spec.setExecutable(“rm”);spec.setExecutable(“rm”);spec.setBatchJob(true);spec.setBatchJob(true);spec.setArguments(“-r”);spec.setArguments(“-r”);……task.setSpecification(spec);task.setSpecification(spec);

Page 56: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Extended Code Example: Setting Up Extended Code Example: Setting Up the Service and Security Contextthe Service and Security Context

Service service=new Service service=new ServiceImpl(Service.JOB_SUBMISSION);ServiceImpl(Service.JOB_SUBMISSION);

service.setProvider(“GT2”);service.setProvider(“GT2”);

SecurityContext securityContext=SecurityContext securityContext=

CoreFactory.newSecurityContext(“GT2”);CoreFactory.newSecurityContext(“GT2”);

//Use cred object from ProxyManager//Use cred object from ProxyManager

securityContext.setCredentials(cred);securityContext.setCredentials(cred);

service.setSecurityContext(service.setSecurityContext(

(SecurityContext)securityContext);(SecurityContext)securityContext);

Page 57: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Extended Example: Set Up Extended Example: Set Up Service Contact and FinishService Contact and Finish

ServiceContact serviceContact=ServiceContact serviceContact=

new ServiceContact(“myhost.myorg.org”);new ServiceContact(“myhost.myorg.org”);

service.setServiceContact(serviceContact);service.setServiceContact(serviceContact);

task.setService(task.setService(

Service.JOB_SUBMISSION_SERVICE,Service.JOB_SUBMISSION_SERVICE,

service);service);

TaskHandler handler=new TaskHandler handler=new GenericTaskHandler();GenericTaskHandler();

handler.submit(task);handler.submit(task);

Page 58: Portals, Portlets, and Clients to Grid Services Marlon Pierce Community Grids Lab Indiana University mpierce@cs.indiana.edu

Monitoring TasksMonitoring Tasks Monitoring running tasks submitted by the COG is done Monitoring running tasks submitted by the COG is done

through a status listener.through a status listener.• Write a class that implements StatusListener interfaceWrite a class that implements StatusListener interface• Create an instance of your listener and add it to the task:Create an instance of your listener and add it to the task:

task.addStatusListener(myListener);task.addStatusListener(myListener); There is a small problem with doing this in a portal applicationThere is a small problem with doing this in a portal application

• The listener must be instantiated in the action code, along with The listener must be instantiated in the action code, along with the rest of the COG classes.the rest of the COG classes.

• But these are lost after the action completes.But these are lost after the action completes. Simple solution: store it in the PortletSessionSimple solution: store it in the PortletSession

• This will keep the listener object alive after the action completesThis will keep the listener object alive after the action completes• Get the session from the PortletRequest (more typically, its Get the session from the PortletRequest (more typically, its

subclass, ActionRequest)subclass, ActionRequest)• Sample codeSample code

PortletSession session=request.getPortletSession();PortletSession session=request.getPortletSession(); session.setAttribute(“mytask”,myListener); session.setAttribute(“mytask”,myListener);

• When you are curious about your task’s status, fetch it out of the When you are curious about your task’s status, fetch it out of the session by name.session by name.