Search in sources :

Example 6 with ComputeResource

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();
        }
    }
}
Also used : EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) HostAliasPK(org.apache.airavata.registry.core.app.catalog.model.HostAliasPK) ComputeResource(org.apache.airavata.registry.core.app.catalog.model.ComputeResource) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) HostAlias(org.apache.airavata.registry.core.app.catalog.model.HostAlias)

Example 7 with ComputeResource

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();
        }
    }
}
Also used : HostIPAddress(org.apache.airavata.registry.core.app.catalog.model.HostIPAddress) EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) HostIPAddressPK(org.apache.airavata.registry.core.app.catalog.model.HostIPAddressPK) ComputeResource(org.apache.airavata.registry.core.app.catalog.model.ComputeResource) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 8 with ComputeResource

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();
        }
    }
}
Also used : EntityManager(javax.persistence.EntityManager) ApplicationDeployment(org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ComputeResource(org.apache.airavata.registry.core.app.catalog.model.ComputeResource) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) ApplicationModule(org.apache.airavata.registry.core.app.catalog.model.ApplicationModule)

Example 9 with ComputeResource

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();
        }
    }
}
Also used : EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) BatchQueue(org.apache.airavata.registry.core.app.catalog.model.BatchQueue) ComputeResource(org.apache.airavata.registry.core.app.catalog.model.ComputeResource) BatchQueue_PK(org.apache.airavata.registry.core.app.catalog.model.BatchQueue_PK) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 10 with ComputeResource

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();
        }
    }
}
Also used : EntityManager(javax.persistence.EntityManager) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) JobSubmissionInterface(org.apache.airavata.registry.core.app.catalog.model.JobSubmissionInterface) JobSubmissionInterface_PK(org.apache.airavata.registry.core.app.catalog.model.JobSubmissionInterface_PK) ComputeResource(org.apache.airavata.registry.core.app.catalog.model.ComputeResource) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Aggregations

EntityManager (javax.persistence.EntityManager)14 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)14 ComputeResource (org.apache.airavata.registry.core.app.catalog.model.ComputeResource)14 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)14 Query (javax.persistence.Query)5 AppCatalogQueryGenerator (org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)5 ArrayList (java.util.ArrayList)4 ApplicationDeployment (org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment)1 ApplicationModule (org.apache.airavata.registry.core.app.catalog.model.ApplicationModule)1 BatchQueue (org.apache.airavata.registry.core.app.catalog.model.BatchQueue)1 BatchQueue_PK (org.apache.airavata.registry.core.app.catalog.model.BatchQueue_PK)1 ComputeResourceFileSystem (org.apache.airavata.registry.core.app.catalog.model.ComputeResourceFileSystem)1 ComputeResourceFileSystem_PK (org.apache.airavata.registry.core.app.catalog.model.ComputeResourceFileSystem_PK)1 DataMovementInterface (org.apache.airavata.registry.core.app.catalog.model.DataMovementInterface)1 DataMovementInterface_PK (org.apache.airavata.registry.core.app.catalog.model.DataMovementInterface_PK)1 HostAlias (org.apache.airavata.registry.core.app.catalog.model.HostAlias)1 HostAliasPK (org.apache.airavata.registry.core.app.catalog.model.HostAliasPK)1 HostIPAddress (org.apache.airavata.registry.core.app.catalog.model.HostIPAddress)1 HostIPAddressPK (org.apache.airavata.registry.core.app.catalog.model.HostIPAddressPK)1 JobSubmissionInterface (org.apache.airavata.registry.core.app.catalog.model.JobSubmissionInterface)1