use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class ClusterServiceTest method testIsRangerRazEnabledOnClusterReturnsFalseIfCmIsRunning.
@Test
void testIsRangerRazEnabledOnClusterReturnsFalseIfCmIsRunning() {
Stack stack = setupStack(STACK_ID);
ClusterApi clusterApi = mock(ClusterApi.class);
ClusterStatusService clusterStatusService = mock(ClusterStatusService.class);
ClusterModificationService clusterModificationService = mock(ClusterModificationService.class);
when(clusterApiConnectors.getConnector(stack)).thenReturn(clusterApi);
when(clusterApi.clusterStatusService()).thenReturn(clusterStatusService);
when(clusterApi.clusterModificationService()).thenReturn(clusterModificationService);
when(clusterStatusService.isClusterManagerRunning()).thenReturn(true);
when(clusterModificationService.isServicePresent(anyString(), eq(RANGER_RAZ))).thenReturn(false);
assertFalse(underTest.isRangerRazEnabledOnCluster(stack));
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class StackStatusIntegrationTest method setUpClusterApi.
private void setUpClusterApi() {
ClusterApi clusterApi = Mockito.mock(ClusterApi.class);
when(clusterApi.clusterStatusService()).thenReturn(clusterStatusService);
when(clusterApiConnectors.getConnector(stack)).thenReturn(clusterApi);
hostStatuses = new HashMap<>();
when(clusterStatusService.getExtendedHostStatuses(any())).thenReturn(new ExtendedHostStatuses(hostStatuses));
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class HealthCheckService method getUnhealthyHosts.
@Retryable(value = RuntimeException.class, maxAttempts = 5, backoff = @Backoff(delay = 5000L))
public Set<String> getUnhealthyHosts(Long stackId) {
Stack stack = stackService.getById(stackId);
ClusterApi connector = clusterApiConnectors.getConnector(stack);
LOGGER.debug("Fetching extended host statuses for stack {} with retries", stack.getName());
ExtendedHostStatuses extendedHostStatuses = connector.clusterStatusService().getExtendedHostStatuses(runtimeVersionService.getRuntimeVersion(stack.getCluster().getId()));
LOGGER.debug("Returned statuses: {}", extendedHostStatuses);
return extendedHostStatuses.getHostsHealth().entrySet().stream().filter(e -> e.getValue().stream().anyMatch(hc -> hc.getType() == HealthCheckType.HOST && hc.getResult() == HealthCheckResult.UNHEALTHY)).map(e -> e.getKey().value()).collect(Collectors.toSet());
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class ClusterHostCertificatesRotationHandler method doAccept.
protected Selectable doAccept(HandlerEvent<ClusterHostCertificatesRotationRequest> event) {
LOGGER.debug("Accepting Cluster Manager host certificates rotation request...");
ClusterHostCertificatesRotationRequest request = event.getData();
Selectable result;
try {
Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
ClusterApi clusterApi = apiConnectors.getConnector(stack);
String subAltName = loadBalancerSANProvider.getLoadBalancerSAN(stack).orElse(null);
if (isRootSshAccessNeededForHostCertRotation(stack)) {
rotateCertsWithSsh(stack, clusterApi, subAltName);
} else {
clusterApi.rotateHostCertificates(null, null, subAltName);
}
result = new ClusterHostCertificatesRotationSuccess(request.getResourceId());
} catch (Exception e) {
LOGGER.info("Cluster Manager host certificates rotation failed", e);
result = new ClusterCertificatesRotationFailed(request.getResourceId(), e);
}
return result;
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class ClusterService method isRangerRazEnabledOnCluster.
public boolean isRangerRazEnabledOnCluster(Stack stack) {
Cluster cluster = stack.getCluster();
ClusterApi clusterApi = clusterApiConnectors.getConnector(stack);
if (!clusterApi.clusterStatusService().isClusterManagerRunning()) {
throw new BadRequestException(String.format("Cloudera Manager is not running for cluster: %s", cluster.getName()));
}
return clusterApi.clusterModificationService().isServicePresent(cluster.getName(), RANGER_RAZ);
}
Aggregations