use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.
the class ApplicationDeploymentImpl method updateApplicationDeployment.
@Override
public void updateApplicationDeployment(String deploymentId, ApplicationDeploymentDescription updatedDeployment) throws AppCatalogException {
try {
AppDeploymentResource deploymentResource = new AppDeploymentResource();
AppDeploymentResource existingDep = (AppDeploymentResource) deploymentResource.get(deploymentId);
ComputeResourceResource computeHostResource = new ComputeResourceResource();
AppModuleResource moduleResource = new AppModuleResource();
if (!computeHostResource.isExists(updatedDeployment.getComputeHostId())) {
logger.error("Compute host does not exist in the system. Please create a Compute host first...");
throw new AppCatalogException("Compute host does not exist in the system. Please create a Compute host first...");
}
if (!moduleResource.isExists(updatedDeployment.getAppModuleId())) {
logger.error("Application module does not exist in the system. Please create an application module first...");
throw new AppCatalogException("Application module does not exist in the system. Please create an application module first...");
}
AppModuleResource module = (AppModuleResource) moduleResource.get(updatedDeployment.getAppModuleId());
existingDep.setAppModuleId(updatedDeployment.getAppModuleId());
existingDep.setModuleResource(module);
existingDep.setHostId(updatedDeployment.getComputeHostId());
existingDep.setHostResource((ComputeResourceResource) computeHostResource.get(updatedDeployment.getComputeHostId()));
existingDep.setAppDes(updatedDeployment.getAppDeploymentDescription());
existingDep.setExecutablePath(updatedDeployment.getExecutablePath());
existingDep.setDefaultQueueName(updatedDeployment.getDefaultQueueName());
existingDep.setDefaultCPUCount(updatedDeployment.getDefaultCPUCount());
existingDep.setDefaultNodeCount(updatedDeployment.getDefaultNodeCount());
existingDep.setDefaultWalltime(updatedDeployment.getDefaultWalltime());
existingDep.setEditableByUser(updatedDeployment.isEditableByUser());
if (updatedDeployment.getParallelism() != null) {
existingDep.setParallelism(updatedDeployment.getParallelism().toString());
}
existingDep.save();
// remove existing module load commands
ModuleLoadCmdResource cmdResource = new ModuleLoadCmdResource();
Map<String, String> ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, deploymentId);
cmdResource.remove(ids);
List<CommandObject> moduleLoadCmds = updatedDeployment.getModuleLoadCmds();
if (moduleLoadCmds != null && !moduleLoadCmds.isEmpty()) {
for (CommandObject cmd : moduleLoadCmds) {
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, deploymentId);
ids.put(AppCatAbstractResource.ModuleLoadCmdConstants.CMD, cmd.getCommand());
if (cmdResource.isExists(ids)) {
cmdResource = (ModuleLoadCmdResource) cmdResource.get(ids);
}
cmdResource.setCmd(cmd.getCommand());
cmdResource.setAppDeploymentResource(existingDep);
cmdResource.setAppDeploymentId(deploymentId);
cmdResource.setOrder(cmd.getCommandOrder());
cmdResource.save();
}
}
PreJobCommandResource preJobCommandResource = new PreJobCommandResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.PreJobCommandConstants.DEPLOYMENT_ID, deploymentId);
preJobCommandResource.remove(ids);
List<CommandObject> preJobCommands = updatedDeployment.getPreJobCommands();
if (preJobCommands != null && !preJobCommands.isEmpty()) {
for (CommandObject cmd : preJobCommands) {
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.PreJobCommandConstants.DEPLOYMENT_ID, deploymentId);
ids.put(AppCatAbstractResource.PreJobCommandConstants.COMMAND, cmd.getCommand());
if (preJobCommandResource.isExists(ids)) {
preJobCommandResource = (PreJobCommandResource) preJobCommandResource.get(ids);
}
preJobCommandResource.setCommand(cmd.getCommand());
preJobCommandResource.setAppDeploymentResource(existingDep);
preJobCommandResource.setAppDeploymentId(deploymentId);
preJobCommandResource.setOrder(cmd.getCommandOrder());
preJobCommandResource.save();
}
}
PostJobCommandResource postJobCommandResource = new PostJobCommandResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.PostJobCommandConstants.DEPLOYMENT_ID, deploymentId);
postJobCommandResource.remove(ids);
List<CommandObject> postJobCommands = updatedDeployment.getPostJobCommands();
if (postJobCommands != null && !postJobCommands.isEmpty()) {
for (CommandObject cmd : postJobCommands) {
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.PostJobCommandConstants.DEPLOYMENT_ID, deploymentId);
ids.put(AppCatAbstractResource.PostJobCommandConstants.COMMAND, cmd.getCommand());
if (postJobCommandResource.isExists(ids)) {
postJobCommandResource = (PostJobCommandResource) postJobCommandResource.get(ids);
}
postJobCommandResource.setCommand(cmd.getCommand());
postJobCommandResource.setOrder(cmd.getCommandOrder());
postJobCommandResource.setAppDeploymentResource(existingDep);
postJobCommandResource.setAppDeploymentId(deploymentId);
postJobCommandResource.save();
}
}
// remove existing lib prepand paths
LibraryPrepandPathResource prepandPathResource = new LibraryPrepandPathResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, deploymentId);
prepandPathResource.remove(ids);
List<SetEnvPaths> libPrependPaths = updatedDeployment.getLibPrependPaths();
if (libPrependPaths != null && !libPrependPaths.isEmpty()) {
for (SetEnvPaths path : libPrependPaths) {
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, deploymentId);
ids.put(AppCatAbstractResource.LibraryPrepandPathConstants.NAME, path.getName());
if (prepandPathResource.isExists(ids)) {
prepandPathResource = (LibraryPrepandPathResource) prepandPathResource.get(ids);
}
prepandPathResource.setAppDeploymentResource(existingDep);
prepandPathResource.setName(path.getName());
prepandPathResource.setValue(path.getValue());
prepandPathResource.setDeploymentId(deploymentId);
prepandPathResource.save();
}
}
List<SetEnvPaths> libApendPaths = updatedDeployment.getLibAppendPaths();
// remove lib append paths
LibraryApendPathResource apendPathResource = new LibraryApendPathResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.LibraryApendPathConstants.DEPLOYMENT_ID, deploymentId);
apendPathResource.remove(ids);
if (libApendPaths != null && !libApendPaths.isEmpty()) {
for (SetEnvPaths path : libApendPaths) {
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.LibraryApendPathConstants.DEPLOYMENT_ID, deploymentId);
ids.put(AppCatAbstractResource.LibraryApendPathConstants.NAME, path.getName());
if (apendPathResource.isExists(ids)) {
apendPathResource = (LibraryApendPathResource) apendPathResource.get(ids);
}
apendPathResource.setAppDeploymentResource(existingDep);
apendPathResource.setName(path.getName());
apendPathResource.setValue(path.getValue());
apendPathResource.setDeploymentId(deploymentId);
apendPathResource.save();
}
}
List<SetEnvPaths> setEnvironment = updatedDeployment.getSetEnvironment();
// remove existing setEnvPaths
AppEnvironmentResource environmentResource = new AppEnvironmentResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.AppEnvironmentConstants.DEPLOYMENT_ID, deploymentId);
environmentResource.remove(ids);
if (setEnvironment != null && !setEnvironment.isEmpty()) {
for (SetEnvPaths path : setEnvironment) {
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.AppEnvironmentConstants.DEPLOYMENT_ID, deploymentId);
ids.put(AppCatAbstractResource.AppEnvironmentConstants.NAME, path.getName());
if (environmentResource.isExists(ids)) {
environmentResource = (AppEnvironmentResource) environmentResource.get(ids);
}
environmentResource.setAppDeploymentResource(existingDep);
environmentResource.setName(path.getName());
environmentResource.setValue(path.getValue());
environmentResource.setDeploymentId(deploymentId);
environmentResource.setOrder(path.getEnvPathOrder());
environmentResource.save();
}
}
} catch (Exception e) {
logger.error("Error while updating application deployment...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.
the class ApplicationDeploymentImpl method getAllApplicationDeployements.
@Override
public List<ApplicationDeploymentDescription> getAllApplicationDeployements(String gatewayId) throws AppCatalogException {
List<ApplicationDeploymentDescription> deploymentDescriptions = new ArrayList<ApplicationDeploymentDescription>();
try {
AppDeploymentResource resource = new AppDeploymentResource();
resource.setGatewayId(gatewayId);
List<AppCatalogResource> resources = resource.getAll();
if (resources != null && !resources.isEmpty()) {
deploymentDescriptions = AppCatalogThriftConversion.getAppDepDescList(resources);
}
} catch (Exception e) {
logger.error("Error while retrieving app deployment list...", e);
throw new AppCatalogException(e);
}
return deploymentDescriptions;
}
use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.
the class ComputeResourceImpl method addCloudJobSubmission.
@Override
public String addCloudJobSubmission(CloudJobSubmission cloudJobSubmission) throws AppCatalogException {
try {
cloudJobSubmission.setJobSubmissionInterfaceId(AppCatalogUtils.getID("Cloud"));
CloudSubmissionResource resource = AppCatalogThriftConversion.getCloudJobSubmission(cloudJobSubmission);
resource.save();
return resource.getJobSubmissionInterfaceId();
} catch (Exception e) {
logger.error("Error while saving SSH Job Submission...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.
the class ComputeResourceImpl method removeComputeResource.
@Override
public void removeComputeResource(String resourceId) throws AppCatalogException {
try {
ComputeResourceResource resource = new ComputeResourceResource();
resource.remove(resourceId);
} catch (Exception e) {
logger.error("Error while removing compute resource...", e);
throw new AppCatalogException(e);
}
}
use of org.apache.airavata.registry.cpi.AppCatalogException in project airavata by apache.
the class ComputeResourceImpl method getCloudJobSubmission.
@Override
public CloudJobSubmission getCloudJobSubmission(String submissionId) throws AppCatalogException {
try {
CloudSubmissionResource resource = new CloudSubmissionResource();
resource = (CloudSubmissionResource) resource.get(submissionId);
return AppCatalogThriftConversion.getCloudJobSubmissionDescription(resource);
} catch (Exception e) {
logger.error("Error while retrieving SSH Job Submission...", e);
throw new AppCatalogException(e);
}
}
Aggregations