ServiceComponentHostResponse r = sch.convertToResponse();
if (filterBasedConfigStaleness && r.isStaleConfig() != staleConfig) {
continue;
}
Host host = hosts.get(sch.getHostName());
if (host == null) {
throw new HostNotFoundException(cluster.getClusterName(), sch.getHostName());
}
r.setMaintenanceState(maintenanceStateHelper.getEffectiveState(sch, host).name());
response.add(r);
} catch (ServiceComponentHostNotFoundException e) {
if (request.getServiceName() != null && request.getComponentName() != null) {
LOG.error("ServiceComponentHost not found ", e);
throw new ServiceComponentHostNotFoundException(cluster.getClusterName(),
request.getServiceName(), request.getComponentName(), request.getHostname());
} else {
LOG.debug("Ignoring not specified host_component ", e);
// ignore this since host_component was not specified
// this is an artifact of how we get host_components and can happen
// in case where we get all host_components for a host
}
}
} else {
for (ServiceComponentHost sch : serviceComponentHostMap.values()) {
if (checkDesiredState && (desiredStateToCheck != sch.getDesiredState())) {
continue;
}
if (request.getAdminState() != null) {
String stringToMatch =
sch.getComponentAdminState() == null ? "" : sch.getComponentAdminState().name();
if (!request.getAdminState().equals(stringToMatch)) {
continue;
}
}
ServiceComponentHostResponse r = sch.convertToResponse();
if (filterBasedConfigStaleness && r.isStaleConfig() != staleConfig) {
continue;
}
Host host = hosts.get(sch.getHostName());
if (host == null) {
throw new HostNotFoundException(cluster.getClusterName(), sch.getHostName());
}
r.setMaintenanceState(maintenanceStateHelper.getEffectiveState(sch, host).name());