@Override public float getOwnLoad() { return getCurrentHostLoads().get(getRegistryHostname()).getLoadFactor(); }
public boolean alreadyRecordedFailureIncident(long jobId) { try { return findFailure(is.getIncidentsOfJob(jobId, true)); } catch (Exception e) { return false; } }
/** * Record an incident for a given job caused by an uncatched exception. This method is intended to record incidents by * the job system itself, e.g. the job dispatcher. Please note that an incident will <em>only</em> be recorded if none * of severity {@link org.opencastproject.job.api.Incident.Severity#FAILURE} has already been recorded by the job or * one of its child jobs. If no job with the given job id exists nothing happens. */ public void unhandledException(long jobId, Severity severity, Throwable t) { try { unhandledException(sr.getJob(jobId), severity, t); } catch (NotFoundException ignore) { } catch (ServiceRegistryException e) { logException(e); } }
/** * {@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"); }
@Override public int compare(ServiceRegistration serviceA, ServiceRegistration serviceB) { String hostA = serviceA.getHost(); String hostB = serviceB.getHost(); return Float.compare(loadByHost.get(hostA).getLoadFactor(), loadByHost.get(hostB).getLoadFactor()); }
public String set(String baseUrl, boolean maintenanceMode) { try { serviceRegistry.setMaintenanceStatus(baseUrl, maintenanceMode); if (maintenanceMode) { return baseUrl + " is now in maintenance mode\n"; } else { return baseUrl + " has returned to service\n"; } } catch (ServiceRegistryException e) { return "Error setting maintenance mode: " + e.getMessage() + "\n"; } catch (NotFoundException e) { return "Error setting maintenance mode, host " + baseUrl + " not found"; } }
/** * Record a failure incident for a given job. * * @see #record(org.opencastproject.job.api.Job, org.opencastproject.job.api.Incident.Severity, int, java.util.Map, * java.util.List) * @see org.opencastproject.job.api.Incident */ public void recordFailure(Job job, int code, List<Tuple<String, String>> details) { record(job, Severity.FAILURE, code, NO_PARAMS, details); }
/** * Constructs a new service statistics instance without statistics. * * @param serviceRegistration * the service registration */ public JaxbServiceStatistics(ServiceRegistration serviceRegistration) { super(); this.serviceRegistration = new JaxbServiceRegistration(serviceRegistration); }
/** * {@inheritDoc} * * @see java.lang.Object#toString() */ @Override public String toString() { return getServiceType() + "@" + getHost(); }
@Override public int compareTo(NodeLoad other) { if (other.getLoadFactor() > this.loadFactor) { return 1; } else if (this.loadFactor > other.getLoadFactor()) { return -1; } else { return 0; } }
/** * {@inheritDoc} * * @see org.opencastproject.serviceregistry.api.ServiceRegistry#createJob(java.lang.String, java.lang.String, java.util.List, java.lang.String, boolean, Float) */ @Override public Job createJob(String type, String operation, List<String> arguments, String payload, boolean queueable, Float jobLoad) throws ServiceRegistryException { return createJob(type, operation, arguments, payload, queueable, null, jobLoad); }
@Override public void removeJobs(List<Long> ids) throws NotFoundException, ServiceRegistryException { synchronized (jobs) { for (long id : ids) { removeJob(id); } } }
@Override public Boolean apply(IncidentTree r) { return findFailure(r); } };
/** * Record a failure incident for a given job. * * @see #record(org.opencastproject.job.api.Job, org.opencastproject.job.api.Incident.Severity, int, java.util.Map, * java.util.List) * @see org.opencastproject.job.api.Incident */ public void recordFailure(Job job, int code, Throwable t, List<Tuple<String, String>> details) { recordFailure(job, code, t, NO_PARAMS, details); }
/** * {@inheritDoc} * * @see org.opencastproject.serviceregistry.api.ServiceRegistry#countByHost(java.lang.String, java.lang.String, * org.opencastproject.job.api.Job.Status) */ @Override public long countByHost(String serviceType, String host, Status status) throws ServiceRegistryException { return count(serviceType, host, null, status); }
public boolean exceeds(NodeLoad other) { if (this.compareTo(other) > 1) { return true; } return false; } }
/** * {@inheritDoc} * * @see org.opencastproject.serviceregistry.api.ServiceRegistry#createJob(java.lang.String, java.lang.String, Float) */ @Override public Job createJob(String type, String operation, Float jobLoad) throws ServiceRegistryException { return createJob(type, operation, null, null, true, 1.0f); }
/** * {@inheritDoc} * * @see org.opencastproject.serviceregistry.api.ServiceRegistry#createJob(java.lang.String, java.lang.String, java.util.List, java.lang.String, boolean, org.opencastproject.job.api.Job) */ @Override public Job createJob(String type, String operation, List<String> arguments, String payload, boolean queueable, Job parentJob) throws ServiceRegistryException { return createJob(type, operation, arguments, payload, queueable, parentJob, 1.0f); }
/** * {@inheritDoc} * * @see org.opencastproject.serviceregistry.api.ServiceRegistry#createJob(java.lang.String, java.lang.String, java.util.List, java.lang.String) */ @Override public Job createJob(String type, String operation, List<String> arguments, String payload) throws ServiceRegistryException { return createJob(type, operation, arguments, payload, true); }
/** * {@inheritDoc} * * @see org.opencastproject.serviceregistry.api.ServiceRegistry#createJob(java.lang.String, java.lang.String, java.util.List, java.lang.String, boolean) */ @Override public Job createJob(String type, String operation, List<String> arguments, String payload, boolean queueable) throws ServiceRegistryException { return createJob(type, operation, arguments, payload, queueable, null, 1.0f); }