public HostsStatistics(List<ServiceStatistics> statistics) { for (ServiceStatistics stats : statistics) { String host = stats.getServiceRegistration().getHost(); boolean online = stats.getServiceRegistration().isOnline(); boolean inMaintenanceMode = stats.getServiceRegistration().isInMaintenanceMode(); if (!stats.getServiceRegistration().isActive()) { hosts.remove(host); logger.trace("Removing inactive host '{}'", host); continue; } if (online && !inMaintenanceMode) { hosts.put(host, ONLINE); } else if (online && inMaintenanceMode) { hosts.put(host, MAINTENANCE); } else { hosts.put(host, OFFLINE); } } }
if (!service.isOnline()) { logger.trace("Not considering {} because it is currently offline", service); continue;
if (unresponsive.remove(service)) { logger.info("Service {} is still online", service); } else if (!service.isOnline()) { try { setOnlineStatus(service.getServiceType(), service.getHost(), service.getPath(), true, true); if (!service.isOnline()) continue; logger.warn("Service {} is not working as expected: {}", service, response.getStatusLine()); if (!service.isOnline()) continue; logger.warn("Unable to reach {} : {}", service, e);
@Override public SystemLoad getCurrentHostLoads() { SystemLoad systemLoad = new SystemLoad(); for (String host : hosts.keySet()) { NodeLoad node = new NodeLoad(); node.setHost(host); for (ServiceRegistration service : services.get(host)) { if (service.isInMaintenanceMode() || !service.isOnline()) { continue; } Set<Job> hostJobs = jobHosts.get(service); float loadSum = 0.0f; if (hostJobs != null) { for (Job job : hostJobs) { if (job.getStatus() != null && JOB_STATUSES_INFLUENCING_LOAD_BALANCING.contains(job.getStatus())) { loadSum += job.getJobLoad(); } } } node.setLoadFactor(node.getLoadFactor() + loadSum); } systemLoad.addNodeLoad(node); } return systemLoad; }
if (!service.isOnline()) { logger.trace("Not considering {} because it is currently offline", service); continue;
/** * Creates a new JAXB annotated service registration based on an existing service registration * * @param serviceRegistration */ public JaxbServiceRegistration(ServiceRegistration serviceRegistration) { this.host = serviceRegistration.getHost(); this.jobProducer = serviceRegistration.isJobProducer(); this.maintenanceMode = serviceRegistration.isInMaintenanceMode(); this.active = serviceRegistration.isActive(); this.online = serviceRegistration.isOnline(); this.onlineFrom = serviceRegistration.getOnlineFrom(); this.path = serviceRegistration.getPath(); this.serviceType = serviceRegistration.getServiceType(); this.serviceState = serviceRegistration.getServiceState(); this.stateChanged = serviceRegistration.getStateChanged(); this.warningStateTrigger = serviceRegistration.getWarningStateTrigger(); this.errorStateTrigger = serviceRegistration.getErrorStateTrigger(); }