use of org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType in project airavata by apache.
the class DataTransferrer method downloadRemoteFiles.
/**
* This method will download all the remote files specified in the output
* context of a job.
*/
public void downloadRemoteFiles() throws GFacProviderException {
String downloadLocation = getDownloadLocation();
File file = new File(downloadLocation);
if (!file.exists()) {
file.mkdirs();
}
Map<String, Object> output = jobContext.getOutMessageContext().getParameters();
Set<String> keys = output.keySet();
for (String outPrm : keys) {
OutputDataObjectType actualParameter = (OutputDataObjectType) output.get(outPrm);
if (DataType.STDERR == actualParameter.getType())
continue;
if (DataType.STDOUT == actualParameter.getType())
continue;
String value = actualParameter.getValue();
FileDownloader fileDownloader = new FileDownloader(value, downloadLocation, Mode.overwrite);
try {
fileDownloader.perform(storageClient);
String outputPath = downloadLocation + File.separator + value.substring(value.lastIndexOf('/') + 1);
actualParameter.setValue(outputPath);
actualParameter.setType(DataType.URI);
jobContext.addOutputFile(outputPath);
} catch (Exception e) {
throw new GFacProviderException(e.getLocalizedMessage(), e);
}
}
downloadStdOuts();
}
use of org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType in project airavata by apache.
the class LaunchApplicationWindow method execute.
private void execute() throws AiravataClientConnectException, InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
List<NodeImpl> nodes = workflow.getGraph().getNodes();
String gatewayId = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE).getGatewayId();
String appId = null;
NodeImpl node = null;
for (int i = 0; i < nodes.size(); i++) {
node = nodes.get(i);
String html = node.getComponent().toHTML();
String nodeType = html.substring(html.indexOf("<h1>") + 4, html.indexOf(":")).trim();
if (nodeType.equals("Application")) {
appId = html.substring(html.indexOf("</h2>") + 6, html.indexOf("<br")).trim();
break;
}
}
String hostId = null;
String hostName = (String) host.getSelectedItem();
hostId = hostNames.get(hostName);
String instanceName = this.instanceNameTextField.getText();
if (instanceName.trim().equals("")) {
JOptionPane.showMessageDialog(engine.getGUI().getFrame(), "Experiment name cannot be empty", "Experiment Name", JOptionPane.ERROR_MESSAGE);
return;
}
// previous instance name
if (!instanceNameTextField.getText().equals("")) {
this.instanceNameTextField.setText("");
}
Project project = new Project();
project.setName("project1");
String owner = this.thriftClientData.getUsername();
if (owner.equals(""))
owner = "NotKnown";
project.setOwner(owner);
project.setProjectID(airavataClient.createProject(gatewayId, project));
// final List<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
final List<DataPort> inputPorts = node.getInputPorts();
final Experiment experiment = new Experiment();
experiment.setApplicationId(appId);
ComputationalResourceScheduling scheduling = new ComputationalResourceScheduling();
scheduling.setResourceHostId(hostId);
if (hostName.trim().equals("trestles.sdsc.xsede.org")) {
scheduling.setComputationalProjectAccount("sds128");
} else if (hostName.trim().equals("stampede.tacc.xsede.org")) {
scheduling.setComputationalProjectAccount("TG-STA110014S");
}
scheduling.setNodeCount(1);
scheduling.setTotalCPUCount(1);
scheduling.setWallTimeLimit(15);
scheduling.setQueueName("normal");
UserConfigurationData userConfigurationData = new UserConfigurationData();
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
userConfigurationData.setComputationalResourceScheduling(scheduling);
experiment.setUserConfigurationData(userConfigurationData);
experiment.setName(instanceName);
experiment.setProjectID(project.getProjectID());
experiment.setUserName(thriftClientData.getUsername());
for (int i = 0; i < inputPorts.size(); i++) {
DataPort inputPort = inputPorts.get(i);
XBayaTextField parameterTextField = this.parameterTextFields.get(i);
String value = parameterTextField.getText();
InputDataObjectType elem = new InputDataObjectType();
elem.setName(inputPort.getName());
elem.setType(elem.getType());
elem.setValue(value);
experiment.addToExperimentInputs(elem);
}
final List<DataPort> outputPorts = node.getOutputPorts();
for (int i = 0; i < outputPorts.size(); i++) {
DataPort outputPort = outputPorts.get(i);
OutputDataObjectType elem = new OutputDataObjectType();
elem.setName(outputPort.getName());
elem.setType(elem.getType());
elem.setValue("");
experiment.addToExperimentOutputs(elem);
}
experiment.setExperimentID(airavataClient.createExperiment(gatewayId, experiment));
airavataClient.launchExperiment(experiment.getExperimentID(), "testToken");
hide();
JOptionPane.showMessageDialog(null, "Experiment Launched. You will be alerted on completion.");
String status = airavataClient.getExperimentStatus(experiment.getExperimentID()).getExperimentState().toString().trim();
while (!status.equals("COMPLETED") && !status.equals("FAILED")) {
try {
Thread.sleep(1000);
status = airavataClient.getExperimentStatus(experiment.getExperimentID()).getExperimentState().toString().trim();
} catch (InterruptedException e) {
logger.error(e.getMessage(), e);
}
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
logger.error(e.getMessage(), e);
}
if (status.equals("COMPLETED")) {
String output = "";
;
String fullOutput = "";
while (output.equals("")) {
output = "";
fullOutput = "Experiment Completed Successfully. Output(s) are shown below:\n";
List<OutputDataObjectType> outputs = airavataClient.getExperimentOutputs(experiment.getExperimentID());
for (int i1 = 0; i1 < outputs.size(); i1++) {
output = outputs.get(i1).getValue();
fullOutput += outputs.get(i1).getName() + ": " + output + "\n";
}
}
JOptionPane.showMessageDialog(null, fullOutput);
} else {
JOptionPane.showMessageDialog(null, "Experiment Failed");
return;
}
new Thread() {
@Override
public void run() {
}
}.start();
hide();
}
use of org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType in project airavata by apache.
the class WorkflowInterpreterLaunchWindow method execute.
private void execute() throws AiravataClientConnectException, TException {
String instanceName = this.instanceNameTextField.getText();
if (instanceName.trim().equals("")) {
JOptionPane.showMessageDialog(engine.getGUI().getFrame(), "Experiment name cannot be empty", "Experiment Name", JOptionPane.ERROR_MESSAGE);
return;
}
ThriftClientData thriftClientData = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE);
Client airavataClient = XBayaUtil.getAiravataClient(thriftClientData);
String gatewayId = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE).getGatewayId();
final List<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
List<InputDataObjectType> inputDataTypes = new ArrayList<InputDataObjectType>();
List<OutputDataObjectType> outputDataTypes = new ArrayList<OutputDataObjectType>();
InputDataObjectType input = null;
for (int i = 0; i < inputNodes.size(); i++) {
InputNode inputNode = inputNodes.get(i);
XBayaTextField parameterTextField = this.parameterTextFields.get(i);
inputNode.getID();
String value = parameterTextField.getText();
input = new InputDataObjectType();
// inputNode.setDefaultValue(value);
input.setName(inputNode.getID());
input.setType(inputNode.getDataType());
input.setValue(value);
input.setApplicationArgument(inputNode.getApplicationArgument());
input.setInputOrder(inputNode.getInputOrder());
inputDataTypes.add(input);
}
final List<OutputNode> outputNodes = GraphUtil.getOutputNodes(this.workflow.getGraph());
OutputDataObjectType output = null;
for (OutputNode outputNode : outputNodes) {
output = new OutputDataObjectType();
output.setName(outputNode.getID());
output.setType(DataType.STRING);
outputDataTypes.add(output);
}
Workflow workflowClone = workflow.clone();
workflowClone.setName(workflowClone.getName() + UUID.randomUUID().toString());
org.apache.airavata.model.Workflow workflowModel = new org.apache.airavata.model.Workflow();
workflowModel.setName(workflowClone.getName());
workflowModel.setGraph(JSONUtil.jsonElementToString(workflowClone.toJSON()));
for (InputDataObjectType inputDataType : inputDataTypes) {
workflowModel.addToWorkflowInputs(inputDataType);
}
for (OutputDataObjectType outputDataType : outputDataTypes) {
workflowModel.addToWorkflowOutputs(outputDataType);
}
workflowModel.setTemplateId(airavataClient.registerWorkflow(gatewayId, workflowModel));
// Use topic as a base of workflow instance ID so that the monitor can
// find it.
Project project = new Project();
project.setName("project1");
project.setOwner(thriftClientData.getUsername());
project.setProjectID(airavataClient.createProject(gatewayId, project));
final Experiment experiment = new Experiment();
experiment.setApplicationId(workflowModel.getTemplateId());
experiment.setName(instanceName);
experiment.setProjectID(project.getProjectID());
experiment.setUserName(thriftClientData.getUsername());
for (InputDataObjectType inputDataType : inputDataTypes) {
experiment.addToExperimentInputs(inputDataType);
}
for (OutputDataObjectType outputDataType : outputDataTypes) {
experiment.addToExperimentOutputs(outputDataType);
}
// Add scheduling configurations
if (host != null && host.getSelectedIndex() >= 0) {
String selectedHostName = host.getSelectedItem().toString();
String computeResouceId = hostNames.get(selectedHostName);
ComputationalResourceScheduling computationalResourceScheduling;
if (selectedHostName.equals("localhost")) {
computationalResourceScheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResouceId, 1, 1, 1, "normal", 1, 0, 1, "test");
} else if (selectedHostName.equals("trestles.sdsc.xsede.org")) {
computationalResourceScheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResouceId, 1, 1, 1, "normal", 1, 0, 1, "sds128");
} else if (selectedHostName.equals("stampede.tacc.xsede.org")) {
computationalResourceScheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResouceId, 2, 32, 1, "development", 90, 0, 1, "TG-STA110014S");
} else if (selectedHostName.equals("bigred2.uits.iu.edu")) {
computationalResourceScheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResouceId, 1, 1, 1, "normal", 1, 0, 1, null);
} else {
// TODO handle for other computer resources too.
throw new IllegalArgumentException("Computational resource scheduling is not configured for host :" + computeResouceId);
}
UserConfigurationData userConfigurationData = new UserConfigurationData();
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
userConfigurationData.setComputationalResourceScheduling(computationalResourceScheduling);
experiment.setUserConfigurationData(userConfigurationData);
} else {
throw new RuntimeException("Resource scheduling failed, target computer resource host name is not defined");
}
/*
// code snippet for load test.
for (int i = 0; i < 20; i++) {
experiment.setName(instanceName + "_" + i);
experiment.setExperimentID(airavataClient.createExperiment(experiment));
try {
this.engine.getMonitor().subscribe(experiment.getExperimentID());
this.engine.getMonitor().fireStartMonitoring(workflow.getName());
} catch (MonitorException e) {
logger.error("Error while subscribing with experiment Id : " + experiment.getExperimentID(), e);
}
airavataClient.launchExperiment(experiment.getExperimentID(), "testToken");
}*/
experiment.setExperimentID(airavataClient.createExperiment(gatewayId, experiment));
try {
this.engine.getMonitor().subscribe(experiment.getExperimentID());
this.engine.getMonitor().fireStartMonitoring(workflow.getName());
} catch (MonitorException e) {
logger.error("Error while subscribing with experiment Id : " + experiment.getExperimentID(), e);
}
airavataClient.launchExperiment(experiment.getExperimentID(), token.getText());
clean();
hide();
}
use of org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType in project airavata by apache.
the class DataTransferrer method extractOutParams.
public List<String> extractOutParams(JobExecutionContext context) {
List<String> outPrmsList = new ArrayList<String>();
List<OutputDataObjectType> applicationOutputs = jobContext.getTaskData().getApplicationOutputs();
if (applicationOutputs != null && !applicationOutputs.isEmpty()) {
for (OutputDataObjectType output : applicationOutputs) {
if (output.getType().equals(DataType.STRING)) {
outPrmsList.add(output.getValue());
} else if (output.getType().equals(DataType.FLOAT) || output.getType().equals(DataType.INTEGER)) {
outPrmsList.add(String.valueOf(output.getValue()));
}
}
}
return outPrmsList;
}
Aggregations