Search in sources :

Example 6 with SystemLoad

use of org.opencastproject.serviceregistry.api.SystemLoad in project opencast by opencast.

the class ServiceRegistryJpaImpl method getServiceRegistrationsByLoad.

/**
 * Do not look at this, it will burn your eyes! This is due to JPA's inability to do a left outer join with join
 * conditions.
 *
 * {@inheritDoc}
 *
 * @see org.opencastproject.serviceregistry.api.ServiceRegistry#getServiceRegistrationsByLoad(java.lang.String)
 */
@Override
public List<ServiceRegistration> getServiceRegistrationsByLoad(String serviceType) throws ServiceRegistryException {
    EntityManager em = null;
    try {
        em = emf.createEntityManager();
        SystemLoad loadByHost = getHostLoads(em);
        List<HostRegistration> hostRegistrations = getHostRegistrations();
        List<ServiceRegistration> serviceRegistrations = getServiceRegistrationsByType(serviceType);
        return getServiceRegistrationsByLoad(serviceType, serviceRegistrations, hostRegistrations, loadByHost);
    } finally {
        if (em != null)
            em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) HostRegistration(org.opencastproject.serviceregistry.api.HostRegistration) SystemLoad(org.opencastproject.serviceregistry.api.SystemLoad) ServiceRegistration(org.opencastproject.serviceregistry.api.ServiceRegistration)

Aggregations

SystemLoad (org.opencastproject.serviceregistry.api.SystemLoad)6 HostRegistration (org.opencastproject.serviceregistry.api.HostRegistration)5 ServiceRegistration (org.opencastproject.serviceregistry.api.ServiceRegistration)3 Test (org.junit.Test)2 Job (org.opencastproject.job.api.Job)2 NodeLoad (org.opencastproject.serviceregistry.api.SystemLoad.NodeLoad)2 LinkedList (java.util.LinkedList)1 EntityManager (javax.persistence.EntityManager)1 Query (javax.persistence.Query)1 TypedQuery (javax.persistence.TypedQuery)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 HttpStatus (org.apache.http.HttpStatus)1 Status (org.opencastproject.job.api.Job.Status)1 ServiceRegistryException (org.opencastproject.serviceregistry.api.ServiceRegistryException)1 RestQuery (org.opencastproject.util.doc.rest.RestQuery)1