/** * {@inheritDoc} * * @see org.opencastproject.serviceregistry.api.ServiceRegistry#registerHost(String, String, long, int, float) */ @Override public void registerHost(String host, String address, long memory, int cores, float maxLoad) throws ServiceRegistryException { HostRegistrationInMemory hrim = new HostRegistrationInMemory(address, address, maxLoad, cores, memory); hosts.put(host, hrim); }
/** * {@inheritDoc} * * @see org.opencastproject.serviceregistry.api.ServiceRegistry#enableHost(String) */ @Override public void enableHost(String host) throws ServiceRegistryException, NotFoundException { if (hosts.containsKey(host)) { hosts.get(host).setActive(true); } else { throw new NotFoundException("The host named " + host + " was not found"); } }
/** * {@inheritDoc} * * @see org.opencastproject.serviceregistry.api.ServiceRegistry#getMaxLoadOnNode(java.lang.String) */ @Override public NodeLoad getMaxLoadOnNode(String host) throws ServiceRegistryException { if (hosts.containsKey(host)) { return new NodeLoad(host, hosts.get(host).getMaxLoad()); } throw new ServiceRegistryException("Unable to find host " + host + " in service registry"); }
/** * {@inheritDoc} * * @see org.opencastproject.serviceregistry.api.ServiceRegistry#setMaintenanceStatus(java.lang.String, boolean) */ @Override public void setMaintenanceStatus(String host, boolean maintenance) throws NotFoundException { List<ServiceRegistrationInMemoryImpl> servicesOnHost = services.get(host); if (!hosts.containsKey(host)) { throw new NotFoundException("Host " + host + " was not found"); } hosts.get(host).setMaintenanceMode(maintenance); if (servicesOnHost != null) { for (ServiceRegistrationInMemoryImpl r : servicesOnHost) { r.setMaintenance(maintenance); } } }
/** * Method to register locally running services. * * @param localService * the service instance * @param maxLoad * the maximum load the host can support * @return the service registration * @throws ServiceRegistryException */ public ServiceRegistration registerService(JobProducer localService, float maxLoad) throws ServiceRegistryException { HostRegistrationInMemory hrim = hosts.get(LOCALHOST); List<ServiceRegistrationInMemoryImpl> servicesOnHost = services.get(LOCALHOST); if (servicesOnHost == null) { servicesOnHost = new ArrayList<ServiceRegistrationInMemoryImpl>(); services.put(LOCALHOST, servicesOnHost); } ServiceRegistrationInMemoryImpl registration = new ServiceRegistrationInMemoryImpl(localService, hrim.getBaseUrl()); registration.setMaintenance(false); servicesOnHost.add(registration); return registration; }
/** * {@inheritDoc} * * @see org.opencastproject.serviceregistry.api.ServiceRegistry#disableHost(String) */ @Override public void disableHost(String host) throws ServiceRegistryException, NotFoundException { if (hosts.containsKey(host)) { hosts.get(host).setActive(false); } else { throw new NotFoundException("The host named " + host + " was not found"); } }