index int64 0 0 | repo_id stringlengths 9 205 | file_path stringlengths 31 246 | content stringlengths 1 12.2M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/task | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/task/type/TaskOutputType.java | package org.apache.airavata.k8s.api.server.model.task.type;
import javax.persistence.*;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
public class TaskOutputType {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
private String type;
@ManyToOne
private TaskModelType taskModelType;
public long getId() {
return id;
}
public TaskOutputType setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public TaskOutputType setName(String name) {
this.name = name;
return this;
}
public String getType() {
return type;
}
public TaskOutputType setType(String type) {
this.type = type;
return this;
}
public TaskModelType getTaskModelType() {
return taskModelType;
}
public TaskOutputType setTaskModelType(TaskModelType taskModelType) {
this.taskModelType = taskModelType;
return this;
}
}
| 8,800 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/task | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/task/type/TaskModelType.java | package org.apache.airavata.k8s.api.server.model.task.type;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
public class TaskModelType {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
private String topicName;
private String icon;
@OneToMany(mappedBy = "taskModelType", cascade = CascadeType.ALL)
private List<TaskInputType> inputTypes = new ArrayList<>();
@OneToMany(mappedBy = "taskModelType", cascade = CascadeType.ALL)
private List<TaskOutputType> outputTypes = new ArrayList<>();
@OneToMany(mappedBy = "taskModelType", cascade = CascadeType.ALL)
private List<TaskOutPortType> outPorts = new ArrayList<>();
public long getId() {
return id;
}
public TaskModelType setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public TaskModelType setName(String name) {
this.name = name;
return this;
}
public String getTopicName() {
return topicName;
}
public TaskModelType setTopicName(String topicName) {
this.topicName = topicName;
return this;
}
public List<TaskInputType> getInputTypes() {
return inputTypes;
}
public TaskModelType setInputTypes(List<TaskInputType> inputTypes) {
this.inputTypes = inputTypes;
return this;
}
public List<TaskOutputType> getOutputTypes() {
return outputTypes;
}
public TaskModelType setOutputTypes(List<TaskOutputType> outputTypes) {
this.outputTypes = outputTypes;
return this;
}
public List<TaskOutPortType> getOutPorts() {
return outPorts;
}
public TaskModelType setOutPorts(List<TaskOutPortType> outPorts) {
this.outPorts = outPorts;
return this;
}
public String getIcon() {
return icon;
}
public TaskModelType setIcon(String icon) {
this.icon = icon;
return this;
}
}
| 8,801 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/task | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/task/type/TaskOutPortType.java | package org.apache.airavata.k8s.api.server.model.task.type;
import javax.persistence.*;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
public class TaskOutPortType {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
@Column(name = "PORT_ORDER")
private int order = 0;
@ManyToOne
private TaskModelType taskModelType;
public long getId() {
return id;
}
public TaskOutPortType setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public TaskOutPortType setName(String name) {
this.name = name;
return this;
}
public int getOrder() {
return order;
}
public TaskOutPortType setOrder(int order) {
this.order = order;
return this;
}
public TaskModelType getTaskModelType() {
return taskModelType;
}
public TaskOutPortType setTaskModelType(TaskModelType taskModelType) {
this.taskModelType = taskModelType;
return this;
}
}
| 8,802 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/job/JobStatus.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.model.job;
import javax.persistence.*;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "JOB_STATUS")
public class JobStatus {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private JobState jobState;
private long timeOfStateChange;
private String reason;
@ManyToOne
private JobModel jobModel;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public JobState getJobState() {
return jobState;
}
public void setJobState(JobState jobState) {
this.jobState = jobState;
}
public long getTimeOfStateChange() {
return timeOfStateChange;
}
public void setTimeOfStateChange(long timeOfStateChange) {
this.timeOfStateChange = timeOfStateChange;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public JobModel getJobModel() {
return jobModel;
}
public JobStatus setJobModel(JobModel jobModel) {
this.jobModel = jobModel;
return this;
}
public enum JobState {
SUBMITTED(0),
QUEUED(1),
ACTIVE(2),
COMPLETE(3),
CANCELED(4),
FAILED(5),
SUSPENDED(6),
UNKNOWN(7);
private final int value;
private JobState(int value) {
this.value = value;
}
/**
* Get the integer value of this enum value, as defined in the Thrift IDL.
*/
public int getValue() {
return value;
}
}
}
| 8,803 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/job/JobModel.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.model.job;
import org.apache.airavata.k8s.api.server.model.task.TaskModel;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "JOB_MODEL")
public class JobModel {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@ManyToOne
private TaskModel task;
private String jobDescription;
private long creationTime;
@OneToMany(mappedBy = "jobModel", cascade = CascadeType.ALL)
private List<JobStatus> jobStatuses = new ArrayList<>();
@ManyToOne
private TaskModel taskModel;
private String computeResourceConsumed;
private String jobName;
private String workingDir;
private String stdOut;
private String stdErr;
private int exitCode;
public long getId() {
return id;
}
public JobModel setId(long id) {
this.id = id;
return this;
}
public TaskModel getTask() {
return task;
}
public JobModel setTask(TaskModel task) {
this.task = task;
return this;
}
public String getJobDescription() {
return jobDescription;
}
public JobModel setJobDescription(String jobDescription) {
this.jobDescription = jobDescription;
return this;
}
public long getCreationTime() {
return creationTime;
}
public JobModel setCreationTime(long creationTime) {
this.creationTime = creationTime;
return this;
}
public List<JobStatus> getJobStatuses() {
return jobStatuses;
}
public JobModel setJobStatuses(List<JobStatus> jobStatuses) {
this.jobStatuses = jobStatuses;
return this;
}
public TaskModel getTaskModel() {
return taskModel;
}
public JobModel setTaskModel(TaskModel taskModel) {
this.taskModel = taskModel;
return this;
}
public String getComputeResourceConsumed() {
return computeResourceConsumed;
}
public JobModel setComputeResourceConsumed(String computeResourceConsumed) {
this.computeResourceConsumed = computeResourceConsumed;
return this;
}
public String getJobName() {
return jobName;
}
public JobModel setJobName(String jobName) {
this.jobName = jobName;
return this;
}
public String getWorkingDir() {
return workingDir;
}
public JobModel setWorkingDir(String workingDir) {
this.workingDir = workingDir;
return this;
}
public String getStdOut() {
return stdOut;
}
public JobModel setStdOut(String stdOut) {
this.stdOut = stdOut;
return this;
}
public String getStdErr() {
return stdErr;
}
public JobModel setStdErr(String stdErr) {
this.stdErr = stdErr;
return this;
}
public int getExitCode() {
return exitCode;
}
public JobModel setExitCode(int exitCode) {
this.exitCode = exitCode;
return this;
}
}
| 8,804 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/experiment/ExperimentStatus.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.model.experiment;
import javax.persistence.*;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "EXPERIMENT_STATUS")
public class ExperimentStatus {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private ExperimentState state; // required
private long timeOfStateChange; // optional
private String reason; // optional
public long getId() {
return id;
}
public ExperimentStatus setId(long id) {
this.id = id;
return this;
}
public ExperimentState getState() {
return state;
}
public ExperimentStatus setState(ExperimentState state) {
this.state = state;
return this;
}
public long getTimeOfStateChange() {
return timeOfStateChange;
}
public ExperimentStatus setTimeOfStateChange(long timeOfStateChange) {
this.timeOfStateChange = timeOfStateChange;
return this;
}
public String getReason() {
return reason;
}
public ExperimentStatus setReason(String reason) {
this.reason = reason;
return this;
}
public enum ExperimentState {
CREATED(0),
VALIDATED(1),
SCHEDULED(2),
LAUNCHED(3),
EXECUTING(4),
CANCELING(5),
CANCELED(6),
COMPLETED(7),
FAILED(8);
private final int value;
private ExperimentState(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
}
| 8,805 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/experiment/Experiment.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.model.experiment;
import org.apache.airavata.k8s.api.server.model.application.ApplicationDeployment;
import org.apache.airavata.k8s.api.server.model.application.ApplicationInterface;
import org.apache.airavata.k8s.api.server.model.commons.ErrorModel;
import org.apache.airavata.k8s.api.server.model.process.ProcessModel;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "EXPERIMENT")
public class Experiment {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String experimentName;
private long creationTime;
private String description;
@ManyToOne
private ApplicationInterface applicationInterface;
@ManyToOne
private ApplicationDeployment applicationDeployment;
@OneToMany
private List<ExperimentInputData> experimentInputs = new ArrayList<>();
@OneToMany
private List<ExperimentOutputData> experimentOutputs = new ArrayList<>();
@OneToMany
private List<ExperimentStatus> experimentStatus = new ArrayList<>();
@OneToMany
private List<ErrorModel> errors = new ArrayList<>();
@OneToMany(mappedBy = "experiment", cascade = CascadeType.ALL)
private List<ProcessModel> processes = new ArrayList<>();
public long getId() {
return id;
}
public Experiment setId(long id) {
this.id = id;
return this;
}
public String getExperimentName() {
return experimentName;
}
public Experiment setExperimentName(String experimentName) {
this.experimentName = experimentName;
return this;
}
public long getCreationTime() {
return creationTime;
}
public Experiment setCreationTime(long creationTime) {
this.creationTime = creationTime;
return this;
}
public String getDescription() {
return description;
}
public Experiment setDescription(String description) {
this.description = description;
return this;
}
public ApplicationInterface getApplicationInterface() {
return applicationInterface;
}
public Experiment setApplicationInterface(ApplicationInterface applicationInterface) {
this.applicationInterface = applicationInterface;
return this;
}
public ApplicationDeployment getApplicationDeployment() {
return applicationDeployment;
}
public Experiment setApplicationDeployment(ApplicationDeployment applicationDeployment) {
this.applicationDeployment = applicationDeployment;
return this;
}
public List<ExperimentInputData> getExperimentInputs() {
return experimentInputs;
}
public Experiment setExperimentInputs(List<ExperimentInputData> experimentInputs) {
this.experimentInputs = experimentInputs;
return this;
}
public List<ExperimentOutputData> getExperimentOutputs() {
return experimentOutputs;
}
public Experiment setExperimentOutputs(List<ExperimentOutputData> experimentOutputs) {
this.experimentOutputs = experimentOutputs;
return this;
}
public List<ExperimentStatus> getExperimentStatus() {
return experimentStatus;
}
public Experiment setExperimentStatus(List<ExperimentStatus> experimentStatus) {
this.experimentStatus = experimentStatus;
return this;
}
public List<ErrorModel> getErrors() {
return errors;
}
public Experiment setErrors(List<ErrorModel> errors) {
this.errors = errors;
return this;
}
public List<ProcessModel> getProcesses() {
return processes;
}
public Experiment setProcesses(List<ProcessModel> processes) {
this.processes = processes;
return this;
}
}
| 8,806 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/experiment/ExperimentOutputData.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.model.experiment;
import javax.persistence.*;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "EXPERIMENT_OUTPUT_OBJECT")
public class ExperimentOutputData {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
private String value;
private DataType type;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public DataType getType() {
return type;
}
public void setType(DataType type) {
this.type = type;
}
public static enum DataType {
STRING(0),
INTEGER(1),
FLOAT(2),
URI(3),
URI_COLLECTION(4),
STDOUT(5),
STDERR(6);
private final int value;
private static Map<Integer, DataType> map = new HashMap<>();
static {
for (DataType dataType : DataType.values()) {
map.put(dataType.value, dataType);
}
}
public static DataType valueOf(int dataType) {
return map.get(dataType);
}
private DataType(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
}
| 8,807 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/experiment/ExperimentInputData.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.model.experiment;
import javax.persistence.*;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "EXPERIMENT_INPUT_OBJECT")
public class ExperimentInputData {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
private String value;
private DataType type;
private String arguments;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public DataType getType() {
return type;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public void setType(DataType type) {
this.type = type;
}
public String getArguments() {
return arguments;
}
public void setArguments(String arguments) {
this.arguments = arguments;
}
public static enum DataType {
STRING(0),
INTEGER(1),
FLOAT(2),
URI(3),
URI_COLLECTION(4),
STDOUT(5),
STDERR(6);
private final int value;
private static Map<Integer, DataType> map = new HashMap<>();
static {
for (DataType dataType : DataType.values()) {
map.put(dataType.value, dataType);
}
}
public static DataType valueOf(int dataType) {
return map.get(dataType);
}
private DataType(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
}
| 8,808 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/application/ApplicationDeployment.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.model.application;
import org.apache.airavata.k8s.api.server.model.compute.ComputeResourceModel;
import javax.persistence.*;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "APPLICATION_DEPLOYMENT")
public class ApplicationDeployment {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@ManyToOne
@JoinColumn(name = "APPLICATION_MODULE_ID")
private ApplicationModule applicationModule;
@ManyToOne
@JoinColumn(name = "COMPUTE_RESOURCE_ID")
private ComputeResourceModel computeResource;
private String name;
private String executablePath;
private String preJobCommand;
private String postJobCommand;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public ApplicationModule getApplicationModule() {
return applicationModule;
}
public void setApplicationModule(ApplicationModule applicationModule) {
this.applicationModule = applicationModule;
}
public ComputeResourceModel getComputeResource() {
return computeResource;
}
public void setComputeResource(ComputeResourceModel computeResourceModel) {
this.computeResource = computeResourceModel;
}
public String getExecutablePath() {
return executablePath;
}
public void setExecutablePath(String executablePath) {
this.executablePath = executablePath;
}
public String getPreJobCommand() {
return preJobCommand;
}
public void setPreJobCommand(String preJobCommand) {
this.preJobCommand = preJobCommand;
}
public String getPostJobCommand() {
return postJobCommand;
}
public void setPostJobCommand(String postJobCommand) {
this.postJobCommand = postJobCommand;
}
public String getName() {
return name;
}
public ApplicationDeployment setName(String name) {
this.name = name;
return this;
}
}
| 8,809 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/application/ApplicationOutput.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.model.application;
import javax.persistence.*;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "APPLICATION_OUTPUT")
public class ApplicationOutput {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
private String value;
private DataType type;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public DataType getType() {
return type;
}
public void setType(DataType type) {
this.type = type;
}
public static enum DataType {
STRING(0),
INTEGER(1),
FLOAT(2),
URI(3),
URI_COLLECTION(4),
STDOUT(5),
STDERR(6);
private final int value;
private static Map<Integer, DataType> map = new HashMap<>();
static {
for (DataType dataType : DataType.values()) {
map.put(dataType.value, dataType);
}
}
private DataType(int value) {
this.value = value;
}
public static DataType valueOf(int dataType) {
return map.get(dataType);
}
public int getValue() {
return value;
}
}
}
| 8,810 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/application/ApplicationInterface.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.model.application;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "APPLICATION_INTERFACE")
public class ApplicationInterface {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
private String description;
@ManyToOne
@JoinColumn(name = "APP_MODULE_ID")
private ApplicationModule applicationModule;
@OneToMany
private List<ApplicationInput> inputs = new ArrayList<>();
@OneToMany
private List<ApplicationOutput> outputs = new ArrayList<>();
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public ApplicationModule getApplicationModule() {
return applicationModule;
}
public void setApplicationModule(ApplicationModule applicationModule) {
this.applicationModule = applicationModule;
}
public List<ApplicationInput> getInputs() {
return inputs;
}
public void setInputs(List<ApplicationInput> inputs) {
this.inputs = inputs;
}
public List<ApplicationOutput> getOutputs() {
return outputs;
}
public void setOutputs(List<ApplicationOutput> outputs) {
this.outputs = outputs;
}
}
| 8,811 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/application/ApplicationInput.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.model.application;
import javax.persistence.*;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "APPLICATION_INPUT")
public class ApplicationInput {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
private String value;
private DataType type;
private String arguments;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public DataType getType() {
return type;
}
public void setType(DataType type) {
this.type = type;
}
public String getArguments() {
return arguments;
}
public void setArguments(String arguments) {
this.arguments = arguments;
}
public static enum DataType {
STRING(0),
INTEGER(1),
FLOAT(2),
URI(3),
URI_COLLECTION(4),
STDOUT(5),
STDERR(6);
private final int value;
private static Map<Integer, DataType> map = new HashMap();
static {
for (DataType dataType : DataType.values()) {
map.put(dataType.value, dataType);
}
}
private DataType(int value) {
this.value = value;
}
public static DataType valueOf(int dataType) {
return map.get(dataType);
}
public int getValue() {
return value;
}
}
}
| 8,812 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/application/ApplicationModule.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.model.application;
import javax.persistence.*;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "APPLICATION_MODULE")
public class ApplicationModule {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
private String version;
private String description;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
| 8,813 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/data/DataStoreModel.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.model.data;
import org.apache.airavata.k8s.api.server.model.experiment.ExperimentInputData;
import org.apache.airavata.k8s.api.server.model.experiment.ExperimentOutputData;
import org.apache.airavata.k8s.api.server.model.task.TaskModel;
import javax.persistence.*;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "DATA_STORE")
public class DataStoreModel {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Lob
@Column(length = 1000000, name = "CONTENT")
@Basic(fetch = FetchType.LAZY)
private byte[] content;
private String identifier;
@ManyToOne
private TaskModel taskModel;
public long getId() {
return id;
}
public DataStoreModel setId(long id) {
this.id = id;
return this;
}
public byte[] getContent() {
return content;
}
public DataStoreModel setContent(byte[] content) {
this.content = content;
return this;
}
public String getIdentifier() {
return identifier;
}
public DataStoreModel setIdentifier(String identifier) {
this.identifier = identifier;
return this;
}
public TaskModel getTaskModel() {
return taskModel;
}
public DataStoreModel setTaskModel(TaskModel taskModel) {
this.taskModel = taskModel;
return this;
}
}
| 8,814 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/process/ProcessStatus.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.model.process;
import javax.persistence.*;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "PROCESS_STATUS")
public class ProcessStatus {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@ManyToOne
private ProcessModel processModel;
private ProcessState state;
private long timeOfStateChange;
private String reason;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public ProcessModel getProcessModel() {
return processModel;
}
public void setProcessModel(ProcessModel processModel) {
this.processModel = processModel;
}
public ProcessState getState() {
return state;
}
public void setState(ProcessState state) {
this.state = state;
}
public long getTimeOfStateChange() {
return timeOfStateChange;
}
public void setTimeOfStateChange(long timeOfStateChange) {
this.timeOfStateChange = timeOfStateChange;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public enum ProcessState {
CREATED(0),
VALIDATED(1),
STARTED(2),
PRE_PROCESSING(3),
CONFIGURING_WORKSPACE(4),
INPUT_DATA_STAGING(5),
EXECUTING(6),
MONITORING(7),
OUTPUT_DATA_STAGING(8),
POST_PROCESSING(9),
COMPLETED(10),
FAILED(11),
CANCELLING(12),
CANCELED(13);
private final int value;
private ProcessState(int value) {
this.value = value;
}
private static Map<Integer, ProcessState> map = new HashMap<>();
static {
for (ProcessState state : ProcessState.values()) {
map.put(state.value, state);
}
}
public static ProcessState valueOf(int prcessState) {
return map.get(prcessState);
}
public int getValue() {
return value;
}
}
}
| 8,815 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/process/ProcessModel.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.model.process;
import org.apache.airavata.k8s.api.server.model.commons.ErrorModel;
import org.apache.airavata.k8s.api.server.model.experiment.Experiment;
import org.apache.airavata.k8s.api.server.model.task.TaskModel;
import org.apache.airavata.k8s.api.server.model.workflow.Workflow;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "PROCESS_MODEL")
public class ProcessModel {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@ManyToOne
private Experiment experiment;
@ManyToOne
private Workflow workflow;
private String name;
private long creationTime;
private long lastUpdateTime;
@OneToMany(mappedBy = "processModel", cascade = CascadeType.ALL)
private List<ProcessStatus> processStatuses = new ArrayList<>();
@OneToMany(mappedBy = "parentProcess", cascade = CascadeType.ALL)
private List<TaskModel> tasks = new ArrayList<>();
@OneToMany(mappedBy = "processModel", cascade = CascadeType.ALL)
private List<ProcessBootstrapData> processBootstrapData = new ArrayList<>();
private String taskDag;
@OneToMany
private List<ErrorModel> processErrors = new ArrayList<>();
private String experimentDataDir;
private ProcessType processType = ProcessType.EXPERIMENT;
public long getId() {
return id;
}
public ProcessModel setId(long id) {
this.id = id;
return this;
}
public Experiment getExperiment() {
return experiment;
}
public ProcessModel setExperiment(Experiment experiment) {
this.experiment = experiment;
return this;
}
public String getName() {
return name;
}
public ProcessModel setName(String name) {
this.name = name;
return this;
}
public long getCreationTime() {
return creationTime;
}
public ProcessModel setCreationTime(long creationTime) {
this.creationTime = creationTime;
return this;
}
public long getLastUpdateTime() {
return lastUpdateTime;
}
public ProcessModel setLastUpdateTime(long lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
return this;
}
public List<ProcessStatus> getProcessStatuses() {
return processStatuses;
}
public ProcessModel setProcessStatuses(List<ProcessStatus> processStatuses) {
this.processStatuses = processStatuses;
return this;
}
public List<TaskModel> getTasks() {
return tasks;
}
public ProcessModel setTasks(List<TaskModel> tasks) {
this.tasks = tasks;
return this;
}
public String getTaskDag() {
return taskDag;
}
public ProcessModel setTaskDag(String taskDag) {
this.taskDag = taskDag;
return this;
}
public List<ErrorModel> getProcessErrors() {
return processErrors;
}
public ProcessModel setProcessErrors(List<ErrorModel> processErrors) {
this.processErrors = processErrors;
return this;
}
public String getExperimentDataDir() {
return experimentDataDir;
}
public ProcessModel setExperimentDataDir(String experimentDataDir) {
this.experimentDataDir = experimentDataDir;
return this;
}
public ProcessType getProcessType() {
return processType;
}
public ProcessModel setProcessType(ProcessType processType) {
this.processType = processType;
return this;
}
public Workflow getWorkflow() {
return workflow;
}
public ProcessModel setWorkflow(Workflow workflow) {
this.workflow = workflow;
return this;
}
public List<ProcessBootstrapData> getProcessBootstrapData() {
return processBootstrapData;
}
public ProcessModel setProcessBootstrapData(List<ProcessBootstrapData> processBootstrapData) {
this.processBootstrapData = processBootstrapData;
return this;
}
public enum ProcessType {
WORKFLOW, EXPERIMENT;
}
}
| 8,816 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/model/process/ProcessBootstrapData.java | package org.apache.airavata.k8s.api.server.model.process;
import javax.persistence.*;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Entity
@Table(name = "PROCESS_BOOTSTRAP_DATA")
public class ProcessBootstrapData {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@ManyToOne
private ProcessModel processModel;
@Column(name = "DATA_KEY")
private String key;
@Column(name = "DATA_VALUE")
private String value;
public long getId() {
return id;
}
public ProcessBootstrapData setId(long id) {
this.id = id;
return this;
}
public ProcessModel getProcessModel() {
return processModel;
}
public ProcessBootstrapData setProcessModel(ProcessModel processModel) {
this.processModel = processModel;
return this;
}
public String getKey() {
return key;
}
public ProcessBootstrapData setKey(String key) {
this.key = key;
return this;
}
public String getValue() {
return value;
}
public ProcessBootstrapData setValue(String value) {
this.value = value;
return this;
}
}
| 8,817 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/ApplicationDeploymentService.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.service;
import org.apache.airavata.k8s.api.server.ServerRuntimeException;
import org.apache.airavata.k8s.api.server.model.application.ApplicationDeployment;
import org.apache.airavata.k8s.api.server.repository.application.ApplicationDeploymentRepository;
import org.apache.airavata.k8s.api.server.repository.application.ApplicationModuleRepository;
import org.apache.airavata.k8s.api.server.repository.compute.ComputeRepository;
import org.apache.airavata.k8s.api.resources.application.ApplicationDeploymentResource;
import org.apache.airavata.k8s.api.server.service.util.ToResourceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Service
public class ApplicationDeploymentService {
private ApplicationDeploymentRepository applicationDeploymentRepository;
private ComputeRepository computeRepository;
private ApplicationModuleRepository applicationModuleRepository;
@Autowired
public ApplicationDeploymentService(ApplicationDeploymentRepository applicationDeploymentRepository,
ComputeRepository computeRepository,
ApplicationModuleRepository applicationModuleRepository) {
this.applicationDeploymentRepository = applicationDeploymentRepository;
this.computeRepository = computeRepository;
this.applicationModuleRepository = applicationModuleRepository;
}
public long create(ApplicationDeploymentResource resource) {
ApplicationDeployment deployment = new ApplicationDeployment();
deployment.setPreJobCommand(resource.getPreJobCommand());
deployment.setPostJobCommand(resource.getPostJobCommand());
deployment.setExecutablePath(resource.getExecutablePath());
deployment.setName(resource.getName());
deployment.setComputeResource(computeRepository
.findById(resource.getComputeResourceId())
.orElseThrow(() -> new ServerRuntimeException("Can not find a compute resource with id " +
resource.getComputeResourceId())));
deployment.setApplicationModule(applicationModuleRepository
.findById(resource.getApplicationModuleId())
.orElseThrow(() -> new ServerRuntimeException("Can not find an app module with id "
+ resource.getApplicationModuleId())));
ApplicationDeployment saved = applicationDeploymentRepository.save(deployment);
return saved.getId();
}
public Optional<ApplicationDeploymentResource> findById(long id) {
return ToResourceUtil.toResource(applicationDeploymentRepository.findById(id).get());
}
public List<ApplicationDeploymentResource> getAll() {
List<ApplicationDeploymentResource> deploymentList = new ArrayList<>();
Optional.ofNullable(applicationDeploymentRepository.findAll())
.ifPresent(deployments ->
deployments.forEach(dep -> deploymentList.add(ToResourceUtil.toResource(dep).get())));
return deploymentList;
}
}
| 8,818 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/ApplicationModuleService.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.service;
import org.apache.airavata.k8s.api.server.model.application.ApplicationModule;
import org.apache.airavata.k8s.api.server.repository.application.ApplicationModuleRepository;
import org.apache.airavata.k8s.api.resources.application.ApplicationModuleResource;
import org.apache.airavata.k8s.api.server.service.util.ToResourceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Service
public class ApplicationModuleService {
private ApplicationModuleRepository applicationModuleRepository;
@Autowired
public ApplicationModuleService(ApplicationModuleRepository applicationModuleRepository) {
this.applicationModuleRepository = applicationModuleRepository;
}
public long create(ApplicationModuleResource resource) {
ApplicationModule module = new ApplicationModule();
module.setName(resource.getName());
module.setVersion(resource.getVersion());
module.setDescription(resource.getDescription());
ApplicationModule saved = this.applicationModuleRepository.save(module);
return saved.getId();
}
public Optional<ApplicationModuleResource> findById(long id) {
return ToResourceUtil.toResource(applicationModuleRepository.findById(id).get());
}
public List<ApplicationModuleResource> getAll() {
List<ApplicationModuleResource> computeList = new ArrayList<>();
Optional.ofNullable(applicationModuleRepository.findAll())
.ifPresent(computes ->
computes.forEach(compute -> computeList.add(ToResourceUtil.toResource(compute).get())));
return computeList;
}
}
| 8,819 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/ApplicationIfaceService.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.service;
import org.apache.airavata.k8s.api.server.ServerRuntimeException;
import org.apache.airavata.k8s.api.server.model.application.ApplicationInput;
import org.apache.airavata.k8s.api.server.model.application.ApplicationInterface;
import org.apache.airavata.k8s.api.server.model.application.ApplicationOutput;
import org.apache.airavata.k8s.api.server.repository.application.ApplicationIfaceRepository;
import org.apache.airavata.k8s.api.server.repository.application.ApplicationInputRepository;
import org.apache.airavata.k8s.api.server.repository.application.ApplicationModuleRepository;
import org.apache.airavata.k8s.api.server.repository.application.ApplicationOutputRepository;
import org.apache.airavata.k8s.api.resources.application.ApplicationIfaceResource;
import org.apache.airavata.k8s.api.server.service.util.ToResourceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Service
public class ApplicationIfaceService {
private ApplicationIfaceRepository ifaceRepository;
private ApplicationInputRepository inputRepository;
private ApplicationOutputRepository outputRepository;
private ApplicationModuleRepository moduleRepository;
@Autowired
public ApplicationIfaceService(ApplicationIfaceRepository ifaceRepository,
ApplicationInputRepository inputRepository,
ApplicationOutputRepository outputRepository,
ApplicationModuleRepository moduleRepository) {
this.ifaceRepository = ifaceRepository;
this.inputRepository = inputRepository;
this.outputRepository = outputRepository;
this.moduleRepository = moduleRepository;
}
public long create(ApplicationIfaceResource resource) {
ApplicationInterface iface = new ApplicationInterface();
iface.setName(resource.getName());
iface.setDescription(resource.getDescription());
iface.setApplicationModule(moduleRepository
.findById(resource.getApplicationModuleId())
.orElseThrow(() -> new ServerRuntimeException("Can not find app module with id " +
resource.getApplicationModuleId())));
Optional.ofNullable(resource.getInputs()).ifPresent(ips -> ips.forEach(ip -> {
ApplicationInput appInput = new ApplicationInput();
appInput.setName(ip.getName());
appInput.setValue(ip.getValue());
appInput.setArguments(ip.getArguments());
appInput.setType(ApplicationInput.DataType.valueOf(ip.getType()));
ApplicationInput saved = inputRepository.save(appInput);
iface.getInputs().add(saved);
}));
Optional.ofNullable(resource.getOutputs()).ifPresent(ops -> ops.forEach(op -> {
ApplicationOutput appOutput = new ApplicationOutput();
appOutput.setName(op.getName());
appOutput.setValue(op.getValue());
appOutput.setType(ApplicationOutput.DataType.valueOf(op.getType()));
ApplicationOutput saved = outputRepository.save(appOutput);
iface.getOutputs().add(saved);
}));
ApplicationInterface saved = ifaceRepository.save(iface);
return saved.getId();
}
public Optional<ApplicationIfaceResource> findById(long id) {
return ToResourceUtil.toResource(ifaceRepository.findById(id).get());
}
public List<ApplicationIfaceResource> getAll() {
List<ApplicationIfaceResource> computeList = new ArrayList<>();
Optional.ofNullable(ifaceRepository.findAll())
.ifPresent(computes ->
computes.forEach(compute -> computeList.add(ToResourceUtil.toResource(compute).get())));
return computeList;
}
}
| 8,820 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/ComputeResourceService.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.service;
import org.apache.airavata.k8s.api.server.model.compute.ComputeResourceModel;
import org.apache.airavata.k8s.api.server.repository.compute.ComputeRepository;
import org.apache.airavata.k8s.api.resources.compute.ComputeResource;
import org.apache.airavata.k8s.api.server.service.util.ToResourceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Service
public class ComputeResourceService {
private ComputeRepository computeRepository;
@Autowired
public ComputeResourceService(ComputeRepository computeRepository) {
this.computeRepository = computeRepository;
}
public long create(ComputeResource resource) {
ComputeResourceModel model = new ComputeResourceModel();
model.setName(resource.getName());
model.setHost(resource.getHost());
model.setUserName(resource.getUserName());
model.setPassword(resource.getPassword());
model.setCommunicationType(resource.getCommunicationType());
ComputeResourceModel saved = computeRepository.save(model);
return saved.getId();
}
public Optional<ComputeResource> findById(long id) {
return ToResourceUtil.toResource(computeRepository.findById(id).get());
}
public List<ComputeResource> getAll() {
List<ComputeResource> computeList = new ArrayList<>();
Optional.ofNullable(computeRepository.findAll())
.ifPresent(computes ->
computes.forEach(compute -> computeList.add(ToResourceUtil.toResource(compute).get())));
return computeList;
}
}
| 8,821 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/WorkflowService.java | package org.apache.airavata.k8s.api.server.service;
import org.apache.airavata.k8s.api.resources.process.ProcessBootstrapDataResource;
import org.apache.airavata.k8s.api.resources.process.ProcessResource;
import org.apache.airavata.k8s.api.resources.workflow.WorkflowResource;
import org.apache.airavata.k8s.api.server.ServerRuntimeException;
import org.apache.airavata.k8s.api.server.model.task.TaskDAG;
import org.apache.airavata.k8s.api.server.model.task.TaskModel;
import org.apache.airavata.k8s.api.server.model.task.TaskOutPort;
import org.apache.airavata.k8s.api.server.model.workflow.Workflow;
import org.apache.airavata.k8s.api.server.repository.task.TaskDAGRepository;
import org.apache.airavata.k8s.api.server.repository.task.TaskOutPortRepository;
import org.apache.airavata.k8s.api.server.repository.task.TaskRepository;
import org.apache.airavata.k8s.api.server.repository.workflow.WorkflowRepository;
import org.apache.airavata.k8s.api.server.service.messaging.MessagingService;
import org.apache.airavata.k8s.api.server.service.task.TaskService;
import org.apache.airavata.k8s.api.server.service.util.GraphParser;
import org.apache.airavata.k8s.api.server.service.util.ToResourceUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Service
public class WorkflowService {
private ProcessService processService;
private TaskService taskService;
private MessagingService messagingService;
private WorkflowRepository workflowRepository;
private TaskOutPortRepository taskOutPortRepository;
private TaskRepository taskRepository;
private TaskDAGRepository taskDAGRepository;
@Value("${scheduler.topic.name}")
private String schedulerTopic;
public WorkflowService(ProcessService processService,
TaskService taskService,
MessagingService messagingService,
WorkflowRepository workflowRepository,
TaskOutPortRepository taskOutPortRepository,
TaskRepository taskRepository,
TaskDAGRepository taskDAGRepository) {
this.processService = processService;
this.taskService = taskService;
this.messagingService = messagingService;
this.workflowRepository = workflowRepository;
this.taskOutPortRepository = taskOutPortRepository;
this.taskRepository = taskRepository;
this.taskDAGRepository = taskDAGRepository;
}
public long createWorkflow(WorkflowResource resource) {
Workflow workflow = new Workflow();
workflow.setName(resource.getName());
workflow.setWorkFlowGraph(resource.getWorkflowGraphXML().getBytes());
Workflow saved = workflowRepository.save(workflow);
return saved.getId();
}
public long launchWorkflow(long id, Map<String, String> boostrapData) {
Workflow workflow = this.workflowRepository.findById(id)
.orElseThrow(() -> new ServerRuntimeException("Workflow with id " + id + "can not be found"));
List<ProcessBootstrapDataResource> bootstrapDataResources = new ArrayList<>();
if (boostrapData != null) {
boostrapData.forEach((key, value) ->
bootstrapDataResources.add(new ProcessBootstrapDataResource().setKey(key).setValue(value)));
}
long processId = processService.create(new ProcessResource()
.setName("Workflow Process : " + workflow.getName() + "-" + UUID.randomUUID().toString())
.setCreationTime(System.currentTimeMillis())
.setProcessType("WORKFLOW")
.setProcessBootstrapData(bootstrapDataResources)
.setWorkflowId(id));
try {
GraphParser.ParseResult parseResult = GraphParser.parse(new String(workflow.getWorkFlowGraph()));
parseResult.getTasks().forEach((mockId, task) -> {
task.getTaskResource().setParentProcessId(processId);
for (GraphParser.OutPort outPort : task.getOutPorts().values()) {
if (outPort.getNextPort() != null && outPort.getNextPort().getParentOperation() != null) {
if ("Stop".equals(outPort.getNextPort().getParentOperation().getName())) {
task.getTaskResource().setStoppingTask(true);
}
}
}
for (GraphParser.InPort inPort : task.getInPorts().values()) {
for (GraphParser.OutPort outPort : inPort.getPreviousPorts().values()) {
if (outPort.getParentOperation() != null && "Start".equals(outPort.getParentOperation().getName())) {
task.getTaskResource().setStartingTask(true);
}
}
}
long taskId = taskService.create(task.getTaskResource());
task.getTaskResource().setId(taskId);
});
parseResult.getEdgeCache().forEach(((outPort, inPort) -> {
if (outPort.getParentTask() != null && outPort.getNextPort().getParentTask() != null) {
Optional<TaskOutPort> sourceOutPort = taskOutPortRepository
.findByReferenceIdAndTaskModel_Id(outPort.getId(), outPort.getParentTask().getTaskResource().getId());
Optional<TaskModel> targetTask = taskRepository.findById(inPort.getParentTask().getTaskResource().getId());
taskDAGRepository.save(new TaskDAG()
.setSourceOutPort(sourceOutPort.get())
.setTargetTask(targetTask.get()));
}
}));
} catch (Exception e) {
throw new ServerRuntimeException("Failed to create workflow", e);
}
this.messagingService.send(schedulerTopic, processId + "");
return 0;
}
public List<WorkflowResource> getAll() {
List<WorkflowResource> workflowResources = new ArrayList<>();
Iterable<Workflow> workFlows = this.workflowRepository.findAll();
Optional.ofNullable(workFlows)
.ifPresent(wfs -> wfs.forEach(wf -> workflowResources.add(ToResourceUtil.toResource(wf).get())));
return workflowResources;
}
public Optional<WorkflowResource> findById(long id) {
return ToResourceUtil.toResource(findEntityById(id).get());
}
@SuppressWarnings("WeakerAccess")
public Optional<Workflow> findEntityById(long id) {
return this.workflowRepository.findById(id);
}
}
| 8,822 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/ProcessService.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.service;
import org.apache.airavata.k8s.api.resources.process.ProcessStatusResource;
import org.apache.airavata.k8s.api.server.ServerRuntimeException;
import org.apache.airavata.k8s.api.server.model.process.ProcessBootstrapData;
import org.apache.airavata.k8s.api.server.model.process.ProcessModel;
import org.apache.airavata.k8s.api.server.model.process.ProcessStatus;
import org.apache.airavata.k8s.api.server.model.task.TaskModel;
import org.apache.airavata.k8s.api.server.repository.process.ProcessBootstrapDataRepository;
import org.apache.airavata.k8s.api.server.repository.process.ProcessRepository;
import org.apache.airavata.k8s.api.resources.process.ProcessResource;
import org.apache.airavata.k8s.api.server.repository.process.ProcessStatusRepository;
import org.apache.airavata.k8s.api.server.repository.workflow.WorkflowRepository;
import org.apache.airavata.k8s.api.server.service.task.TaskService;
import org.apache.airavata.k8s.api.server.service.util.ToResourceUtil;
import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Service
public class ProcessService {
private ProcessRepository processRepository;
private ProcessStatusRepository processStatusRepository;
private ProcessBootstrapDataRepository bootstrapDataRepository;
private ExperimentService experimentService;
private TaskService taskService;
private WorkflowRepository workflowRepository;
public ProcessService(ProcessRepository processRepository,
ProcessStatusRepository processStatusRepository,
ExperimentService experimentService,
TaskService taskService,
WorkflowRepository workflowRepository,
ProcessBootstrapDataRepository bootstrapDataRepository) {
this.processRepository = processRepository;
this.processStatusRepository = processStatusRepository;
this.experimentService = experimentService;
this.taskService = taskService;
this.workflowRepository = workflowRepository;
this.bootstrapDataRepository = bootstrapDataRepository;
}
public long create(ProcessResource resource) {
ProcessModel processModel = new ProcessModel();
processModel.setId(resource.getId());
processModel.setCreationTime(resource.getCreationTime());
processModel.setLastUpdateTime(resource.getLastUpdateTime());
processModel.setName(resource.getName());
processModel.setProcessType(ProcessModel.ProcessType.valueOf(resource.getProcessType()));
if (resource.getExperimentId() != 0) {
processModel.setExperiment(experimentService.findEntityById(resource.getExperimentId())
.orElseThrow(() -> new ServerRuntimeException("Can not find experiment with id " +
resource.getExperimentId())));
}
if (resource.getWorkflowId() != 0) {
processModel.setWorkflow(workflowRepository.findById(resource.getWorkflowId())
.orElseThrow(() -> new ServerRuntimeException("Can not find workflow with id " +
resource.getWorkflowId())));
}
processModel.setExperimentDataDir(resource.getExperimentDataDir());
ProcessModel saved = processRepository.save(processModel);
Optional.ofNullable(resource.getTasks()).ifPresent(taskResources -> taskResources.forEach(taskRes -> {
TaskModel taskModel = new TaskModel();
taskRes.setParentProcessId(saved.getId());
taskModel.setId(taskService.create(taskRes));
}));
Optional.ofNullable(resource.getProcessBootstrapData()).ifPresent(bootstrapDatas -> bootstrapDatas.forEach(data -> {
ProcessBootstrapData bootstrapData = new ProcessBootstrapData();
bootstrapData.setProcessModel(saved);
bootstrapData.setKey(data.getKey());
bootstrapData.setValue(data.getValue());
this.bootstrapDataRepository.save(bootstrapData);
}));
return saved.getId();
}
public long addProcessStatus(long processId, ProcessStatusResource resource) {
ProcessModel processModel = processRepository.findById(processId)
.orElseThrow(() -> new ServerRuntimeException("Process with id " + processId + " can not be found"));
ProcessStatus status = new ProcessStatus();
status.setReason(resource.getReason());
status.setState(ProcessStatus.ProcessState.valueOf(resource.getState()));
status.setTimeOfStateChange(resource.getTimeOfStateChange());
status.setProcessModel(processModel);
ProcessStatus savedStatus = processStatusRepository.save(status);
return savedStatus.getId();
}
public Optional<ProcessResource> findById(long id) {
return ToResourceUtil.toResource(processRepository.findById(id).get());
}
}
| 8,823 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/ExperimentService.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.service;
import org.apache.airavata.k8s.api.server.ServerRuntimeException;
import org.apache.airavata.k8s.api.server.model.experiment.Experiment;
import org.apache.airavata.k8s.api.server.model.experiment.ExperimentInputData;
import org.apache.airavata.k8s.api.server.model.experiment.ExperimentOutputData;
import org.apache.airavata.k8s.api.server.model.experiment.ExperimentStatus;
import org.apache.airavata.k8s.api.resources.experiment.ExperimentResource;
import org.apache.airavata.k8s.api.server.repository.application.ApplicationDeploymentRepository;
import org.apache.airavata.k8s.api.server.repository.application.ApplicationIfaceRepository;
import org.apache.airavata.k8s.api.server.repository.experiment.ExperimentInputDataRepository;
import org.apache.airavata.k8s.api.server.repository.experiment.ExperimentOutputDataRepository;
import org.apache.airavata.k8s.api.server.repository.experiment.ExperimentRepository;
import org.apache.airavata.k8s.api.server.repository.experiment.ExperimentStatusRepository;
import org.apache.airavata.k8s.api.server.service.messaging.MessagingService;
import org.apache.airavata.k8s.api.server.service.util.ToResourceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Service
@Transactional
public class ExperimentService {
private ExperimentRepository experimentRepository;
private ApplicationDeploymentRepository appDepRepository;
private ApplicationIfaceRepository appIfaceRepository;
private ExperimentInputDataRepository inputDataRepository;
private ExperimentOutputDataRepository outputDataRepository;
private ExperimentStatusRepository experimentStatusRepository;
private MessagingService messagingService;
@Value("${launch.topic.name}")
private String launchTopic;
@Autowired
public ExperimentService(ExperimentRepository experimentRepository,
ApplicationDeploymentRepository appDepRepository,
ApplicationIfaceRepository appIfaceRepository,
ExperimentInputDataRepository inputDataRepository,
ExperimentOutputDataRepository outputDataRepository,
ExperimentStatusRepository experimentStatusRepository,
MessagingService messagingService) {
this.experimentRepository = experimentRepository;
this.appDepRepository = appDepRepository;
this.appIfaceRepository = appIfaceRepository;
this.inputDataRepository = inputDataRepository;
this.outputDataRepository = outputDataRepository;
this.experimentStatusRepository = experimentStatusRepository;
this.messagingService = messagingService;
}
public long create(ExperimentResource resource) {
Experiment experiment = new Experiment();
experiment.setExperimentName(resource.getExperimentName());
experiment.setApplicationDeployment(appDepRepository.findById(resource.getApplicationDeploymentId())
.orElseThrow(() -> new ServerRuntimeException("Can not find app deployment with id " +
resource.getApplicationDeploymentId())));
experiment.setApplicationInterface(appIfaceRepository.findById(resource.getApplicationInterfaceId())
.orElseThrow(() -> new ServerRuntimeException("Can not find app inerface with id " +
resource.getApplicationInterfaceId())));
Optional.ofNullable(resource.getExperimentOutputs()).ifPresent(ops -> {
ops.forEach(op -> {
ExperimentOutputData outputData = new ExperimentOutputData();
outputData.setName(op.getName());
outputData.setValue(op.getValue());
outputData.setType(ExperimentOutputData.DataType.valueOf(op.getType()));
ExperimentOutputData saved = outputDataRepository.save(outputData);
experiment.getExperimentOutputs().add(saved);
});
});
Optional.ofNullable(resource.getExperimentInputs()).ifPresent(ips -> {
ips.forEach(ip -> {
ExperimentInputData inputData = new ExperimentInputData();
inputData.setName(ip.getName());
inputData.setValue(ip.getValue());
inputData.setType(ExperimentInputData.DataType.valueOf(ip.getType()));
inputData.setArguments(ip.getArguments());
ExperimentInputData saved = inputDataRepository.save(inputData);
experiment.getExperimentInputs().add(saved);
});
});
Experiment saved = experimentRepository.save(experiment);
return saved.getId();
}
public Optional<ExperimentResource> findById(long id) {
return ToResourceUtil.toResource(findEntityById(id).get());
}
public Optional<Experiment> findEntityById(long id) {
return this.experimentRepository.findById(id);
}
public long launchExperiment(long id) {
Experiment experiment = this.experimentRepository.findById(id).orElseThrow(() -> new ServerRuntimeException("Experiment with id " +
id + "can not be found"));
// TODO validate status and get a lock
ExperimentStatus experimentStatus = this.experimentStatusRepository.save(new ExperimentStatus()
.setState(ExperimentStatus.ExperimentState.LAUNCHED)
.setTimeOfStateChange(System.currentTimeMillis()));
experiment.getExperimentStatus().add(experimentStatus);
this.messagingService.send(this.launchTopic, "exp-" + id);
return 0;
}
public List<ExperimentResource> getAll() {
List<ExperimentResource> experimentList = new ArrayList<>();
Optional.ofNullable(experimentRepository.findAll())
.ifPresent(experiments ->
experiments.forEach(experiment -> experimentList.add(ToResourceUtil.toResource(experiment).get())));
return experimentList;
}
}
| 8,824 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/util/ToResourceUtil.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.service.util;
import org.apache.airavata.k8s.api.resources.experiment.ExperimentStatusResource;
import org.apache.airavata.k8s.api.resources.process.ProcessBootstrapDataResource;
import org.apache.airavata.k8s.api.resources.process.ProcessStatusResource;
import org.apache.airavata.k8s.api.resources.task.*;
import org.apache.airavata.k8s.api.resources.task.type.TaskInputTypeResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskOutPortTypeResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskOutputTypeResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import org.apache.airavata.k8s.api.resources.workflow.WorkflowResource;
import org.apache.airavata.k8s.api.server.model.application.ApplicationDeployment;
import org.apache.airavata.k8s.api.server.model.application.ApplicationInterface;
import org.apache.airavata.k8s.api.server.model.application.ApplicationModule;
import org.apache.airavata.k8s.api.server.model.compute.ComputeResourceModel;
import org.apache.airavata.k8s.api.server.model.experiment.Experiment;
import org.apache.airavata.k8s.api.server.model.experiment.ExperimentInputData;
import org.apache.airavata.k8s.api.server.model.experiment.ExperimentOutputData;
import org.apache.airavata.k8s.api.server.model.experiment.ExperimentStatus;
import org.apache.airavata.k8s.api.server.model.process.ProcessBootstrapData;
import org.apache.airavata.k8s.api.server.model.process.ProcessModel;
import org.apache.airavata.k8s.api.server.model.process.ProcessStatus;
import org.apache.airavata.k8s.api.server.model.task.*;
import org.apache.airavata.k8s.api.resources.application.*;
import org.apache.airavata.k8s.api.resources.compute.ComputeResource;
import org.apache.airavata.k8s.api.resources.experiment.ExperimentInputResource;
import org.apache.airavata.k8s.api.resources.experiment.ExperimentOutputResource;
import org.apache.airavata.k8s.api.resources.experiment.ExperimentResource;
import org.apache.airavata.k8s.api.resources.process.ProcessResource;
import org.apache.airavata.k8s.api.server.model.task.type.TaskInputType;
import org.apache.airavata.k8s.api.server.model.task.type.TaskModelType;
import org.apache.airavata.k8s.api.server.model.task.type.TaskOutPortType;
import org.apache.airavata.k8s.api.server.model.task.type.TaskOutputType;
import org.apache.airavata.k8s.api.server.model.workflow.Workflow;
import java.util.Optional;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ToResourceUtil {
public static Optional<ExperimentStatusResource> toResource(ExperimentStatus experimentStatus) {
if (experimentStatus != null) {
ExperimentStatusResource resource = new ExperimentStatusResource();
resource.setId(experimentStatus.getId());
resource.setState(experimentStatus.getState().getValue());
resource.setReason(experimentStatus.getReason());
resource.setStateStr(experimentStatus.getState().name());
resource.setTimeOfStateChange(experimentStatus.getTimeOfStateChange());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<ExperimentResource> toResource(Experiment experiment) {
if (experiment != null) {
ExperimentResource resource = new ExperimentResource();
resource.setId(experiment.getId());
resource.setExperimentName(experiment.getExperimentName());
resource.setDescription(experiment.getDescription());
resource.setCreationTime(experiment.getCreationTime());
Optional.ofNullable(experiment.getErrors())
.ifPresent(errs -> errs.forEach(err -> resource.getErrorsIds().add(err.getId())));
Optional.ofNullable(experiment.getExperimentStatus())
.ifPresent(sts -> sts.forEach(status -> resource.getExperimentStatus().add(toResource(status).get())));
Optional.ofNullable(experiment.getExperimentInputs())
.ifPresent(ips -> ips.forEach(ip -> resource.getExperimentInputs().add(toResource(ip).get())));
Optional.ofNullable(experiment.getExperimentOutputs())
.ifPresent(ops -> ops.forEach(op -> resource.getExperimentOutputs().add(toResource(op).get())));
Optional.ofNullable(experiment.getApplicationDeployment())
.ifPresent(appDep -> {
resource.setApplicationDeploymentId(appDep.getId());
resource.setApplicationDeploymentName(appDep.getName());
});
Optional.ofNullable(experiment.getApplicationInterface())
.ifPresent(iface -> {
resource.setApplicationInterfaceId(iface.getId());
resource.setApplicationInterfaceName(iface.getName());
});
Optional.ofNullable(experiment.getProcesses())
.ifPresent(processModels -> processModels
.forEach(processModel -> resource.getProcessIds().add(processModel.getId())));
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<ExperimentInputResource> toResource(ExperimentInputData input) {
if (input != null) {
ExperimentInputResource resource = new ExperimentInputResource();
resource.setId(input.getId());
resource.setName(input.getName());
resource.setValue(input.getValue());
resource.setType(input.getType().getValue());
resource.setArguments(input.getArguments());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<ExperimentOutputResource> toResource(ExperimentOutputData output) {
if (output != null) {
ExperimentOutputResource resource = new ExperimentOutputResource();
resource.setId(output.getId());
resource.setName(output.getName());
resource.setValue(output.getValue());
resource.setType(output.getType().getValue());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<ComputeResource> toResource(ComputeResourceModel computeResourceModel) {
if (computeResourceModel != null) {
ComputeResource resource = new ComputeResource();
resource.setId(computeResourceModel.getId());
resource.setName(computeResourceModel.getName());
resource.setUserName(computeResourceModel.getUserName());
resource.setPassword(computeResourceModel.getPassword());
resource.setCommunicationType(computeResourceModel.getCommunicationType());
resource.setHost(computeResourceModel.getHost());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<ApplicationModuleResource> toResource(ApplicationModule applicationModule) {
if (applicationModule != null) {
ApplicationModuleResource resource = new ApplicationModuleResource();
resource.setId(applicationModule.getId());
resource.setName(applicationModule.getName());
resource.setDescription(applicationModule.getDescription());
resource.setVersion(applicationModule.getVersion());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<ApplicationDeploymentResource> toResource(ApplicationDeployment applicationDeployment) {
if (applicationDeployment != null) {
ApplicationDeploymentResource resource = new ApplicationDeploymentResource();
resource.setId(applicationDeployment.getId());
resource.setExecutablePath(applicationDeployment.getExecutablePath());
resource.setPreJobCommand(applicationDeployment.getPreJobCommand());
resource.setPostJobCommand(applicationDeployment.getPostJobCommand());
resource.setName(applicationDeployment.getName());
Optional.ofNullable(applicationDeployment.getApplicationModule())
.ifPresent(module -> resource.setApplicationModuleId(module.getId()));
Optional.ofNullable(applicationDeployment.getComputeResource())
.ifPresent(cr -> resource.setComputeResourceId(cr.getId()));
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<ApplicationIfaceResource> toResource(ApplicationInterface applicationInterface) {
if (applicationInterface != null) {
ApplicationIfaceResource resource = new ApplicationIfaceResource();
resource.setId(applicationInterface.getId());
resource.setName(applicationInterface.getName());
resource.setApplicationModuleId(applicationInterface.getId());
resource.setDescription(applicationInterface.getDescription());
Optional.ofNullable(applicationInterface.getInputs()).ifPresent(ips -> ips.forEach(ip -> {
ApplicationInputResource ipResource = new ApplicationInputResource();
ipResource.setId(ip.getId());
ipResource.setName(ip.getName());
ipResource.setArguments(ip.getArguments());
ipResource.setType(ip.getType().getValue());
ipResource.setValue(ip.getValue());
resource.getInputs().add(ipResource);
}));
Optional.ofNullable(applicationInterface.getOutputs()).ifPresent(ops -> ops.forEach(op -> {
ApplicationOutputResource opResource = new ApplicationOutputResource();
opResource.setId(op.getId());
opResource.setName(op.getName());
opResource.setType(op.getType().getValue());
opResource.setValue(op.getValue());
resource.getOutputs().add(opResource);
}));
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<TaskResource> toResource(TaskModel taskModel) {
if (taskModel != null) {
TaskResource resource = new TaskResource();
resource.setName(taskModel.getName());
resource.setId(taskModel.getId());
resource.setLastUpdateTime(taskModel.getLastUpdateTime());
resource.setCreationTime(taskModel.getCreationTime());
resource.setParentProcessId(taskModel.getParentProcess().getId());
resource.setTaskType(toResource(taskModel.getTaskType()).get());
resource.setTaskTypeStr(taskModel.getTaskType().getName());
resource.setTaskDetail(taskModel.getTaskDetail());
resource.setStartingTask(taskModel.isStartingTask());
resource.setStoppingTask(taskModel.isStoppingTask());
resource.setReferenceId(taskModel.getReferenceId());
Optional.ofNullable(taskModel.getTaskInputs())
.ifPresent(inputs ->
inputs.forEach(input -> resource.getInputs()
.add(toResource(input).get())));
Optional.ofNullable(taskModel.getTaskOutputs())
.ifPresent(outputs ->
outputs.forEach(output -> resource.getOutputs()
.add(toResource(output).get())));
Optional.ofNullable(taskModel.getTaskStatuses())
.ifPresent(taskStatuses ->
taskStatuses.forEach(taskStatus -> resource.getTaskStatus()
.add(toResource(taskStatus).get())));
Optional.ofNullable(taskModel.getTaskOutPorts())
.ifPresent(outPorts -> outPorts.forEach(outPort -> resource.getOutPorts()
.add(toResource(outPort).get())));
resource.setOrder(taskModel.getOrderIndex());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<TaskStatusResource> toResource(TaskStatus taskStatus) {
if (taskStatus != null) {
TaskStatusResource resource = new TaskStatusResource();
resource.setId(taskStatus.getId());
resource.setState(taskStatus.getState().getValue());
resource.setTimeOfStateChange(taskStatus.getTimeOfStateChange());
resource.setTaskId(taskStatus.getTaskModel().getId());
resource.setStateStr(taskStatus.getState().name());
resource.setReason(taskStatus.getReason());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<TaskInputResource> toResource(TaskInput taskInput) {
if (taskInput != null) {
TaskInputResource resource = new TaskInputResource();
resource.setId(taskInput.getId());
resource.setName(taskInput.getName());
resource.setValue(taskInput.getValue());
resource.setType(taskInput.getType());
resource.setImportFrom(taskInput.getImportFrom());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<TaskOutputResource> toResource(TaskOutput taskOutput) {
if (taskOutput != null) {
TaskOutputResource resource = new TaskOutputResource();
resource.setId(taskOutput.getId());
resource.setName(taskOutput.getName());
resource.setValue(taskOutput.getValue());
resource.setType(taskOutput.getType());
resource.setExportTo(taskOutput.getExportTo());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<ProcessResource> toResource(ProcessModel processModel) {
if (processModel != null) {
ProcessResource processResource = new ProcessResource();
processResource.setId(processModel.getId());
processResource.setLastUpdateTime(processModel.getLastUpdateTime());
Optional.ofNullable(processModel.getExperiment()).ifPresent(experiment -> {
processResource.setExperimentId(experiment.getId());
});
Optional.ofNullable(processModel.getWorkflow()).ifPresent(workflow -> {
processResource.setWorkflowId(workflow.getId());
});
processResource.setTaskDag(processModel.getTaskDag());
processResource.setCreationTime(processModel.getCreationTime());
Optional.ofNullable(processModel.getProcessStatuses())
.ifPresent(stss -> stss.forEach(sts -> processResource.getProcessStatuses().add(toResource(sts).get())));
Optional.ofNullable(processModel.getTasks())
.ifPresent(tasks -> tasks.forEach(task -> processResource.getTasks().add(toResource(task).get())));
Optional.ofNullable(processModel.getProcessErrors())
.ifPresent(errs -> errs.forEach(err -> processResource.getProcessErrorIds().add(err.getId())));
Optional.ofNullable(processModel.getProcessBootstrapData())
.ifPresent(datas -> datas.forEach(data -> processResource.getProcessBootstrapData().add(toResource(data).get())));
return Optional.of(processResource);
} else {
return Optional.empty();
}
}
public static Optional<ProcessBootstrapDataResource> toResource(ProcessBootstrapData bootstrapData) {
if (bootstrapData != null) {
ProcessBootstrapDataResource resource = new ProcessBootstrapDataResource();
resource.setId(bootstrapData.getId());
resource.setKey(bootstrapData.getKey());
resource.setValue(bootstrapData.getValue());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<ProcessStatusResource> toResource(ProcessStatus processStatus) {
if (processStatus != null) {
ProcessStatusResource resource = new ProcessStatusResource();
resource.setId(processStatus.getId());
resource.setState(processStatus.getState().getValue());
resource.setTimeOfStateChange(processStatus.getTimeOfStateChange());
resource.setStateStr(processStatus.getState().name());
resource.setReason(processStatus.getReason());
resource.setProcessId(processStatus.getProcessModel().getId());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<TaskTypeResource> toResource(TaskModelType taskModelType) {
if (taskModelType != null) {
TaskTypeResource resource = new TaskTypeResource();
resource.setName(taskModelType.getName());
resource.setId(taskModelType.getId());
resource.setTopicName(taskModelType.getTopicName());
resource.setIcon(taskModelType.getIcon());
Optional.ofNullable(taskModelType.getInputTypes())
.ifPresent(taskInputTypes -> taskInputTypes.forEach(taskInputType -> {
resource.getInputTypes().add(toResource(taskInputType).get());
}));
Optional.ofNullable(taskModelType.getOutputTypes())
.ifPresent(taskOutputTypes -> taskOutputTypes.forEach(taskOutputType -> {
resource.getOutputTypes().add(toResource(taskOutputType).get());
}));
Optional.ofNullable(taskModelType.getOutPorts())
.ifPresent(taskOutPorts -> taskOutPorts.forEach(taskOutPort -> {
resource.getOutPorts().add(toResource(taskOutPort).get());
}));
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<TaskInputTypeResource> toResource(TaskInputType taskInputType) {
if (taskInputType != null) {
TaskInputTypeResource resource = new TaskInputTypeResource();
resource.setId(taskInputType.getId());
resource.setName(taskInputType.getName());
resource.setType(taskInputType.getType());
resource.setDefaultValue(taskInputType.getDefaultValue());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<TaskOutputTypeResource> toResource(TaskOutputType taskOutputType) {
if (taskOutputType != null) {
TaskOutputTypeResource resource = new TaskOutputTypeResource();
resource.setId(taskOutputType.getId());
resource.setName(taskOutputType.getName());
resource.setType(taskOutputType.getType());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<TaskOutPortTypeResource> toResource(TaskOutPortType taskOutPort) {
if (taskOutPort != null) {
TaskOutPortTypeResource resource = new TaskOutPortTypeResource();
resource.setId(taskOutPort.getId());
resource.setName(taskOutPort.getName());
resource.setOrder(taskOutPort.getOrder());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<WorkflowResource> toResource(Workflow workflow) {
if (workflow != null) {
WorkflowResource resource = new WorkflowResource();
resource.setId(workflow.getId());
resource.setName(workflow.getName());
resource.setWorkflowGraphXML(new String(workflow.getWorkFlowGraph()));
Optional.ofNullable(workflow.getProcesses()).ifPresent(processModels -> {
processModels.forEach(processModel -> {
resource.getProcessIds().add(processModel.getId());
});
});
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<TaskDagResource> toResource(TaskDAG taskDAG) {
if (taskDAG != null) {
TaskDagResource resource = new TaskDagResource();
resource.setId(taskDAG.getId());
resource.setSourceOutPort(toResource(taskDAG.getSourceOutPort()).get());
resource.setTargetTask(toResource(taskDAG.getTargetTask()).get());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
public static Optional<TaskOutPortResource> toResource(TaskOutPort outPort) {
if (outPort != null) {
TaskOutPortResource resource = new TaskOutPortResource();
resource.setId(outPort.getId());
resource.setReferenceId(outPort.getReferenceId());
resource.setName(outPort.getName());
//resource.setTaskResource(toResource(outPort.getTaskModel()).get());
return Optional.of(resource);
} else {
return Optional.empty();
}
}
}
| 8,825 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/util/GraphParser.java | package org.apache.airavata.k8s.api.server.service.util;
import org.apache.airavata.k8s.api.resources.task.TaskInputResource;
import org.apache.airavata.k8s.api.resources.task.TaskOutPortResource;
import org.apache.airavata.k8s.api.resources.task.TaskOutputResource;
import org.apache.airavata.k8s.api.resources.task.TaskResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import javax.persistence.criteria.CriteriaBuilder;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class GraphParser {
public static ParseResult parse(String content) throws Exception {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(new InputSource(new StringReader(content)));
doc.getDocumentElement().normalize();
NodeList nList = doc.getElementsByTagName("root");
Node rootNode = nList.item(0);
NodeList elementNodeList = rootNode.getChildNodes();
ParseResult result = new ParseResult();
for (int temp = 0; temp < elementNodeList.getLength(); temp++) {
Node nNode = elementNodeList.item(temp);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
if ("ProcessingElement".equals(eElement.getTagName())) {
TaskResource taskResource = new TaskResource();
NamedNodeMap attributes = eElement.getAttributes();
int id = -1;
for (int i = 0; i < attributes.getLength(); i++) {
Node attr = attributes.item(i);
if ("name".equals(attr.getNodeName())) {
taskResource.setName(attr.getNodeValue());
} else if ("Type".equals(attr.getNodeName())) {
taskResource.setTaskType(new TaskTypeResource().setId(Long.parseLong(attr.getNodeValue())));
} else if (attr.getNodeName().startsWith("in-") || attr.getNodeName().startsWith("out-")) {
} else if ("id".equals(attr.getNodeName())) {
id = Integer.parseInt(attr.getNodeValue());
taskResource.setReferenceId(id);
} else if (attr.getNodeName().startsWith("output-")) {
TaskOutputResource outputResource = new TaskOutputResource();
outputResource.setName(attr.getNodeName().substring(7));
outputResource.setValue(attr.getNodeValue());
} else {
TaskInputResource inputResource = new TaskInputResource();
inputResource.setName(attr.getNodeName());
inputResource.setValue(attr.getNodeValue());
taskResource.getInputs().add(inputResource);
}
}
Task task = new Task();
task.id = id;
task.taskResource = taskResource;
result.tasks.put(id, task);
} else if ("Operation".equals(eElement.getTagName())) {
NamedNodeMap attributes = eElement.getAttributes();
int id = -1;
String name = null;
for (int i = 0; i < attributes.getLength(); i++) {
Node attr = attributes.item(i);
if ("name".equals(attr.getNodeName())) {
name = attr.getNodeValue();
} else if ("id".equals(attr.getNodeName())) {
id = Integer.parseInt(attr.getNodeValue());
}
}
Operation operation = new Operation();
operation.id = id;
operation.name = name;
result.operations.put(id, operation);
} else if ("InPort".equals(eElement.getTagName())) {
int id = Integer.parseInt(eElement.getAttribute("id"));
String name = eElement.getAttribute("name");
Element mxCell = null;
NodeList childNodes = eElement.getChildNodes();
for (int i = 0 ; i < childNodes.getLength(); i++) {
Node tempInPort = childNodes.item(i);
if (tempInPort.getNodeType() == Node.ELEMENT_NODE) {
Element tmpInElement = (Element) tempInPort;
if ("mxCell".equals(tmpInElement.getTagName())) {
mxCell = tmpInElement;
break;
}
}
}
int parentId = Integer.parseInt(mxCell.getAttribute("parent"));
InPort inPort = new InPort();
inPort.id = id;
inPort.name = name;
result.portCache.put(id, inPort);
if (result.tasks.containsKey(parentId)) {
inPort.parentTask = result.tasks.get(parentId);
result.tasks.get(parentId).inPorts.put(id, inPort);
} else if (result.operations.containsKey(parentId)) {
inPort.parentOperation = result.operations.get(parentId);
result.operations.get(parentId).inPorts.put(id, inPort);
} else {
throw new Exception("Failed to find parent id " + parentId + " for in port " + id);
}
} else if ("OutPort".equals(eElement.getTagName())) {
int id = Integer.parseInt(eElement.getAttribute("id"));
String name = eElement.getAttribute("name");
NamedNodeMap attributes = eElement.getAttributes();
Element mxCell = null;
NodeList childNodes = eElement.getChildNodes();
for (int i = 0 ; i < childNodes.getLength(); i++) {
Node tempOutPort = childNodes.item(i);
if (tempOutPort.getNodeType() == Node.ELEMENT_NODE) {
Element tmpOutElement = (Element) tempOutPort;
if ("mxCell".equals(tmpOutElement.getTagName())) {
mxCell = tmpOutElement;
break;
}
}
}
int parentId = Integer.parseInt(mxCell.getAttribute("parent"));
OutPort outPort = new OutPort();
outPort.id = id;
outPort.name = name;
result.portCache.put(id, outPort);
if (result.tasks.containsKey(parentId)) {
outPort.parentTask = result.tasks.get(parentId);
result.tasks.get(parentId).outPorts.put(id, outPort);
result.tasks.get(parentId).getTaskResource().getOutPorts()
.add(new TaskOutPortResource()
.setName(outPort.name)
.setReferenceId(outPort.id));
} else if (result.operations.containsKey(parentId)) {
outPort.parentOperation = result.operations.get(parentId);
result.operations.get(parentId).outPorts.put(id, outPort);
} else {
throw new Exception("Failed to find parent id " + parentId + " for out port " + id);
}
} else if ("mxCell".equals(eElement.getTagName())) {
if (eElement.hasAttribute("edge") && eElement.hasAttribute("source") && eElement.hasAttribute("target")) {
int sourceId = Integer.parseInt(eElement.getAttribute("source"));
int targetId = Integer.parseInt(eElement.getAttribute("target"));
if (result.portCache.containsKey(targetId) && result.portCache.containsKey(sourceId)) {
InPort inPort = (InPort) result.portCache.get(targetId);
OutPort outPort = (OutPort) result.portCache.get(sourceId);
outPort.nextPort = inPort;
inPort.previousPorts.put(outPort.id, outPort);
result.edgeCache.put(outPort, inPort);
} else {
throw new Exception("Invalid connection with source id " + sourceId + " target id " + targetId);
}
}
}
}
}
return result;
}
public static class ParseResult {
private Map<Integer, Task> tasks = new HashMap<>();
private Map<Integer, Operation> operations = new HashMap<>();
private Map<Integer, Object> portCache = new HashMap<>();
private Map<OutPort, InPort> edgeCache = new HashMap<>();
public Map<Integer, Task> getTasks() {
return tasks;
}
public ParseResult setTasks(Map<Integer, Task> tasks) {
this.tasks = tasks;
return this;
}
public Map<Integer, Operation> getOperations() {
return operations;
}
public ParseResult setOperations(Map<Integer, Operation> operations) {
this.operations = operations;
return this;
}
public Map<Integer, Object> getPortCache() {
return portCache;
}
public ParseResult setPortCache(Map<Integer, Object> portCache) {
this.portCache = portCache;
return this;
}
public Map<OutPort, InPort> getEdgeCache() {
return edgeCache;
}
public ParseResult setEdgeCache(Map<OutPort, InPort> edgeCache) {
this.edgeCache = edgeCache;
return this;
}
}
public static class Task {
private int id;
private TaskResource taskResource;
private Map<Integer, InPort> inPorts = new HashMap<>();
private Map<Integer, OutPort> outPorts = new HashMap<>();
public int getId() {
return id;
}
public Task setId(int id) {
this.id = id;
return this;
}
public TaskResource getTaskResource() {
return taskResource;
}
public Task setTaskResource(TaskResource taskResource) {
this.taskResource = taskResource;
return this;
}
public Map<Integer, InPort> getInPorts() {
return inPorts;
}
public Task setInPorts(Map<Integer, InPort> inPorts) {
this.inPorts = inPorts;
return this;
}
public Map<Integer, OutPort> getOutPorts() {
return outPorts;
}
public Task setOutPorts(Map<Integer, OutPort> outPorts) {
this.outPorts = outPorts;
return this;
}
}
public static class OutPort {
private InPort nextPort;
private Task parentTask;
private Operation parentOperation;
private String name;
private int id;
public InPort getNextPort() {
return nextPort;
}
public OutPort setNextPort(InPort nextPort) {
this.nextPort = nextPort;
return this;
}
public Task getParentTask() {
return parentTask;
}
public OutPort setParentTask(Task parentTask) {
this.parentTask = parentTask;
return this;
}
public Operation getParentOperation() {
return parentOperation;
}
public OutPort setParentOperation(Operation parentOperation) {
this.parentOperation = parentOperation;
return this;
}
public String getName() {
return name;
}
public OutPort setName(String name) {
this.name = name;
return this;
}
public int getId() {
return id;
}
public OutPort setId(int id) {
this.id = id;
return this;
}
}
public static class InPort {
private Map<Integer, OutPort> previousPorts = new HashMap<>();
private Task parentTask;
private Operation parentOperation;
private String name;
private int id;
public Map<Integer, OutPort> getPreviousPorts() {
return previousPorts;
}
public InPort setPreviousPorts(Map<Integer, OutPort> previousPorts) {
this.previousPorts = previousPorts;
return this;
}
public Task getParentTask() {
return parentTask;
}
public InPort setParentTask(Task parentTask) {
this.parentTask = parentTask;
return this;
}
public Operation getParentOperation() {
return parentOperation;
}
public InPort setParentOperation(Operation parentOperation) {
this.parentOperation = parentOperation;
return this;
}
public String getName() {
return name;
}
public InPort setName(String name) {
this.name = name;
return this;
}
public int getId() {
return id;
}
public InPort setId(int id) {
this.id = id;
return this;
}
}
public static class Operation {
private int id;
private String name;
private Map<Integer, InPort> inPorts = new HashMap<>();
private Map<Integer, OutPort> outPorts = new HashMap<>();
public int getId() {
return id;
}
public Operation setId(int id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public Operation setName(String name) {
this.name = name;
return this;
}
public Map<Integer, InPort> getInPorts() {
return inPorts;
}
public Operation setInPorts(Map<Integer, InPort> inPorts) {
this.inPorts = inPorts;
return this;
}
public Map<Integer, OutPort> getOutPorts() {
return outPorts;
}
public Operation setOutPorts(Map<Integer, OutPort> outPorts) {
this.outPorts = outPorts;
return this;
}
}
}
| 8,826 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/task/TaskService.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.service.task;
import org.apache.airavata.k8s.api.resources.task.TaskDagResource;
import org.apache.airavata.k8s.api.resources.task.TaskResource;
import org.apache.airavata.k8s.api.resources.task.TaskStatusResource;
import org.apache.airavata.k8s.api.server.ServerRuntimeException;
import org.apache.airavata.k8s.api.server.model.task.*;
import org.apache.airavata.k8s.api.server.repository.process.ProcessRepository;
import org.apache.airavata.k8s.api.server.repository.task.*;
import org.apache.airavata.k8s.api.server.repository.task.type.TaskTypeRepository;
import org.apache.airavata.k8s.api.server.service.util.ToResourceUtil;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Service
public class TaskService {
private ProcessRepository processRepository;
private TaskRepository taskRepository;
private TaskInputRepository taskInputRepository;
private TaskOutputRepository taskOutputRepository;
private TaskStatusRepository taskStatusRepository;
private TaskTypeRepository taskTypeRepository;
private TaskOutPortRepository taskOutPortRepository;
private TaskDAGRepository taskDAGRepository;
public TaskService(ProcessRepository processRepository,
TaskRepository taskRepository,
TaskInputRepository taskInputRepository,
TaskOutputRepository taskOutputRepository,
TaskStatusRepository taskStatusRepository,
TaskTypeRepository taskTypeRepository,
TaskOutPortRepository taskOutPortRepository,
TaskDAGRepository taskDAGRepository) {
this.processRepository = processRepository;
this.taskRepository = taskRepository;
this.taskInputRepository = taskInputRepository;
this.taskOutputRepository = taskOutputRepository;
this.taskStatusRepository = taskStatusRepository;
this.taskTypeRepository = taskTypeRepository;
this.taskOutPortRepository = taskOutPortRepository;
this.taskDAGRepository = taskDAGRepository;
}
public long create(TaskResource resource) {
TaskModel taskModel = new TaskModel();
taskModel.setName(resource.getName());
taskModel.setCreationTime(resource.getCreationTime());
taskModel.setLastUpdateTime(resource.getLastUpdateTime());
taskModel.setOrderIndex(resource.getOrder());
taskModel.setStartingTask(resource.isStartingTask());
taskModel.setStoppingTask(resource.isStoppingTask());
taskModel.setTaskDetail(resource.getTaskDetail());
taskModel.setReferenceId(resource.getReferenceId());
taskModel.setParentProcess(processRepository.findById(resource.getParentProcessId())
.orElseThrow(() -> new ServerRuntimeException("Can not find process with id " +
resource.getParentProcessId())));
taskModel.setTaskType(taskTypeRepository.findById(resource.getTaskType().getId())
.orElseThrow(() -> new ServerRuntimeException("Can not find task type with id " +
resource.getTaskType().getId())));
TaskModel savedTask = taskRepository.save(taskModel);
Optional.ofNullable(resource.getInputs()).ifPresent(inputs -> inputs.forEach(input -> {
TaskInput taskInput = new TaskInput();
taskInput.setName(input.getName());
taskInput.setValue(input.getValue());
taskInput.setType(input.getType());
taskInput.setImportFrom(input.getImportFrom());
taskInput.setTaskModel(savedTask);
taskInputRepository.save(taskInput);
}));
Optional.ofNullable(resource.getOutputs()).ifPresent(outputs -> outputs.forEach(output -> {
TaskOutput taskOutput = new TaskOutput();
taskOutput.setName(output.getName());
taskOutput.setValue(output.getValue());
taskOutput.setType(output.getType());
taskOutput.setExportTo(output.getExportTo());
taskOutput.setTaskModel(savedTask);
taskOutputRepository.save(taskOutput);
}));
Optional.ofNullable(resource.getOutPorts()).ifPresent(outPorts -> outPorts.forEach(outPort -> {
TaskOutPort taskOutPort = new TaskOutPort();
taskOutPort.setName(outPort.getName());
taskOutPort.setReferenceId(outPort.getReferenceId());
taskOutPort.setTaskModel(taskModel);
taskOutPortRepository.save(taskOutPort);
}));
return savedTask.getId();
}
public long addTaskStatus(long taskId, TaskStatusResource resource) {
TaskModel taskModel = taskRepository.findById(taskId)
.orElseThrow(() -> new ServerRuntimeException("Task with id " + taskId + " can not be found"));
TaskStatus status = new TaskStatus();
status.setReason(resource.getReason());
status.setState(TaskStatus.TaskState.valueOf(resource.getState()));
status.setTimeOfStateChange(resource.getTimeOfStateChange());
status.setTaskModel(taskModel);
TaskStatus savedStatus = taskStatusRepository.save(status);
return savedStatus.getId();
}
public Optional<TaskStatusResource> findTaskStatusById(long id) {
return ToResourceUtil.toResource(taskStatusRepository.findById(id).get());
}
public Optional<TaskResource> findById(long id) {
return ToResourceUtil.toResource(taskRepository.findById(id).get());
}
public Set<TaskDagResource> getDagForProcess(long processId) {
Set<TaskDagResource> taskDagResources = new HashSet<>();
Iterable<TaskDAG> taskDags = this.taskDAGRepository.findBysourceOutPort_taskModel_parentProcess_id(processId);
Optional.ofNullable(taskDags).ifPresent(dags -> dags.forEach(taskDAG -> {
taskDagResources.add(ToResourceUtil.toResource(taskDAG).get());
}));
return taskDagResources;
}
}
| 8,827 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/task | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/task/type/TaskTypeService.java | package org.apache.airavata.k8s.api.server.service.task.type;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import org.apache.airavata.k8s.api.server.model.task.type.TaskInputType;
import org.apache.airavata.k8s.api.server.model.task.type.TaskModelType;
import org.apache.airavata.k8s.api.server.model.task.type.TaskOutPortType;
import org.apache.airavata.k8s.api.server.model.task.type.TaskOutputType;
import org.apache.airavata.k8s.api.server.repository.task.type.TaskInputTypeRepository;
import org.apache.airavata.k8s.api.server.repository.task.type.TaskOutPortTypeRepository;
import org.apache.airavata.k8s.api.server.repository.task.type.TaskOutputTypeRepository;
import org.apache.airavata.k8s.api.server.repository.task.type.TaskTypeRepository;
import org.apache.airavata.k8s.api.server.service.util.ToResourceUtil;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Service
public class TaskTypeService {
private TaskTypeRepository taskTypeRepository;
private TaskInputTypeRepository taskInputTypeRepository;
private TaskOutputTypeRepository taskOutputTypeRepository;
private TaskOutPortTypeRepository taskOutPortTypeRepository;
public TaskTypeService(TaskTypeRepository taskTypeRepository,
TaskInputTypeRepository taskInputTypeRepository,
TaskOutputTypeRepository taskOutputTypeRepository,
TaskOutPortTypeRepository taskOutPortTypeRepository) {
this.taskTypeRepository = taskTypeRepository;
this.taskInputTypeRepository = taskInputTypeRepository;
this.taskOutputTypeRepository = taskOutputTypeRepository;
this.taskOutPortTypeRepository = taskOutPortTypeRepository;
}
public long create(TaskTypeResource resource) {
Optional<TaskModelType> taskType = taskTypeRepository.findByName(resource.getName());
if (taskType.isPresent()) {
return taskType.get().getId();
}
TaskModelType taskModelType = new TaskModelType();
taskModelType.setName(resource.getName());
taskModelType.setTopicName(resource.getTopicName());
taskModelType.setIcon(resource.getIcon());
TaskModelType savedTaskType = taskTypeRepository.save(taskModelType);
Optional.ofNullable(resource.getInputTypes()).ifPresent(inputs -> inputs.forEach(input -> {
TaskInputType inputType = new TaskInputType();
inputType.setName(input.getName());
inputType.setType(input.getType());
inputType.setDefaultValue(input.getDefaultValue());
inputType.setTaskModelType(savedTaskType);
taskInputTypeRepository.save(inputType);
}));
Optional.ofNullable(resource.getOutputTypes()).ifPresent(outputs -> outputs.forEach(output -> {
TaskOutputType outputType = new TaskOutputType();
outputType.setName(output.getName());
outputType.setType(output.getType());
outputType.setTaskModelType(savedTaskType);
taskOutputTypeRepository.save(outputType);
}));
Optional.ofNullable(resource.getOutPorts()).ifPresent(outPorts -> outPorts.forEach(outPort -> {
TaskOutPortType outPortType = new TaskOutPortType();
outPortType.setName(outPort.getName());
outPortType.setOrder(outPort.getOrder());
outPortType.setTaskModelType(savedTaskType);
taskOutPortTypeRepository.save(outPortType);
}));
return savedTaskType.getId();
}
public List<TaskTypeResource> getAll() {
List<TaskTypeResource> types = new ArrayList<>();
Optional.ofNullable(taskTypeRepository.findAll())
.ifPresent(taskModelTypes -> taskModelTypes.forEach(taskModelType -> {
types.add(ToResourceUtil.toResource(taskModelType).get());
}));
return types;
}
}
| 8,828 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/data/DataStoreService.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.service.data;
import org.apache.airavata.k8s.api.resources.data.DataEntryResource;
import org.apache.airavata.k8s.api.server.model.data.DataStoreModel;
import org.apache.airavata.k8s.api.server.repository.data.DataStoreRepository;
import org.apache.airavata.k8s.api.server.repository.experiment.ExperimentOutputDataRepository;
import org.apache.airavata.k8s.api.server.repository.task.TaskRepository;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Service
public class DataStoreService {
private DataStoreRepository dataStoreRepository;
private TaskRepository taskRepository;
private ExperimentOutputDataRepository experimentOutputDataRepository;
public DataStoreService(DataStoreRepository dataStoreRepository,
TaskRepository taskRepository,
ExperimentOutputDataRepository experimentOutputDataRepository) {
this.dataStoreRepository = dataStoreRepository;
this.taskRepository = taskRepository;
this.experimentOutputDataRepository = experimentOutputDataRepository;
}
public long createEntry(long taskId, String identifier, byte[] content) {
DataStoreModel model = new DataStoreModel();
model.setTaskModel(taskRepository.findById(taskId).get())
.setIdentifier(identifier)
.setContent(content);
return dataStoreRepository.save(model).getId();
}
public List<DataEntryResource> getEntriesForProcess(long processId) {
List<DataEntryResource> entries = new ArrayList<>();
List<DataStoreModel> dataStoreModels = this.dataStoreRepository.findByTaskModel_ParentProcess_Id(processId);
Optional.ofNullable(dataStoreModels).ifPresent(models -> models.forEach(model -> entries.add(new DataEntryResource()
.setId(model.getId())
.setName(model.getIdentifier()))));
return entries;
}
}
| 8,829 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/messaging/MessagingService.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.service.messaging;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Service
public class MessagingService {
@Autowired
private KafkaTemplate<String, String> kafkaTemplate;
public void send(String topic, String payload) {
kafkaTemplate.send(topic, payload);
}
}
| 8,830 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/api-server/src/main/java/org/apache/airavata/k8s/api/server/service/messaging/SenderConfig.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.server.service.messaging;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.serialization.StringSerializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.core.ProducerFactory;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Configuration
public class SenderConfig {
@Value("${kafka.bootstrap-servers}")
private String bootstrapServers;
@Bean
public Map<String, Object> producerConfigs() {
Map<String, Object> props = new HashMap<>();
// list of host:port pairs used for establishing the initial connections to the Kakfa cluster
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
return props;
}
@Bean
public ProducerFactory<String, String> producerFactory() {
return new DefaultKafkaProducerFactory<String, String>(producerConfigs());
}
@Bean
public KafkaTemplate<String, String> kafkaTemplate() {
return new KafkaTemplate<>(producerFactory());
}
}
| 8,831 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/data-out-task/src/main/java/org/apache/airavata/helix/task | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/data-out-task/src/main/java/org/apache/airavata/helix/task/dataout/Participant.java | package org.apache.airavata.helix.task.dataout;
import org.apache.airavata.helix.api.HelixParticipant;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import org.apache.helix.task.Task;
import org.apache.helix.task.TaskCallbackContext;
import org.apache.helix.task.TaskFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class Participant extends HelixParticipant {
public Participant(String propertyFile) throws IOException {
super(propertyFile);
}
@Override
public Map<String, TaskFactory> getTaskFactory() {
Map<String, TaskFactory> taskRegistry = new HashMap<String, TaskFactory>();
TaskFactory dataInTask = new TaskFactory() {
@Override
public Task createNewTask(TaskCallbackContext context) {
return new DataOutputTask(context, getPropertyResolver());
}
};
taskRegistry.put(DataOutputTask.NAME, dataInTask);
return taskRegistry;
}
@Override
public TaskTypeResource getTaskType() {
return DataOutputTask.getTaskType();
}
public static void main(String args[]) {
try {
HelixParticipant participant = new Participant("application.properties");
new Thread(participant).start();
} catch (IOException e) {
e.printStackTrace();
}
}
}
| 8,832 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/data-out-task/src/main/java/org/apache/airavata/helix/task | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/data-out-task/src/main/java/org/apache/airavata/helix/task/dataout/DataOutputTask.java | package org.apache.airavata.helix.task.dataout;
import org.apache.airavata.helix.api.AbstractTask;
import org.apache.airavata.helix.api.PropertyResolver;
import org.apache.airavata.k8s.api.resources.compute.ComputeResource;
import org.apache.airavata.k8s.api.resources.task.TaskStatusResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskInputTypeResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskOutPortTypeResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import org.apache.helix.task.TaskCallbackContext;
import org.apache.helix.task.TaskResult;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.util.LinkedMultiValueMap;
import java.util.Arrays;
import java.util.UUID;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class DataOutputTask extends AbstractTask {
public static final String NAME = "DATA_OUTPUT";
private String sourcePath;
private String identifier;
private String computeResourceId;
private ComputeResource computeResource;
public DataOutputTask(TaskCallbackContext callbackContext, PropertyResolver propertyResolver) {
super(callbackContext, propertyResolver);
}
@Override
public void init() {
this.sourcePath = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.SOURCE_PATH);
this.identifier = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.IDENTIFIER);
this.computeResourceId = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.COMPUTE_RESOURCE);
this.computeResource = this.getRestTemplate().getForObject("http://" + this.getApiServerUrl()
+ "/compute/" + Long.parseLong(this.computeResourceId), ComputeResource.class);
}
@Override
public TaskResult onRun() {
try {
publishTaskStatus(TaskStatusResource.State.EXECUTING, "");
String temporaryFile = "/tmp/" + UUID.randomUUID().toString();
System.out.println("Downloading " + sourcePath + " to " + temporaryFile + " from compute resource "
+ computeResource.getName());
fetchComputeResourceOperation(computeResource).transferDataOut(sourcePath, temporaryFile, "SCP");
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
map.add("file", new FileSystemResource(temporaryFile));
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<>(map, headers);
System.out.println("Uploading data file with task id " + getTaskId() + " and identifier "
+ identifier + " to data store");
getRestTemplate().exchange("http://" + getApiServerUrl() + "/data/" + getTaskId() + "/"
+ identifier + "/upload", HttpMethod.POST, requestEntity, Long.class);
publishTaskStatus(TaskStatusResource.State.COMPLETED, "Task completed");
sendToOutPort("Out");
return new TaskResult(TaskResult.Status.COMPLETED, "Task completed");
} catch (Exception e) {
e.printStackTrace();
publishTaskStatus(TaskStatusResource.State.FAILED, e.getMessage());
sendToOutPort("Error");
return new TaskResult(TaskResult.Status.FATAL_FAILED, "Task completed");
}
}
@Override
public void onCancel() {
}
public static final class PARAMS {
public static final String SOURCE_PATH = "source_path";
public static final String COMPUTE_RESOURCE = "compute_resource";
public static final String IDENTIFIER = "identifier";
}
public static TaskTypeResource getTaskType() {
TaskTypeResource taskTypeResource = new TaskTypeResource();
taskTypeResource.setName(NAME);
taskTypeResource.setTopicName("airavata-data-collect");
taskTypeResource.setIcon("assets/icons/dataout.png");
taskTypeResource.getInputTypes().addAll(
Arrays.asList(
new TaskInputTypeResource()
.setName(PARAMS.SOURCE_PATH)
.setType("String")
.setDefaultValue(""),
new TaskInputTypeResource()
.setName(PARAMS.IDENTIFIER)
.setType("String")
.setDefaultValue(""),
new TaskInputTypeResource()
.setName(PARAMS.COMPUTE_RESOURCE)
.setType("Long")
.setDefaultValue("")));
taskTypeResource.getOutPorts().addAll(
Arrays.asList(
new TaskOutPortTypeResource()
.setName("Out")
.setOrder(0),
new TaskOutPortTypeResource()
.setName("Error")
.setOrder(1))
);
return taskTypeResource;
}
} | 8,833 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/async-command-monitor/src/main/java/org/apache/airavata/task/async/command | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/async-command-monitor/src/main/java/org/apache/airavata/task/async/command/monitor/AsyncCommandMonitor.java | package org.apache.airavata.task.async.command.monitor;
import org.apache.airavata.agents.core.AsyncCommandStatus;
import org.apache.airavata.helix.api.AbstractTask;
import org.apache.airavata.helix.api.PropertyResolver;
import org.apache.airavata.k8s.api.resources.task.TaskStatusResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskInputTypeResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskOutPortTypeResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import org.apache.helix.task.TaskCallbackContext;
import org.apache.helix.task.TaskResult;
import java.util.Arrays;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class AsyncCommandMonitor extends AbstractTask {
public static final String NAME = "ASYNC_COMMAND_MONITOR";
private AsyncCommandStatus status;
private String message;
public AsyncCommandMonitor(TaskCallbackContext callbackContext, PropertyResolver propertyResolver) {
super(callbackContext, propertyResolver);
}
@Override
public void init() {
super.init();
this.status = AsyncCommandStatus.valueOf(getCallbackContext().getTaskConfig().getConfigMap().get("event"));
this.message = getCallbackContext().getTaskConfig().getConfigMap().get("message");
}
@Override
public TaskResult onRun() {
System.out.println("Received status " + this.status.name() + " with message " + this.message);
if (this.status != null) {
sendToOutPort(this.status.name());
publishTaskStatus(TaskStatusResource.State.COMPLETED, "Sending to out port " + this.status.name());
return new TaskResult(TaskResult.Status.COMPLETED, "Sending to out port " + this.status.name());
} else {
publishTaskStatus(TaskStatusResource.State.FAILED, "Unsupported status");
return new TaskResult(TaskResult.Status.FATAL_FAILED, "Unsupported status");
}
}
@Override
public void onCancel() {
}
public static TaskTypeResource getTaskType() {
TaskTypeResource taskTypeResource = new TaskTypeResource();
taskTypeResource.setName(NAME);
taskTypeResource.setIcon("assets/icons/ssh.png");
taskTypeResource.getInputTypes().addAll(
Arrays.asList(
new TaskInputTypeResource()
.setName(PARAMS.STATUS_KEY)
.setType("String")
.setDefaultValue("status"),
new TaskInputTypeResource()
.setName(PARAMS.MESSAGE_KEY)
.setType("String")
.setDefaultValue("message")
));
taskTypeResource.getOutPorts().addAll(
Arrays.asList(
new TaskOutPortTypeResource()
.setName(AsyncCommandStatus.PENDING.name())
.setOrder(0),
new TaskOutPortTypeResource()
.setName(AsyncCommandStatus.RUNNING.name())
.setOrder(1),
new TaskOutPortTypeResource()
.setName(AsyncCommandStatus.SUCCESS.name())
.setOrder(2),
new TaskOutPortTypeResource()
.setName(AsyncCommandStatus.CANCEL.name())
.setOrder(3),
new TaskOutPortTypeResource()
.setName(AsyncCommandStatus.ERROR.name())
.setOrder(4),
new TaskOutPortTypeResource()
.setName(AsyncCommandStatus.PAUSE.name())
.setOrder(5),
new TaskOutPortTypeResource()
.setName(AsyncCommandStatus.WARNING.name())
.setOrder(6),
new TaskOutPortTypeResource()
.setName(AsyncCommandStatus.MANUAL_RECOVERY.name())
.setOrder(7)
)
);
return taskTypeResource;
}
public static final class PARAMS {
public static final String STATUS_KEY = "status-key";
public static final String MESSAGE_KEY = "message-key";
}
}
| 8,834 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/async-command-monitor/src/main/java/org/apache/airavata/task/async/command | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/async-command-monitor/src/main/java/org/apache/airavata/task/async/command/monitor/Participant.java | package org.apache.airavata.task.async.command.monitor;
import org.apache.airavata.helix.api.HelixParticipant;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import org.apache.helix.task.Task;
import org.apache.helix.task.TaskCallbackContext;
import org.apache.helix.task.TaskFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class Participant extends HelixParticipant {
public Participant(String propertyFile) throws IOException {
super(propertyFile);
}
@Override
public Map<String, TaskFactory> getTaskFactory() {
Map<String, TaskFactory> taskRegistry = new HashMap<String, TaskFactory>();
TaskFactory commandTaskFac = new TaskFactory() {
@Override
public Task createNewTask(TaskCallbackContext context) {
return new AsyncCommandMonitor(context, getPropertyResolver());
}
};
taskRegistry.put(AsyncCommandMonitor.NAME, commandTaskFac);
return taskRegistry;
}
@Override
public TaskTypeResource getTaskType() {
return AsyncCommandMonitor.getTaskType();
}
public static void main(String args[]) {
try {
HelixParticipant participant = new Participant("application.properties");
new Thread(participant).start();
} catch (IOException e) {
e.printStackTrace();
}
}
}
| 8,835 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/async-command-task/src/main/java/org/apache/airavata/helix/task/async | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/async-command-task/src/main/java/org/apache/airavata/helix/task/async/command/Participant.java | package org.apache.airavata.helix.task.async.command;
import org.apache.airavata.helix.api.HelixParticipant;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import org.apache.helix.task.Task;
import org.apache.helix.task.TaskCallbackContext;
import org.apache.helix.task.TaskFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class Participant extends HelixParticipant {
public Participant(String propertyFile) throws IOException {
super(propertyFile);
}
@Override
public Map<String, TaskFactory> getTaskFactory() {
Map<String, TaskFactory> taskRegistry = new HashMap<String, TaskFactory>();
TaskFactory commandTaskFac = new TaskFactory() {
@Override
public Task createNewTask(TaskCallbackContext context) {
return new AsyncCommandTask(context, getPropertyResolver());
}
};
taskRegistry.put(AsyncCommandTask.NAME, commandTaskFac);
return taskRegistry;
}
@Override
public TaskTypeResource getTaskType() {
return AsyncCommandTask.getTaskType();
}
public static void main(String args[]) {
try {
HelixParticipant participant = new Participant("application.properties");
new Thread(participant).start();
} catch (IOException e) {
e.printStackTrace();
}
}
}
| 8,836 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/async-command-task/src/main/java/org/apache/airavata/helix/task/async | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/async-command-task/src/main/java/org/apache/airavata/helix/task/async/command/AsyncCommandTask.java | package org.apache.airavata.helix.task.async.command;
import org.apache.airavata.agents.core.AsyncOperation;
import org.apache.airavata.helix.api.AbstractTask;
import org.apache.airavata.helix.api.PropertyResolver;
import org.apache.airavata.k8s.api.resources.compute.ComputeResource;
import org.apache.airavata.k8s.api.resources.task.TaskStatusResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskInputTypeResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskOutPortTypeResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import org.apache.helix.task.TaskCallbackContext;
import org.apache.helix.task.TaskResult;
import org.apache.kafka.clients.producer.ProducerRecord;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class AsyncCommandTask extends AbstractTask {
public static final String NAME = "ASYNC_COMMAND_TASK";
private String command;
private String arguments;
private String stdOutPath;
private String stdErrPath;
private String computeResourceId;
private ComputeResource computeResource;
private Long callBackWorkflowId;
public AsyncCommandTask(TaskCallbackContext callbackContext, PropertyResolver propertyResolver) {
super(callbackContext, propertyResolver);
}
@Override
public void init() {
this.command = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.COMMAND);
this.arguments = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.ARGUMENTS);
this.stdOutPath = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.STD_OUT_PATH);
this.stdErrPath = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.STD_ERR_PATH);
this.computeResourceId = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.COMPUTE_RESOURCE);
this.callBackWorkflowId = Long.parseLong(getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.CALLBACK_WORKFLOW));
this.computeResource = this.getRestTemplate().getForObject("http://" + this.getApiServerUrl()
+ "/compute/" + Long.parseLong(this.computeResourceId), ComputeResource.class);
}
@Override
public TaskResult onRun() {
try {
AsyncOperation operation = (AsyncOperation) Class.forName("org.apache.airavata.agents.thrift.operation.ThriftAgentOperation")
.getConstructor(ComputeResource.class).newInstance(this.computeResource);
operation.executeCommandAsync(this.command, this.callBackWorkflowId);
publishTaskStatus(TaskStatusResource.State.COMPLETED, "Task completed");
return new TaskResult(TaskResult.Status.COMPLETED, "Task completed");
} catch (InstantiationException | IllegalAccessException |
InvocationTargetException | ClassNotFoundException | NoSuchMethodException | ClassCastException e) {
e.printStackTrace();
publishTaskStatus(TaskStatusResource.State.FAILED, "Failed to load async operation");
return new TaskResult(TaskResult.Status.FATAL_FAILED, "Task failed");
}
}
@Override
public void onCancel() {
}
public static TaskTypeResource getTaskType() {
TaskTypeResource taskTypeResource = new TaskTypeResource();
taskTypeResource.setName(NAME);
taskTypeResource.setIcon("assets/icons/ssh.png");
taskTypeResource.getInputTypes().addAll(
Arrays.asList(
new TaskInputTypeResource()
.setName(PARAMS.COMMAND)
.setType("String")
.setDefaultValue(""),
new TaskInputTypeResource()
.setName(PARAMS.ARGUMENTS)
.setType("String")
.setDefaultValue(""),
new TaskInputTypeResource()
.setName(PARAMS.COMPUTE_RESOURCE)
.setType("Long")
.setDefaultValue(""),
new TaskInputTypeResource()
.setName(PARAMS.CALLBACK_WORKFLOW)
.setType("Long")
.setDefaultValue(""),
new TaskInputTypeResource()
.setName(PARAMS.STD_OUT_PATH)
.setType("String")
.setDefaultValue(""),
new TaskInputTypeResource()
.setName(PARAMS.STD_ERR_PATH)
.setType("String")
.setDefaultValue("")));
taskTypeResource.getOutPorts().addAll(
Arrays.asList(
new TaskOutPortTypeResource()
.setName("Out")
.setOrder(0),
new TaskOutPortTypeResource()
.setName("Error")
.setOrder(1))
);
return taskTypeResource;
}
public static final class PARAMS {
public static final String COMMAND = "command";
public static final String ARGUMENTS = "arguments";
public static final String STD_OUT_PATH = "std_out_path";
public static final String STD_ERR_PATH = "std_err_path";
public static final String COMPUTE_RESOURCE = "compute_resource";
public static final String CALLBACK_WORKFLOW = "callback_workflow";
}
}
| 8,837 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/command-task/src/main/java/org/apache/airavata/helix/task | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/command-task/src/main/java/org/apache/airavata/helix/task/command/Participant.java | package org.apache.airavata.helix.task.command;
import org.apache.airavata.helix.api.HelixParticipant;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import org.apache.helix.task.Task;
import org.apache.helix.task.TaskCallbackContext;
import org.apache.helix.task.TaskFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class Participant extends HelixParticipant {
public Participant(String propertyFile) throws IOException {
super(propertyFile);
}
@Override
public Map<String, TaskFactory> getTaskFactory() {
Map<String, TaskFactory> taskRegistry = new HashMap<String, TaskFactory>();
TaskFactory commandTaskFac = new TaskFactory() {
@Override
public Task createNewTask(TaskCallbackContext context) {
return new CommandTask(context, getPropertyResolver());
}
};
taskRegistry.put(CommandTask.NAME, commandTaskFac);
return taskRegistry;
}
@Override
public TaskTypeResource getTaskType() {
return CommandTask.getTaskType();
}
public static void main(String args[]) {
try {
HelixParticipant participant = new Participant("application.properties");
new Thread(participant).start();
} catch (IOException e) {
e.printStackTrace();
}
}
}
| 8,838 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/command-task/src/main/java/org/apache/airavata/helix/task | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/command-task/src/main/java/org/apache/airavata/helix/task/command/CommandTask.java | package org.apache.airavata.helix.task.command;
import org.apache.airavata.helix.api.AbstractTask;
import org.apache.airavata.helix.api.PropertyResolver;
import org.apache.airavata.k8s.api.resources.compute.ComputeResource;
import org.apache.airavata.k8s.api.resources.task.TaskStatusResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskInputTypeResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskOutPortTypeResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import org.apache.airavata.k8s.compute.api.ExecutionResult;
import org.apache.helix.task.TaskCallbackContext;
import org.apache.helix.task.TaskResult;
import java.util.Arrays;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class CommandTask extends AbstractTask {
public static final String NAME = "COMMAND";
private String command;
private String arguments;
private String stdOutPath;
private String stdErrPath;
private String computeResourceId;
private ComputeResource computeResource;
public CommandTask(TaskCallbackContext callbackContext, PropertyResolver propertyResolver) {
super(callbackContext, propertyResolver);
}
@Override
public void init() {
this.command = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.COMMAND);
this.arguments = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.ARGUMENTS);
this.stdOutPath = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.STD_OUT_PATH);
this.stdErrPath = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.STD_ERR_PATH);
this.computeResourceId = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.COMPUTE_RESOURCE);
this.computeResource = this.getRestTemplate().getForObject("http://" + this.getApiServerUrl()
+ "/compute/" + Long.parseLong(this.computeResourceId), ComputeResource.class);
}
public TaskResult onRun() {
System.out.println("Executing command " + command);
try {
String stdOutSuffix = " > " + stdOutPath + " 2> " + stdErrPath;
publishTaskStatus(TaskStatusResource.State.EXECUTING, "");
String finalCommand = command + (arguments != null ? arguments : "") + stdOutSuffix;
System.out.println("Executing command " + finalCommand);
Thread.sleep(2000);
ExecutionResult executionResult = fetchComputeResourceOperation(computeResource).executeCommand(finalCommand);
if (executionResult.getExitStatus() == 0) {
publishTaskStatus(TaskStatusResource.State.COMPLETED, "Task completed");
sendToOutPort("Out");
return new TaskResult(TaskResult.Status.COMPLETED, "Task completed");
} else if (executionResult.getExitStatus() == -1) {
publishTaskStatus(TaskStatusResource.State.FAILED, "Process didn't exit successfully");
sendToOutPort("Error");
return new TaskResult(TaskResult.Status.FATAL_FAILED, "Task failed");
} else {
publishTaskStatus(TaskStatusResource.State.FAILED, "Process exited with error status " + executionResult.getExitStatus());
sendToOutPort("Error");
return new TaskResult(TaskResult.Status.FATAL_FAILED, "Task failed");
}
} catch (Exception e) {
e.printStackTrace();
publishTaskStatus(TaskStatusResource.State.FAILED, e.getMessage());
return new TaskResult(TaskResult.Status.FATAL_FAILED, "Task failed");
}
}
public void onCancel() {
}
public static TaskTypeResource getTaskType() {
TaskTypeResource taskTypeResource = new TaskTypeResource();
taskTypeResource.setName(NAME);
taskTypeResource.setTopicName("airavata-command");
taskTypeResource.setIcon("assets/icons/ssh.png");
taskTypeResource.getInputTypes().addAll(
Arrays.asList(
new TaskInputTypeResource()
.setName(PARAMS.COMMAND)
.setType("String")
.setDefaultValue(""),
new TaskInputTypeResource()
.setName(PARAMS.ARGUMENTS)
.setType("String")
.setDefaultValue(""),
new TaskInputTypeResource()
.setName(PARAMS.COMPUTE_RESOURCE)
.setType("Long")
.setDefaultValue(""),
new TaskInputTypeResource()
.setName(PARAMS.STD_OUT_PATH)
.setType("String")
.setDefaultValue(""),
new TaskInputTypeResource()
.setName(PARAMS.STD_ERR_PATH)
.setType("String")
.setDefaultValue("")));
taskTypeResource.getOutPorts().addAll(
Arrays.asList(
new TaskOutPortTypeResource()
.setName("Out")
.setOrder(0),
new TaskOutPortTypeResource()
.setName("Error")
.setOrder(1))
);
return taskTypeResource;
}
public static final class PARAMS {
public static final String COMMAND = "command";
public static final String ARGUMENTS = "arguments";
public static final String STD_OUT_PATH = "std_out_path";
public static final String STD_ERR_PATH = "std_err_path";
public static final String COMPUTE_RESOURCE = "compute_resource";
}
}
| 8,839 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/data-in-task/src/main/java/org/apache/airavata/helix/task | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/data-in-task/src/main/java/org/apache/airavata/helix/task/datain/Participant.java | package org.apache.airavata.helix.task.datain;
import org.apache.airavata.helix.api.HelixParticipant;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import org.apache.helix.task.Task;
import org.apache.helix.task.TaskCallbackContext;
import org.apache.helix.task.TaskFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class Participant extends HelixParticipant {
public Participant(String propertyFile) throws IOException {
super(propertyFile);
}
@Override
public Map<String, TaskFactory> getTaskFactory() {
Map<String, TaskFactory> taskRegistry = new HashMap<String, TaskFactory>();
TaskFactory dataInTask = new TaskFactory() {
@Override
public Task createNewTask(TaskCallbackContext context) {
return new DataInputTask(context, getPropertyResolver());
}
};
taskRegistry.put(DataInputTask.NAME, dataInTask);
return taskRegistry;
}
@Override
public TaskTypeResource getTaskType() {
return DataInputTask.getTaskType();
}
public static void main(String args[]) {
try {
HelixParticipant participant = new Participant("application.properties");
new Thread(participant).start();
} catch (IOException e) {
e.printStackTrace();
}
}
}
| 8,840 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/data-in-task/src/main/java/org/apache/airavata/helix/task | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/tasks/data-in-task/src/main/java/org/apache/airavata/helix/task/datain/DataInputTask.java | package org.apache.airavata.helix.task.datain;
import org.apache.airavata.helix.api.AbstractTask;
import org.apache.airavata.helix.api.PropertyResolver;
import org.apache.airavata.k8s.api.resources.compute.ComputeResource;
import org.apache.airavata.k8s.api.resources.task.TaskStatusResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskInputTypeResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskOutPortTypeResource;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import org.apache.commons.io.FileUtils;
import org.apache.helix.task.TaskCallbackContext;
import org.apache.helix.task.TaskResult;
import java.io.File;
import java.net.URL;
import java.util.Arrays;
import java.util.UUID;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class DataInputTask extends AbstractTask {
public static final String NAME = "DATA_INPUT";
private String remoteSourcePath;
private String targetPath;
private String computeResourceId;
private ComputeResource computeResource;
public DataInputTask(TaskCallbackContext callbackContext, PropertyResolver propertyResolver) {
super(callbackContext, propertyResolver);
}
@Override
public void init() {
this.remoteSourcePath = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.REMOTE_SOURCE_PATH);
this.targetPath = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.TARGET_PATH);
this.computeResourceId = getCallbackContext().getTaskConfig().getConfigMap().get(PARAMS.COMPUTE_RESOURCE);
this.computeResource = this.getRestTemplate().getForObject("http://" + this.getApiServerUrl()
+ "/compute/" + Long.parseLong(this.computeResourceId), ComputeResource.class);
}
@Override
public TaskResult onRun() {
try {
String tempFilePath = "/tmp/" + UUID.randomUUID().toString();
System.out.println("Creating tmp file " + tempFilePath);
publishTaskStatus(TaskStatusResource.State.EXECUTING, "");
if (remoteSourcePath.startsWith("http")) {
System.out.println("Downloading text file " + remoteSourcePath);
FileUtils.copyURLToFile(new URL(remoteSourcePath), new File(tempFilePath));
} else {
publishTaskStatus(TaskStatusResource.State.FAILED, "Unsupported source type");
sendToOutPort("Error");
return new TaskResult(TaskResult.Status.FATAL_FAILED, "Task failed");
}
System.out.println("Transferring file to remote resource");
fetchComputeResourceOperation(computeResource).transferDataIn(tempFilePath, this.targetPath, "SCP");
publishTaskStatus(TaskStatusResource.State.COMPLETED, "Task completed");
sendToOutPort("Out");
return new TaskResult(TaskResult.Status.COMPLETED, "Task completed");
} catch (Exception e) {
e.printStackTrace();
publishTaskStatus(TaskStatusResource.State.FAILED, e.getMessage());
sendToOutPort("Error");
return new TaskResult(TaskResult.Status.FATAL_FAILED, "Task failed");
}
}
@Override
public void onCancel() {
}
public static TaskTypeResource getTaskType() {
TaskTypeResource taskTypeResource = new TaskTypeResource();
taskTypeResource.setName(NAME);
taskTypeResource.setTopicName("airavata-data-collect");
taskTypeResource.setIcon("assets/icons/datain.png");
taskTypeResource.getInputTypes().addAll(
Arrays.asList(
new TaskInputTypeResource()
.setName(PARAMS.REMOTE_SOURCE_PATH)
.setType("String")
.setDefaultValue(""),
new TaskInputTypeResource()
.setName(PARAMS.TARGET_PATH)
.setType("String")
.setDefaultValue(""),
new TaskInputTypeResource()
.setName(PARAMS.COMPUTE_RESOURCE)
.setType("Long")
.setDefaultValue("")));
taskTypeResource.getOutPorts().addAll(
Arrays.asList(
new TaskOutPortTypeResource()
.setName("Out")
.setOrder(0),
new TaskOutPortTypeResource()
.setName("Error")
.setOrder(1))
);
return taskTypeResource;
}
public static final class PARAMS {
public static final String REMOTE_SOURCE_PATH = "remote_source_path";
public static final String TARGET_PATH = "target_path";
public static final String COMPUTE_RESOURCE = "compute_resource";
}
}
| 8,841 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/async-event-listener/src/main/java/org/apache/airavata/async/event | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/async-event-listener/src/main/java/org/apache/airavata/async/event/listener/Application.java | package org.apache.airavata.async.event.listener;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@SpringBootApplication
@Configuration
@ComponentScan
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}
}
| 8,842 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/async-event-listener/src/main/java/org/apache/airavata/async/event/listener | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/async-event-listener/src/main/java/org/apache/airavata/async/event/listener/service/ListenerService.java | package org.apache.airavata.async.event.listener.service;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Service
public class ListenerService {
private final RestTemplate restTemplate;
@Value("${api.server.url}")
private String apiServerUrl;
public ListenerService(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
public void onEventReceived(long workflowId, String event, String message) {
Map<String, String> boostrapData = new HashMap<>();
boostrapData.put("event", event);
boostrapData.put("message", message);
this.restTemplate.postForObject("http://" + apiServerUrl + "/workflow/" + workflowId + "/launch", boostrapData, Long.class);
}
}
| 8,843 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/async-event-listener/src/main/java/org/apache/airavata/async/event/listener | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/async-event-listener/src/main/java/org/apache/airavata/async/event/listener/messaging/KafkaReceiver.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.async.event.listener.messaging;
import org.apache.airavata.async.event.listener.service.ListenerService;
import org.springframework.kafka.annotation.KafkaListener;
import javax.annotation.Resource;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class KafkaReceiver {
@Resource
private ListenerService listenerService;
@KafkaListener(topics = "${listener.topic.name}", containerFactory = "kafkaListenerContainerFactory")
public void receiveProcesses(String payload) {
System.out.println("received process=" + payload);
long workflowId = Long.parseLong(payload.split(",")[0]);
String event = payload.split(",")[1];
String message = payload.split(",")[2];
listenerService.onEventReceived(workflowId, event, message);
}
//
// @KafkaListener(topics = "${task.event.topic.name}", containerFactory = "kafkaEventListenerContainerFactory")
// public void receiveTaskEvent(TaskContext taskContext) {
// System.out.println("received event for task id =" + taskContext.getTaskId());
// workerService.onTaskStateEvent(taskContext);
// }
}
| 8,844 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/async-event-listener/src/main/java/org/apache/airavata/async/event/listener | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/async-event-listener/src/main/java/org/apache/airavata/async/event/listener/messaging/ReceiverConfig.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.async.event.listener.messaging;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.config.KafkaListenerContainerFactory;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Configuration
@EnableKafka
public class ReceiverConfig {
@Value("${kafka.bootstrap-servers}")
private String bootstrapServers;
@Value("${listener.group.name}")
private String listenerGroupName;
@Bean
public Map<String, Object> consumerConfigs() {
Map<String, Object> props = new HashMap<>();
// list of host:port pairs used for establishing the initial connections to the Kakfa cluster
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
// allows a pool of processes to divide the work of consuming and processing records
props.put(ConsumerConfig.GROUP_ID_CONFIG, listenerGroupName);
return props;
}
@Bean
public ConsumerFactory<String, String> consumerFactory() {
return new DefaultKafkaConsumerFactory<String, String>(consumerConfigs());
}
@Bean
public KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<String, String>> kafkaListenerContainerFactory() {
ConcurrentKafkaListenerContainerFactory<String, String> factory =
new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(consumerFactory());
return factory;
}
@Bean
public KafkaReceiver receiver() {
return new KafkaReceiver();
}
}
| 8,845 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/event-sink/src/main/java/org/apache/airavata/k8s | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/event-sink/src/main/java/org/apache/airavata/k8s/sink/Application.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.sink;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@SpringBootApplication
@Configuration
@ComponentScan
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}
}
| 8,846 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/event-sink/src/main/java/org/apache/airavata/k8s/sink | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/event-sink/src/main/java/org/apache/airavata/k8s/sink/service/EventPersistingService.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.sink.service;
import org.apache.airavata.k8s.api.resources.task.TaskStatusResource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Service
public class EventPersistingService {
private final RestTemplate restTemplate;
@Value("${api.server.url}")
private String apiServerUrl;
public EventPersistingService(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
public void persistTaskState(long processId, long taskId, int state, String reason) {
System.out.println("Persisting task state event for process " + processId + ", task " + taskId + ", state "
+ state + ", reason " + reason);
TaskStatusResource statusResource = new TaskStatusResource();
statusResource.setTaskId(taskId);
statusResource.setTimeOfStateChange(System.currentTimeMillis());
statusResource.setState(state);
statusResource.setReason(reason);
this.restTemplate.postForObject("http://" + this.apiServerUrl + "/task/" + taskId + "/status", statusResource,
Long.class);
}
}
| 8,847 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/event-sink/src/main/java/org/apache/airavata/k8s/sink | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/event-sink/src/main/java/org/apache/airavata/k8s/sink/messaging/KafkaSender.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.sink.messaging;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class KafkaSender {
@Autowired
private KafkaTemplate<String, String> kafkaTemplate;
public void send(String topic, String payload) {
kafkaTemplate.send(topic, payload);
}
public void send(String topic, String key, String payload) {
kafkaTemplate.send(topic, key, payload);
}
}
| 8,848 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/event-sink/src/main/java/org/apache/airavata/k8s/sink | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/event-sink/src/main/java/org/apache/airavata/k8s/sink/messaging/KafkaReceiver.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.sink.messaging;
import org.apache.airavata.k8s.sink.service.EventPersistingService;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import javax.annotation.Resource;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class KafkaReceiver {
@Resource
private EventPersistingService eventPersistingService;
@KafkaListener(topics = "${task.event.topic.name}")
public void receiveTasks(String payload, Acknowledgment ack) {
System.out.println("received task status=" + payload);
String[] eventParts = payload.split(",");
long processId = Long.parseLong(eventParts[0]);
long taskId = Long.parseLong(eventParts[1]);
int state = Integer.parseInt(eventParts[2]);
String reason = "";
if (eventParts.length == 4 ) {
reason = eventParts[3];
}
eventPersistingService.persistTaskState(processId, taskId, state, reason);
ack.acknowledge();
}
}
| 8,849 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/event-sink/src/main/java/org/apache/airavata/k8s/sink | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/event-sink/src/main/java/org/apache/airavata/k8s/sink/messaging/SenderConfig.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.sink.messaging;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.serialization.StringSerializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.core.ProducerFactory;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Configuration
public class SenderConfig {
@Value("${kafka.bootstrap-servers}")
private String bootstrapServers;
@Bean
public Map<String, Object> producerConfigs() {
Map<String, Object> props = new HashMap<>();
// list of host:port pairs used for establishing the initial connections to the Kakfa cluster
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
return props;
}
@Bean
public ProducerFactory<String, String> producerFactory() {
return new DefaultKafkaProducerFactory<String, String>(producerConfigs());
}
@Bean
public KafkaTemplate<String, String> kafkaTemplate() {
return new KafkaTemplate<>(producerFactory());
}
@Bean
public KafkaSender kafkaSender() {
return new KafkaSender();
}
}
| 8,850 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/event-sink/src/main/java/org/apache/airavata/k8s/sink | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/event-sink/src/main/java/org/apache/airavata/k8s/sink/messaging/ReceiverConfig.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.sink.messaging;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.config.KafkaListenerContainerFactory;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
import org.springframework.kafka.listener.AbstractMessageListenerContainer;
import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Configuration
@EnableKafka
public class ReceiverConfig {
@Value("${kafka.bootstrap-servers}")
private String bootstrapServers;
@Value("${task.group.name}")
private String taskGroupName;
@Bean
public Map<String, Object> consumerConfigs() {
Map<String, Object> props = new HashMap<>();
// list of host:port pairs used for establishing the initial connections to the Kakfa cluster
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
// allows a pool of processes to divide the work of consuming and processing records
props.put(ConsumerConfig.GROUP_ID_CONFIG, taskGroupName);
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
return props;
}
@Bean
public ConsumerFactory<String, String> consumerFactory() {
return new DefaultKafkaConsumerFactory<String, String>(consumerConfigs());
}
@Bean
public KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<String, String>> kafkaListenerContainerFactory() {
ConcurrentKafkaListenerContainerFactory<String, String> factory =
new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(consumerFactory());
factory.getContainerProperties().setAckMode(AbstractMessageListenerContainer.AckMode.MANUAL_IMMEDIATE);
return factory;
}
@Bean
public KafkaReceiver receiver() {
return new KafkaReceiver();
}
}
| 8,851 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/helix-controller/src/main/java/org/apache/airavata | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/helix-controller/src/main/java/org/apache/airavata/helix/HelixController.java | package org.apache.airavata.helix;
import org.apache.airavata.helix.api.PropertyResolver;
import org.apache.helix.controller.HelixControllerMain;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class HelixController implements Runnable {
private static final Logger logger = LogManager.getLogger(HelixController.class);
private String clusterName;
private String controllerName;
private String zkAddress;
private org.apache.helix.HelixManager zkHelixManager;
private CountDownLatch startLatch = new CountDownLatch(1);
private CountDownLatch stopLatch = new CountDownLatch(1);
public HelixController(String propertyFile) throws IOException {
PropertyResolver propertyResolver = new PropertyResolver();
propertyResolver.loadInputStream(this.getClass().getClassLoader().getResourceAsStream(propertyFile));
this.clusterName = propertyResolver.get("helix.cluster.name");
this.controllerName = propertyResolver.get("helix.controller.name");
this.zkAddress = propertyResolver.get("zookeeper.connection.url");
}
public void run() {
try {
zkHelixManager = HelixControllerMain.startHelixController(zkAddress, clusterName,
controllerName, HelixControllerMain.STANDALONE);
startLatch.countDown();
stopLatch.await();
} catch (Exception ex) {
logger.error("Error in run() for Controller: " + controllerName + ", reason: " + ex, ex);
} finally {
disconnect();
}
}
public void start() {
new Thread(this).start();
try {
startLatch.await();
logger.info("Controller: " + controllerName + ", has connected to cluster: " + clusterName);
Runtime.getRuntime().addShutdownHook(
new Thread() {
@Override
public void run() {
disconnect();
}
}
);
} catch (InterruptedException ex) {
logger.error("Controller: " + controllerName + ", is interrupted! reason: " + ex, ex);
}
}
public void stop() {
stopLatch.countDown();
}
private void disconnect() {
if (zkHelixManager != null) {
logger.info("Controller: " + controllerName + ", has disconnected from cluster: " + clusterName);
zkHelixManager.disconnect();
}
}
public static void main(String args[]) {
try {
HelixController helixController = new HelixController("application.properties");
helixController.start();
} catch (IOException e) {
e.printStackTrace();
}
}
}
| 8,852 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/workflow-scheduler/src/main/java/org/apache/airavata/k8s | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/workflow-scheduler/src/main/java/org/apache/airavata/k8s/gfac/Application.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.gfac;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@SpringBootApplication
@Configuration
@ComponentScan
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}
}
| 8,853 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/workflow-scheduler/src/main/java/org/apache/airavata/k8s/gfac | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/workflow-scheduler/src/main/java/org/apache/airavata/k8s/gfac/core/HelixWorkflowManager.java | package org.apache.airavata.k8s.gfac.core;
import org.apache.airavata.k8s.api.resources.process.ProcessBootstrapDataResource;
import org.apache.airavata.k8s.api.resources.process.ProcessStatusResource;
import org.apache.airavata.k8s.api.resources.task.TaskResource;
import org.apache.helix.HelixManagerFactory;
import org.apache.helix.InstanceType;
import org.apache.helix.task.*;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class HelixWorkflowManager {
private static final Logger logger = LogManager.getLogger(HelixWorkflowManager.class);
private long processId;
private List<TaskResource> tasks;
private List<ProcessBootstrapDataResource> boostrapData;
// out port id, next task id
private Map<Long, Long> edgeMap;
// Todo abstract out these parameters to reusable class
private final RestTemplate restTemplate;
private String apiServerUrl;
private String zkConnectionString;
private String helixClusterName;
private String instanceName;
public HelixWorkflowManager(long processId, List<TaskResource> tasks, List<ProcessBootstrapDataResource> boostrapData,
Map<Long, Long> edgeMap, RestTemplate restTemplate, String apiServerUrl,
String zkConnectionString, String helixClusterName, String instanceName) {
this.processId = processId;
this.tasks = tasks;
this.edgeMap = edgeMap;
this.restTemplate = restTemplate;
this.apiServerUrl = apiServerUrl;
this.zkConnectionString = zkConnectionString;
this.helixClusterName = helixClusterName;
this.instanceName = instanceName;
this.boostrapData = boostrapData;
}
public void launchWorkflow() {
org.apache.helix.HelixManager helixManager = HelixManagerFactory.getZKHelixManager(helixClusterName, instanceName,
InstanceType.SPECTATOR, zkConnectionString);
try {
updateProcessStatus(ProcessStatusResource.State.CREATED);
Workflow.Builder workflowBuilder = createWorkflow(this.boostrapData);
WorkflowConfig.Builder config = new WorkflowConfig.Builder().setFailureThreshold(0);
workflowBuilder.setWorkflowConfig(config.build());
if (workflowBuilder == null) {
throw new Exception("Failed to create a workflow for process id " + processId);
}
Workflow workflow = workflowBuilder.build();
updateProcessStatus(ProcessStatusResource.State.VALIDATED);
helixManager.connect();
TaskDriver taskDriver = new TaskDriver(helixManager);
Runtime.getRuntime().addShutdownHook(
new Thread() {
@Override
public void run() {
helixManager.disconnect();
}
}
);
taskDriver.start(workflow);
updateProcessStatus(ProcessStatusResource.State.STARTED);
logger.info("Started workflow");
TaskState taskState = taskDriver.pollForWorkflowState(workflow.getName(), TaskState.COMPLETED, TaskState.FAILED, TaskState.STOPPED, TaskState.ABORTED);
updateProcessStatus(taskState);
System.out.println("Workflow state " + taskState.name());
} catch (Exception ex) {
logger.error("Error in connect() for Admin, reason: " + ex, ex);
}
}
private Workflow.Builder createWorkflow(List<ProcessBootstrapDataResource> bootstrapData) {
Optional<TaskResource> startingTask = tasks.stream().filter(TaskResource::isStartingTask).findFirst();
if (startingTask.isPresent()) {
Workflow.Builder workflow = new Workflow.Builder("Airavata_Process_" + processId).setExpiry(0);
createWorkflowRecursively(startingTask.get(), workflow, null, bootstrapData);
return workflow;
} else {
System.out.println("No starting task for this process " + processId);
updateProcessStatus(ProcessStatusResource.State.CANCELED, "No starting task for this process");
return null;
}
}
private void createWorkflowRecursively(TaskResource taskResource, Workflow.Builder workflow, Long parentTaskId,
List<ProcessBootstrapDataResource> boostrapData) {
TaskConfig.Builder taskBuilder = new TaskConfig.Builder().setTaskId("Task_" + taskResource.getId())
.setCommand(taskResource.getTaskType().getName());
Optional.ofNullable(taskResource.getInputs()).ifPresent(inputs -> inputs.forEach(input -> {
taskBuilder.addConfig(input.getName(), input.getValue());
}));
taskBuilder.addConfig("task_id", taskResource.getId() + "");
taskBuilder.addConfig("process_id", taskResource.getParentProcessId() + "");
Optional.ofNullable(boostrapData).ifPresent(data -> {
data.forEach(d -> taskBuilder.addConfig(d.getKey(), d.getValue()));
});
Optional.ofNullable(taskResource.getOutPorts()).ifPresent(outPorts -> outPorts.forEach(outPort -> {
Optional.ofNullable(edgeMap.get(outPort.getId())).ifPresent(nextTask -> {
Optional<TaskResource> nextTaskResource = tasks.stream().filter(task -> task.getId() == nextTask).findFirst();
nextTaskResource.ifPresent(t -> {
taskBuilder.addConfig("OUT_"+ outPort.getName(), "JOB_" + t.getId());
});
});
}));
List<TaskConfig> taskBuilds = new ArrayList<>();
taskBuilds.add(taskBuilder.build());
JobConfig.Builder job = new JobConfig.Builder()
.addTaskConfigs(taskBuilds)
.setFailureThreshold(0)
.setMaxAttemptsPerTask(3)
.setInstanceGroupTag(taskResource.getTaskType().getName());
workflow.addJob(("JOB_" + taskResource.getId()), job);
if (parentTaskId != null) {
workflow.addParentChildDependency("JOB_" + parentTaskId, "JOB_" + taskResource.getId());
}
Optional.ofNullable(taskResource.getOutPorts()).ifPresent(outPorts -> outPorts.forEach(outPort -> {
Optional.ofNullable(edgeMap.get(outPort.getId())).ifPresent(nextTask -> {
Optional<TaskResource> nextTaskResource = tasks.stream().filter(task -> task.getId() == nextTask).findFirst();
nextTaskResource.ifPresent(t -> {
createWorkflowRecursively(t, workflow, taskResource.getId(), null);
});
});
}));
}
private void updateProcessStatus(TaskState taskState) {
switch (taskState) {
case ABORTED:
updateProcessStatus(ProcessStatusResource.State.ABORTED);
break;
case COMPLETED:
updateProcessStatus(ProcessStatusResource.State.COMPLETED);
break;
case STOPPED:
updateProcessStatus(ProcessStatusResource.State.STOPPED);
break;
case NOT_STARTED:
updateProcessStatus(ProcessStatusResource.State.NOT_STARTED);
break;
case FAILED:
updateProcessStatus(ProcessStatusResource.State.FAILED);
break;
case IN_PROGRESS:
updateProcessStatus(ProcessStatusResource.State.EXECUTING);
break;
}
}
private void updateProcessStatus(ProcessStatusResource.State state) {
updateProcessStatus(state, "");
}
private void updateProcessStatus(ProcessStatusResource.State state, String reason) {
this.restTemplate.postForObject("http://" + apiServerUrl + "/process/" + this.processId + "/status",
new ProcessStatusResource()
.setState(state.getValue())
.setReason(reason)
.setTimeOfStateChange(System.currentTimeMillis()),
Long.class);
}
}
| 8,854 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/workflow-scheduler/src/main/java/org/apache/airavata/k8s/gfac | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/workflow-scheduler/src/main/java/org/apache/airavata/k8s/gfac/service/WorkerService.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.gfac.service;
import org.apache.airavata.k8s.api.resources.process.ProcessResource;
import org.apache.airavata.k8s.api.resources.task.TaskDagResource;
import org.apache.airavata.k8s.api.resources.task.TaskResource;
import org.apache.airavata.k8s.gfac.core.HelixWorkflowManager;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Service
public class WorkerService {
private final RestTemplate restTemplate;
ExecutorService executorService = Executors.newFixedThreadPool(10);
@Value("${api.server.url}")
private String apiServerUrl;
@Value("${zookeeper.connection.url}")
private String zkConnectionString;
@Value("${helix.cluster.name}")
private String helixClusterName;
@Value("${instance.name}")
private String instanceName;
public WorkerService(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
public void launchProcess(long processId) {
System.out.println("Launching process " + processId);
ProcessResource processResource = this.restTemplate.getForObject("http://" + apiServerUrl + "/process/" + processId,
ProcessResource.class);
List<TaskResource> taskResources = processResource.getTasks();
Set<TaskDagResource> takDagSet = this.restTemplate.exchange("http://" + apiServerUrl + "/task/dag/"
+ processId, HttpMethod.GET, null, new ParameterizedTypeReference<Set<TaskDagResource>>() {})
.getBody();
final Map<Long, Long> edgeMap = new HashMap<>();
Optional.ofNullable(takDagSet)
.ifPresent(dags -> dags.forEach(dag ->
edgeMap.put(dag.getSourceOutPort().getId(), dag.getTargetTask().getId())));
System.out.println("Starting to execute process " + processId);
//ProcessLifeCycleManager manager =
// new ProcessLifeCycleManager(processId, taskResources, edgeMap, kafkaSender, restTemplate, apiServerUrl);
//manager.init();
//manager.start();
//processLifecycleStore.put(processId, manager);
final HelixWorkflowManager helixWorkflowManager = new HelixWorkflowManager(processId, taskResources,
processResource.getProcessBootstrapData(), edgeMap,
restTemplate, apiServerUrl,
zkConnectionString, helixClusterName, instanceName);
executorService.execute(new Runnable() {
@Override
public void run() {
helixWorkflowManager.launchWorkflow();
}
});
}
}
| 8,855 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/workflow-scheduler/src/main/java/org/apache/airavata/k8s/gfac | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/workflow-scheduler/src/main/java/org/apache/airavata/k8s/gfac/messaging/KafkaReceiver.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.gfac.messaging;
import org.apache.airavata.k8s.gfac.service.WorkerService;
import org.springframework.kafka.annotation.KafkaListener;
import javax.annotation.Resource;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class KafkaReceiver {
@Resource
private WorkerService workerService;
@KafkaListener(topics = "${scheduler.topic.name}", containerFactory = "kafkaListenerContainerFactory")
public void receiveProcesses(String payload) {
System.out.println("received process=" + payload);
workerService.launchProcess(Long.parseLong(payload));
}
//
// @KafkaListener(topics = "${task.event.topic.name}", containerFactory = "kafkaEventListenerContainerFactory")
// public void receiveTaskEvent(TaskContext taskContext) {
// System.out.println("received event for task id =" + taskContext.getTaskId());
// workerService.onTaskStateEvent(taskContext);
// }
}
| 8,856 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/workflow-scheduler/src/main/java/org/apache/airavata/k8s/gfac | Create_ds/airavata-sandbox/airavata-kubernetes/modules/microservices/workflow-scheduler/src/main/java/org/apache/airavata/k8s/gfac/messaging/ReceiverConfig.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.gfac.messaging;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.config.KafkaListenerContainerFactory;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
@Configuration
@EnableKafka
public class ReceiverConfig {
@Value("${kafka.bootstrap-servers}")
private String bootstrapServers;
@Value("${scheduler.group.name}")
private String schedulerGroupName;
@Bean
public Map<String, Object> consumerConfigs() {
Map<String, Object> props = new HashMap<>();
// list of host:port pairs used for establishing the initial connections to the Kakfa cluster
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
// allows a pool of processes to divide the work of consuming and processing records
props.put(ConsumerConfig.GROUP_ID_CONFIG, schedulerGroupName);
return props;
}
@Bean
public ConsumerFactory<String, String> consumerFactory() {
return new DefaultKafkaConsumerFactory<String, String>(consumerConfigs());
}
@Bean
public KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<String, String>> kafkaListenerContainerFactory() {
ConcurrentKafkaListenerContainerFactory<String, String> factory =
new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(consumerFactory());
return factory;
}
@Bean
public KafkaReceiver receiver() {
return new KafkaReceiver();
}
}
| 8,857 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/compute/ComputeResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.compute;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ComputeResource {
private long id;
private String name;
private String host;
private String userName;
private String password;
private String communicationType;
public long getId() {
return id;
}
public ComputeResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public ComputeResource setName(String name) {
this.name = name;
return this;
}
public String getHost() {
return host;
}
public ComputeResource setHost(String host) {
this.host = host;
return this;
}
public String getUserName() {
return userName;
}
public ComputeResource setUserName(String userName) {
this.userName = userName;
return this;
}
public String getPassword() {
return password;
}
public ComputeResource setPassword(String password) {
this.password = password;
return this;
}
public String getCommunicationType() {
return communicationType;
}
public ComputeResource setCommunicationType(String communicationType) {
this.communicationType = communicationType;
return this;
}
}
| 8,858 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/workflow/WorkflowResource.java | package org.apache.airavata.k8s.api.resources.workflow;
import java.util.ArrayList;
import java.util.List;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class WorkflowResource {
private long id;
private String name;
private String workflowGraphXML;
private List<Long> processIds = new ArrayList<>();
public long getId() {
return id;
}
public WorkflowResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public WorkflowResource setName(String name) {
this.name = name;
return this;
}
public String getWorkflowGraphXML() {
return workflowGraphXML;
}
public WorkflowResource setWorkflowGraphXML(String workflowGraphXML) {
this.workflowGraphXML = workflowGraphXML;
return this;
}
public List<Long> getProcessIds() {
return processIds;
}
public WorkflowResource setProcessIds(List<Long> processIds) {
this.processIds = processIds;
return this;
}
}
| 8,859 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task/TaskParamResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.task;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class TaskParamResource {
private long id;
private String key;
private String value;
public long getId() {
return id;
}
public TaskParamResource setId(long id) {
this.id = id;
return this;
}
public String getKey() {
return key;
}
public TaskParamResource setKey(String key) {
this.key = key;
return this;
}
public String getValue() {
return value;
}
public TaskParamResource setValue(String value) {
this.value = value;
return this;
}
}
| 8,860 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task/TaskInputResource.java | package org.apache.airavata.k8s.api.resources.task;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class TaskInputResource {
private long id;
private String name;
private String value;
private String type;
private String importFrom;
public long getId() {
return id;
}
public TaskInputResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public TaskInputResource setName(String name) {
this.name = name;
return this;
}
public String getValue() {
return value;
}
public TaskInputResource setValue(String value) {
this.value = value;
return this;
}
public String getType() {
return type;
}
public TaskInputResource setType(String type) {
this.type = type;
return this;
}
public String getImportFrom() {
return importFrom;
}
public TaskInputResource setImportFrom(String importFrom) {
this.importFrom = importFrom;
return this;
}
}
| 8,861 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task/TaskDagResource.java | package org.apache.airavata.k8s.api.resources.task;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class TaskDagResource {
private long id;
private TaskOutPortResource sourceOutPort;
private TaskResource targetTask;
public long getId() {
return id;
}
public TaskDagResource setId(long id) {
this.id = id;
return this;
}
public TaskOutPortResource getSourceOutPort() {
return sourceOutPort;
}
public TaskDagResource setSourceOutPort(TaskOutPortResource sourceOutPort) {
this.sourceOutPort = sourceOutPort;
return this;
}
public TaskResource getTargetTask() {
return targetTask;
}
public TaskDagResource setTargetTask(TaskResource targetTask) {
this.targetTask = targetTask;
return this;
}
}
| 8,862 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task/TaskStatusResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.task;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class TaskStatusResource {
private long id;
private int state;
private String stateStr;
private long timeOfStateChange;
private String reason;
private long taskId;
public long getId() {
return id;
}
public TaskStatusResource setId(long id) {
this.id = id;
return this;
}
public int getState() {
return state;
}
public TaskStatusResource setState(int state) {
this.state = state;
return this;
}
public long getTimeOfStateChange() {
return timeOfStateChange;
}
public TaskStatusResource setTimeOfStateChange(long timeOfStateChange) {
this.timeOfStateChange = timeOfStateChange;
return this;
}
public String getReason() {
return reason;
}
public TaskStatusResource setReason(String reason) {
this.reason = reason;
return this;
}
public long getTaskId() {
return taskId;
}
public TaskStatusResource setTaskId(long taskId) {
this.taskId = taskId;
return this;
}
public String getStateStr() {
return stateStr;
}
public TaskStatusResource setStateStr(String stateStr) {
this.stateStr = stateStr;
return this;
}
public static final class State {
public static final int CREATED = 0;
public static final int SCHEDULED = 1;
public static final int EXECUTING = 2;
public static final int COMPLETED = 3;
public static final int FAILED = 4;
public static final int CANCELED = 5;
}
}
| 8,863 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task/TaskOutPortResource.java | package org.apache.airavata.k8s.api.resources.task;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class TaskOutPortResource {
private long id;
private String name;
private int referenceId = 0;
private TaskResource taskResource;
public long getId() {
return id;
}
public TaskOutPortResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public TaskOutPortResource setName(String name) {
this.name = name;
return this;
}
public int getReferenceId() {
return referenceId;
}
public TaskOutPortResource setReferenceId(int referenceId) {
this.referenceId = referenceId;
return this;
}
public TaskResource getTaskResource() {
return taskResource;
}
public TaskOutPortResource setTaskResource(TaskResource taskResource) {
this.taskResource = taskResource;
return this;
}
}
| 8,864 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task/TaskResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.task;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import java.util.ArrayList;
import java.util.List;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class TaskResource {
private long id;
private int referenceId; // for workflows
private String name;
private TaskTypeResource taskType;
private String taskTypeStr;
private long parentProcessId;
private long creationTime;
private long lastUpdateTime;
private List<TaskStatusResource> taskStatus = new ArrayList<>();
private String taskDetail;
private List<Long> taskErrorIds = new ArrayList<>();
private List<TaskInputResource> inputs = new ArrayList<>();
private List<TaskOutputResource> outputs = new ArrayList<>();
private List<TaskOutPortResource> outPorts = new ArrayList<>();
private List<Long> jobIds;
private int order;
private boolean startingTask;
private boolean stoppingTask;
public long getId() {
return id;
}
public TaskResource setId(long id) {
this.id = id;
return this;
}
public TaskTypeResource getTaskType() {
return taskType;
}
public TaskResource setTaskType(TaskTypeResource taskType) {
this.taskType = taskType;
return this;
}
public long getParentProcessId() {
return parentProcessId;
}
public TaskResource setParentProcessId(long parentProcessId) {
this.parentProcessId = parentProcessId;
return this;
}
public long getCreationTime() {
return creationTime;
}
public TaskResource setCreationTime(long creationTime) {
this.creationTime = creationTime;
return this;
}
public long getLastUpdateTime() {
return lastUpdateTime;
}
public TaskResource setLastUpdateTime(long lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
return this;
}
public List<TaskStatusResource> getTaskStatus() {
return taskStatus;
}
public TaskResource setTaskStatus(List<TaskStatusResource> taskStatus) {
this.taskStatus = taskStatus;
return this;
}
public String getTaskDetail() {
return taskDetail;
}
public TaskResource setTaskDetail(String taskDetail) {
this.taskDetail = taskDetail;
return this;
}
public List<Long> getTaskErrorIds() {
return taskErrorIds;
}
public TaskResource setTaskErrorIds(List<Long> taskErrorIds) {
this.taskErrorIds = taskErrorIds;
return this;
}
public List<Long> getJobIds() {
return jobIds;
}
public TaskResource setJobIds(List<Long> jobIds) {
this.jobIds = jobIds;
return this;
}
public List<TaskInputResource> getInputs() {
return inputs;
}
public TaskResource setInputs(List<TaskInputResource> inputs) {
this.inputs = inputs;
return this;
}
public List<TaskOutputResource> getOutputs() {
return outputs;
}
public TaskResource setOutputs(List<TaskOutputResource> outputs) {
this.outputs = outputs;
return this;
}
public String getTaskTypeStr() {
return taskTypeStr;
}
public TaskResource setTaskTypeStr(String taskTypeStr) {
this.taskTypeStr = taskTypeStr;
return this;
}
public int getOrder() {
return order;
}
public TaskResource setOrder(int order) {
this.order = order;
return this;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<TaskOutPortResource> getOutPorts() {
return outPorts;
}
public void setOutPorts(List<TaskOutPortResource> outPorts) {
this.outPorts = outPorts;
}
public boolean isStartingTask() {
return startingTask;
}
public TaskResource setStartingTask(boolean startingTask) {
this.startingTask = startingTask;
return this;
}
public boolean isStoppingTask() {
return stoppingTask;
}
public TaskResource setStoppingTask(boolean stoppingTask) {
this.stoppingTask = stoppingTask;
return this;
}
public int getReferenceId() {
return referenceId;
}
public TaskResource setReferenceId(int referenceId) {
this.referenceId = referenceId;
return this;
}
public static final class TaskTypes {
public static final int ENV_SETUP = 0;
public static final int INGRESS_DATA_STAGING = 1;
public static final int EGRESS_DATA_STAGING = 2;
public static final int JOB_SUBMISSION = 3;
public static final int ENV_CLEANUP = 4;
public static final int MONITORING = 5;
public static final int OUTPUT_FETCHING = 6;
}
}
| 8,865 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task/TaskOutputResource.java | package org.apache.airavata.k8s.api.resources.task;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class TaskOutputResource {
private long id;
private String name;
private String value;
private String type;
private String exportTo;
public long getId() {
return id;
}
public TaskOutputResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public TaskOutputResource setName(String name) {
this.name = name;
return this;
}
public String getValue() {
return value;
}
public TaskOutputResource setValue(String value) {
this.value = value;
return this;
}
public String getType() {
return type;
}
public TaskOutputResource setType(String type) {
this.type = type;
return this;
}
public String getExportTo() {
return exportTo;
}
public TaskOutputResource setExportTo(String exportTo) {
this.exportTo = exportTo;
return this;
}
}
| 8,866 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task/type/TaskInputTypeResource.java | package org.apache.airavata.k8s.api.resources.task.type;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class TaskInputTypeResource {
private long id;
private String name;
private String type;
private String defaultValue;
public long getId() {
return id;
}
public TaskInputTypeResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public TaskInputTypeResource setName(String name) {
this.name = name;
return this;
}
public String getType() {
return type;
}
public TaskInputTypeResource setType(String type) {
this.type = type;
return this;
}
public String getDefaultValue() {
return defaultValue;
}
public TaskInputTypeResource setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
return this;
}
}
| 8,867 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task/type/TaskTypeResource.java | package org.apache.airavata.k8s.api.resources.task.type;
import java.util.ArrayList;
import java.util.List;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class TaskTypeResource {
private long id;
private String name;
private String topicName;
private String icon;
private List<TaskInputTypeResource> inputTypes = new ArrayList<>();
private List<TaskOutputTypeResource> outputTypes = new ArrayList<>();
private List<TaskOutPortTypeResource> outPorts = new ArrayList<>();
public long getId() {
return id;
}
public TaskTypeResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public TaskTypeResource setName(String name) {
this.name = name;
return this;
}
public String getTopicName() {
return topicName;
}
public TaskTypeResource setTopicName(String topicName) {
this.topicName = topicName;
return this;
}
public List<TaskInputTypeResource> getInputTypes() {
return inputTypes;
}
public TaskTypeResource setInputTypes(List<TaskInputTypeResource> inputTypes) {
this.inputTypes = inputTypes;
return this;
}
public List<TaskOutputTypeResource> getOutputTypes() {
return outputTypes;
}
public TaskTypeResource setOutputTypes(List<TaskOutputTypeResource> outputTypes) {
this.outputTypes = outputTypes;
return this;
}
public List<TaskOutPortTypeResource> getOutPorts() {
return outPorts;
}
public TaskTypeResource setOutPorts(List<TaskOutPortTypeResource> outPorts) {
this.outPorts = outPorts;
return this;
}
public String getIcon() {
return icon;
}
public TaskTypeResource setIcon(String icon) {
this.icon = icon;
return this;
}
}
| 8,868 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task/type/TaskOutputTypeResource.java | package org.apache.airavata.k8s.api.resources.task.type;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class TaskOutputTypeResource {
private long id;
private String name;
private String type;
public long getId() {
return id;
}
public TaskOutputTypeResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public TaskOutputTypeResource setName(String name) {
this.name = name;
return this;
}
public String getType() {
return type;
}
public TaskOutputTypeResource setType(String type) {
this.type = type;
return this;
}
}
| 8,869 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/task/type/TaskOutPortTypeResource.java | package org.apache.airavata.k8s.api.resources.task.type;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class TaskOutPortTypeResource {
private long id;
private String name;
private int order = 0;
public long getId() {
return id;
}
public TaskOutPortTypeResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public TaskOutPortTypeResource setName(String name) {
this.name = name;
return this;
}
public int getOrder() {
return order;
}
public TaskOutPortTypeResource setOrder(int order) {
this.order = order;
return this;
}
}
| 8,870 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/experiment/ExperimentInputResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.experiment;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ExperimentInputResource {
private long id;
private String name;
private int type;
private String value;
private String arguments;
public long getId() {
return id;
}
public ExperimentInputResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public ExperimentInputResource setName(String name) {
this.name = name;
return this;
}
public int getType() {
return type;
}
public ExperimentInputResource setType(int type) {
this.type = type;
return this;
}
public String getValue() {
return value;
}
public ExperimentInputResource setValue(String value) {
this.value = value;
return this;
}
public String getArguments() {
return arguments;
}
public ExperimentInputResource setArguments(String arguments) {
this.arguments = arguments;
return this;
}
public static final class Types {
public static final int STRING = 0;
public static final int INTEGER = 1;
public static final int FLOAT = 2;
public static final int URI = 3;
public static final int URI_COLLECTION = 4;
public static final int STDOUT = 5;
public static final int STDERR = 6;
}
}
| 8,871 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/experiment/ExperimentOutputResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.experiment;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ExperimentOutputResource {
private long id;
private String name;
private String value;
private int type;
public long getId() {
return id;
}
public ExperimentOutputResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public ExperimentOutputResource setName(String name) {
this.name = name;
return this;
}
public String getValue() {
return value;
}
public ExperimentOutputResource setValue(String value) {
this.value = value;
return this;
}
public int getType() {
return type;
}
public ExperimentOutputResource setType(int type) {
this.type = type;
return this;
}
public static final class Types {
public static final int STRING = 0;
public static final int INTEGER = 1;
public static final int FLOAT = 2;
public static final int URI = 3;
public static final int URI_COLLECTION = 4;
public static final int STDOUT = 5;
public static final int STDERR = 6;
}
}
| 8,872 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/experiment/ExperimentStatusResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.experiment;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ExperimentStatusResource {
private long id;
private int state;
private String stateStr;
private long timeOfStateChange;
private String reason;
public long getId() {
return id;
}
public ExperimentStatusResource setId(long id) {
this.id = id;
return this;
}
public int getState() {
return state;
}
public ExperimentStatusResource setState(int state) {
this.state = state;
return this;
}
public String getStateStr() {
return stateStr;
}
public ExperimentStatusResource setStateStr(String stateStr) {
this.stateStr = stateStr;
return this;
}
public long getTimeOfStateChange() {
return timeOfStateChange;
}
public ExperimentStatusResource setTimeOfStateChange(long timeOfStateChange) {
this.timeOfStateChange = timeOfStateChange;
return this;
}
public String getReason() {
return reason;
}
public ExperimentStatusResource setReason(String reason) {
this.reason = reason;
return this;
}
}
| 8,873 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/experiment/ExperimentResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.experiment;
import java.util.ArrayList;
import java.util.List;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ExperimentResource {
private long id;
private String experimentName;
private long creationTime;
private String description;
private long applicationInterfaceId;
private String applicationInterfaceName;
private long applicationDeploymentId;
private String applicationDeploymentName;
private List<ExperimentInputResource> experimentInputs = new ArrayList<>();
private List<ExperimentOutputResource> experimentOutputs = new ArrayList<>();
private List<ExperimentStatusResource> experimentStatus = new ArrayList<>();
private List<Long> errorsIds = new ArrayList<>();
private List<Long> processIds = new ArrayList<>();
public long getId() {
return id;
}
public ExperimentResource setId(long id) {
this.id = id;
return this;
}
public String getExperimentName() {
return experimentName;
}
public ExperimentResource setExperimentName(String experimentName) {
this.experimentName = experimentName;
return this;
}
public long getCreationTime() {
return creationTime;
}
public ExperimentResource setCreationTime(long creationTime) {
this.creationTime = creationTime;
return this;
}
public String getDescription() {
return description;
}
public ExperimentResource setDescription(String description) {
this.description = description;
return this;
}
public long getApplicationInterfaceId() {
return applicationInterfaceId;
}
public ExperimentResource setApplicationInterfaceId(long applicationInterfaceId) {
this.applicationInterfaceId = applicationInterfaceId;
return this;
}
public long getApplicationDeploymentId() {
return applicationDeploymentId;
}
public ExperimentResource setApplicationDeploymentId(long applicationDeploymentId) {
this.applicationDeploymentId = applicationDeploymentId;
return this;
}
public List<ExperimentInputResource> getExperimentInputs() {
return experimentInputs;
}
public ExperimentResource setExperimentInputs(List<ExperimentInputResource> experimentInputs) {
this.experimentInputs = experimentInputs;
return this;
}
public List<ExperimentOutputResource> getExperimentOutputs() {
return experimentOutputs;
}
public ExperimentResource setExperimentOutputs(List<ExperimentOutputResource> experimentOutputs) {
this.experimentOutputs = experimentOutputs;
return this;
}
public List<ExperimentStatusResource> getExperimentStatus() {
return experimentStatus;
}
public ExperimentResource setExperimentStatus(List<ExperimentStatusResource> experimentStatus) {
this.experimentStatus = experimentStatus;
return this;
}
public List<Long> getErrorsIds() {
return errorsIds;
}
public ExperimentResource setErrorsIds(List<Long> errorsIds) {
this.errorsIds = errorsIds;
return this;
}
public List<Long> getProcessIds() {
return processIds;
}
public ExperimentResource setProcessIds(List<Long> processIds) {
this.processIds = processIds;
return this;
}
public String getApplicationInterfaceName() {
return applicationInterfaceName;
}
public ExperimentResource setApplicationInterfaceName(String applicationInterfaceName) {
this.applicationInterfaceName = applicationInterfaceName;
return this;
}
public String getApplicationDeploymentName() {
return applicationDeploymentName;
}
public ExperimentResource setApplicationDeploymentName(String applicationDeploymentName) {
this.applicationDeploymentName = applicationDeploymentName;
return this;
}
}
| 8,874 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/application/ApplicationOutputResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.application;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ApplicationOutputResource {
private long id;
private String name;
private int type;
private String value;
public long getId() {
return id;
}
public ApplicationOutputResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public ApplicationOutputResource setName(String name) {
this.name = name;
return this;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getValue() {
return value;
}
public ApplicationOutputResource setValue(String value) {
this.value = value;
return this;
}
}
| 8,875 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/application/ApplicationDeploymentResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.application;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ApplicationDeploymentResource {
private long id;
private String name;
private long applicationModuleId;
private long computeResourceId;
private String executablePath;
private String preJobCommand;
private String postJobCommand;
public long getId() {
return id;
}
public ApplicationDeploymentResource setId(long id) {
this.id = id;
return this;
}
public long getApplicationModuleId() {
return applicationModuleId;
}
public ApplicationDeploymentResource setApplicationModuleId(long applicationModuleId) {
this.applicationModuleId = applicationModuleId;
return this;
}
public long getComputeResourceId() {
return computeResourceId;
}
public ApplicationDeploymentResource setComputeResourceId(long computeResourceId) {
this.computeResourceId = computeResourceId;
return this;
}
public String getExecutablePath() {
return executablePath;
}
public ApplicationDeploymentResource setExecutablePath(String executablePath) {
this.executablePath = executablePath;
return this;
}
public String getPreJobCommand() {
return preJobCommand;
}
public ApplicationDeploymentResource setPreJobCommand(String preJobCommand) {
this.preJobCommand = preJobCommand;
return this;
}
public String getPostJobCommand() {
return postJobCommand;
}
public ApplicationDeploymentResource setPostJobCommand(String postJobCommand) {
this.postJobCommand = postJobCommand;
return this;
}
public String getName() {
return name;
}
public ApplicationDeploymentResource setName(String name) {
this.name = name;
return this;
}
}
| 8,876 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/application/ApplicationModuleResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.application;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ApplicationModuleResource {
private long id;
private String name;
private String version;
private String description;
public long getId() {
return id;
}
public ApplicationModuleResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public ApplicationModuleResource setName(String name) {
this.name = name;
return this;
}
public String getVersion() {
return version;
}
public ApplicationModuleResource setVersion(String version) {
this.version = version;
return this;
}
public String getDescription() {
return description;
}
public ApplicationModuleResource setDescription(String description) {
this.description = description;
return this;
}
}
| 8,877 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/application/ApplicationIfaceResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.application;
import java.util.ArrayList;
import java.util.List;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ApplicationIfaceResource {
private long id;
private String name;
private String description;
private long applicationModuleId;
private List<ApplicationInputResource> inputs = new ArrayList<>();
private List<ApplicationOutputResource> outputs = new ArrayList<>();
public long getId() {
return id;
}
public ApplicationIfaceResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public ApplicationIfaceResource setName(String name) {
this.name = name;
return this;
}
public String getDescription() {
return description;
}
public ApplicationIfaceResource setDescription(String description) {
this.description = description;
return this;
}
public long getApplicationModuleId() {
return applicationModuleId;
}
public ApplicationIfaceResource setApplicationModuleId(long applicationModuleId) {
this.applicationModuleId = applicationModuleId;
return this;
}
public List<ApplicationInputResource> getInputs() {
return inputs;
}
public ApplicationIfaceResource setInputs(List<ApplicationInputResource> inputs) {
this.inputs = inputs;
return this;
}
public List<ApplicationOutputResource> getOutputs() {
return outputs;
}
public ApplicationIfaceResource setOutputs(List<ApplicationOutputResource> outputs) {
this.outputs = outputs;
return this;
}
}
| 8,878 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/application/ApplicationInputResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.application;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ApplicationInputResource {
private long id;
private String name;
private int type;
private String value;
private String arguments;
public long getId() {
return id;
}
public ApplicationInputResource setId(long id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public ApplicationInputResource setName(String name) {
this.name = name;
return this;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getValue() {
return value;
}
public ApplicationInputResource setValue(String value) {
this.value = value;
return this;
}
public String getArguments() {
return arguments;
}
public ApplicationInputResource setArguments(String arguments) {
this.arguments = arguments;
return this;
}
}
| 8,879 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/data/DataEntryResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.data;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class DataEntryResource {
private long id;
private String dataType;
private String name;
public long getId() {
return id;
}
public DataEntryResource setId(long id) {
this.id = id;
return this;
}
public String getDataType() {
return dataType;
}
public DataEntryResource setDataType(String dataType) {
this.dataType = dataType;
return this;
}
public String getName() {
return name;
}
public DataEntryResource setName(String name) {
this.name = name;
return this;
}
}
| 8,880 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/process/ProcessBootstrapDataResource.java | package org.apache.airavata.k8s.api.resources.process;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ProcessBootstrapDataResource {
private long id;
private String key;
private String value;
public long getId() {
return id;
}
public ProcessBootstrapDataResource setId(long id) {
this.id = id;
return this;
}
public String getKey() {
return key;
}
public ProcessBootstrapDataResource setKey(String key) {
this.key = key;
return this;
}
public String getValue() {
return value;
}
public ProcessBootstrapDataResource setValue(String value) {
this.value = value;
return this;
}
}
| 8,881 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/process/ProcessResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.process;
import org.apache.airavata.k8s.api.resources.task.TaskResource;
import java.util.ArrayList;
import java.util.List;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ProcessResource {
private long id;
private String name;
private long experimentId;
private long workflowId;
private long creationTime;
private long lastUpdateTime;
private List<ProcessStatusResource> processStatuses = new ArrayList<>();
private List<TaskResource> tasks = new ArrayList<>();
private List<Long> processErrorIds = new ArrayList<>();
private List<ProcessBootstrapDataResource> processBootstrapData = new ArrayList<>();
private String taskDag;
private String experimentDataDir;
private String processType;
public long getId() {
return id;
}
public ProcessResource setId(long id) {
this.id = id;
return this;
}
public long getExperimentId() {
return experimentId;
}
public ProcessResource setExperimentId(long experimentId) {
this.experimentId = experimentId;
return this;
}
public long getCreationTime() {
return creationTime;
}
public ProcessResource setCreationTime(long creationTime) {
this.creationTime = creationTime;
return this;
}
public long getLastUpdateTime() {
return lastUpdateTime;
}
public ProcessResource setLastUpdateTime(long lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
return this;
}
public List<ProcessStatusResource> getProcessStatuses() {
return processStatuses;
}
public ProcessResource setProcessStatuses(List<ProcessStatusResource> processStatuses) {
this.processStatuses = processStatuses;
return this;
}
public List<TaskResource> getTasks() {
return tasks;
}
public ProcessResource setTasks(List<TaskResource> tasks) {
this.tasks = tasks;
return this;
}
public String getTaskDag() {
return taskDag;
}
public ProcessResource setTaskDag(String taskDag) {
this.taskDag = taskDag;
return this;
}
public List<Long> getProcessErrorIds() {
return processErrorIds;
}
public ProcessResource setProcessErrorIds(List<Long> processErrorIds) {
this.processErrorIds = processErrorIds;
return this;
}
public String getExperimentDataDir() {
return experimentDataDir;
}
public ProcessResource setExperimentDataDir(String experimentDataDir) {
this.experimentDataDir = experimentDataDir;
return this;
}
public String getProcessType() {
return processType;
}
public ProcessResource setProcessType(String processType) {
this.processType = processType;
return this;
}
public String getName() {
return name;
}
public ProcessResource setName(String name) {
this.name = name;
return this;
}
public long getWorkflowId() {
return workflowId;
}
public ProcessResource setWorkflowId(long workflowId) {
this.workflowId = workflowId;
return this;
}
public List<ProcessBootstrapDataResource> getProcessBootstrapData() {
return processBootstrapData;
}
public ProcessResource setProcessBootstrapData(List<ProcessBootstrapDataResource> processBootstrapData) {
this.processBootstrapData = processBootstrapData;
return this;
}
}
| 8,882 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources | Create_ds/airavata-sandbox/airavata-kubernetes/modules/api-resource/src/main/java/org/apache/airavata/k8s/api/resources/process/ProcessStatusResource.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.api.resources.process;
import java.util.HashMap;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ProcessStatusResource {
private long id;
private int state;
private String stateStr;
private long timeOfStateChange;
private String reason;
private long processId;
public long getId() {
return id;
}
public ProcessStatusResource setId(long id) {
this.id = id;
return this;
}
public int getState() {
return state;
}
public ProcessStatusResource setState(int state) {
this.state = state;
return this;
}
public long getTimeOfStateChange() {
return timeOfStateChange;
}
public ProcessStatusResource setTimeOfStateChange(long timeOfStateChange) {
this.timeOfStateChange = timeOfStateChange;
return this;
}
public String getReason() {
return reason;
}
public ProcessStatusResource setReason(String reason) {
this.reason = reason;
return this;
}
public long getProcessId() {
return processId;
}
public ProcessStatusResource setProcessId(long processId) {
this.processId = processId;
return this;
}
public String getStateStr() {
return stateStr;
}
public ProcessStatusResource setStateStr(String stateStr) {
this.stateStr = stateStr;
return this;
}
public static enum State {
CREATED(0),
VALIDATED(1),
STARTED(2),
PRE_PROCESSING(3),
CONFIGURING_WORKSPACE(4),
INPUT_DATA_STAGING(5),
EXECUTING(6),
MONITORING(7),
OUTPUT_DATA_STAGING(8),
POST_PROCESSING(9),
COMPLETED(10),
FAILED(11),
CANCELLING(12),
CANCELED(13),
ABORTED(14),
STOPPED(15),
NOT_STARTED(16);
private final int value;
private State(int value) {
this.value = value;
}
private static Map<Integer, State> map = new HashMap<>();
static {
for (State state : State.values()) {
map.put(state.value, state);
}
}
public static State valueOf(int taskState) {
return map.get(taskState);
}
/**
* Get the integer value of this enum value, as defined in the Thrift IDL.
*/
public int getValue() {
return value;
}
}
}
| 8,883 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/agent-core/src/main/java/org/apache/airavata/agents | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/agent-core/src/main/java/org/apache/airavata/agents/core/AsyncCommandStatus.java | package org.apache.airavata.agents.core;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public enum AsyncCommandStatus {
PENDING,
RUNNING,
SUCCESS,
PAUSE,
WARNING,
ERROR,
CANCEL,
MANUAL_RECOVERY;
}
| 8,884 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/agent-core/src/main/java/org/apache/airavata/agents | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/agent-core/src/main/java/org/apache/airavata/agents/core/AsyncOperation.java | package org.apache.airavata.agents.core;
import org.apache.airavata.k8s.api.resources.compute.ComputeResource;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public abstract class AsyncOperation {
private ComputeResource computeResource;
public AsyncOperation(ComputeResource computeResource) {
this.computeResource = computeResource;
}
public abstract void executeCommandAsync(String command, long callbackWorkflowId);
public ComputeResource getComputeResource() {
return computeResource;
}
}
| 8,885 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/agent-core/src/main/java/org/apache/airavata/agents | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/agent-core/src/main/java/org/apache/airavata/agents/core/StatusPublisher.java | package org.apache.airavata.agents.core;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.ProducerRecord;
import java.util.Properties;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class StatusPublisher {
private String brokerUrl;
private String topicName;
private Producer<String, String> eventProducer;
public StatusPublisher(String brokerUrl, String topicName) {
this.brokerUrl = brokerUrl;
this.topicName = topicName;
this.initializeKafkaEventProducer();
}
public void publishStatus(long callbackWorkflowId, AsyncCommandStatus status, String message) {
this.eventProducer.send(new ProducerRecord<String, String>(
this.topicName, String.join(",", callbackWorkflowId + "", status.name(), message)));
}
public void initializeKafkaEventProducer() {
Properties props = new Properties();
props.put("bootstrap.servers", this.brokerUrl);
props.put("acks", "all");
props.put("retries", 0);
props.put("batch.size", 16384);
props.put("linger.ms", 1);
props.put("buffer.memory", 33554432);
props.put("key.serializer",
"org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer",
"org.apache.kafka.common.serialization.StringSerializer");
eventProducer = new KafkaProducer<String, String>(props);
}
}
| 8,886 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/thrift-agent/src/main/java/org/apache/airavata/agents/thrift | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/thrift-agent/src/main/java/org/apache/airavata/agents/thrift/handler/OperationHandler.java | package org.apache.airavata.agents.thrift.handler;
import org.apache.airavata.agents.core.StatusPublisher;
import org.apache.airavata.agents.thrift.stubs.OperationException;
import org.apache.airavata.agents.thrift.stubs.OperationService;
import org.apache.thrift.TException;
import static org.apache.airavata.agents.core.AsyncCommandStatus.*;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class OperationHandler extends StatusPublisher implements OperationService.Iface {
public OperationHandler(String brokerUrl, String topicName) {
super(brokerUrl, topicName);
}
@Override
public void executeCommand(String command, long callbackWorkflowId) throws OperationException, TException {
publishStatus(callbackWorkflowId, PENDING, "Pending for execution");
publishStatus(callbackWorkflowId, RUNNING, "Starting command execution");
Runnable task = new Runnable() {
@Override
public void run() {
System.out.println("Executing command " + command);
publishStatus(callbackWorkflowId, SUCCESS, "Command execution succeeded");
}
};
new Thread(task).start();
}
}
| 8,887 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/thrift-agent/src/main/java/org/apache/airavata/agents/thrift | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/thrift-agent/src/main/java/org/apache/airavata/agents/thrift/stubs/OperationException.java | /**
* Autogenerated by Thrift Compiler (0.10.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.airavata.agents.thrift.stubs;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2017-12-02")
public class OperationException extends org.apache.thrift.TException implements org.apache.thrift.TBase<OperationException, OperationException._Fields>, java.io.Serializable, Cloneable, Comparable<OperationException> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("OperationException");
private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField STACKTRACE_FIELD_DESC = new org.apache.thrift.protocol.TField("stacktrace", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new OperationExceptionStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new OperationExceptionTupleSchemeFactory();
public java.lang.String message; // required
public java.lang.String stacktrace; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
MESSAGE((short)1, "message"),
STACKTRACE((short)2, "stacktrace");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
static {
for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // MESSAGE
return MESSAGE;
case 2: // STACKTRACE
return STACKTRACE;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(java.lang.String name) {
return byName.get(name);
}
private final short _thriftId;
private final java.lang.String _fieldName;
_Fields(short thriftId, java.lang.String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public java.lang.String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.STACKTRACE, new org.apache.thrift.meta_data.FieldMetaData("stacktrace", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(OperationException.class, metaDataMap);
}
public OperationException() {
}
public OperationException(
java.lang.String message,
java.lang.String stacktrace)
{
this();
this.message = message;
this.stacktrace = stacktrace;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public OperationException(OperationException other) {
if (other.isSetMessage()) {
this.message = other.message;
}
if (other.isSetStacktrace()) {
this.stacktrace = other.stacktrace;
}
}
public OperationException deepCopy() {
return new OperationException(this);
}
@Override
public void clear() {
this.message = null;
this.stacktrace = null;
}
public java.lang.String getMessage() {
return this.message;
}
public OperationException setMessage(java.lang.String message) {
this.message = message;
return this;
}
public void unsetMessage() {
this.message = null;
}
/** Returns true if field message is set (has been assigned a value) and false otherwise */
public boolean isSetMessage() {
return this.message != null;
}
public void setMessageIsSet(boolean value) {
if (!value) {
this.message = null;
}
}
public java.lang.String getStacktrace() {
return this.stacktrace;
}
public OperationException setStacktrace(java.lang.String stacktrace) {
this.stacktrace = stacktrace;
return this;
}
public void unsetStacktrace() {
this.stacktrace = null;
}
/** Returns true if field stacktrace is set (has been assigned a value) and false otherwise */
public boolean isSetStacktrace() {
return this.stacktrace != null;
}
public void setStacktraceIsSet(boolean value) {
if (!value) {
this.stacktrace = null;
}
}
public void setFieldValue(_Fields field, java.lang.Object value) {
switch (field) {
case MESSAGE:
if (value == null) {
unsetMessage();
} else {
setMessage((java.lang.String)value);
}
break;
case STACKTRACE:
if (value == null) {
unsetStacktrace();
} else {
setStacktrace((java.lang.String)value);
}
break;
}
}
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case MESSAGE:
return getMessage();
case STACKTRACE:
return getStacktrace();
}
throw new java.lang.IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new java.lang.IllegalArgumentException();
}
switch (field) {
case MESSAGE:
return isSetMessage();
case STACKTRACE:
return isSetStacktrace();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that == null)
return false;
if (that instanceof OperationException)
return this.equals((OperationException)that);
return false;
}
public boolean equals(OperationException that) {
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_message = true && this.isSetMessage();
boolean that_present_message = true && that.isSetMessage();
if (this_present_message || that_present_message) {
if (!(this_present_message && that_present_message))
return false;
if (!this.message.equals(that.message))
return false;
}
boolean this_present_stacktrace = true && this.isSetStacktrace();
boolean that_present_stacktrace = true && that.isSetStacktrace();
if (this_present_stacktrace || that_present_stacktrace) {
if (!(this_present_stacktrace && that_present_stacktrace))
return false;
if (!this.stacktrace.equals(that.stacktrace))
return false;
}
return true;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = hashCode * 8191 + ((isSetMessage()) ? 131071 : 524287);
if (isSetMessage())
hashCode = hashCode * 8191 + message.hashCode();
hashCode = hashCode * 8191 + ((isSetStacktrace()) ? 131071 : 524287);
if (isSetStacktrace())
hashCode = hashCode * 8191 + stacktrace.hashCode();
return hashCode;
}
@Override
public int compareTo(OperationException other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = java.lang.Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetMessage()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetStacktrace()).compareTo(other.isSetStacktrace());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStacktrace()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.stacktrace, other.stacktrace);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
scheme(iprot).read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
scheme(oprot).write(oprot, this);
}
@Override
public java.lang.String toString() {
java.lang.StringBuilder sb = new java.lang.StringBuilder("OperationException(");
boolean first = true;
sb.append("message:");
if (this.message == null) {
sb.append("null");
} else {
sb.append(this.message);
}
first = false;
if (!first) sb.append(", ");
sb.append("stacktrace:");
if (this.stacktrace == null) {
sb.append("null");
} else {
sb.append(this.stacktrace);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class OperationExceptionStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public OperationExceptionStandardScheme getScheme() {
return new OperationExceptionStandardScheme();
}
}
private static class OperationExceptionStandardScheme extends org.apache.thrift.scheme.StandardScheme<OperationException> {
public void read(org.apache.thrift.protocol.TProtocol iprot, OperationException struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // MESSAGE
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.message = iprot.readString();
struct.setMessageIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // STACKTRACE
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.stacktrace = iprot.readString();
struct.setStacktraceIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, OperationException struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.message != null) {
oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
oprot.writeString(struct.message);
oprot.writeFieldEnd();
}
if (struct.stacktrace != null) {
oprot.writeFieldBegin(STACKTRACE_FIELD_DESC);
oprot.writeString(struct.stacktrace);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class OperationExceptionTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public OperationExceptionTupleScheme getScheme() {
return new OperationExceptionTupleScheme();
}
}
private static class OperationExceptionTupleScheme extends org.apache.thrift.scheme.TupleScheme<OperationException> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, OperationException struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet optionals = new java.util.BitSet();
if (struct.isSetMessage()) {
optionals.set(0);
}
if (struct.isSetStacktrace()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetMessage()) {
oprot.writeString(struct.message);
}
if (struct.isSetStacktrace()) {
oprot.writeString(struct.stacktrace);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, OperationException struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.message = iprot.readString();
struct.setMessageIsSet(true);
}
if (incoming.get(1)) {
struct.stacktrace = iprot.readString();
struct.setStacktraceIsSet(true);
}
}
}
private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
}
}
| 8,888 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/thrift-agent/src/main/java/org/apache/airavata/agents/thrift | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/thrift-agent/src/main/java/org/apache/airavata/agents/thrift/stubs/OperationService.java | /**
* Autogenerated by Thrift Compiler (0.10.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.airavata.agents.thrift.stubs;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)", date = "2017-12-02")
public class OperationService {
public interface Iface {
public void executeCommand(java.lang.String command, long callbackWorkflowId) throws OperationException, org.apache.thrift.TException;
}
public interface AsyncIface {
public void executeCommand(java.lang.String command, long callbackWorkflowId, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException;
}
public static class Client extends org.apache.thrift.TServiceClient implements Iface {
public static class Factory implements org.apache.thrift.TServiceClientFactory<Client> {
public Factory() {}
public Client getClient(org.apache.thrift.protocol.TProtocol prot) {
return new Client(prot);
}
public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
return new Client(iprot, oprot);
}
}
public Client(org.apache.thrift.protocol.TProtocol prot)
{
super(prot, prot);
}
public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
super(iprot, oprot);
}
public void executeCommand(java.lang.String command, long callbackWorkflowId) throws OperationException, org.apache.thrift.TException
{
send_executeCommand(command, callbackWorkflowId);
recv_executeCommand();
}
public void send_executeCommand(java.lang.String command, long callbackWorkflowId) throws org.apache.thrift.TException
{
executeCommand_args args = new executeCommand_args();
args.setCommand(command);
args.setCallbackWorkflowId(callbackWorkflowId);
sendBase("executeCommand", args);
}
public void recv_executeCommand() throws OperationException, org.apache.thrift.TException
{
executeCommand_result result = new executeCommand_result();
receiveBase(result, "executeCommand");
if (result.ex != null) {
throw result.ex;
}
return;
}
}
public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {
private org.apache.thrift.async.TAsyncClientManager clientManager;
private org.apache.thrift.protocol.TProtocolFactory protocolFactory;
public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) {
this.clientManager = clientManager;
this.protocolFactory = protocolFactory;
}
public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) {
return new AsyncClient(protocolFactory, clientManager, transport);
}
}
public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) {
super(protocolFactory, clientManager, transport);
}
public void executeCommand(java.lang.String command, long callbackWorkflowId, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException {
checkReady();
executeCommand_call method_call = new executeCommand_call(command, callbackWorkflowId, resultHandler, this, ___protocolFactory, ___transport);
this.___currentMethod = method_call;
___manager.call(method_call);
}
public static class executeCommand_call extends org.apache.thrift.async.TAsyncMethodCall<Void> {
private java.lang.String command;
private long callbackWorkflowId;
public executeCommand_call(java.lang.String command, long callbackWorkflowId, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
super(client, protocolFactory, transport, resultHandler, false);
this.command = command;
this.callbackWorkflowId = callbackWorkflowId;
}
public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("executeCommand", org.apache.thrift.protocol.TMessageType.CALL, 0));
executeCommand_args args = new executeCommand_args();
args.setCommand(command);
args.setCallbackWorkflowId(callbackWorkflowId);
args.write(prot);
prot.writeMessageEnd();
}
public Void getResult() throws OperationException, org.apache.thrift.TException {
if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
throw new java.lang.IllegalStateException("Method call not finished!");
}
org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
return null;
}
}
}
public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor {
private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName());
public Processor(I iface) {
super(iface, getProcessMap(new java.util.HashMap<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>()));
}
protected Processor(I iface, java.util.Map<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
super(iface, getProcessMap(processMap));
}
private static <I extends Iface> java.util.Map<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(java.util.Map<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
processMap.put("executeCommand", new executeCommand());
return processMap;
}
public static class executeCommand<I extends Iface> extends org.apache.thrift.ProcessFunction<I, executeCommand_args> {
public executeCommand() {
super("executeCommand");
}
public executeCommand_args getEmptyArgsInstance() {
return new executeCommand_args();
}
protected boolean isOneway() {
return false;
}
public executeCommand_result getResult(I iface, executeCommand_args args) throws org.apache.thrift.TException {
executeCommand_result result = new executeCommand_result();
try {
iface.executeCommand(args.command, args.callbackWorkflowId);
} catch (OperationException ex) {
result.ex = ex;
}
return result;
}
}
}
public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> {
private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName());
public AsyncProcessor(I iface) {
super(iface, getProcessMap(new java.util.HashMap<java.lang.String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>>()));
}
protected AsyncProcessor(I iface, java.util.Map<java.lang.String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> processMap) {
super(iface, getProcessMap(processMap));
}
private static <I extends AsyncIface> java.util.Map<java.lang.String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase,?>> getProcessMap(java.util.Map<java.lang.String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> processMap) {
processMap.put("executeCommand", new executeCommand());
return processMap;
}
public static class executeCommand<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, executeCommand_args, Void> {
public executeCommand() {
super("executeCommand");
}
public executeCommand_args getEmptyArgsInstance() {
return new executeCommand_args();
}
public org.apache.thrift.async.AsyncMethodCallback<Void> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
final org.apache.thrift.AsyncProcessFunction fcall = this;
return new org.apache.thrift.async.AsyncMethodCallback<Void>() {
public void onComplete(Void o) {
executeCommand_result result = new executeCommand_result();
try {
fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
} catch (org.apache.thrift.transport.TTransportException e) {
_LOGGER.error("TTransportException writing to internal frame buffer", e);
fb.close();
} catch (java.lang.Exception e) {
_LOGGER.error("Exception writing to internal frame buffer", e);
onError(e);
}
}
public void onError(java.lang.Exception e) {
byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
org.apache.thrift.TSerializable msg;
executeCommand_result result = new executeCommand_result();
if (e instanceof OperationException) {
result.ex = (OperationException) e;
result.setExIsSet(true);
msg = result;
} else if (e instanceof org.apache.thrift.transport.TTransportException) {
_LOGGER.error("TTransportException inside handler", e);
fb.close();
return;
} else if (e instanceof org.apache.thrift.TApplicationException) {
_LOGGER.error("TApplicationException inside handler", e);
msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
msg = (org.apache.thrift.TApplicationException)e;
} else {
_LOGGER.error("Exception inside handler", e);
msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
}
try {
fcall.sendResponse(fb,msg,msgType,seqid);
} catch (java.lang.Exception ex) {
_LOGGER.error("Exception writing to internal frame buffer", ex);
fb.close();
}
}
};
}
protected boolean isOneway() {
return false;
}
public void start(I iface, executeCommand_args args, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException {
iface.executeCommand(args.command, args.callbackWorkflowId,resultHandler);
}
}
}
public static class executeCommand_args implements org.apache.thrift.TBase<executeCommand_args, executeCommand_args._Fields>, java.io.Serializable, Cloneable, Comparable<executeCommand_args> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("executeCommand_args");
private static final org.apache.thrift.protocol.TField COMMAND_FIELD_DESC = new org.apache.thrift.protocol.TField("command", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField CALLBACK_WORKFLOW_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("callbackWorkflowId", org.apache.thrift.protocol.TType.I64, (short)2);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new executeCommand_argsStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new executeCommand_argsTupleSchemeFactory();
public java.lang.String command; // required
public long callbackWorkflowId; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
COMMAND((short)1, "command"),
CALLBACK_WORKFLOW_ID((short)2, "callbackWorkflowId");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
static {
for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // COMMAND
return COMMAND;
case 2: // CALLBACK_WORKFLOW_ID
return CALLBACK_WORKFLOW_ID;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(java.lang.String name) {
return byName.get(name);
}
private final short _thriftId;
private final java.lang.String _fieldName;
_Fields(short thriftId, java.lang.String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public java.lang.String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __CALLBACKWORKFLOWID_ISSET_ID = 0;
private byte __isset_bitfield = 0;
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.COMMAND, new org.apache.thrift.meta_data.FieldMetaData("command", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.CALLBACK_WORKFLOW_ID, new org.apache.thrift.meta_data.FieldMetaData("callbackWorkflowId", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(executeCommand_args.class, metaDataMap);
}
public executeCommand_args() {
}
public executeCommand_args(
java.lang.String command,
long callbackWorkflowId)
{
this();
this.command = command;
this.callbackWorkflowId = callbackWorkflowId;
setCallbackWorkflowIdIsSet(true);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public executeCommand_args(executeCommand_args other) {
__isset_bitfield = other.__isset_bitfield;
if (other.isSetCommand()) {
this.command = other.command;
}
this.callbackWorkflowId = other.callbackWorkflowId;
}
public executeCommand_args deepCopy() {
return new executeCommand_args(this);
}
@Override
public void clear() {
this.command = null;
setCallbackWorkflowIdIsSet(false);
this.callbackWorkflowId = 0;
}
public java.lang.String getCommand() {
return this.command;
}
public executeCommand_args setCommand(java.lang.String command) {
this.command = command;
return this;
}
public void unsetCommand() {
this.command = null;
}
/** Returns true if field command is set (has been assigned a value) and false otherwise */
public boolean isSetCommand() {
return this.command != null;
}
public void setCommandIsSet(boolean value) {
if (!value) {
this.command = null;
}
}
public long getCallbackWorkflowId() {
return this.callbackWorkflowId;
}
public executeCommand_args setCallbackWorkflowId(long callbackWorkflowId) {
this.callbackWorkflowId = callbackWorkflowId;
setCallbackWorkflowIdIsSet(true);
return this;
}
public void unsetCallbackWorkflowId() {
__isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __CALLBACKWORKFLOWID_ISSET_ID);
}
/** Returns true if field callbackWorkflowId is set (has been assigned a value) and false otherwise */
public boolean isSetCallbackWorkflowId() {
return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __CALLBACKWORKFLOWID_ISSET_ID);
}
public void setCallbackWorkflowIdIsSet(boolean value) {
__isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __CALLBACKWORKFLOWID_ISSET_ID, value);
}
public void setFieldValue(_Fields field, java.lang.Object value) {
switch (field) {
case COMMAND:
if (value == null) {
unsetCommand();
} else {
setCommand((java.lang.String)value);
}
break;
case CALLBACK_WORKFLOW_ID:
if (value == null) {
unsetCallbackWorkflowId();
} else {
setCallbackWorkflowId((java.lang.Long)value);
}
break;
}
}
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case COMMAND:
return getCommand();
case CALLBACK_WORKFLOW_ID:
return getCallbackWorkflowId();
}
throw new java.lang.IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new java.lang.IllegalArgumentException();
}
switch (field) {
case COMMAND:
return isSetCommand();
case CALLBACK_WORKFLOW_ID:
return isSetCallbackWorkflowId();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that == null)
return false;
if (that instanceof executeCommand_args)
return this.equals((executeCommand_args)that);
return false;
}
public boolean equals(executeCommand_args that) {
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_command = true && this.isSetCommand();
boolean that_present_command = true && that.isSetCommand();
if (this_present_command || that_present_command) {
if (!(this_present_command && that_present_command))
return false;
if (!this.command.equals(that.command))
return false;
}
boolean this_present_callbackWorkflowId = true;
boolean that_present_callbackWorkflowId = true;
if (this_present_callbackWorkflowId || that_present_callbackWorkflowId) {
if (!(this_present_callbackWorkflowId && that_present_callbackWorkflowId))
return false;
if (this.callbackWorkflowId != that.callbackWorkflowId)
return false;
}
return true;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = hashCode * 8191 + ((isSetCommand()) ? 131071 : 524287);
if (isSetCommand())
hashCode = hashCode * 8191 + command.hashCode();
hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(callbackWorkflowId);
return hashCode;
}
@Override
public int compareTo(executeCommand_args other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = java.lang.Boolean.valueOf(isSetCommand()).compareTo(other.isSetCommand());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetCommand()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.command, other.command);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.valueOf(isSetCallbackWorkflowId()).compareTo(other.isSetCallbackWorkflowId());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetCallbackWorkflowId()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.callbackWorkflowId, other.callbackWorkflowId);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
scheme(iprot).read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
scheme(oprot).write(oprot, this);
}
@Override
public java.lang.String toString() {
java.lang.StringBuilder sb = new java.lang.StringBuilder("executeCommand_args(");
boolean first = true;
sb.append("command:");
if (this.command == null) {
sb.append("null");
} else {
sb.append(this.command);
}
first = false;
if (!first) sb.append(", ");
sb.append("callbackWorkflowId:");
sb.append(this.callbackWorkflowId);
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class executeCommand_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public executeCommand_argsStandardScheme getScheme() {
return new executeCommand_argsStandardScheme();
}
}
private static class executeCommand_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<executeCommand_args> {
public void read(org.apache.thrift.protocol.TProtocol iprot, executeCommand_args struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // COMMAND
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.command = iprot.readString();
struct.setCommandIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // CALLBACK_WORKFLOW_ID
if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
struct.callbackWorkflowId = iprot.readI64();
struct.setCallbackWorkflowIdIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, executeCommand_args struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.command != null) {
oprot.writeFieldBegin(COMMAND_FIELD_DESC);
oprot.writeString(struct.command);
oprot.writeFieldEnd();
}
oprot.writeFieldBegin(CALLBACK_WORKFLOW_ID_FIELD_DESC);
oprot.writeI64(struct.callbackWorkflowId);
oprot.writeFieldEnd();
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class executeCommand_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public executeCommand_argsTupleScheme getScheme() {
return new executeCommand_argsTupleScheme();
}
}
private static class executeCommand_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<executeCommand_args> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, executeCommand_args struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet optionals = new java.util.BitSet();
if (struct.isSetCommand()) {
optionals.set(0);
}
if (struct.isSetCallbackWorkflowId()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetCommand()) {
oprot.writeString(struct.command);
}
if (struct.isSetCallbackWorkflowId()) {
oprot.writeI64(struct.callbackWorkflowId);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, executeCommand_args struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.command = iprot.readString();
struct.setCommandIsSet(true);
}
if (incoming.get(1)) {
struct.callbackWorkflowId = iprot.readI64();
struct.setCallbackWorkflowIdIsSet(true);
}
}
}
private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
}
}
public static class executeCommand_result implements org.apache.thrift.TBase<executeCommand_result, executeCommand_result._Fields>, java.io.Serializable, Cloneable, Comparable<executeCommand_result> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("executeCommand_result");
private static final org.apache.thrift.protocol.TField EX_FIELD_DESC = new org.apache.thrift.protocol.TField("ex", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new executeCommand_resultStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new executeCommand_resultTupleSchemeFactory();
public OperationException ex; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
EX((short)1, "ex");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
static {
for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // EX
return EX;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(java.lang.String name) {
return byName.get(name);
}
private final short _thriftId;
private final java.lang.String _fieldName;
_Fields(short thriftId, java.lang.String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public java.lang.String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.EX, new org.apache.thrift.meta_data.FieldMetaData("ex", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, OperationException.class)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(executeCommand_result.class, metaDataMap);
}
public executeCommand_result() {
}
public executeCommand_result(
OperationException ex)
{
this();
this.ex = ex;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public executeCommand_result(executeCommand_result other) {
if (other.isSetEx()) {
this.ex = new OperationException(other.ex);
}
}
public executeCommand_result deepCopy() {
return new executeCommand_result(this);
}
@Override
public void clear() {
this.ex = null;
}
public OperationException getEx() {
return this.ex;
}
public executeCommand_result setEx(OperationException ex) {
this.ex = ex;
return this;
}
public void unsetEx() {
this.ex = null;
}
/** Returns true if field ex is set (has been assigned a value) and false otherwise */
public boolean isSetEx() {
return this.ex != null;
}
public void setExIsSet(boolean value) {
if (!value) {
this.ex = null;
}
}
public void setFieldValue(_Fields field, java.lang.Object value) {
switch (field) {
case EX:
if (value == null) {
unsetEx();
} else {
setEx((OperationException)value);
}
break;
}
}
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case EX:
return getEx();
}
throw new java.lang.IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new java.lang.IllegalArgumentException();
}
switch (field) {
case EX:
return isSetEx();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that == null)
return false;
if (that instanceof executeCommand_result)
return this.equals((executeCommand_result)that);
return false;
}
public boolean equals(executeCommand_result that) {
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_ex = true && this.isSetEx();
boolean that_present_ex = true && that.isSetEx();
if (this_present_ex || that_present_ex) {
if (!(this_present_ex && that_present_ex))
return false;
if (!this.ex.equals(that.ex))
return false;
}
return true;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = hashCode * 8191 + ((isSetEx()) ? 131071 : 524287);
if (isSetEx())
hashCode = hashCode * 8191 + ex.hashCode();
return hashCode;
}
@Override
public int compareTo(executeCommand_result other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = java.lang.Boolean.valueOf(isSetEx()).compareTo(other.isSetEx());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetEx()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ex, other.ex);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
scheme(iprot).read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
scheme(oprot).write(oprot, this);
}
@Override
public java.lang.String toString() {
java.lang.StringBuilder sb = new java.lang.StringBuilder("executeCommand_result(");
boolean first = true;
sb.append("ex:");
if (this.ex == null) {
sb.append("null");
} else {
sb.append(this.ex);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class executeCommand_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public executeCommand_resultStandardScheme getScheme() {
return new executeCommand_resultStandardScheme();
}
}
private static class executeCommand_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<executeCommand_result> {
public void read(org.apache.thrift.protocol.TProtocol iprot, executeCommand_result struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // EX
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.ex = new OperationException();
struct.ex.read(iprot);
struct.setExIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, executeCommand_result struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.ex != null) {
oprot.writeFieldBegin(EX_FIELD_DESC);
struct.ex.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class executeCommand_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public executeCommand_resultTupleScheme getScheme() {
return new executeCommand_resultTupleScheme();
}
}
private static class executeCommand_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<executeCommand_result> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, executeCommand_result struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet optionals = new java.util.BitSet();
if (struct.isSetEx()) {
optionals.set(0);
}
oprot.writeBitSet(optionals, 1);
if (struct.isSetEx()) {
struct.ex.write(oprot);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, executeCommand_result struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet incoming = iprot.readBitSet(1);
if (incoming.get(0)) {
struct.ex = new OperationException();
struct.ex.read(iprot);
struct.setExIsSet(true);
}
}
}
private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
}
}
}
| 8,889 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/thrift-agent/src/main/java/org/apache/airavata/agents/thrift | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/thrift-agent/src/main/java/org/apache/airavata/agents/thrift/operation/ThriftAgentOperation.java | package org.apache.airavata.agents.thrift.operation;
import org.apache.airavata.agents.core.AsyncOperation;
import org.apache.airavata.agents.thrift.stubs.OperationService;
import org.apache.airavata.k8s.api.resources.compute.ComputeResource;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ThriftAgentOperation extends AsyncOperation {
private OperationService.Client client;
public ThriftAgentOperation(ComputeResource computeResource) {
super(computeResource);
}
@Override
public void executeCommandAsync(String command, long callbackWorkflowId) {
try {
System.out.println("Submitting command");
try {
TTransport transport = new TSocket(getComputeResource().getHost(), 9090);
transport.open();
TProtocol protocol = new TBinaryProtocol(transport);
this.client = new OperationService.Client(protocol);
client.executeCommand(command, callbackWorkflowId);
System.out.println("Finished submitting");
transport.close();
} catch (TTransportException e) {
e.printStackTrace();
}
} catch (TException e) {
e.printStackTrace();
}
}
}
| 8,890 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/thrift-agent/src/main/java/org/apache/airavata/agents/thrift | Create_ds/airavata-sandbox/airavata-kubernetes/modules/agents/thrift-agent/src/main/java/org/apache/airavata/agents/thrift/server/OperationServer.java | package org.apache.airavata.agents.thrift.server;
import org.apache.airavata.agents.thrift.handler.OperationHandler;
import org.apache.airavata.agents.thrift.stubs.OperationService;
import org.apache.airavata.helix.api.PropertyResolver;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TSimpleServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TServerTransport;
import java.io.IOException;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class OperationServer {
private static OperationHandler operationHandler;
private static OperationService.Processor processor;
public static void main(String args[]) throws IOException {
PropertyResolver resolver = new PropertyResolver();
resolver.loadInputStream(OperationService.class.getClassLoader().getResourceAsStream("application.properties"));
operationHandler = new OperationHandler(resolver.get("kafka.bootstrap.url"), resolver.get("async.event.listener.topic"));
processor = new OperationService.Processor(operationHandler);
Runnable server = new Runnable() {
@Override
public void run() {
simple(processor);
}
};
new Thread(server).start();
}
public static void simple(OperationService.Processor processor) {
try {
TServerTransport serverTransport = new TServerSocket(9090);
TServer server = new TSimpleServer(new TServer.Args(serverTransport).processor(processor));
System.out.println("Starting the operation server...");
server.serve();
} catch (Exception e) {
e.printStackTrace();
}
}
}
| 8,891 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/helix-task-api/src/main/java/org/apache/airavata/helix | Create_ds/airavata-sandbox/airavata-kubernetes/modules/helix-task-api/src/main/java/org/apache/airavata/helix/api/PropertyResolver.java | package org.apache.airavata.helix.api;
import java.io.*;
import java.util.Properties;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class PropertyResolver {
private Properties properties = new Properties();
public void loadFromFile(File propertyFile) throws IOException {
properties = new Properties();
properties.load(new FileInputStream(propertyFile));
}
public void loadInputStream(InputStream inputStream) throws IOException {
properties = new Properties();
properties.load(inputStream);
}
public String get(String key) {
if (properties.containsKey(key)) {
if (System.getenv(key.replace(".", "_")) != null) {
return System.getenv(key.replace(".", "_"));
} else {
return properties.getProperty(key);
}
} else {
return null;
}
}
}
| 8,892 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/helix-task-api/src/main/java/org/apache/airavata/helix | Create_ds/airavata-sandbox/airavata-kubernetes/modules/helix-task-api/src/main/java/org/apache/airavata/helix/api/HelixParticipant.java | package org.apache.airavata.helix.api;
import org.apache.airavata.k8s.api.resources.task.type.TaskTypeResource;
import org.apache.helix.InstanceType;
import org.apache.helix.examples.OnlineOfflineStateModelFactory;
import org.apache.helix.manager.zk.ZKHelixAdmin;
import org.apache.helix.manager.zk.ZKHelixManager;
import org.apache.helix.manager.zk.ZNRecordSerializer;
import org.apache.helix.manager.zk.ZkClient;
import org.apache.helix.model.BuiltInStateModelDefinitions;
import org.apache.helix.model.InstanceConfig;
import org.apache.helix.participant.StateMachineEngine;
import org.apache.helix.task.TaskFactory;
import org.apache.helix.task.TaskStateModelFactory;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.web.client.RestTemplate;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public abstract class HelixParticipant implements Runnable {
private static final Logger logger = LogManager.getLogger(HelixParticipant.class);
private String zkAddress;
private String clusterName;
private String participantName;
private ZKHelixManager zkHelixManager;
private String taskTypeName;
private String apiServerUrl;
private RestTemplate restTemplate;
private PropertyResolver propertyResolver;
public HelixParticipant(String propertyFile) throws IOException {
logger.debug("Initializing Participant Node");
this.propertyResolver = new PropertyResolver();
propertyResolver.loadInputStream(this.getClass().getClassLoader().getResourceAsStream(propertyFile));
this.zkAddress = propertyResolver.get("zookeeper.connection.url");
this.clusterName = propertyResolver.get("helix.cluster.name");
this.participantName = propertyResolver.get("participant.name");
this.taskTypeName = propertyResolver.get("task.type.name");
this.apiServerUrl = propertyResolver.get("api.server.url");
this.restTemplate = new RestTemplate();
}
public abstract Map<String, TaskFactory> getTaskFactory();
public abstract TaskTypeResource getTaskType();
public void run() {
ZkClient zkClient = null;
try {
zkClient = new ZkClient(zkAddress, ZkClient.DEFAULT_SESSION_TIMEOUT,
ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
ZKHelixAdmin zkHelixAdmin = new ZKHelixAdmin(zkClient);
List<String> nodesInCluster = zkHelixAdmin.getInstancesInCluster(clusterName);
if (!nodesInCluster.contains(participantName)) {
InstanceConfig instanceConfig = new InstanceConfig(participantName);
instanceConfig.setHostName("localhost");
instanceConfig.setInstanceEnabled(true);
instanceConfig.addTag(taskTypeName);
zkHelixAdmin.addInstance(clusterName, instanceConfig);
logger.debug("Instance: " + participantName + ", has been added to cluster: " + clusterName);
} else {
zkHelixAdmin.addInstanceTag(clusterName, participantName, taskTypeName);
}
Runtime.getRuntime().addShutdownHook(
new Thread() {
@Override
public void run() {
logger.debug("Participant: " + participantName + ", shutdown hook called.");
disconnect();
}
}
);
// connect the participant manager
register();
connect();
} catch (Exception ex) {
logger.error("Error in run() for Participant: " + participantName + ", reason: " + ex, ex);
} finally {
if (zkClient != null) {
zkClient.close();
}
}
}
private void register() {
this.restTemplate.postForObject("http://" + apiServerUrl + "/taskType", getTaskType(), Long.class);
}
private void connect() {
try {
zkHelixManager = new ZKHelixManager(clusterName, participantName, InstanceType.PARTICIPANT, zkAddress);
// register online-offline model
StateMachineEngine machineEngine = zkHelixManager.getStateMachineEngine();
OnlineOfflineStateModelFactory factory = new OnlineOfflineStateModelFactory(participantName);
machineEngine.registerStateModelFactory(BuiltInStateModelDefinitions.OnlineOffline.name(), factory);
// register task model
machineEngine.registerStateModelFactory("Task", new TaskStateModelFactory(zkHelixManager, getTaskFactory()));
logger.debug("Participant: " + participantName + ", registered state model factories.");
zkHelixManager.connect();
logger.info("Participant: " + participantName + ", has connected to cluster: " + clusterName);
Thread.currentThread().join();
} catch (InterruptedException ex) {
logger.error("Participant: " + participantName + ", is interrupted! reason: " + ex, ex);
}
catch (Exception ex) {
logger.error("Error in connect() for Participant: " + participantName + ", reason: " + ex, ex);
} finally {
disconnect();
}
}
private void disconnect() {
if (zkHelixManager != null) {
logger.info("Participant: " + participantName + ", has disconnected from cluster: " + clusterName);
zkHelixManager.disconnect();
}
}
public PropertyResolver getPropertyResolver() {
return propertyResolver;
}
}
| 8,893 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/helix-task-api/src/main/java/org/apache/airavata/helix | Create_ds/airavata-sandbox/airavata-kubernetes/modules/helix-task-api/src/main/java/org/apache/airavata/helix/api/AbstractTask.java | package org.apache.airavata.helix.api;
import org.apache.airavata.k8s.api.resources.compute.ComputeResource;
import org.apache.airavata.k8s.compute.api.ComputeOperations;
import org.apache.airavata.k8s.compute.impl.MockComputeOperation;
import org.apache.airavata.k8s.compute.impl.SSHComputeOperations;
import org.apache.helix.task.Task;
import org.apache.helix.task.TaskCallbackContext;
import org.apache.helix.task.TaskResult;
import org.apache.helix.task.UserContentStore;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.springframework.web.client.RestTemplate;
import java.util.Properties;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public abstract class AbstractTask extends UserContentStore implements Task {
public static final String NEXT_JOB = "next-job";
public static final String WORKFLOW_STARTED = "workflow-started";
public static final String TASK_ID = "task_id";
public static final String PROCESS_ID = "process_id";
//Configurable values
private String apiServerUrl;
private String kafkaBootstrapUrl;
private String eventTopic;
private TaskCallbackContext callbackContext;
private RestTemplate restTemplate;
private Producer<String, String> eventProducer;
private long processId;
private long taskId;
private PropertyResolver propertyResolver;
public AbstractTask(TaskCallbackContext callbackContext, PropertyResolver propertyResolver) {
this.callbackContext = callbackContext;
this.taskId = Long.parseLong(this.callbackContext.getTaskConfig().getConfigMap().get(TASK_ID));
this.processId = Long.parseLong(this.callbackContext.getTaskConfig().getConfigMap().get(PROCESS_ID));
this.restTemplate = new RestTemplate();
this.propertyResolver = propertyResolver;
this.apiServerUrl = getPropertyResolver().get("api.server.url");
this.kafkaBootstrapUrl = getPropertyResolver().get("kafka.bootstrap.url");
this.eventTopic = getPropertyResolver().get("event.topic");
initializeKafkaEventProducer();
init();
}
public TaskCallbackContext getCallbackContext() {
return callbackContext;
}
@Override
public final TaskResult run() {
boolean isThisNextJob = getUserContent(WORKFLOW_STARTED, Scope.WORKFLOW) == null ||
this.callbackContext.getJobConfig().getJobId()
.equals(this.callbackContext.getJobConfig().getWorkflow() + "_" + getUserContent(NEXT_JOB, Scope.WORKFLOW));
if (isThisNextJob) {
return onRun();
} else {
return new TaskResult(TaskResult.Status.COMPLETED, "Not a target job");
}
}
@Override
public final void cancel() {
onCancel();
}
public void init() {
}
public abstract TaskResult onRun();
public abstract void onCancel();
public void sendToOutPort(String port) {
putUserContent(WORKFLOW_STARTED, "TRUE", Scope.WORKFLOW);
String outJob = getCallbackContext().getTaskConfig().getConfigMap().get("OUT_" + port);
if (outJob != null) {
putUserContent(NEXT_JOB, outJob, Scope.WORKFLOW);
}
}
public RestTemplate getRestTemplate() {
return restTemplate;
}
public String getApiServerUrl() {
return apiServerUrl;
}
public ComputeOperations fetchComputeResourceOperation(ComputeResource computeResource) throws Exception {
ComputeOperations operations;
if ("SSH".equals(computeResource.getCommunicationType())) {
operations = new SSHComputeOperations(computeResource.getHost(), computeResource.getUserName(), computeResource.getPassword());
} else if ("Mock".equals(computeResource.getCommunicationType())) {
operations = new MockComputeOperation(computeResource.getHost());
} else {
throw new Exception("No compatible communication method {" + computeResource.getCommunicationType() + "} not found for compute resource " + computeResource.getName());
}
return operations;
}
public void initializeKafkaEventProducer() {
Properties props = new Properties();
props.put("bootstrap.servers", this.kafkaBootstrapUrl);
props.put("acks", "all");
props.put("retries", 0);
props.put("batch.size", 16384);
props.put("linger.ms", 1);
props.put("buffer.memory", 33554432);
props.put("key.serializer",
"org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer",
"org.apache.kafka.common.serialization.StringSerializer");
eventProducer = new KafkaProducer<String, String>(props);
}
public void publishTaskStatus(long status, String reason) {
eventProducer.send(new ProducerRecord<String, String>(
this.eventTopic, String.join(",", this.processId + "", this.taskId + "", status + "", reason)));
}
public long getProcessId() {
return processId;
}
public long getTaskId() {
return taskId;
}
public Producer<String, String> getEventProducer() {
return eventProducer;
}
public PropertyResolver getPropertyResolver() {
return propertyResolver;
}
}
| 8,894 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/compute-resource-api/src/main/java/org/apache/airavata/k8s/compute | Create_ds/airavata-sandbox/airavata-kubernetes/modules/compute-resource-api/src/main/java/org/apache/airavata/k8s/compute/impl/SSHComputeOperations.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.compute.impl;
import com.jcraft.jsch.*;
import org.apache.airavata.k8s.compute.api.ComputeOperations;
import org.apache.airavata.k8s.compute.api.ExecutionResult;
import java.io.*;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class SSHComputeOperations implements ComputeOperations {
private String computeHost;
private String userName;
private String password;
private int port = 22;
public SSHComputeOperations(String computeHost, String userName, String password) {
this.computeHost = computeHost;
this.userName = userName;
this.password = password;
}
public SSHComputeOperations(String computeHost, String userName, String password, int port) {
this.computeHost = computeHost;
this.userName = userName;
this.password = password;
this.port = port;
}
public ExecutionResult executeCommand(String command) throws Exception {
Session session = getConnectedSession(this.userName, this.password, this.computeHost, this.port);
Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
ByteArrayOutputStream sysOut = new ByteArrayOutputStream();
channel.setOutputStream(sysOut);
ByteArrayOutputStream sysErr = new ByteArrayOutputStream();
((ChannelExec) channel).setErrStream(sysErr);
InputStream in = channel.getInputStream();
channel.connect();
ExecutionResult result = new ExecutionResult();
byte[] tmp = new byte[1024];
while (true) {
while (in.available() > 0) {
int i = in.read(tmp, 0, 1024);
if (i < 0) break;
System.out.print(new String(tmp, 0, i));
}
if (channel.isClosed()) {
if (in.available() > 0) continue;
System.out.println("exit-status: " + channel.getExitStatus());
result.setExitStatus(channel.getExitStatus());
break;
}
try {
Thread.sleep(1000);
} catch (Exception e) {
}
}
channel.disconnect();
session.disconnect();
result.setStdErr(sysErr.toString("UTF-8"));
result.setStdOut(sysOut.toString("UTF-8"));
return result;
}
public void transferDataIn(String source, String target, String protocol) throws Exception {
Session session = getConnectedSession(this.userName, this.password, this.computeHost, this.port);
copyLocalToRemote(session, source, target);
}
public void transferDataOut(String source, String target, String protocol) throws Exception {
Session session = getConnectedSession(this.userName, this.password, this.computeHost, this.port);
copyRemoteToLocal(session, source, target);
}
private static Session getConnectedSession(String userName, String password, String computeHost, int port) throws Exception {
JSch jsch = new JSch();
Session session = jsch.getSession(userName, computeHost, port);
session.setConfig("StrictHostKeyChecking", "no");
session.setUserInfo(getUserInfo(password));
session.connect();
return session;
}
private static UserInfo getUserInfo(String password) {
return new UserInfo() {
@Override
public String getPassphrase() {
return password;
}
@Override
public String getPassword() {
return password;
}
@Override
public boolean promptPassword(String s) {
return true;
}
@Override
public boolean promptPassphrase(String s) {
return false;
}
@Override
public boolean promptYesNo(String s) {
return false;
}
@Override
public void showMessage(String s) {
}
};
}
private static void copyLocalToRemote(Session session, String source, String target) throws Exception {
FileInputStream fis = null;
boolean ptimestamp = true;
// exec 'scp -t rfile' remotely
String command = "scp " + (ptimestamp ? "-p" : "") + " -t " + target;
Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
// get I/O streams for remote scp
OutputStream out = channel.getOutputStream();
InputStream in = channel.getInputStream();
channel.connect();
if (checkAck(in) != 0) {
return;
}
File _lfile = new File(source);
if (ptimestamp) {
command = "T" + (_lfile.lastModified() / 1000) + " 0";
// The access time should be sent here,
// but it is not accessible with JavaAPI ;-<
command += (" " + (_lfile.lastModified() / 1000) + " 0\n");
out.write(command.getBytes());
out.flush();
if (checkAck(in) != 0) {
return;
}
}
// send "C0644 filesize filename", where filename should not include '/'
long filesize = _lfile.length();
command = "C0644 " + filesize + " ";
if (source.lastIndexOf('/') > 0) {
command += source.substring(source.lastIndexOf('/') + 1);
} else {
command += source;
}
command += "\n";
out.write(command.getBytes());
out.flush();
if (checkAck(in) != 0) {
return;
}
// send a content of lfile
fis = new FileInputStream(source);
byte[] buf = new byte[1024];
while (true) {
int len = fis.read(buf, 0, buf.length);
if (len <= 0) break;
out.write(buf, 0, len); //out.flush();
}
fis.close();
fis = null;
// send '\0'
buf[0] = 0;
out.write(buf, 0, 1);
out.flush();
if (checkAck(in) != 0) {
return;
}
out.close();
channel.disconnect();
session.disconnect();
}
private static void copyRemoteToLocal(Session session, String source, String target) throws JSchException, IOException {
// exec 'scp -f rfile' remotely
String command = "scp -f " + source;
Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
// get I/O streams for remote scp
OutputStream out = channel.getOutputStream();
InputStream in = channel.getInputStream();
channel.connect();
byte[] buf = new byte[1024];
// send '\0'
buf[0] = 0;
out.write(buf, 0, 1);
out.flush();
while (true) {
int c = checkAck(in);
if (c != 'C') {
break;
}
// read '0644 '
in.read(buf, 0, 5);
long filesize = 0L;
while (true) {
if (in.read(buf, 0, 1) < 0) {
// error
break;
}
if (buf[0] == ' ') break;
filesize = filesize * 10L + (long) (buf[0] - '0');
}
String file = null;
for (int i = 0; ; i++) {
in.read(buf, i, 1);
if (buf[i] == (byte) 0x0a) {
file = new String(buf, 0, i);
break;
}
}
System.out.println("file-size=" + filesize + ", file=" + file);
// send '\0'
buf[0] = 0;
out.write(buf, 0, 1);
out.flush();
// read a content of lfile
FileOutputStream fos = new FileOutputStream(target);
int foo;
while (true) {
if (buf.length < filesize) foo = buf.length;
else foo = (int) filesize;
foo = in.read(buf, 0, foo);
if (foo < 0) {
// error
break;
}
fos.write(buf, 0, foo);
filesize -= foo;
if (filesize == 0L) break;
}
if (checkAck(in) != 0) {
return;
}
// send '\0'
buf[0] = 0;
out.write(buf, 0, 1);
out.flush();
try {
if (fos != null) fos.close();
} catch (Exception ex) {
System.out.println(ex);
}
}
channel.disconnect();
session.disconnect();
}
public static int checkAck(InputStream in) throws IOException {
int b = in.read();
// b may be 0 for success,
// 1 for error,
// 2 for fatal error,
// -1
if (b == 0) return b;
if (b == -1) return b;
if (b == 1 || b == 2) {
StringBuffer sb = new StringBuffer();
int c;
do {
c = in.read();
sb.append((char) c);
}
while (c != '\n');
if (b == 1) { // error
System.out.print(sb.toString());
}
if (b == 2) { // fatal error
System.out.print(sb.toString());
}
}
return b;
}
public static void main(String args[]) throws IOException, Exception {
SSHComputeOperations operations = new SSHComputeOperations("192.168.1.101", "dimuthu", "123456");
//ExecutionResult result = operations.executeCommand("sh /opt/sample.sh > /tmp/stdout.txt 2> /tmp/stderr.txt");
//System.out.println(result.getStdOut());
//System.out.println(result.getStdErr());
operations.transferDataIn("/tmp/a.txt", "/tmp/b.txt", "SCP");
}
}
| 8,895 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/compute-resource-api/src/main/java/org/apache/airavata/k8s/compute | Create_ds/airavata-sandbox/airavata-kubernetes/modules/compute-resource-api/src/main/java/org/apache/airavata/k8s/compute/impl/MockComputeOperation.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.compute.impl;
import org.apache.airavata.k8s.compute.api.ComputeOperations;
import org.apache.airavata.k8s.compute.api.ExecutionResult;
import java.io.File;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class MockComputeOperation implements ComputeOperations {
private String computeHost;
public MockComputeOperation(String computeHost) {
this.computeHost = computeHost;
}
@Override
public ExecutionResult executeCommand(String command) throws Exception {
System.out.println("Executing command " + command + " on host " + this.computeHost);
ExecutionResult executionResult = new ExecutionResult();
executionResult.setExitStatus(0);
executionResult.setStdOut("Sample standard out");
executionResult.setStdErr("Simple standard error");
Thread.sleep(5000);
System.out.println("Command successfully executed");
return executionResult;
}
@Override
public void transferDataIn(String source, String target, String protocol) throws Exception {
System.out.println("Transferring data in from " + source + " to " + target);
Thread.sleep(5000);
System.out.println("Transferred data in from " + source + " to " + target);
}
@Override
public void transferDataOut(String source, String target, String protocol) throws Exception {
System.out.println("Transferring data out from " + source + " to " + target);
File f = new File(target);
f.getParentFile().mkdirs();
f.createNewFile();
System.out.println("Transferred data out from " + source + " to " + target);
}
}
| 8,896 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/compute-resource-api/src/main/java/org/apache/airavata/k8s/compute | Create_ds/airavata-sandbox/airavata-kubernetes/modules/compute-resource-api/src/main/java/org/apache/airavata/k8s/compute/api/ComputeOperations.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.compute.api;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public interface ComputeOperations {
public ExecutionResult executeCommand(String command) throws Exception;
public void transferDataIn(String source, String target, String protocol) throws Exception;
public void transferDataOut(String source, String target, String protocol) throws Exception;
}
| 8,897 |
0 | Create_ds/airavata-sandbox/airavata-kubernetes/modules/compute-resource-api/src/main/java/org/apache/airavata/k8s/compute | Create_ds/airavata-sandbox/airavata-kubernetes/modules/compute-resource-api/src/main/java/org/apache/airavata/k8s/compute/api/ExecutionResult.java | /**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.k8s.compute.api;
/**
* TODO: Class level comments please
*
* @author dimuthu
* @since 1.0.0-SNAPSHOT
*/
public class ExecutionResult {
private String stdOut;
private String stdErr;
private int exitStatus = -1;
public String getStdOut() {
return stdOut;
}
public ExecutionResult setStdOut(String stdOut) {
this.stdOut = stdOut;
return this;
}
public String getStdErr() {
return stdErr;
}
public ExecutionResult setStdErr(String stdErr) {
this.stdErr = stdErr;
return this;
}
public int getExitStatus() {
return exitStatus;
}
public ExecutionResult setExitStatus(int exitStatus) {
this.exitStatus = exitStatus;
return this;
}
}
| 8,898 |
0 | Create_ds/airavata-sandbox/airavata-layered-architecture/src/test/java/org/apache/airavata/resources | Create_ds/airavata-sandbox/airavata-layered-architecture/src/test/java/org/apache/airavata/resources/batch/HPCBatchResourceTest.java | /*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.airavata.resources.batch;
import org.apache.airavata.models.*;
import org.apache.airavata.models.resources.hpc.GroovyMap;
import org.apache.airavata.models.resources.hpc.JobManagerConfiguration;
import org.apache.airavata.models.resources.hpc.PBSJobConfiguration;
import org.apache.airavata.models.resources.hpc.Script;
import org.apache.airavata.models.runners.ssh.SSHKeyAuthentication;
import org.apache.airavata.models.runners.ssh.SSHServerInfo;
import org.apache.airavata.runners.ssh.SSHRunnerTest;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
public class HPCBatchResourceTest {
private final static Logger logger = LoggerFactory.getLogger(HPCBatchResourceTest.class);
@Test
public void testGenericResource() throws Exception {
SSHKeyAuthentication br2SshAuthentication = new SSHKeyAuthentication(
Constants.loginUserName,
IOUtils.toByteArray(SSHRunnerTest.class.getClassLoader().getResourceAsStream("ssh/id_rsa")),
IOUtils.toByteArray(SSHRunnerTest.class.getClassLoader().getResourceAsStream("ssh/id_rsa.pub")),
"dummy",
SSHRunnerTest.class.getClassLoader().getResource("ssh/known_hosts").getPath(),
false
);
SSHServerInfo br2 = new SSHServerInfo(Constants.loginUserName, "bigred2.uits.iu.edu", br2SshAuthentication,22);
Map<JobManagerConfiguration.JobManagerCommand, String> jobManagerCommands = new HashMap<>();
jobManagerCommands.put(JobManagerConfiguration.JobManagerCommand.SUBMISSION, "qsub");
jobManagerCommands.put(JobManagerConfiguration.JobManagerCommand.JOB_MONITORING, "qstat");
jobManagerCommands.put(JobManagerConfiguration.JobManagerCommand.DELETION, "qdel");
JobManagerConfiguration pbsJobConfiguration = new PBSJobConfiguration(PBSJobConfiguration.class.getClassLoader().
getResource("resources/batch/PBS_Groovy.template").getPath(), ".pbs",
"/opt/torque/torque-5.0.1/bin", jobManagerCommands, new BatchJobOutputParser());
HPCBatchResource hpcBatchResource = new HPCBatchResource(br2, pbsJobConfiguration, br2SshAuthentication);
String routingKey = UUID.randomUUID().toString();
//Defining all the configurations
hpcBatchResource.submitBatchJob(routingKey, getJobSpecification());
}
@Test
public void testBR2() throws Exception {
String routingKey = UUID.randomUUID().toString();
//Defining only which resource to use and the implementation handles the details
BigRed2 bigRed2 = new BigRed2();
bigRed2.submitBatchJob(routingKey, getJobSpecification());
}
private GroovyMap getJobSpecification(){
GroovyMap jobSpecification = new GroovyMap();
jobSpecification.add(Script.NODES, 1);
jobSpecification.add(Script.PROCESS_PER_NODE, 16);
jobSpecification.add(Script.MAX_WALL_TIME, "00:30:00");
jobSpecification.add(Script.QUEUE_NAME, "debug_gpu");
jobSpecification.add(Script.MAIL_ADDRESS, "supun.nakandala@gmail.com");
List<String> moduleLoads = new ArrayList<>();
moduleLoads.add("module load ccm");
moduleLoads.add("module load singularity");
jobSpecification.add(Script.MODULE_COMMANDS, moduleLoads);
jobSpecification.add(Script.WORKING_DIR, "/N/dc2/scratch/snakanda/work-dirs");
List<String> inputs = new ArrayList<>();
inputs.add("~/airavata/code_tf.py");
jobSpecification.add(Script.INPUTS, inputs);
jobSpecification.add(Script.EXECUTABLE_PATH, "singularity exec /N/soft/cle5/singularity/images/tensorflow1.1-ubuntu-py2.7.11-test.img python");
jobSpecification.add(Script.JOB_SUBMITTER_COMMAND,"ccmrun");
jobSpecification.add(Script.STANDARD_OUT_FILE, "STDOUT.txt");
jobSpecification.add(Script.STANDARD_ERROR_FILE, "STDERR.txt");
return jobSpecification;
}
} | 8,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.