Grid Computing LAB
Grid Computing LAB
Grid Computing LAB
COMPUTING
LAB
Ex:No:1 DEVELOP A NEW WEB SERVICE FOR CALCULATOR
Date:
Aim:
To develop a new Web Services for Calculator.
Procedure:
MathService.java:
package pks.math;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
/**
*
* @author nsp
*/
@WebService(serviceName = "MathService")
public class MathService {
/**
* This is a sample web service operation
*/
@WebMethod(operationName = "hello")
public String hello(@WebParam(name = "name") String txt) {
return "Hello " + txt + " !"; }
@WebMethod(operationName = "addSer")
public String addSer(@WebParam(name = "value1") int v1, @WebParam(name =
"value2") int v2) {
return "Answer: " + (v1+v2) + " !!!"; }
@WebMethod(operationName = "subSer")
public String subSer(@WebParam(name = "value1") int v1, @WebParam(name =
"value2") int v2) {
return "Answer: " + (v1-v2) + " !!!"; }
@WebMethod(operationName = "mulSer")
public String mulSer(@WebParam(name = "value1") int v1, @WebParam(name =
"value2") int v2) {
return "Answer: " + (v1*v2) + " !!!"; }
@WebMethod(operationName = "divSer")
public String divSer(@WebParam(name = "value1") int v1, @WebParam(name =
"value2") int v2) {
float res=0;
try
{ res= ((float)v1)/((float)v2);
return "Answer: " + res + " !!!"; }
catch (ArithmeticException e) {
System.out.println ("Can't be divided by Zero"+e);
return "Answer: "+e.getMessage().toString()+"!!!"; } }
http://localhost:8080/WebApplication1/MathService?Tester
<!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is Metro/2.3.1-b419
(branches/2.3.1.x-7937; 2014-08-04T08:11:03+0000) JAXWS-RI/2.2.10-
b140803.1500 JAXWS-API/2.2.11 JAXB-RI/2.2.10-b140802.1033 JAXB-
API/2.2.12-b140109.1041 svn-revision#unknown. -->
<!-- Generated by JAX-WS RI (http://jax-ws.java.net). RI's version is Metro/2.3.1-b419
(branches/2.3.1.x-7937; 2014-08-04T08:11:03+0000) JAXWS-RI/2.2.10-
b140803.1500 JAXWS-API/2.2.11 JAXB-RI/2.2.10-b140802.1033 JAXB-
API/2.2.12-b140109.1041 svn-revision#unknown. -->
<definitions targetNamespace="http://math.pks/" name="MathService">
<types><xsd:schema>
<xsd:import namespace="http://math.pks/"
schemaLocation="http://localhost:8080/WebApplication1/MathService?xsd=1"/>
</xsd:schema></types>
<message name="mulSer"><part name="parameters"
element="tns:mulSer"/></message>
<message name="mulSerResponse">
<part name="parameters" element="tns:mulSerResponse"/></message>
<message name="divSer"><part name="parameters"
element="tns:divSer"/></message>
<message name="divSerResponse">
<part name="parameters" element="tns:divSerResponse"/></message>
<message name="subSer"><part name="parameters"
element="tns:subSer"/></message>
<message name="subSerResponse">
<part name="parameters" element="tns:subSerResponse"/></message>
<message name="addSer"><part name="parameters"
element="tns:addSer"/></message>
<message name="addSerResponse">
<part name="parameters" element="tns:addSerResponse"/></message>
<portType name="MathService">
<operation name="mulSer">
<input wsam:Action="http://math.pks/MathService/mulSerRequest"
message="tns:mulSer"/>
<output wsam:Action="http://math.pks/MathService/mulSerResponse"
message="tns:mulSerResponse"/></operation>
<operation name="divSer">
<input wsam:Action="http://math.pks/MathService/divSerRequest"
message="tns:divSer"/>
<output wsam:Action="http://math.pks/MathService/divSerResponse"
message="tns:divSerResponse"/></operation>
<operation name="subSer">
<input wsam:Action="http://math.pks/MathService/subSerRequest"
message="tns:subSer"/>
<output wsam:Action="http://math.pks/MathService/subSerResponse"
message="tns:subSerResponse"/></operation>
<operation name="addSer">
<input wsam:Action="http://math.pks/MathService/addSerRequest"
message="tns:addSer"/>
<output wsam:Action="http://math.pks/MathService/addSerResponse"
message="tns:addSerResponse"/></operation>
</portType>
<binding name="MathServicePortBinding" type="tns:MathService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="mulSer"><soap:operation soapAction=""/>
<input><soap:body use="literal"/></input>
<output><soap:body use="literal"/></output></operation>
<operation name="divSer"><soap:operation soapAction=""/>
<input><soap:body use="literal"/></input>
<output><soap:body use="literal"/></output></operation>
<operation name="subSer"><soap:operation soapAction=""/>
<input><soap:body use="literal"/></input>
<output><soap:body use="literal"/></output></operation>
<operation name="addSer"><soap:operation soapAction=""/>
<input><soap:body use="literal"/></input>
<output><soap:body use="literal"/></output></operation></binding>
<service name="MathService">
<port name="MathServicePort" binding="tns:MathServicePortBinding">
<soap:address location="http://localhost:8080/WebApplication1/MathService"/>
</port></service></definitions>
OUTPUT:
Result:
Thus a Web Services for Calculator has been created and executed successfully.
EX:NO:2 DEVELOP NEW OGSA-COMPLIANT WEB SERVICE
Date:
Aim:
Procedure:
∑ Expand the Project Files node in the Projects window and double-click pom.xml to
open the file in the editor.
The basic POM for the project should be similar to the following.
∑ Modify the parent pom.xml to add the following elements. Save your changes.
The Maven category in the New Projects wizard includes an OSGi Bundle
archetype for creating OSGi bundle projects. When you create an OSGi bundle project,
the generated POM declares the org.osgi.core JAR as a dependency and specifies the
maven-bundle-plugin for building the project.
In this exercise you will use the New Project wizard to create an OSGi bundle project
that will provide a simple interface that will be implemented by other bundles. After you
create the bundle and interface, you will modify the POM to update the dependency on
the org.osgi.core artifact that you specified in the parent POM project.
∑ Choose File > New Project to open the New Project wizard.
∑ Choose OSGi Bundle from Maven category. Click Next.
∑ Type MavenHelloServiceApi for the Project Name.
∑ Click Browse and select the MavenOSGiCDIProject POM project as the
Location. Click Finish.
When you click Finish, the IDE creates the bundle project and opens the project
in the Projects window. If you open pom.xml for the MavenHelloServiceApi project in the
editor you can see that the packaging element specifies bundle and that the maven-
bundle-plugin will be used when building the bundle.
<project><modelVersion>4.0.0</modelVersion>
<parent><artifactId>MavenOSGiCDIProject</artifactId>
<groupId>com.mycompany</groupId>
<version>1.0-SNAPSHOT</version></parent>
<groupId>com.mycompany</groupId>
<artifactId>MavenHelloServiceApi</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>MavenHelloServiceApi OSGi Bundle</name>
<properties><project.build.sourceEncoding>UTF-
8</project.build.sourceEncoding>
</properties>
<dependencies><dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.0</version>
<scope>provided</scope>
</dependency></dependencies>
<build><plugins><plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration><instructions>
<Bundle-Activator>com.mycompany.mavenhelloserviceimpl.Activator</Bundle-
Activator>
<Export-Package />
</instructions></configuration></plugin>
...
</plugins></build>
...
<project>
You can also see that when you create an OSGi bundle project using the Maven
OSGi Bundle archetype, the IDE added the org.osgi.core artifact as a dependency by
default.
∑ Right-click the project node in the Projects window and choose Build.
After you build the project, if you open the Files window and expand the project
node you can see that MavenHelloServiceApi-1.0-SNAPSHOT.jar is created in the
target folder.
The maven-bundle-plugin handles the generation of the MANIFEST.MF file when
you build the project. If you open the MANIFEST.MF file in the compiled JAR you will
see that the plugin generated a manifest header that declares the export packages. For
OSGi, all bundles that you want to be exposed and available to other bundles must be
listed in the Export-Package element in MANIFEST.MF.
The OSGi container will read the Export-Package manifest header to determine
the classes in the bundle that can be accessed from outside the bundle. In this
example, the classes in the com.mycompany.mavenhelloserviceapi package are
exposed.
Note. If the MANIFEST.MF does not contain the Export-Package element, you
will need to enable the default plugin behavior for the plugin in the Project Properties
window and rebuild the project. In the Project Properties window, select the Export
Packages category and select the Default maven-bundle-plugin behavior option. You
can use the Export Packages panel of the Project Properties window to explicitly specify
the packages that should be exposed or specify the packages directly in pom.xml.
In this exercise you will create the MavenHelloServiceImpl in the POM project.
∑ Choose File > New Project to open the New Project wizard.
∑ Choose OSGi Bundle from the Maven category. Click Next.
∑ Type MavenHelloServiceImpl for the Project Name.
∑ Click Browse and select the MavenOSGiCDIProject POM project as the
Location (if not selected). Click Finish.
∑ Right-click the project node in the Projects window and choose Properties.
∑ Select the Sources category in the Project Properties dialog box.
∑ Set the Source/Binary Format to 1.6 and confirm that the Encoding is UTF-8.
Click OK.
∑ Right-click Source Packages node in the Projects window and choose New >
Java Class.
∑ Type HelloImpl for the Class Name.
∑ Select com.mycompany.mavenhelloserviceimpl as the Package. Click Finish.
∑ Type the following (in bold) and save your changes.
∑ public class HelloImpl implements Hello {
public String sayHello(String name) { return "Hello " + name; }}
When you implement Hello, the IDE will display an error that you need to resolve
by adding the MavenHelloServiceApi project as a dependency.
∑ Right-click in the HelloImpl.java class that is open in the editor and choose Fix
Imports (Alt-Shift-I; ⌘-Shift-I on Mac) to add an import statement for
com.mycompany.mavenhelloserviceapi.Hello. Save your changes.
∑ Expand the com.mycompany.mavenhelloserviceimpl package and double-click
Activator.java to open the file in the editor.
The IDE automatically created the Activator.java bundle activator class in your
project. A bundle activator is used to manage the lifecycle of a bundle. The bundle
activator class is declared in the MANIFEST.MF of the bundle and instantiated when the
bundle is started by the container.
An OSGi bundle does not require a bundle activator class, but you can use the
start() method in the activator class, for example, to initialize services or other resources
that are required by the bundle. In this exercise you will add some lines of code to the
class that will print messages to the Output window. This will make it easier for you to
identify when the bundle starts and stops.
∑ Modify the start() and stop() methods in the bundle activator class to add the
following lines (in bold).
If you look at the POM for the project you can see the <Bundle-Activator> element
that specifies the bundle activator under the configuration element for the maven-
bundle-plugin.
<plugin><groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version><extensions>true</extensions>
<configuration><instructions><Bundle-
Activator>com.mycompany.mavenhelloserviceimpl.Activator</Bundle-
Activator></instructions></configuration></plugin>
When you build the bundle, the plugin will generate a Manifest Header in the
bundle's manifest file in the JAR and specify the Bundle Activator class. The OSGi
runtime looks for the Bundle-Activator header in the manifest file when a bundle is
deployed.
Note. Remove any older versions of the artifact that are listed under the Dependencies
node by right-clicking the artifact and choosing Remove Dependency. The only
dependencies should be the MavenHelloServiceApi project and the org.osgi.core
artifact.
Building and Deploying the OSGi Bundles
In this exercise you will build the OSGi bundles and deploy the bundles to GlassFish.
When you build the project the IDE will create the JAR files in the target folder of
each of the projects and also install the snapshot JAR in the local repository. In the Files
window, you can expand the target folder for each of the two bundle projects to see the
two JAR archives (MavenHelloServiceApi-1.0-SNAPSHOT.jar and
MavenHelloServiceImpl-1.0-SNAPSHOT.jar).
You should see output similar to the following in the GlassFish Server log in the
Output window.
Right-click the GlassFish server node in the Services window and choose View
Domain Server Log if the server log is not visible in the Output window.
INFO: HelloActivator::start
INFO: HelloActivator::registration of Hello service successful
INFO: Started bundle: file:/glassfish-
4.0/glassfish/domains/domain1/autodeploy/bundles/MavenHelloServiceImpl-1.0-
SNAPSHOT.jar
INFO: Started bundle: file:/glassfish-
4.0/glassfish/domains/domain1/autodeploy/bundles/MavenHelloServiceImpl-1.0-
SNAPSHOT.jar
Result:
Thus the new OGSA-compliant Web Service has been developed and
executed successfully.
EX:NO:3 USING APACHE AXIS DEVELOP A GRID SERVICE
Date:
Aim:
Procedure:
∑ Right Click on MyFirstWebService in Project Explorer and select New –-> Class
and give suitable package name and class name. I have given com.sencide as
package name and FirstWebService as class name.
package com.sencide;
public class FirstWebService {
public int addTwoNumbers(int firstNumber, int secondNumber){
return firstNumber + secondNumber; }}
∑ Then, select File --> New –-> Other and choose Web Service.
∑ Select the FirstWebService class as service implementation and to make sure
that the Configuration is setup correctly click on Server runtime.
∑ There set the Web Service runtime as Axis2 (Default one is Axis) and click Ok.
∑ Click Next and make sure Generate a default service.xml file is selected.
∑ Click Next and Start the Server and after server is started you can Finish if you
do not want to publish the Web service to a test UDDI repository.
You can go to http://localhost:8888/MyFirstWebService/services/listServices to see
your running service which is deployed by Axis2. You can see the WSDL by clicking the
link FirstWebService.
We have to use Eclipse every time when we want to run the service if we do not
create .aar (Axis Archive) file and deploy it to the server. So let’s see how we can create
it.
∑ Using command prompt start the Apache Tomcat (Go to bin directory and run the
file startup.bat). Now there will be new directory called axis2 inside the webapps
directory. Now if you go to the http://localhost:8080/axis2/ you can see the home
page of Axis2 Web Application.
∑ Then click the link Administration and login using username : admin and
password : axis2. There you can see upload service link on top left and there you
can upload the created FirstWebService.aar file. This is equal to manually
copping the FirstWebService.aar to webapps\axis2\WEB-INF\services directory.
∑ Now when you list the services by going to
http://localhost:8080/axis2/services/listServices you should be able to see our
newly added service.
OUTPUT
package com.sencide;
import java.rmi.RemoteException;
import com.sencide.FirstWebServiceStub.AddTwoNumbers;
import com.sencide.FirstWebServiceStub.AddTwoNumbersResponse;
public class TestClient {
public static void main(String[] args) throws RemoteException {
FirstWebServiceStub stub = new FirstWebServiceStub();
AddTwoNumbers atn = new AddTwoNumbers();
atn.setFirstNumber(5);
atn.setSecondNumber(7);
AddTwoNumbersResponse res = stub.addTwoNumbers(atn);
System.out.println(res.get_return()); }
}
Result:
Thus a Grid service hasa been developed using Apache Axis and
executed successfully.
Ex:NO:4 DEVELOP APPLICATIONS USING JAVA
Date:
Aim:
Procedure:
∑ Create CounterServiceFactoy using the Create counter service instance with the
service browser
∑ Use the second counter service instance with the command line
You may open a new window as globus (the user who installed the toolkit) and
run globus-start-container from the globus-install directory ($GLOBUS_LOCATION).
On x1, as the globus user, issue the following commands to start the container:
$ cd $GLOBUS_LOCATION
Because of the quantity of data included in the service browser, make sure the
resolution is set to display the necessary information in the window. In our lab a display
resolution of 1024 by 768 was used. Also, you may need to run xhost to allow the use
of the GUI, as described below.
As root, run xhost:
# xhost +
In a separate window, log in as the itso user and start the service browser. As the
itso user, issue the following commands for this purpose:
$ cd $GLOBUS_LOCATION
At the end of this step, a Java-based GUI would have appeared on screen. That
is the service browser tool.
The idea of the service browser, presented in Figure 4-5, is similar to a Web
browser, where you can specify the URL for the required Web location and allow
navigating on it as well. For a Grid service, the URL is replaced by a URI (Uniform
Resource Identifier).
Step 1: Invoking the counter factory service
You may see the Service Group Entry Inspection panel in the bottom portion of
the service browser. All services that are deployed in the container are listed there. You
need to locate the CounterFactoryService in the Table tab
Now, double-click on the highlighted CounterFactoryService to invoke it. The
service browser can take a long time to come up, so please be patient. The window will
show CounterFactoryService in the URI field near the top of the screen
Near the bottom of the screen, you find a text box for entering an instance name
and a Create Instance button. You may enter an instance name (for example, C1) and
click this button to create a service instance.
After you press the Create Instance button, a new window will show the client
interface for the newly C1 created counter factory service instance (c1),
This is the GSH of the counter factory service instance. Note that the instance
name c1 has been added at the end of GSH.
Now we will perform operations on the counter factory service client. Near the
bottom portion of the screen, under the Counter Example panel, you will find a text box
for entering values and two buttons:
1. Add
2. Subtract
The buttons represents the available operations you can perform on the Counter
Value. Note that the initial the value is 0. Let us increase the value of the counter by
entering 10 in the text box provided for the value and pressing the Add button. Note that
the value is 10 now. Now we can subtract 5 from the counter by entering 5 in the text
box and clicking on the Subtract button.
You may observe that the final value at the end of the operation is 5. In the next
section, let us see how you can perform these steps using command line clients.
GT is bundled with the ogsa-samples.jar file, which also contains Java programs
that are basically command line clients. Java classes are available for creating and
destroying counter service instances. Let us now see how to create a second counter
service instance and perform the operations using the command line.
In order to create a new instance, you need to use a Java program named
CreateService, and pass the GSH of the factory service and the instance name as
arguments. On x1, as the itso user, issue the following commands to create the service
instance called c2:
$ cd $GLOBUS_LOCATION
$ . setenv.sh
$ java org.globus.ogsa.client.CreateService \
http://localhost:8080/ogsa/services/samples/counter/basic/CounterFactoryService c2
Creating the service instance called c2 output
[itso@x1 globus]$ java org.globus.ogsa.client.CreateService
http://localhost:8080/ogsa/services/samples/counter/basic/CounterFactoryService c2
Termination Time: infinity
Created service with reference:
<definitions name="Counter"
targetNamespace="http://ogsa.globus.org/samples/counter/service"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:counterbinding="http://ogsa.globus.org/samples/counter/bindings"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"><import
location="http://192.168.0.241:8080/schema/samples/counter/counter_bindings.wsdl"
namespace="http://ogsa.globus.org/samples/counter/bindings"/><service
name="CounterService"
xmlns:gsdl="http://ogsa.globus.org/"><gsdl:instanceOf
handle="http://192.168.0.241:8080/ogsa/services/samples/counter/basic/CounterFactor
yService/c2" xmlns=""/><gsdl:instanceOf
handle="http://192.168.0.241:8080/ogsa/services/instance"
xmlns=""/><port binding="counterbinding:CounterSOAPBinding"
name="CounterPort"><soap:address
location="http://192.168.0.241:8080/ogsa/services/samples/counter/basic/CounterFacto
ryService/c2"/></port></service></definitions>
[itso@x1 globus]$
On x1, as the itso user, issue the following commands to add 5, subtract 2, and get the
results:
$ java org.globus.ogsa.impl.samples.counter.client.Add 5 \
http://localhost:8080/ogsa/services/samples/counter/basic/CounterFactoryService/c2
$ java org.globus.ogsa.impl.samples.counter.client.Subtract 2 \
http://localhost:8080/ogsa/services/samples/counter/basic/CounterFactoryService/c2
$ java org.globus.ogsa.impl.samples.counter.client.GetValue \
http://localhost:8080/ogsa/services/samples/counter/basic/CounterFactoryService/c2
You should get an output.
[itso@x1 globus]$ java org.globus.ogsa.impl.samples.counter.client.Add 5
http://localhost:8080/ogsa/services/samples/counter/basic/CounterFactoryService/c2
Counter Value:5
[itso@x1 globus]$ java org.globus.ogsa.impl.samples.counter.client.Subtract 2
http://localhost:8080/ogsa/services/samples/counter/basic/CounterFactoryService/c2
Counter Value:3
[itso@x1 globus]$ java org.globus.ogsa.impl.samples.counter.client.GetValue
http://localhost:8080/ogsa/services/samples/counter/basic/CounterFactoryService/c2
Counter Value:3
Result:
Thus an application has been developed using Java and the output was verified
successfully.
EX:NO: 5 DEVELOP SECURED APPLICATIONS USING BASIC SECURITY
Date: MECHANISMS AVAILABLE IN GLOBUS TOOLKIT
Aim:
Procedure:
Certificate Au t h o r i t y Setup
This script will setup a Certificate Authority for signing Globus users certificates. It will
also generate a simple CA package that can be distributed to the users of the CA. The
CA information about the certificates it distributes will be kept in:
/var/lib/globus/simple_ca
The unique subject name for this CA is:
cn=Globus Simple CA, ou=simpleCA-nspublin, ou=GlobusTest, o=Grid
Installing new CA files to /etc/grid-security/certificates... done
Creating RPM source tarball... done
globus_simple_ca_1b5e8514.tar.gz
EX:NO .6 DEVELOP A GRID PORTAL, WHERE USER CAN SUBMIT A JOB AND
GRAM CONCEPT
Aim:
To develop a Grid portal, where user can submit a job and get the result with and
without GRAM concept.
Procedure:
The first step to being able to use GRAM5 after installation is to acquire a
temporary Grid credential to use to authenticate with the GRAM5 service and any file
services your job requires. Normally this is done via either grid-proxy-init or via the
MyProxy service.
Proxy credentials with grid-proxy-init
To generate a proxy credential using the grid-proxy-init program, execute the
command with no arguments.
% bin/grid-proxy-init
Your identity: /O=Grid/OU=Example/CN=Joe User
Enter GRID pass phrase for this identity:
Creating proxy ................................. Done
Your proxy is valid until: Tue Oct 26 01:33:42 2010
∑ The GRAM5 service uses the credential to send job state notification messages
to clients which have registered to receive them.
∑ The GRAM5 service uses the credential to contact GASS and GridFTP file
servers to stage files to and from the execution resource
∑ The job executed by the GRAM5 service can use the delegated credential for
application-specific purposes.
Submitting jobs
Resource Names
In GRAM5, a Gatekeeper Service Contact contains the host, port, service name,
and service identity required to contact a particular GRAM service. For convenience,
default values are used when parts of the contact are omitted. An example of a full
gatekeeper service contact is
grid.example.org:2119/jobmanager:/C=US/O=Example/OU=Grid/CN=host/grid.example
.org.
The various forms of the resource name using default values follow:
∑ HOST
∑ HOST:PORT
∑ HOST:PORT/SERVICE
∑ HOST/SERVICE
∑ HOST:/SERVICE
∑ HOST:PORT:SUBJECT
∑ HOST/SERVICE:SUBJECT
∑ HOST:/SERVICE:SUBJECT
∑ HOST:PORT/SERVICE:SUBJECT
The following command line submits a single instance of the /bin/hostname executable
to the resource named by grid.example.org:2119/jobmanager-pbs.
This example shows how using the Control+C (or other system-specific mechanism for
sending the SIGINT signal) can be used to cancel a GRAM job.
The following command line submits one instances of the executable /usr/bin/env,
setting some environment variables in the job environment beyond those set by
GRAM5.
The following command line submits an mpi job using globus-job-run, setting the
jobtype RSL attribute to mpi. Any RSL attribute understood by the LRM can be added to
a job via this method.
The globus-job-run program can also generate the RSL language description of a job
based on the command-line options given to it. This example combines some of the
features above and prints out the resulting RSL. This RSL string can be passed to tools
such as globusrun to be run later.
% globus-job-run -dumprsl grid.example.org:2119/jobmanager-pbs -np 5 -x
'&(jobtype=mpi)' -env GRID=1 -env TEST=1 a.out
&(jobtype=mpi)
(executable="a.out")
(environment= ("GRID" "1") ("TEST" "1"))
(count=5)
Submitting Jobs with globus-job-submit
globus-job-submit
The globusrun tool provides a more flexible tool for submitting, monitoring, and
canceling jobs. With this tool, most of the functionality of the GRAM5 APIs are made
available.
One major difference between globusrun and the other tools described above is
that globusrun uses the RSL language to provide the job description, instead of
multiple command-line options to describe the various aspects of the job. The section
on globus-job-run contained a brief example RSL in the -dumprsl example above.
% globusrun-p "&(executable=a.out)"
% globusrun-a -r grid.example.org:2119/jobmanager-pbs
GRAM Authentication test successful
% globusrun-a -r grid.example.org:2119/jobmanager-lsf
GRAM Authentication test failure: the gatekeeper failed to find the requested service
% globusrun-a -r grid.example.org:2119/jobmanager-pbs:host@not.example.org
GRAM Authentication test failure: an authorization operation failed
globus_xio_gsi: gss_init_sec_context failed.
GSS Major Status: Unexpected Gatekeeper or Service Name
globus_gsi_gssapi: Authorization denied: The name of the remote host
(host@not.example.org), and the expected name for the remote host
(grid.example.org) do not match. This happens when the name in the host certificate
does not match the information obtained from DNS and is often a DNS configuration
problem.
This example shows how to submit interactive job with globusrun. When the -s
is used, the output of the job command is returned to the client and displayed as if the
command ran locally. This is similar to the behavior of the globus-job-run program
described above.
% globusrun-s -r example.grid.org/jobmanager-pbs
"&(executable=/bin/hostname)(count=5)"
node03.grid.example.org
node01.grid.example.org
node02.grid.example.urg
node05.grid.example.org
node04.grid.example.org
This example shows how to submit, monitor, and cancel a batch job using
globusrun. This method is useful for the case where the job may run for a long time,
the job may be queued for a long time, or when there are network reliability issues
between the client and service.
% globusrun-b -r grid.example.org:2119/jobmanager-pbs
"&(executable=/bin/sleep)(arguments=500)"
globus_gram_client_callback_allow successful
GRAM Job submission successful
https://grid.example.org:38824/16001608125017717261/5295612977486019989/
GLOBUS_GRAM_PROTOCOL_JOB_STATE_PENDING
% globusrun-status
https://grid.example.org:38824/16001608125017717261/5295612977486019989/
PENDING
% globusrun-k
https://grid.example.org:38824/16001608125017717261/5295612977486019989/
%
% globusrun-refresh-proxy
https://grid.example.org:38824/16001608125017717261/5295612977486019989/
% echo $?
0
When the Job Manager's credential is about to expire, it sends a message to all
clients registered for GLOBUS_GRAM_PROTOCOL_JOB_STATE_FAILED
notifications that the job manager is terminating and that the job will continue to run
without the job manager. Any client which receives such a message can (if necessary)
generate a new proxy as described above and then submit a restart request to start a
job manager with a new credential. This job manager will resume monitoring the jobs
which were started prior to proxy expiration.
A two phase protocol is also used at job termination if the save_state RSL
attribute is used along with the two_phase attribute. When the job manager sends a
callback with the job state set to GLOBUS_GRAM_PROTOCOL_JOB_STATE_DONE
or GLOBUS_GRAM_PROTOCOL_JOB_STATE_DONE it will wait to clean up the job
until the two phase commit occurs. The client must reply with the
GLOBUS_GRAM_PROTOCOL_JOB_SIGNAL_COMMIT_END signal to cause the job
to be cleaned. Otherwise, the job will be unloaded from memory until a client restarts
the job and sends the signal.
globus_gram_client_callback_allow successful
GRAM Job submission successful
GLOBUS_GRAM_PROTOCOL_JOB_STATE_PENDING
GLOBUS_GRAM_PROTOCOL_JOB_STATE_ACTIVE
GLOBUS_GRAM_PROTOCOL_JOB_STATE_DONE
%
Reconnecting to a job
If a job manager or client exits before a job has completed, the job will continue
to run. The client can reconnect to a job manager and receive job state notifications and
output using the restart RSL attribute.
Restart example
% globus-job-submitgrid.example.org:2119/jobmanager-pbs /bin/sleep 90
https://grid.example.org:38824/16001746665595486521/5295612977486005662/
% globusrun-r grid.example.org:2119/jobmanager-pbs \
"&(restart =
https://grid.example.org:38824/16001746665595486521/5295612977486005662/)"
globus_gram_client_callback_allow successful
GRAM Job submission successful
GLOBUS_GRAM_PROTOCOL_JOB_STATE_DONE
%
Java example
This example uses globus-job-submit to submit a java job, staging a jar file
from a remote service.
% globusrun-r grid.example.org:2119/jobmanager-pbs \
"&(environment = (PATH '/usr/bin:/bin') (CLASSPATH \$(SCRATCH_DIRECTORY)))
(scratch_dir = \$(HOME))
(directory = \$(SCRATCH_DIRECTORY))
(rsl_substitution = (JAVA_SERVER http://java.example.org))
(file_stage_in =
(\$(JAVA_SERVER)/example.jar \$(SCRATCH_DIRECTORY)/example.jar)
(\$(JAVA_SERVER)/support.jar \$(SCRATCH_DIRECTORY)/support.jar))
(executable=/bin/sh)
(arguments=-c 'java -jar example.jar')"
globus_gram_client_callback_allow successful
GRAM Job submission successful
GLOBUS_GRAM_PROTOCOL_JOB_STATE_PENDING
GLOBUS_GRAM_PROTOCOL_JOB_STATE_ACTIVE
GLOBUS_GRAM_PROTOCOL_JOB_STATE_DONE
%
Result:
Thus a grid portal for the user to submit a job and get the result using GRAM
concept is created and executed successfully.