Workflow Tutorial 1 - Application Discovery
Introduction
The learning objectives for this exercise are:
1. Understand how to discover the applications that have been deployed to the GRIA 5.x Job service; and
2. Understand how to discover further details of deployed applications, including details of inputs and outputs.
Step 1: Create a client proxy to the remote job service.
First create a State Repository which holds references to our services and resources. Then use the getOrCreateObject method on the repository with the class of object we wish to create and the EndpointReference of the Object.
StateRepository repository = new MemoryStateRepository(); RemoteJobService jobService = (RemoteJobService) repository.getOrCreateObject(RemoteJobService.class,ConversationID.getEPR(JOB_SERVICE_ENDPOINT));
Be sure to use an appropriate String value for JOB_SERVICE_ENDPOINT. The job service endpoint must be of the following format:
<PROTOCOL>://<HOST>:<PORT>/gria-basic-app-services/services/JobService
or
<PROTOCOL>://<HOST>/gria-basic-app-services/services/JobService
For example:
https://example.company.com:8443/gria-basic-app-services/services/JobService
https://griademo1.it-innovation.soton.ac.uk/gria-basic-app-services/services/JobService
Step 2: List the applications that are deployed at the job service.
String[] applicationList = jobService.getApplications();
The getApplications method on the RemoteJobService returns a list of URIs. Each URI is a unique name for an application that has been deployed at the job service.
The URI is taken from the ApplicationMetadata.xml file that was used when deploying the application using the Job service administration web pages.
Step 3: Get futher details of a specific application.
String applicationURI = applicationList[0]; Document appDescription = jobService.getApplicationMetadata(applicationUri);
Here, appDescription is a DOM Document that represents the ApplicationMetadata.xml file that the job service administrator used when they deployed the application. Its contents can be examined to determine the number and types of inputs and outputs.
The following code can be used to output the document to standard output.
String strAppDescription = XMLUtils.DocumentToString(appDescription);
System.out.println("\t" + strAppDescription);
Completed Java
If you need some help here is a completed version of the java file
import java.net.URL;
import org.apache.axis.utils.XMLUtils;
import org.w3c.dom.Document;
import uk.ac.soton.ecs.iam.grid.comms.client.StateRepository;
import uk.ac.soton.ecs.iam.grid.client.staterepos.MemoryStateRepository;
import uk.ac.soton.ecs.iam.grid.comms.client.RemoteJobService;
import uk.ac.soton.itinnovation.grid.types.ConversationID;
public class ApplicationDiscovery {
private static String JOB_SERVICE_ENDPOINT = "https://.../gria-basic-app-services/services/JobService";
public static void main(String[] args) throws Exception {
StateRepository repository = new MemoryStateRepository();
RemoteJobService jobService =
(RemoteJobService)repository.getOrCreateObject(RemoteJobService.class,ConversationID.getEPR(JOB_SERVICE_ENDPOINT));
String[] applicationList = jobService.getApplications();
if(applicationList.length > 0){
System.out.println("Found "+applicationList.length+" applications.");
for(String applicationURI : applicationList){
Document appDescription = jobService.getApplicationMetadata(applicationURI);
String strApplicationDescription = XMLUtils.DocumentToString(appDescription);
System.out.println("\t"+strApplicationDescription);
}
}else{
System.out.println("No applications found on server.");
}
}
}
This tutorial has covered discovering details of applications that have been deployed at a GRIA 5.x job service.
