airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1436470 - in /airavata/sandbox/grid-tools/bes-client/src: main/java/org/apache/airavata/sample/bes/ test/resources/
Date Mon, 21 Jan 2013 16:37:53 GMT
Author: lahiru
Date: Mon Jan 21 16:37:52 2013
New Revision: 1436470

URL: http://svn.apache.org/viewvc?rev=1436470&view=rev
Log:
committing Shabhaz patches to scratch, from https://issues.apache.org/jira/browse/AIRAVATA-657.

Added:
    airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/AbstractJobCommand.java
    airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/CreateAndTerminateActivityTask.java
    airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/MonitorJobStatusTask.java
    airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/RunAndTerminateJob.java
    airavata/sandbox/grid-tools/bes-client/src/test/resources/fsp.xml
    airavata/sandbox/grid-tools/bes-client/src/test/resources/sleep.xml

Added: airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/AbstractJobCommand.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/AbstractJobCommand.java?rev=1436470&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/AbstractJobCommand.java
(added)
+++ airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/AbstractJobCommand.java
Mon Jan 21 16:37:52 2013
@@ -0,0 +1,36 @@
+package org.apache.airavata.sample.bes;
+
+import de.fzj.unicore.uas.security.ClientProperties;
+import eu.unicore.security.util.client.IClientProperties;
+
+public abstract class AbstractJobCommand {
+	
+	
+	
+	public static final String factoryUrl = "https://zam1161v01.zam.kfa-juelich.de:8002/INTEROP1/services/BESFactory?res=default_bes_factory";
+	public static final String dateJsdlPath = "src/test/resources/date.xml";
+	
+	protected IClientProperties securityProperties;
+	
+	
+	public AbstractJobCommand() {
+		securityProperties = initSecurityProperties();
+	}
+	
+	protected ClientProperties initSecurityProperties() {
+
+		ClientProperties sp = new ClientProperties();
+
+		sp.setSslEnabled(true);
+		sp.setSignMessage(true);
+
+		sp.setKeystore("src/test/resources/demo-keystore.jks");
+		sp.setKeystorePassword("654321");
+		sp.setKeystoreAlias("demouser-new");
+		sp.setKeystoreType("JKS");
+
+		return sp;
+
+	}
+	
+}

Added: airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/CreateAndTerminateActivityTask.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/CreateAndTerminateActivityTask.java?rev=1436470&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/CreateAndTerminateActivityTask.java
(added)
+++ airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/CreateAndTerminateActivityTask.java
Mon Jan 21 16:37:52 2013
@@ -0,0 +1,79 @@
+package org.apache.airavata.sample.bes;
+
+import java.util.Calendar;
+
+import org.ggf.schemas.bes.x2006.x08.besFactory.ActivityStateEnumeration;
+import org.ggf.schemas.bes.x2006.x08.besFactory.CreateActivityDocument;
+import org.ggf.schemas.bes.x2006.x08.besFactory.CreateActivityResponseDocument;
+import org.ggf.schemas.bes.x2006.x08.besFactory.TerminateActivitiesResponseType;
+import org.w3.x2005.x08.addressing.EndpointReferenceType;
+
+import de.fzj.unicore.bes.client.FactoryClient;
+import de.fzj.unicore.wsrflite.xmlbeans.WSUtilities;
+import eu.unicore.security.util.client.IClientProperties;
+
+public class CreateAndTerminateActivityTask {
+
+	private BESJob job;
+
+	private IClientProperties sec;
+	private String jobId;
+	
+	
+	public CreateAndTerminateActivityTask(BESJob job, IClientProperties sec) {
+		this.job = job;
+		this.sec = sec;
+		
+	}
+
+	public void startJob() throws Exception {
+		String factoryUrl = job.getFactoryUrl();
+		EndpointReferenceType eprt = EndpointReferenceType.Factory
+				.newInstance();
+		eprt.addNewAddress().setStringValue(factoryUrl);
+		System.out.println("========================================");
+		System.out.println(String.format("Job Submitted to %s.\n", factoryUrl));
+		FactoryClient factory = new FactoryClient(eprt, sec);
+		CreateActivityDocument cad = CreateActivityDocument.Factory
+				.newInstance();
+		cad.addNewCreateActivity().addNewActivityDocument()
+				.setJobDefinition(job.getJobDoc().getJobDefinition());
+		CreateActivityResponseDocument response = factory.createActivity(cad);
+		EndpointReferenceType activityEpr = response
+				.getCreateActivityResponse().getActivityIdentifier();
+		jobId = WSUtilities.extractResourceID(activityEpr);
+		if (jobId == null) {
+			jobId = new Long(Calendar.getInstance().getTimeInMillis())
+					.toString();
+		}
+		
+		String status;
+		
+		status = String.format("Job %s is %s.\n", activityEpr.getAddress()
+				.getStringValue(), factory.getActivityStatus(activityEpr)
+				.toString()).toString();
+		
+		System.out.println(status);
+		
+		TerminateActivitiesResponseType terminateResType = factory.terminateActivity(activityEpr);
+		
+		Thread.sleep(500);
+		System.out.println(terminateResType);
+
+		if (!(factory.getActivityStatus(activityEpr) == ActivityStateEnumeration.CANCELLED)) {
+			throw new Exception("Job "+activityEpr.getAddress().getStringValue()+" not CANCELLED");
+		}
+		
+		status = String.format("Job %s is %s.\n", activityEpr.getAddress()
+				.getStringValue(), factory.getActivityStatus(activityEpr)
+				.toString()).toString();
+		
+		System.out.println(status);
+		
+
+		
+	}
+
+	
+
+}

Added: airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/MonitorJobStatusTask.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/MonitorJobStatusTask.java?rev=1436470&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/MonitorJobStatusTask.java
(added)
+++ airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/MonitorJobStatusTask.java
Mon Jan 21 16:37:52 2013
@@ -0,0 +1,26 @@
+package org.apache.airavata.sample.bes;
+
+import org.w3.x2005.x08.addressing.EndpointReferenceType;
+
+import de.fzj.unicore.wsrflite.xmlbeans.WSUtilities;
+
+import eu.unicore.security.util.client.IClientProperties;
+
+public class MonitorJobStatusTask {
+	
+	private String factoryUrl;
+	private EndpointReferenceType jobEPR;
+	private IClientProperties sec;
+	
+	public MonitorJobStatusTask(String factoryUrl, IClientProperties sec, EndpointReferenceType
jobEPR) {
+		this.factoryUrl = factoryUrl;
+		this.jobEPR = jobEPR;
+		this.sec = sec; 
+	}
+	
+	
+	
+	
+
+	
+}

Added: airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/RunAndTerminateJob.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/RunAndTerminateJob.java?rev=1436470&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/RunAndTerminateJob.java
(added)
+++ airavata/sandbox/grid-tools/bes-client/src/main/java/org/apache/airavata/sample/bes/RunAndTerminateJob.java
Mon Jan 21 16:37:52 2013
@@ -0,0 +1,36 @@
+package org.apache.airavata.sample.bes;
+
+import java.io.File;
+
+import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument;
+
+public class RunAndTerminateJob extends AbstractJobCommand {
+
+	public RunAndTerminateJob() {
+		super();
+	}
+
+	public void runAndTerminate(){
+		JobDefinitionDocument jobDoc = null;
+		try {
+			jobDoc = JobDefinitionDocument.Factory.parse(new File(dateJsdlPath));
+		} catch (Exception e) {
+			System.err.println("Error parsing JSDL instance. " + e);
+		}
+
+		BESJob job = new BESJob();
+		job.setFactory(factoryUrl);
+		job.setJobDoc(jobDoc);
+
+		CreateAndTerminateActivityTask th = new CreateAndTerminateActivityTask(job, securityProperties);
+		try {
+			th.startJob();
+		} catch (Exception e) {
+
+			System.err.println("Couldn't run job: " + e);
+		}
+	}
+	
+
+}
+

Added: airavata/sandbox/grid-tools/bes-client/src/test/resources/fsp.xml
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/bes-client/src/test/resources/fsp.xml?rev=1436470&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/bes-client/src/test/resources/fsp.xml (added)
+++ airavata/sandbox/grid-tools/bes-client/src/test/resources/fsp.xml Mon Jan 21 16:37:52
2013
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<p:JobDefinition xmlns:p="http://schemas.ggf.org/jsdl/2005/11/jsdl"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://schemas.ggf.org/jsdl/2005/11/jsdl jsdl.xsd ">
+	<p:JobDescription>
+		<p:Application>
+			<POSIXApplication xmlns="http://schemas.ggf.org/jsdl/2005/11/jsdl-posix">
+				<Executable>/bin/date;/bin/cat</Executable>
+				<Argument>input.txt</Argument>
+				<Output>stdout.txt</Output>
+				<Error>stderr.txt</Error>
+			</POSIXApplication>
+		</p:Application>
+		<p:DataStaging>
+			<p:FileName>input.txt</p:FileName>
+			<p:CreationFlag>overwrite</p:CreationFlag>
+			<p:Source>
+				<p:URI>ftp://host.name:8004/hello.txt
+				</p:URI>
+			</p:Source>
+			<ac:Credential xmlns:ac="http://schemas.ogf.org/hpcp/2007/11/ac">
+				<wsse:UsernameToken
+					xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+					<wsse:Username>myuser</wsse:Username>
+					<wsse:Password>mypass</wsse:Password>
+				</wsse:UsernameToken>
+			</ac:Credential>
+		</p:DataStaging>
+		<p:DataStaging>
+			<p:FileName>input.txt</p:FileName>
+			<p:CreationFlag>overwrite</p:CreationFlag>
+			<p:Target>
+				<p:URI>ftp://host.name:8004/input.txt</p:URI>
+			</p:Target>
+			<ac:Credential xmlns:ac="http://schemas.ogf.org/hpcp/2007/11/ac">
+				<wsse:UsernameToken
+					xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+					<wsse:Username>myuser</wsse:Username>
+					<wsse:Password>mypass</wsse:Password>
+				</wsse:UsernameToken>
+			</ac:Credential>
+		</p:DataStaging>
+		<p:DataStaging>
+			<p:FileName>stderr.txt</p:FileName>
+			<p:CreationFlag>overwrite</p:CreationFlag>
+			<p:Target>
+				<!-- replace gridsam with your middleware client - arc clients : ftp://zam1161v01.zam.kfa-juelich.de:8004/ogf27/arc/test__9_200.out

+					- genesis clients : ftp://zam1161v01.zam.kfa-juelich.de:8004/ogf27/genesis/test__9_200.out
-->
+				<p:URI>ftp://host.name:8004/stderr.txt</p:URI>
+			</p:Target>
+			<ac:Credential xmlns:ac="http://schemas.ogf.org/hpcp/2007/11/ac">
+				<wsse:UsernameToken
+					xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+					<wsse:Username>myuser</wsse:Username>
+					<wsse:Password>mypass</wsse:Password>
+				</wsse:UsernameToken>
+			</ac:Credential>
+		</p:DataStaging>
+		<p:DataStaging>
+			<p:FileName>stdout.txt</p:FileName>
+			<p:CreationFlag>overwrite</p:CreationFlag>
+			<!-- replace gridsam with your middleware client - arc clients : ftp://zam1161v01.zam.kfa-juelich.de:8004/ogf27/arc/test__9_200.out

+				- genesis clients : ftp://zam1161v01.zam.kfa-juelich.de:8004/ogf27/genesis/test__9_200.out
-->
+
+			<p:Target>
+				<p:URI>ftp://host.name:8004/stdout.txt</p:URI>
+			</p:Target>
+			<ac:Credential xmlns:ac="http://schemas.ogf.org/hpcp/2007/11/ac">
+				<wsse:UsernameToken
+					xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+					<wsse:Username>myuser</wsse:Username>
+					<wsse:Password>mypass</wsse:Password>
+				</wsse:UsernameToken>
+			</ac:Credential>
+		</p:DataStaging>
+	</p:JobDescription>
+</p:JobDefinition>
\ No newline at end of file

Added: airavata/sandbox/grid-tools/bes-client/src/test/resources/sleep.xml
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/bes-client/src/test/resources/sleep.xml?rev=1436470&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/bes-client/src/test/resources/sleep.xml (added)
+++ airavata/sandbox/grid-tools/bes-client/src/test/resources/sleep.xml Mon Jan 21 16:37:52
2013
@@ -0,0 +1,10 @@
+<JobDefinition xmlns="http://schemas.ggf.org/jsdl/2005/11/jsdl" xmlns:jsdl="http://schemas.ggf.org/jsdl/2005/11/jsdl-posix"
xmlns:ac="http://schemas.ogf.org/hpcp/2007/11/ac" xmlns:oas="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+  <JobDescription>
+    <Application>
+      <jsdl:POSIXApplication>
+        <jsdl:Executable>/bin/sleep</jsdl:Executable>
+        <jsdl:Argument>10000</jsdl:Argument>
+      </jsdl:POSIXApplication>
+    </Application>
+  </JobDescription>
+</JobDefinition>
\ No newline at end of file



Mime
View raw message