URL resource = GramProviderTest.class.getClassLoader().getResource("gfac-config.xml");
GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()),null,null);
// gFacConfiguration.s
//have to set InFlwo Handlers and outFlowHandlers
ApplicationContext applicationContext = new ApplicationContext();
HostDescription host = new HostDescription(SSHHostType.type);
host.getType().setHostName("gw85.iu.xsede.org");
host.getType().setHostAddress("gw85.iu.xsede.org");
applicationContext.setHostDescription(host);
/*
* App
*/
ApplicationDescription appDesc = new ApplicationDescription();
ApplicationDeploymentDescriptionType app = appDesc.getType();
ApplicationDeploymentDescriptionType.ApplicationName name = ApplicationDeploymentDescriptionType.ApplicationName.Factory.newInstance();
name.setStringValue("EchoSSH");
app.setApplicationName(name);
/*
* Use bat file if it is compiled on Windows
*/
if (SystemUtils.IS_OS_WINDOWS) {
URL url = this.getClass().getClassLoader().getResource("echo.bat");
app.setExecutableLocation(url.getFile());
} else {
//for unix and Mac
app.setExecutableLocation("/bin/echo");
}
/*
* Job location
*/
String tempDir = "/tmp";
String date = (new Date()).toString();
date = date.replaceAll(" ", "_");
date = date.replaceAll(":", "_");
tempDir = tempDir + File.separator
+ "EchoSSH" + "_" + date + "_" + UUID.randomUUID();
app.setScratchWorkingDirectory(tempDir);
app.setStaticWorkingDirectory(tempDir);
app.setInputDataDirectory(tempDir + File.separator + "input");
app.setOutputDataDirectory(tempDir + File.separator + "output");
app.setStandardOutput(tempDir + File.separator + "echo.stdout");
app.setStandardError(tempDir + File.separator + "echo.stderr");
applicationContext.setApplicationDeploymentDescription(appDesc);
/*
* Service
*/
ServiceDescription serv = new ServiceDescription();
serv.getType().setName("EchoSSH");
List<InputParameterType> inputList = new ArrayList<InputParameterType>();
InputParameterType input = InputParameterType.Factory.newInstance();
input.setParameterName("echo_input");
input.setParameterType(StringParameterType.Factory.newInstance());
inputList.add(input);
InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
.size()]);
List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
OutputParameterType output = OutputParameterType.Factory.newInstance();
output.setParameterName("echo_output");
output.setParameterType(StringParameterType.Factory.newInstance());
outputList.add(output);
OutputParameterType[] outputParamList = outputList
.toArray(new OutputParameterType[outputList.size()]);
serv.getType().setInputParametersArray(inputParamList);
serv.getType().setOutputParametersArray(outputParamList);
jobExecutionContext = new JobExecutionContext(gFacConfiguration,serv.getType().getName());
jobExecutionContext.setApplicationContext(applicationContext);
// Add security context
jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, getSecurityContext());
/*
* Host
*/
applicationContext.setServiceDescription(serv);
MessageContext inMessage = new MessageContext();
ActualParameter echo_input = new ActualParameter();
((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
inMessage.addParameter("echo_input", echo_input);