use of org.apache.airavata.model.workspace.Project in project airavata by apache.
the class RegistryServerHandler method getUserProjects.
/**
* Get All User Projects
* Get all Project for the user with pagination. Results will be ordered based on creation time DESC.
*
* @param gatewayId The identifier for the requested gateway.
* @param userName The identifier of the user.
* @param limit The amount results to be fetched.
* @param offset The starting point of the results to be fetched.
*/
@Override
public List<Project> getUserProjects(String gatewayId, String userName, int limit, int offset) throws RegistryServiceException, TException {
if (!validateString(userName)) {
logger.error("Username cannot be empty. Please provide a valid user..");
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Username cannot be empty. Please provide a valid user..");
throw exception;
}
if (!isGatewayExistInternal(gatewayId)) {
logger.error("Gateway does not exist.Please provide a valid gateway id...");
throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
}
List<Project> projects = new ArrayList<Project>();
try {
if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)) {
logger.warn("User does not exist in the system. Please provide a valid user..");
return projects;
}
experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
Map<String, String> filters = new HashMap<String, String>();
filters.put(Constants.FieldConstants.ProjectConstants.OWNER, userName);
filters.put(Constants.FieldConstants.ProjectConstants.GATEWAY_ID, gatewayId);
List<Object> list = experimentCatalog.search(ExperimentCatalogModelType.PROJECT, filters, limit, offset, Constants.FieldConstants.ProjectConstants.CREATION_TIME, ResultOrderType.DESC);
if (list != null && !list.isEmpty()) {
for (Object o : list) {
projects.add((Project) o);
}
}
logger.debug("Airavata retrieved projects for user : " + userName + " and gateway id : " + gatewayId);
return projects;
} catch (RegistryException e) {
logger.error("Error while retrieving projects", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while retrieving projects. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.model.workspace.Project in project airavata by apache.
the class RegistryServerHandler method searchProjects.
/**
* Search User Projects
* Search and get all Projects for user by project description or/and project name with pagination.
* Results will be ordered based on creation time DESC.
*
* @param gatewayId The unique identifier of the gateway making the request.
* @param userName The identifier of the user.
* @param filters Map of multiple filter criteria. Currenlt search filters includes Project Name and Project Description
* @param limit The amount results to be fetched.
* @param offset The starting point of the results to be fetched.
*/
@Override
public List<Project> searchProjects(String gatewayId, String userName, List<String> accessibleProjIds, Map<ProjectSearchFields, String> filters, int limit, int offset) throws RegistryServiceException, TException {
if (!validateString(userName)) {
logger.error("Username cannot be empty. Please provide a valid user..");
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage("Username cannot be empty. Please provide a valid user..");
throw exception;
}
if (!isGatewayExistInternal(gatewayId)) {
logger.error("Gateway does not exist.Please provide a valid gateway id...");
throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
}
try {
if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)) {
logger.error("User does not exist in the system. Please provide a valid user..");
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
exception.setMessage("User does not exist in the system. Please provide a valid user..");
throw exception;
}
List<Project> projects = new ArrayList<Project>();
experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
Map<String, String> regFilters = new HashMap<String, String>();
regFilters.put(Constants.FieldConstants.ProjectConstants.GATEWAY_ID, gatewayId);
for (Map.Entry<ProjectSearchFields, String> entry : filters.entrySet()) {
if (entry.getKey().equals(ProjectSearchFields.PROJECT_NAME)) {
regFilters.put(Constants.FieldConstants.ProjectConstants.PROJECT_NAME, entry.getValue());
} else if (entry.getKey().equals(ProjectSearchFields.PROJECT_DESCRIPTION)) {
regFilters.put(Constants.FieldConstants.ProjectConstants.DESCRIPTION, entry.getValue());
}
}
if (accessibleProjIds.size() == 0 && !ServerSettings.isEnableSharing()) {
if (!regFilters.containsKey(AbstractExpCatResource.ProjectConstants.USERNAME)) {
regFilters.put(AbstractExpCatResource.ProjectConstants.USERNAME, userName);
}
}
List<Object> results = experimentCatalog.searchAllAccessible(ExperimentCatalogModelType.PROJECT, accessibleProjIds, regFilters, limit, offset, Constants.FieldConstants.ProjectConstants.CREATION_TIME, ResultOrderType.DESC);
for (Object object : results) {
projects.add((Project) object);
}
logger.debug("Airavata retrieved projects for user : " + userName + " and gateway id : " + gatewayId);
return projects;
} catch (Exception e) {
logger.error("Error while retrieving projects", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while retrieving projects. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.model.workspace.Project in project airavata by apache.
the class CreateLaunchExperiment method createExperimentForStampedeAmber.
public static String createExperimentForStampedeAmber(Airavata.Client client) throws TException {
try {
List<InputDataObjectType> exInputs = client.getApplicationInputs(new AuthzToken(""), amberAppId);
// }
for (InputDataObjectType inputDataObjectType : exInputs) {
if (inputDataObjectType.getName().equalsIgnoreCase("Heat_Restart_File")) {
inputDataObjectType.setValue("file://ogce@stampede.xsede.org:/scratch/01437/ogce/gta-work-dirs/PROCESS_e0610a6c-5778-4a69-a004-f440e29194af/02_Heat.rst");
} else if (inputDataObjectType.getName().equalsIgnoreCase("Production_Control_File")) {
inputDataObjectType.setValue("file://ogce@stampede.xsede.org:/scratch/01437/ogce/gta-work-dirs/PROCESS_e0610a6c-5778-4a69-a004-f440e29194af/03_Prod.in");
} else if (inputDataObjectType.getName().equalsIgnoreCase("Parameter_Topology_File")) {
inputDataObjectType.setValue("file://ogce@stampede.xsede.org:/scratch/01437/ogce/gta-work-dirs/PROCESS_e0610a6c-5778-4a69-a004-f440e29194af/prmtop");
}
}
List<OutputDataObjectType> exOut = client.getApplicationOutputs(new AuthzToken(""), amberAppId);
Project project = ProjectModelUtil.createProject("default", "admin", "test project");
String projectId = client.createProject(new AuthzToken(""), DEFAULT_GATEWAY, project);
ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY, projectId, "admin", "sshEchoExperiment", "SimpleEchoBR", amberAppId, exInputs);
simpleExperiment.setExperimentOutputs(exOut);
Map<String, String> computeResources = airavataClient.getAvailableAppInterfaceComputeResources(new AuthzToken(""), amberAppId);
if (computeResources != null && computeResources.size() != 0) {
for (String id : computeResources.keySet()) {
String resourceName = computeResources.get(id);
if (resourceName.equals(stampedeHostName)) {
ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 4, 1, 1, "normal", 20, 1);
UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
userConfigurationData.setComputationalResourceScheduling(scheduling);
simpleExperiment.setUserConfigurationData(userConfigurationData);
return client.createExperiment(new AuthzToken(""), DEFAULT_GATEWAY, simpleExperiment);
}
}
}
} catch (AiravataSystemException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new AiravataSystemException(e);
} catch (InvalidRequestException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new InvalidRequestException(e);
} catch (AiravataClientException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new AiravataClientException(e);
} catch (TException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new TException(e);
}
return null;
}
use of org.apache.airavata.model.workspace.Project in project airavata by apache.
the class CreateLaunchExperimentUS3 method createUS3ExperimentForStampede.
public static String createUS3ExperimentForStampede(Airavata.Client client) throws AiravataSystemException, InvalidRequestException, AiravataClientException, TException {
try {
List<InputDataObjectType> exInputs = new ArrayList<InputDataObjectType>();
InputDataObjectType input = new InputDataObjectType();
input.setName("input");
input.setType(DataType.URI);
input.setValue("file:///home/sgg/chathuri/laptop_backup/airavata/ultrascan_input/hpcinput.tar");
InputDataObjectType input1 = new InputDataObjectType();
input1.setName("walltime");
input1.setType(DataType.STRING);
input1.setValue("-walltime=60");
InputDataObjectType input2 = new InputDataObjectType();
input2.setName("mgroupcount");
input2.setType(DataType.STRING);
input2.setValue("-mgroupcount=1");
exInputs.add(input);
exInputs.add(input1);
exInputs.add(input2);
List<OutputDataObjectType> exOut = new ArrayList<OutputDataObjectType>();
OutputDataObjectType output = new OutputDataObjectType();
output.setName("output");
output.setType(DataType.URI);
output.setValue("");
// OutputDataObjectType output1 = new OutputDataObjectType();
// output1.setName("stdout");
// output1.setType(DataType.STDOUT);
// output1.setValue("");
// OutputDataObjectType output2 = new OutputDataObjectType();
// output2.setName("stderr");
// output2.setType(DataType.STDERR);
// output2.setValue("");
exOut.add(output);
// exOut.add(output1);
// exOut.add(output2);
Project project = ProjectModelUtil.createProject("project1", "admin", "test project");
String projectId = client.createProject(new AuthzToken(""), DEFAULT_GATEWAY, project);
ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY, projectId, "ultrascan", "US3ExperimentStampede", "US3AppStampede", "ultrascan_7ce6cd43-622c-44e0-87c5-fb7a6528c799", exInputs);
simpleExperiment.setExperimentOutputs(exOut);
ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling("stampede.tacc.xsede.org_e59e046f-e0e1-49c4-8475-2fab2e35d044", 32, 2, 0, "normal", 30, 0);
scheduling.setResourceHostId("stampede.tacc.xsede.org_e59e046f-e0e1-49c4-8475-2fab2e35d044");
UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
userConfigurationData.setComputationalResourceScheduling(scheduling);
/* AdvancedOutputDataHandling dataHandling = new AdvancedOutputDataHandling();
dataHandling.setOutputDataDir("/home/sgg/chathuri/laptop_backup/airavata");
userConfigurationData.setAdvanceOutputDataHandling(dataHandling);*/
simpleExperiment.setUserConfigurationData(userConfigurationData);
return client.createExperiment(new AuthzToken(""), DEFAULT_GATEWAY, simpleExperiment);
} catch (AiravataSystemException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new AiravataSystemException(e);
} catch (InvalidRequestException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new InvalidRequestException(e);
} catch (AiravataClientException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new AiravataClientException(e);
} catch (TException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new TException(e);
}
}
use of org.apache.airavata.model.workspace.Project in project airavata by apache.
the class CreateLaunchExperimentUS3 method createExperimentForTrestles.
// public static void addDescriptors() throws AiravataAPIInvocationException,ApplicationSettingsException {
// try {
// UltrascanDocumentCreator documentCreator = new UltrascanDocumentCreator(getAiravataAPI());
// documentCreator.createMPIPBSDocsTrestles();
// documentCreator.createEchoPBSDocsforTestles();
// documentCreator.createEchoSlurmDocsofStampede();
// documentCreator.createMPISLURMDocsStampede();
// } catch (AiravataAPIInvocationException e) {
// logger.error("Unable to create airavata API", e.getMessage());
// throw new AiravataAPIInvocationException(e);
// } catch (ApplicationSettingsException e) {
// logger.error("Unable to create airavata API", e.getMessage());
// throw new ApplicationSettingsException(e.getMessage());
// }
// }
// private static AiravataAPI getAiravataAPI() throws AiravataAPIInvocationException, ApplicationSettingsException {
// AiravataAPI airavataAPI;
// try {
// String sysUser = ClientSettings.getSetting(DEFAULT_USER);
// String gateway = ClientSettings.getSetting(DEFAULT_GATEWAY);
// airavataAPI = AiravataAPIFactory.getAPI(gateway, sysUser);
// } catch (AiravataAPIInvocationException e) {
// logger.error("Unable to create airavata API", e.getMessage());
// throw new AiravataAPIInvocationException(e);
// } catch (ApplicationSettingsException e) {
// logger.error("Unable to create airavata API", e.getMessage());
// throw new ApplicationSettingsException(e.getMessage());
// }
// return airavataAPI;
// }
public static String createExperimentForTrestles(Airavata.Client client) throws TException {
try {
List<InputDataObjectType> exInputs = new ArrayList<InputDataObjectType>();
InputDataObjectType input = new InputDataObjectType();
input.setName("echo_input");
input.setType(DataType.STRING);
input.setValue("echo_output=Hello World");
exInputs.add(input);
List<OutputDataObjectType> exOut = new ArrayList<OutputDataObjectType>();
OutputDataObjectType output = new OutputDataObjectType();
output.setName("echo_output");
output.setType(DataType.STRING);
output.setValue("");
exOut.add(output);
Project project = ProjectModelUtil.createProject("project1", "admin", "test project");
String projectId = client.createProject(new AuthzToken(""), DEFAULT_GATEWAY, project);
ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY, projectId, "admin", "US3EchoExperimentTrestles", "US3EchoTrestles", "US3EchoTrestles", exInputs);
simpleExperiment.setExperimentOutputs(exOut);
ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling("trestles.sdsc.edu", 1, 1, 1, "shared", 0, 0);
scheduling.setResourceHostId("gsissh-trestles");
UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
userConfigurationData.setComputationalResourceScheduling(scheduling);
simpleExperiment.setUserConfigurationData(userConfigurationData);
return client.createExperiment(new AuthzToken(""), DEFAULT_GATEWAY, simpleExperiment);
} catch (AiravataSystemException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new AiravataSystemException(e);
} catch (InvalidRequestException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new InvalidRequestException(e);
} catch (AiravataClientException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new AiravataClientException(e);
} catch (TException e) {
logger.error("Error occured while creating the experiment...", e.getMessage());
throw new TException(e);
}
}
Aggregations