# Presentation: 036320

## caGrid Version 0.5 API Specification ReviewMetadata and DiscoverycaBIG Architecture Workspace Face to FaceGeorgetown UniversityAugust 16, 2005

- Scott Oster
- Ohio State University
- oster@bmi.osu.edu

## Outline

- caGrid Standard Metadata
- Querying Globus Service Metadata
- caGrid Discovery API
- caGrid Metadata API
- Example Discovery code

## Common Service Metadata

- Describes Research Center information
- Required of all caGrid Services (core, security, data, analytical)

## caDSR Metadata

- Describes the Domain of the service’s objects
- Used by data services to identify the caDSR domain being exposed, and the subset of its Domain Objects
- Defines common description of caDSR metadata
- Used by both Data Services and Analytical Services

## caDSR Metadata - Domain Object

**caDSR Metadata - Domain Object**

- Describes a caDSR-registered Object
- Defines the EVS concept codes its based on
- Describes its relationships to other Objects
- Details its attributes

## caDSR Metadata - Domain Object Attribute

- Describes a caDSR-registered Attribute
- Defines the EVS concept codes its based on
- Describes its Value Domain
- List contained within each Domain Object

## caDSR Metadata - Domain Object Association

**caDSR Metadata - Domain Object Association**

- Describes a named relationship (source -> target) between two Domain Objects
- Uses references to domain object id instead of value copy
- List contained within each Domain Object

## Analytical Metadata

- Defines a list of caDSR Domain Objects
- Does not use associations
- Defines a list of operations over those Domain Objects
- Each input parameter is named and its corresponding Domain Object is referenced
- Each output references its appropriate Domain Object

## Accessing Service Data as a Client

- Polling
- findServiceData
- Pull mechanism
- Synchronous
- Extensible query language (default support for by name and XPath)
- Supported by every Grid Service
- Subscription
- subscribe and deliver operations
- Push mechanism
- Asynchronous
- Extensible subscription language
- Not supported by all Grid Services (every caGrid service does)

## Accessing Service Data via findServiceData

- Invoked on base grid service
- org.globus.ogsa.utils.QueryHelper can be used to help build queries
- org.globus.ogsa.utils.AnyHelper can be used to help process results

- ExtensibilityType extensibility = 	*gridService*.**findServiceData**(QueryHelper.**getNamesQuery**(*SDE_NAME*));
- ServiceDataValuesType serviceData = AnyHelper.**getAsServiceDataValues**(extensibility);
- String asString = AnyHelper.**getAsString**(serviceData);

- By Name Query

- String[] namespaces = QueryHelper.**tokenizeNamespaces**(*namespaceMappings*);
- ExtensibilityType results = 	*gridService*.**findServiceData**(QueryHelper.**getXPathQuer**y(*SDE_QNAME*, 	*XPATH_QUERY*, namespaces));
- ResearchCenterInfoType ccc = (ResearchCenterInfoType) AnyHelper.**getAsSingleObject**(results, 	ResearchCenterInfoType.class);

- By XPath Query

## Accessing Service Data via subscribe

- Invoked on service supporting NotificationSource
- NotificationSinkManager can be used to manage subscriptions and callbacks to client
- Results can be processed just as with findServiceData

- NotificationSinkManager notifManager = NotificationSinkManager.getManager();
- notifManager.**startListening**(NotificationSinkManager.MAIN_THREAD);
- String sink  =  notifManager.**addListener**(SDE_NAME, null, SOURCE_GSH, **this**);
- ...
- public void **deliverNotification**(ExtensibilityType any) throws RemoteException {
-     // Service Data has changed.
-     ServiceDataValuesType serviceData = AnyHelper.**getAsServiceDataValues**(any);
-     ...
- }

- By Subscription

## Index Service aggregated Service Data

- Index Service creates subscriptions to appropriate Service Data of registered services
- Upon updates, it publishes the SDEs as its own (creating an array of values for each SDE), and publishes the values under the serviceDataValues of the appropriate registration entry (the SDE published to describe the registered services)
- Clients can query the aggregated SDEs using either findServiceData or subscriptions

## Example Index Service Query

- “Find me the *GSH* of all the services registered from *Ohio State University*”
- Can be satisfied by using findServiceData or the Globus Service Browser with the information below

**SDE Namespace**: http://www.gridforum.org/namespaces/2003/03/OGSI
**SDE Name**: entry
**XPath Expression:**
- /ogsi:**entry**[ogsi:content/sd:**serviceDataValues**/ca:CommonServiceMetadata/ ca:researchCenterInfo/ca:researchCenterName/text()="**Ohio State University**"]/ ogsi:memberServiceLocator/ogsi:**handle**
**XPath Namespace Mappings:**
- xmlns:ogsi=http://www.gridforum.org/namespaces/2003/03/OGSI xmlns:sd=http://www.gridforum.org/namespaces/2003/03/serviceData xmlns:ca=http://cagrid.nci.nih.gov/1/CommonServiceMetadata

## caGrid Discovery and Service Data API

- While all the previously described standard Globus mechanisms will work for caBIG, caGrid provides a Discovery and Service Data API to make the Index Service and metadata easier to deal with
- Discovery API facilitates the process of asking a specified Index Service to return the GSH of all the registered services which satisfy some criteria over standard caGrid metadata
- Service Data API facilitates introspection of standard caGrid metadata given a discovered service’s GSH

## Generic Discovery Client

- Every discovery method returns a List of HandleTypes (bean representation of GSH)

## Analytical Discovery Client

- Inherits all Generic discovery methods
- Returns GSH of only Analytical Services

## Data Service Discovery Client

- Inherits all Generic discovery methods
- Returns GSH of only Data Services

## Service Data Utils

- Static class with convenience methods to access the object representation of common service metadata for any GSH, as well as some other common SDEs
- Convenience methods for query by XPath and Name

## Analytical and Data Service Data Utils

- AnalyticalServiceDataUtils provides access to bean representation of Analytical metadata

- DataServiceDataUtils provides access to bean representation of exposed Domain Model and Domain Objects

## Generic Discovery Examples

- Use the DiscoveryClient to query the Index Service for all registered services
- Then use the ServiceDataUtils to get the supported interfaces of each service

- DiscoveryClient client = new **DiscoveryClient**(*INDEX_GSH*);
- List allServices = client.**getAllServices**();
- for (int i = 0; i < allServices.size(); i++) {
-     HandleType service = ((**HandleType**) allServices.get(i));
-     System.out.println("Service: " + service.getValue() + " implements:");
-     QName[] serviceInterfaces = ServiceDataUtils.**getServiceInterfaces**(service);
-     if (serviceInterfaces != null) {
-         for (int j = 0; j < serviceInterfaces.length; j++) {
-         System.out.println("\t" + serviceInterfaces[j]);
-     }
- }

## Generic Discovery Examples

- Use the DiscoveryClient to query the Index Service for all registered services that have common service metadata matching the specified search string (goolge-like)

- DiscoveryClient client = new **DiscoveryClient**(*INDEX_GSH*);
- String search = "Gen";
- List stringList = client.**discoverServicesBySearchString**(search);
- System.out.println("Services matching search string:" + search);
- for (int i = 0; i < stringList.size(); i++) {
-     System.out.println(stringList.get(i));
- }

## Data Discovery Examples

- Use the DataServiceDiscoveryClient to query the Index Service for all registered services that are exposing the caArray model.

- DataServiceDiscoveryClient client = new **DataServiceDiscoveryClient**(*INDEX_GSH*);
- String mod = "**caArray**";
- List modlist = client.**discoverServicesByModelName**(mod);
- System.out.println("Services using model:" + mod);
- for (int i = 0; i < modlist.size(); i++) {
-     System.out.println(modlist.get(i));
- }

## Data Discovery Examples

- Use the DataServiceDiscoveryClient to query the Index Service for all registered services that have the specified search string in the model being exposed
- Then use the DataServiceDataUtils to get the bean representation of the Domain Model and print its short name

- DataServiceDiscoveryClient client = new **DataServiceDiscoveryClient**(*INDEX_GSH*);
- String search = "**protocol is a rule**";
- List list = client.**discoverServicesByModelSearchString**(search);
- System.out.println("Services with object model containing search string:" + search);
- for (int i = 0; i < list.size(); i++) {
-     System.out.println(list.get(i));
-     DomainModelType domainModel = DataServiceDataUtils.**getDomainModel**((**HandleType**) list.get(i));
-     System.out.println(domainModel.**getShortName**());
- }

## Analytical Discovery Examples

- Use the AnalyticalServiceDiscoveryClient to query the Index Service for all registered services that have methods producing Genes as output.

- AnalyticalServiceDiscoveryClient client = new **AnalyticalServiceDiscoveryClient**(*INDEX_GSH*);
- String output = "**Gene**";
- List olist = client.**discoverServicesByMethodOutputClass**(output);
- System.out.println("Services with analytical methods producing output class:" + output);
- for (int i = 0; i < olist.size(); i++) {
-     System.out.println(olist.get(i));
- }

## Analytical Discovery Examples

- Use the AnalyticalServiceDiscoveryClient to query the Index Service for all registered services that work with Objects or Attributes that are based on the concept code C45374 (Nucleotide Sequence)
- Then use the AnalyticalServiceDataUtils to get the bean representation of the Analytical metadata and print the number of operations it supports

- AnalyticalServiceDiscoveryClient client = new **AnalyticalServiceDiscoveryClient**(*INDEX_GSH*);
- String code = "**C45374**"; // Nucleotide Sequence
- List clist = client.**discoverServicesByConceptCode**(code);
- System.out.println("Services with object model using concept code:" + code);
- for (int i = 0; i < clist.size(); i++) {
-     System.out.println(clist.get(i));
-     AnalyticalType analyticalType = AnalyticalServiceDataUtils.**getAnalyticalType**((**HandleType**) clist.get(i));
-     System.out.println("\t has "+analyticalType.**getOperation**().length+" operations.");
- }