Search in sources :

Example 11 with HostRegistration

use of org.opencastproject.serviceregistry.api.HostRegistration 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

HostRegistration (org.opencastproject.serviceregistry.api.HostRegistration)11 SystemLoad (org.opencastproject.serviceregistry.api.SystemLoad)5 ServiceRegistration (org.opencastproject.serviceregistry.api.ServiceRegistration)4 ArrayList (java.util.ArrayList)3 LinkedList (java.util.LinkedList)2 Before (org.junit.Before)2 Test (org.junit.Test)2 ServersListQuery (org.opencastproject.index.service.resources.list.query.ServersListQuery)2 Job (org.opencastproject.job.api.Job)2 ServiceRegistry (org.opencastproject.serviceregistry.api.ServiceRegistry)2 NodeLoad (org.opencastproject.serviceregistry.api.SystemLoad.NodeLoad)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)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