use of org.apache.airavata.model.workspace.Project in project airavata by apache.
the class CreateLaunchExperimentUS3 method createUS3ExperimentForTrestles.
public static String createUS3ExperimentForTrestles(Airavata.Client client) throws AiravataSystemException, InvalidRequestException, AiravataClientException, TException {
try {
List<InputDataObjectType> exInputs = new ArrayList<InputDataObjectType>();
InputDataObjectType input = new InputDataObjectType();
input.setName("input");
input.setType(DataType.URI);
input.setValue("file:///home/sgg/chathuri/laptop_backup/airavata/ultrascan_input/hpcinput.tar");
InputDataObjectType input1 = new InputDataObjectType();
input1.setName("walltime");
input1.setType(DataType.STRING);
input1.setValue("-walltime=60");
InputDataObjectType input2 = new InputDataObjectType();
input2.setName("mgroupcount");
input2.setType(DataType.STRING);
input2.setValue("-mgroupcount=1");
exInputs.add(input);
exInputs.add(input1);
exInputs.add(input2);
List<OutputDataObjectType> exOut = new ArrayList<OutputDataObjectType>();
OutputDataObjectType output = new OutputDataObjectType();
output.setName("output");
output.setType(DataType.URI);
output.setValue("");
// OutputDataObjectType output1 = new OutputDataObjectType();
// output1.setName("stdout");
// output1.setType(DataType.STDOUT);
// output1.setValue("");
// OutputDataObjectType output2 = new OutputDataObjectType();
// output2.setName("stderr");
// output2.setType(DataType.STDERR);
// output2.setValue("");
exOut.add(output);
// exOut.add(output1);
// exOut.add(output2);
Project project = ProjectModelUtil.createProject("ultrascan", "ultrascan", "test project");
String projectId = client.createProject(new AuthzToken(""), DEFAULT_GATEWAY, project);
ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY, projectId, "ultrascan", "US3ExperimentTrestles", "US3AppTrestles", "ultrascan_7ce6cd43-622c-44e0-87c5-fb7a6528c799", exInputs);
simpleExperiment.setExperimentOutputs(exOut);
ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling("trestles.sdsc.xsede.org_72b9181b-7156-4975-a386-ed98b4949496", 32, 1, 0, "shared", 30, 0);
UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
scheduling.setResourceHostId("trestles.sdsc.xsede.org_72b9181b-7156-4975-a386-ed98b4949496");
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
/* AdvancedOutputDataHandling dataHandling = new AdvancedOutputDataHandling();
dataHandling.setOutputDataDir("/home/sgg/chathuri/laptop_backup/airavata");
userConfigurationData.setAdvanceOutputDataHandling(dataHandling);*/
userConfigurationData.setComputationalResourceScheduling(scheduling);
simpleExperiment.setUserConfigurationData(userConfigurationData);
return client.createExperiment(new AuthzToken(""), DEFAULT_GATEWAY, simpleExperiment);
} catch (AiravataSystemException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new AiravataSystemException(e);
} catch (InvalidRequestException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new InvalidRequestException(e);
} catch (AiravataClientException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new AiravataClientException(e);
} catch (TException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new TException(e);
}
}
use of org.apache.airavata.model.workspace.Project in project airavata by apache.
the class CreateLaunchExperiment method createEchoExperimentForTrestles.
public static String createEchoExperimentForTrestles(Airavata.Client client) throws TException {
try {
List<InputDataObjectType> exInputs = client.getApplicationInputs(new AuthzToken(""), echoAppId);
for (InputDataObjectType inputDataObjectType : exInputs) {
if (inputDataObjectType.getName().equalsIgnoreCase("Input_to_Echo")) {
inputDataObjectType.setValue("Hello World");
}
}
List<OutputDataObjectType> exOut = client.getApplicationOutputs(new AuthzToken(""), echoAppId);
Project project = ProjectModelUtil.createProject("default", "admin", "test project");
String projectId = client.createProject(new AuthzToken(""), DEFAULT_GATEWAY, project);
ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY, projectId, "admin", "echoExperiment", "SimpleEcho3", echoAppId, exInputs);
simpleExperiment.setExperimentOutputs(exOut);
Map<String, String> computeResources = airavataClient.getAvailableAppInterfaceComputeResources(new AuthzToken(""), echoAppId);
if (computeResources != null && computeResources.size() != 0) {
for (String id : computeResources.keySet()) {
String resourceName = computeResources.get(id);
if (resourceName.equals(trestlesHostName)) {
ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 1, 1, 1, "normal", 30, 1);
UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
userConfigurationData.setComputationalResourceScheduling(scheduling);
simpleExperiment.setUserConfigurationData(userConfigurationData);
return client.createExperiment(new AuthzToken(""), DEFAULT_GATEWAY, simpleExperiment);
}
}
}
} catch (AiravataSystemException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new AiravataSystemException(e);
} catch (InvalidRequestException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new InvalidRequestException(e);
} catch (AiravataClientException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new AiravataClientException(e);
} catch (TException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new TException(e);
}
return null;
}
use of org.apache.airavata.model.workspace.Project 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.workspace.Project in project airavata by apache.
the class DataRetrievalIT method addProjects.
private void addProjects() throws TException {
for (int i = 0; i < projects.length; i++) {
Project project = ProjectModelUtil.createProject(projects[i], "admin", "test project");
String projectId = getClient().createProject(authzToken, "default", project);
projectIds.add(projectId);
}
}
use of org.apache.airavata.model.workspace.Project 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();
}
Aggregations