use of org.apache.airavata.registry.core.app.catalog.model.ComputeResource in project airavata by apache.
the class HostAliasAppResource method save.
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
HostAlias existingHostAlias = em.find(HostAlias.class, new HostAliasPK(resourceID, alias));
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
if (existingHostAlias != null) {
existingHostAlias.setAlias(alias);
existingHostAlias.setComputeResource(computeResource);
existingHostAlias.setResourceID(resourceID);
em.merge(existingHostAlias);
} else {
HostAlias hostAlias = new HostAlias();
hostAlias.setAlias(alias);
hostAlias.setResourceID(resourceID);
hostAlias.setComputeResource(computeResource);
em.persist(hostAlias);
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
use of org.apache.airavata.registry.core.app.catalog.model.ComputeResource in project airavata by apache.
the class HostIPAddressResource method save.
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
HostIPAddress existingHostIP = em.find(HostIPAddress.class, new HostIPAddressPK(resourceID, ipaddress));
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
if (existingHostIP != null) {
existingHostIP.setIpaddress(ipaddress);
existingHostIP.setResourceID(resourceID);
existingHostIP.setComputeResource(computeResource);
em.merge(existingHostIP);
} else {
HostIPAddress hostIPAddress = new HostIPAddress();
hostIPAddress.setIpaddress(ipaddress);
hostIPAddress.setResourceID(resourceID);
hostIPAddress.setComputeResource(computeResource);
em.persist(hostIPAddress);
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
use of org.apache.airavata.registry.core.app.catalog.model.ComputeResource in project airavata by apache.
the class AppDeploymentResource method save.
@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
ApplicationDeployment existingDeployment = em.find(ApplicationDeployment.class, deploymentId);
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
ApplicationModule applicationModule = em.find(ApplicationModule.class, appModuleId);
ComputeResource computeHost = em.find(ComputeResource.class, hostId);
if (existingDeployment != null) {
existingDeployment.setDeploymentID(deploymentId);
existingDeployment.setApplicationDesc(appDes);
existingDeployment.setAppModuleID(appModuleId);
existingDeployment.setApplicationModule(applicationModule);
existingDeployment.setComputeResource(computeHost);
existingDeployment.setHostID(hostId);
existingDeployment.setExecutablePath(executablePath);
existingDeployment.setParallelism(parallelism);
existingDeployment.setGatewayId(gatewayId);
existingDeployment.setDefaultQueueName(defaultQueueName);
existingDeployment.setDefaultCPUCount(defaultCPUCount);
existingDeployment.setDefaultNodeCount(defaultNodeCount);
existingDeployment.setDefaultWalltime(defaultWalltime);
existingDeployment.setEditableByUser(editableByUser);
existingDeployment.setUpdateTime(AiravataUtils.getCurrentTimestamp());
em.merge(existingDeployment);
} else {
ApplicationDeployment deployment = new ApplicationDeployment();
deployment.setApplicationDesc(appDes);
deployment.setDeploymentID(deploymentId);
deployment.setAppModuleID(appModuleId);
deployment.setHostID(hostId);
deployment.setApplicationModule(applicationModule);
deployment.setComputeResource(computeHost);
deployment.setExecutablePath(executablePath);
deployment.setParallelism(parallelism);
deployment.setGatewayId(gatewayId);
deployment.setDefaultQueueName(defaultQueueName);
deployment.setDefaultCPUCount(defaultCPUCount);
deployment.setDefaultNodeCount(defaultNodeCount);
deployment.setDefaultWalltime(defaultWalltime);
deployment.setEditableByUser(editableByUser);
deployment.setCreationTime(AiravataUtils.getCurrentTimestamp());
em.persist(deployment);
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
use of org.apache.airavata.registry.core.app.catalog.model.ComputeResource in project airavata by apache.
the class BatchQueueResource method save.
@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
BatchQueue existingBatchQueue = em.find(BatchQueue.class, new BatchQueue_PK(computeResourceId, queueName));
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
BatchQueue batchQueue;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
if (existingBatchQueue == null) {
batchQueue = new BatchQueue();
} else {
batchQueue = existingBatchQueue;
}
batchQueue.setComputeResourceId(getComputeResourceId());
ComputeResource computeResource = em.find(ComputeResource.class, getComputeResourceId());
batchQueue.setComputeResource(computeResource);
batchQueue.setMaxRuntime(getMaxRuntime());
batchQueue.setMaxJobInQueue(getMaxJobInQueue());
batchQueue.setQueueDescription(getQueueDescription());
batchQueue.setQueueName(getQueueName());
batchQueue.setMaxProcessors(getMaxProcessors());
batchQueue.setMaxNodes(getMaxNodes());
batchQueue.setMaxMemory(getMaxMemory());
batchQueue.setCpuPerNode(getCpuPerNode());
batchQueue.setDefaultCPUCount(getDefaultCPUCount());
batchQueue.setDefaultNodeCount(getDefaultNodeCount());
batchQueue.setDefaultWalltime(getDefaultWalltime());
batchQueue.setQueueSpecificMacros(getQueueSpecificMacros());
batchQueue.setIsDefaultQueue(isDefaultQueue());
if (existingBatchQueue == null) {
em.persist(batchQueue);
} else {
em.merge(batchQueue);
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
use of org.apache.airavata.registry.core.app.catalog.model.ComputeResource in project airavata by apache.
the class JobSubmissionInterfaceResource method save.
@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
JobSubmissionInterface existingJobSubmissionInterface = em.find(JobSubmissionInterface.class, new JobSubmissionInterface_PK(jobSubmissionInterfaceId, computeResourceId));
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
JobSubmissionInterface jobSubmissionInterface;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
if (existingJobSubmissionInterface == null) {
jobSubmissionInterface = new JobSubmissionInterface();
jobSubmissionInterface.setCreationTime(AiravataUtils.getCurrentTimestamp());
} else {
jobSubmissionInterface = existingJobSubmissionInterface;
jobSubmissionInterface.setUpdateTime(AiravataUtils.getCurrentTimestamp());
}
jobSubmissionInterface.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId());
jobSubmissionInterface.setComputeResourceId(getComputeResourceId());
ComputeResource computeResource = em.find(ComputeResource.class, getComputeResourceId());
jobSubmissionInterface.setComputeResource(computeResource);
jobSubmissionInterface.setJobSubmissionProtocol(getJobSubmissionProtocol());
jobSubmissionInterface.setPriorityOrder(getPriorityOrder());
if (existingJobSubmissionInterface == null) {
em.persist(jobSubmissionInterface);
} else {
em.merge(jobSubmissionInterface);
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
Aggregations