use of com.cloudera.api.swagger.model.ApiHealthCheck in project cloudbreak by hortonworks.
the class ClouderaManagerClusterStatusService method getCertCheck.
private static Optional<HealthCheck> getCertCheck(ApiHost apiHost) {
Optional<ApiHealthCheck> healthCheck = emptyIfNull(apiHost.getHealthChecks()).stream().filter(health -> HOST_AGENT_CERTIFICATE_EXPIRY.equals(health.getName())).findFirst();
if (healthCheck.isPresent()) {
HealthCheckResult result = ApiHealthSummary.BAD.equals(healthCheck.get().getSummary()) || ApiHealthSummary.CONCERNING.equals(healthCheck.get().getSummary()) ? HealthCheckResult.UNHEALTHY : HealthCheckResult.HEALTHY;
Optional<String> reason = Optional.ofNullable(healthCheck.get().getSummary()).map(apiSum -> "Cert health on CM: " + apiSum.getValue());
return Optional.of(new HealthCheck(HealthCheckType.CERT, result, reason));
}
return Optional.empty();
}
use of com.cloudera.api.swagger.model.ApiHealthCheck in project cloudbreak by hortonworks.
the class ClouderaManagerClusterStatusServiceTest method filtersAppropriateHealthCheckForHost.
@Test
public void filtersAppropriateHealthCheckForHost() throws ApiException {
hostsAre(new ApiHost().hostname("host").addHealthChecksItem(new ApiHealthCheck().name("fake_check").summary(ApiHealthSummary.BAD)).addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.CONCERNING)).addHealthChecksItem(new ApiHealthCheck().name("another").summary(ApiHealthSummary.BAD)));
assertTrue(subject.getExtendedHostStatuses(Optional.of("7.2.12")).isHostHealthy(hostName("host")));
}
use of com.cloudera.api.swagger.model.ApiHealthCheck in project cloudbreak by hortonworks.
the class ClouderaManagerClusterStatusServiceTest method collectsExtendedHostHealthIfAvailable.
@Test
public void collectsExtendedHostHealthIfAvailable() throws ApiException {
hostsAre(new ApiHost().hostname("host1").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.GOOD)).addHealthChecksItem(new ApiHealthCheck().name(HOST_AGENT_CERTIFICATE_EXPIRY).summary(ApiHealthSummary.GOOD)), new ApiHost().hostname("host2").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.CONCERNING)).addHealthChecksItem(new ApiHealthCheck().name(HOST_AGENT_CERTIFICATE_EXPIRY).summary(ApiHealthSummary.CONCERNING).explanation("in 30 days")), new ApiHost().hostname("host3").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.BAD).explanation("explanation.")).addHealthChecksItem(new ApiHealthCheck().name(HOST_AGENT_CERTIFICATE_EXPIRY).summary(ApiHealthSummary.BAD).explanation("in 2 days")), new ApiHost().hostname("host4").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.NOT_AVAILABLE)), new ApiHost().hostname("host5").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.HISTORY_NOT_AVAILABLE)), new ApiHost().hostname("host6").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.DISABLED)), new ApiHost().hostname("host7").maintenanceMode(true).addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.GOOD)).addHealthChecksItem(new ApiHealthCheck().name(HOST_AGENT_CERTIFICATE_EXPIRY).summary(ApiHealthSummary.GOOD)));
ExtendedHostStatuses extendedHostStatuses = subject.getExtendedHostStatuses(Optional.of("7.2.12"));
assertEquals("explanation. Cert health on CM: BAD", extendedHostStatuses.statusReasonForHost(hostName("host3")));
assertTrue(extendedHostStatuses.isAnyCertExpiring());
assertTrue(extendedHostStatuses.isHostHealthy(hostName("host1")));
assertTrue(extendedHostStatuses.isHostHealthy(hostName("host2")));
assertFalse(extendedHostStatuses.isHostHealthy(hostName("host3")));
assertFalse(extendedHostStatuses.isHostHealthy(hostName("host7")));
}
use of com.cloudera.api.swagger.model.ApiHealthCheck in project cloudbreak by hortonworks.
the class ClouderaManagerClusterStatusServiceTest method testServiceBadHealth.
@Test
public void testServiceBadHealth() throws ApiException {
hostsAre(new ApiHost().hostname("host1").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.BAD).explanation("explanation")).addHealthChecksItem(new ApiHealthCheck().name(HOST_AGENT_CERTIFICATE_EXPIRY).summary(ApiHealthSummary.GOOD)).addRoleRefsItem(roleRef("badservice", ApiHealthSummary.BAD)), new ApiHost().hostname("host2").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.GOOD)).addHealthChecksItem(new ApiHealthCheck().name(HOST_AGENT_CERTIFICATE_EXPIRY).summary(ApiHealthSummary.GOOD).explanation("in 30 days")).addRoleRefsItem(roleRef("badservice2", ApiHealthSummary.BAD)).addRoleRefsItem(roleRef("badservice3", ApiHealthSummary.BAD)));
ExtendedHostStatuses extendedHostStatuses = subject.getExtendedHostStatuses(Optional.of("7.2.12"));
assertFalse(extendedHostStatuses.isAnyCertExpiring());
assertFalse(extendedHostStatuses.isHostHealthy(hostName("host1")));
assertFalse(extendedHostStatuses.isHostHealthy(hostName("host2")));
assertEquals("explanation. The following services are in bad health: badservice.", extendedHostStatuses.statusReasonForHost(hostName("host1")));
assertEquals("The following services are in bad health: badservice2, badservice3.", extendedHostStatuses.statusReasonForHost(hostName("host2")));
extendedHostStatuses = subject.getExtendedHostStatuses(Optional.of("7.2.11"));
assertFalse(extendedHostStatuses.isAnyCertExpiring());
assertFalse(extendedHostStatuses.isHostHealthy(hostName("host1")));
assertTrue(extendedHostStatuses.isHostHealthy(hostName("host2")));
assertEquals("explanation.", extendedHostStatuses.statusReasonForHost(hostName("host1")));
}
use of com.cloudera.api.swagger.model.ApiHealthCheck in project cloudbreak by hortonworks.
the class ClouderaManagerClusterStatusServiceTest method collectsHostHealthIfAvailable.
@Test
public void collectsHostHealthIfAvailable() throws ApiException {
hostsAre(new ApiHost().hostname("host1").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.GOOD)), new ApiHost().hostname("host2").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.CONCERNING)), new ApiHost().hostname("host3").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.BAD)), new ApiHost().hostname("host4").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.NOT_AVAILABLE)), new ApiHost().hostname("host5").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.HISTORY_NOT_AVAILABLE)), new ApiHost().hostname("host6").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.DISABLED)));
ExtendedHostStatuses extendedHostStatuses = subject.getExtendedHostStatuses(Optional.of("7.2.12"));
assertFalse(extendedHostStatuses.isHostHealthy(hostName("host3")));
assertTrue(extendedHostStatuses.isHostHealthy(hostName("host1")));
assertTrue(extendedHostStatuses.isHostHealthy(hostName("host2")));
}
Aggregations