use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method removeUserConfigData.
public void removeUserConfigData(String experimentId) throws RegistryException {
try {
ExperimentResource experiment = new ExperimentResource();
experiment.setExperimentId(experimentId);
experiment.remove(ResourceType.USER_CONFIGURATION_DATA, experimentId);
} catch (Exception e) {
logger.error("Error while removing experiment config..", e);
throw new RegistryException(e);
}
}
use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method searchAllAccessibleExperiments.
public List<ExperimentSummaryModel> searchAllAccessibleExperiments(List<String> accessibleIds, Map<String, String> filters, int limit, int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException {
Map<String, String> fil = new HashMap<String, String>();
if (filters != null && filters.size() != 0) {
List<ExperimentSummaryModel> experimentSummaries = new ArrayList<>();
long fromTime = 0;
long toTime = 0;
try {
for (String field : filters.keySet()) {
if (field.equals(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_NAME)) {
fil.put(AbstractExpCatResource.ExperimentConstants.EXPERIMENT_NAME, filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.USER_NAME)) {
fil.put(AbstractExpCatResource.ExperimentConstants.USER_NAME, filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.PROJECT_ID)) {
fil.put(AbstractExpCatResource.ExperimentConstants.PROJECT_ID, filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.GATEWAY_ID)) {
fil.put(AbstractExpCatResource.ExperimentConstants.GATEWAY_ID, filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.DESCRIPTION)) {
fil.put(AbstractExpCatResource.ExperimentConstants.DESCRIPTION, filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.EXECUTION_ID)) {
fil.put(AbstractExpCatResource.ExperimentConstants.EXECUTION_ID, filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_STATUS)) {
fil.put(AbstractExpCatResource.ExperimentStatusConstants.STATE, filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.FROM_DATE)) {
fromTime = Long.parseLong(filters.get(field));
} else if (field.equals(Constants.FieldConstants.ExperimentConstants.TO_DATE)) {
toTime = Long.parseLong(filters.get(field));
}
}
List<ExperimentSummaryResource> experimentSummaryResources;
if (fromTime != 0 && toTime != 0) {
experimentSummaryResources = workerResource.searchExperiments(accessibleIds, new Timestamp(fromTime), new Timestamp(toTime), fil, limit, offset, orderByIdentifier, resultOrderType);
} else {
experimentSummaryResources = workerResource.searchExperiments(accessibleIds, null, null, fil, limit, offset, orderByIdentifier, resultOrderType);
}
if (experimentSummaryResources != null && !experimentSummaryResources.isEmpty()) {
for (ExperimentSummaryResource ex : experimentSummaryResources) {
experimentSummaries.add(ThriftDataModelConversion.getExperimentSummary(ex));
}
}
return experimentSummaries;
} catch (Exception e) {
logger.error("Error while retrieving experiment summary from registry", e);
throw new RegistryException(e);
}
}
return null;
}
use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method addExperimentStatus.
public String addExperimentStatus(ExperimentStatus experimentStatus, String expId) throws RegistryException {
try {
ExperimentResource experiment = new ExperimentResource();
experiment.setExperimentId(expId);
ExperimentStatusResource status = experiment.getExperimentStatus();
ExperimentState newState = experimentStatus.getState();
if (status == null) {
status = (ExperimentStatusResource) experiment.create(ResourceType.EXPERIMENT_STATUS);
status.setStatusId(getStatusID("EXPERIMENT_STATE"));
} else {
String state = status.getState();
if (newState != null && !state.equals(newState.toString())) {
status.setStatusId(getStatusID("EXPERIMENT_STATE"));
}
}
status.setExperimentId(expId);
status.setTimeOfStateChange(AiravataUtils.getTime(experimentStatus.getTimeOfStateChange()));
if (newState != null) {
status.setState(newState.toString());
}
status.setReason(experimentStatus.getReason());
status.save();
logger.debug(expId, "Added experiment {} status to {}.", expId, experimentStatus.toString());
} catch (Exception e) {
logger.error(expId, "Error while adding experiment status...", e);
throw new RegistryException(e);
}
return expId;
}
use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method addUserConfigData.
public String addUserConfigData(UserConfigurationDataModel configurationData, String experimentId) throws RegistryException {
try {
UserConfigurationDataResource configDataResource = new UserConfigurationDataResource();
configDataResource.setExperimentId(experimentId);
configDataResource.setAiravataAutoSchedule(configurationData.isAiravataAutoSchedule());
configDataResource.setOverrideManualScheduledParams(configurationData.isOverrideManualScheduledParams());
configDataResource.setShareExperimentPublically(configurationData.isShareExperimentPublicly());
configDataResource.setThrottleResources(configurationData.isThrottleResources());
configDataResource.setUserDn(configurationData.getUserDN());
configDataResource.setGenerateCert(configurationData.isGenerateCert());
configDataResource.setResourceHostId(configurationData.getComputationalResourceScheduling().getResourceHostId());
configDataResource.setTotalCpuCount(configurationData.getComputationalResourceScheduling().getTotalCPUCount());
configDataResource.setNodeCount(configurationData.getComputationalResourceScheduling().getNodeCount());
configDataResource.setNumberOfThreads(configurationData.getComputationalResourceScheduling().getNumberOfThreads());
configDataResource.setQueueName(configurationData.getComputationalResourceScheduling().getQueueName());
configDataResource.setWallTimeLimit(configurationData.getComputationalResourceScheduling().getWallTimeLimit());
configDataResource.setTotalPhysicalMemory(configurationData.getComputationalResourceScheduling().getTotalPhysicalMemory());
configDataResource.setStaticWorkingDir(configurationData.getComputationalResourceScheduling().getStaticWorkingDir());
configDataResource.setStorageId(configurationData.getStorageId());
configDataResource.setExperimentDataDir(configurationData.getExperimentDataDir());
configDataResource.setUseUserCRPref(configurationData.isUseUserCRPref());
configDataResource.setOverrideLoginUserName(configurationData.getComputationalResourceScheduling().getOverrideLoginUserName());
configDataResource.setOverrideScratchLocation(configurationData.getComputationalResourceScheduling().getOverrideScratchLocation());
configDataResource.setOverrideAllocationProjectNumber(configurationData.getComputationalResourceScheduling().getOverrideAllocationProjectNumber());
configDataResource.save();
} catch (Exception e) {
logger.error("Unable to save user config data", e);
throw new RegistryException(e);
}
return experimentId;
}
use of org.apache.airavata.registry.cpi.RegistryException in project airavata by apache.
the class ExperimentRegistry method updateJob.
public String updateJob(JobModel job, CompositeIdentifier cis) throws RegistryException {
String taskId = (String) cis.getTopLevelIdentifier();
String jobId = (String) cis.getSecondLevelIdentifier();
try {
TaskResource taskResource = new TaskResource();
taskResource.setTaskId(taskId);
JobResource jobResource = taskResource.getJob(jobId);
jobResource.setJobId(jobId);
jobResource.setTaskId(job.getTaskId());
jobResource.setProcessId(job.getProcessId());
jobResource.setJobDescription(job.getJobDescription());
jobResource.setCreationTime(AiravataUtils.getTime(job.getCreationTime()));
jobResource.setComputeResourceConsumed(job.getComputeResourceConsumed());
jobResource.setJobName(job.getJobName());
jobResource.setWorkingDir(job.getWorkingDir());
jobResource.setStdOut(job.getStdOut());
jobResource.setStdErr(job.getStdErr());
jobResource.setExitCode(job.getExitCode());
jobResource.save();
} catch (Exception e) {
logger.error(jobId, "Error while adding job...", e);
throw new RegistryException(e);
}
return jobId;
}
Aggregations