use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.
the class BESJobSubmissionTask method copyOutputFilesToStorage.
private void copyOutputFilesToStorage(TaskContext taskContext, List<OutputDataObjectType> copyOutput) throws GFacException {
ProcessContext pc = taskContext.getParentProcessContext();
String remoteFilePath = null, fileName = null, localFilePath = null;
try {
authenticationInfo = Factory.getStorageSSHKeyAuthentication(pc);
ServerInfo serverInfo = pc.getComputeResourceServerInfo();
Session sshSession = Factory.getSSHSession(authenticationInfo, serverInfo);
for (OutputDataObjectType output : copyOutput) {
switch(output.getType()) {
case STDERR:
case STDOUT:
case STRING:
case URI:
localFilePath = output.getValue();
if (localFilePath.contains("://")) {
localFilePath = localFilePath.substring(localFilePath.indexOf("://") + 2, localFilePath.length());
}
fileName = localFilePath.substring(localFilePath.lastIndexOf("/") + 1);
URI destinationURI = TaskUtils.getDestinationURI(taskContext, hostName, inputPath, fileName);
remoteFilePath = destinationURI.getPath();
log.info("SCP local file :{} -> from remote :{}", localFilePath, remoteFilePath);
SSHUtils.scpTo(localFilePath, remoteFilePath, sshSession);
output.setValue(destinationURI.toString());
break;
default:
break;
}
}
} catch (IOException | JSchException | SSHApiException | URISyntaxException | CredentialStoreException e) {
log.error("Error while coping local file " + localFilePath + " to remote " + remoteFilePath, e);
throw new GFacException("Error while scp output files to remote storage file location", e);
}
}
use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.
the class GFacUtils method saveProcessOutput.
public static void saveProcessOutput(ProcessContext processContext, String outputName, String outputVal) throws GFacException {
try {
ExperimentCatalog experimentCatalog = processContext.getExperimentCatalog();
String processId = processContext.getProcessId();
List<OutputDataObjectType> processOutputs = (List<OutputDataObjectType>) experimentCatalog.get(ExperimentCatalogModelType.PROCESS_OUTPUT, processId);
if (processOutputs != null && !processOutputs.isEmpty()) {
for (OutputDataObjectType processOutput : processOutputs) {
if (processOutput.getName().equals(outputName)) {
processOutput.setValue(outputVal);
}
}
}
ProcessModel processModel = processContext.getProcessModel();
processModel.setProcessOutputs(processOutputs);
experimentCatalog.update(ExperimentCatalogModelType.PROCESS, processModel, processId);
} catch (RegistryException e) {
String msg = "expId: " + processContext.getExperimentId() + " processId: " + processContext.getProcessId() + " : - Error while updating experiment outputs";
throw new GFacException(msg, e);
}
}
use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.
the class GFacUtils method getProcessOutputValues.
private static List<String> getProcessOutputValues(List<OutputDataObjectType> processOutputs) {
List<String> inputValues = new ArrayList<>();
if (processOutputs != null) {
for (OutputDataObjectType output : processOutputs) {
if (output.getApplicationArgument() != null && !output.getApplicationArgument().equals("")) {
inputValues.add(output.getApplicationArgument());
}
if (output.getValue() != null && !output.getValue().equals("") && output.isRequiredToAddedToCommandLine()) {
if (output.getType() == DataType.URI) {
String filePath = output.getValue();
filePath = filePath.substring(filePath.lastIndexOf(File.separatorChar) + 1, filePath.length());
inputValues.add(filePath);
}
}
}
}
return inputValues;
}
use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.
the class WorkflowInterpreter method finish.
private void finish() throws WorkflowException, RegistryException {
ArrayList<Node> outoutNodes = new ArrayList<Node>();
List<NodeImpl> nodes = this.getGraph().getNodes();
for (Node node : nodes) {
if (node instanceof OutputNode) {
if (node.getInputPort(0).getFromNode().getState() == NodeExecutionState.FINISHED) {
outoutNodes.add(node);
} else {
// workflowFinished
return;
}
}
}
LinkedList<Object> outputValues = new LinkedList<Object>();
LinkedList<String> outputKeywords = new LinkedList<String>();
for (Node outputNode : outoutNodes) {
OutputNode node = (OutputNode) outputNode;
List<DataPort> inputPorts = node.getInputPorts();
for (DataPort dataPort : inputPorts) {
Object val = InterpreterUtil.findInputFromPort(dataPort, this.invokerMap);
;
if (null == val) {
throw new WorkFlowInterpreterException("Unable to find output for the node:" + node.getID());
}
WorkflowNodeDetails workflowNodeDetails = nodeInstanceList.get(node);
OutputDataObjectType elem = new OutputDataObjectType();
elem.setName(node.getName());
elem.setValue(val.toString());
workflowNodeDetails.addToNodeOutputs(elem);
try {
getExperimentCatalog().update(ExperimentCatalogModelType.WORKFLOW_NODE_DETAIL, workflowNodeDetails, workflowNodeDetails.getNodeInstanceId());
} catch (RegistryException e) {
log.error(e.getMessage(), e);
}
updateWorkflowNodeStatus(workflowNodeDetails, WorkflowNodeState.COMPLETED);
}
}
}
use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.
the class WorkflowInterpreter method taskOutputChanged.
@Subscribe
public void taskOutputChanged(TaskOutputChangeEvent taskOutputEvent) {
String taskId = taskOutputEvent.getTaskIdentity().getTaskId();
if (isTaskAwaiting(taskId)) {
ProcessState state = ProcessState.COMPLETED;
Node node = getAwaitingNodeForTask(taskId);
List<OutputDataObjectType> applicationOutputs = taskOutputEvent.getOutput();
Map<String, String> outputData = new HashMap<String, String>();
for (OutputDataObjectType outputObj : applicationOutputs) {
List<DataPort> outputPorts = node.getOutputPorts();
for (DataPort dataPort : outputPorts) {
if (dataPort.getName().equals(outputObj.getName())) {
outputData.put(outputObj.getName(), outputObj.getValue());
}
}
}
nodeOutputData.put(node, outputData);
setupNodeDetailsOutput(node);
node.setState(NodeExecutionState.FINISHED);
try {
publishNodeStatusChange(WorkflowNodeState.COMPLETED, node.getID(), experiment.getExperimentID());
updateWorkflowNodeStatus(nodeInstanceList.get(node), state);
} catch (RegistryException e) {
log.error(e.getMessage(), e);
} catch (AiravataException e) {
log.error(e.getMessage(), e);
}
}
}
Aggregations