Search in sources :

Example 11 with ClusterApi

use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.

the class ClusterServiceTest method setupClusterApi.

private void setupClusterApi(Stack stack, HealthCheckResult healthCheckResult, String statusReason) {
    ClusterApi connector = mock(ClusterApi.class);
    ClusterStatusService clusterStatusService = mock(ClusterStatusService.class);
    when(clusterStatusService.isClusterManagerRunning()).thenReturn(true);
    when(connector.clusterStatusService()).thenReturn(clusterStatusService);
    Map<HostName, Set<HealthCheck>> clusterManagerStateMap = new HashMap<>();
    if (healthCheckResult != null) {
        clusterManagerStateMap.put(HostName.hostName(FQDN1), Sets.newHashSet(new HealthCheck(HealthCheckType.HOST, healthCheckResult, Optional.ofNullable(statusReason))));
    }
    ExtendedHostStatuses extendedHostStatuses = new ExtendedHostStatuses(clusterManagerStateMap);
    when(clusterStatusService.getExtendedHostStatuses(any())).thenReturn(extendedHostStatuses);
    when(clusterApiConnectors.getConnector(stack)).thenReturn(connector);
}
Also used : ExtendedHostStatuses(com.sequenceiq.cloudbreak.cluster.status.ExtendedHostStatuses) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) Set(java.util.Set) HashMap(java.util.HashMap) HealthCheck(com.sequenceiq.cloudbreak.common.type.HealthCheck) ClusterStatusService(com.sequenceiq.cloudbreak.cluster.api.ClusterStatusService) HostName(com.sequenceiq.cloudbreak.cloud.model.HostName)

Example 12 with ClusterApi

use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.

the class NifiUpgradeValidator method validateNifiWorkingDirectory.

private void validateNifiWorkingDirectory(Stack stack) {
    ClusterApi connector = clusterApiConnectors.getConnector(stack);
    Optional<String> nifiWorkingDirectory = connector.getRoleConfigValueByServiceType(stack.getCluster().getName(), ROLE_TYPE, NIFI_SERVICE_TYPE, NIFI_WORKING_DIRECTORY);
    LOGGER.debug("Validating Nifi working directory: {}", nifiWorkingDirectory);
    if (nifiWorkingDirectory.isPresent() && nifiWorkingDirectory.get().startsWith(VolumeUtils.VOLUME_PREFIX)) {
        LOGGER.debug("Nifi working directory validation was successful");
    } else {
        throw new UpgradeValidationFailedException(String.format("Nifi working directory validation failed. The current directory %s is not eligible for upgrade.", nifiWorkingDirectory.get()));
    }
}
Also used : ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)

Example 13 with ClusterApi

use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.

the class ActiveCommandsValidator method validate.

@Override
public void validate(ServiceUpgradeValidationRequest validationRequest) {
    ClusterApi connector = clusterApiConnectors.getConnector(validationRequest.getStack());
    List<String> activeCommands = connector.clusterStatusService().getActiveCommandsList();
    if (CollectionUtils.isNotEmpty(activeCommands)) {
        throw new UpgradeValidationFailedException("There are active commands running on CM, upgrade is not possible. Active commands: " + String.join(",", activeCommands));
    }
}
Also used : ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) UpgradeValidationFailedException(com.sequenceiq.cloudbreak.common.exception.UpgradeValidationFailedException)

Example 14 with ClusterApi

use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.

the class ClusterServiceTest method testIsRangerRazEnabledOnClusterThrowsExceptionIfCmIsNotRunning.

@Test
void testIsRangerRazEnabledOnClusterThrowsExceptionIfCmIsNotRunning() {
    Stack stack = setupStack(STACK_ID);
    ClusterApi clusterApi = mock(ClusterApi.class);
    ClusterStatusService clusterStatusService = mock(ClusterStatusService.class);
    when(clusterApiConnectors.getConnector(stack)).thenReturn(clusterApi);
    when(clusterApi.clusterStatusService()).thenReturn(clusterStatusService);
    when(clusterStatusService.isClusterManagerRunning()).thenReturn(false);
    BadRequestException exception = assertThrows(BadRequestException.class, () -> underTest.isRangerRazEnabledOnCluster(stack));
    assertEquals(String.format("Cloudera Manager is not running for cluster: %s", CLUSTER_NAME), exception.getMessage());
}
Also used : ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ClusterStatusService(com.sequenceiq.cloudbreak.cluster.api.ClusterStatusService) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with ClusterApi

use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.

the class ClusterServiceTest method testIsRangerRazEnabledOnClusterReturnsTrueWhenCmIsRunning.

@Test
void testIsRangerRazEnabledOnClusterReturnsTrueWhenCmIsRunning() {
    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(true);
    assertTrue(underTest.isRangerRazEnabledOnCluster(stack));
}
Also used : ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) ClusterModificationService(com.sequenceiq.cloudbreak.cluster.api.ClusterModificationService) ClusterStatusService(com.sequenceiq.cloudbreak.cluster.api.ClusterStatusService) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ClusterApi (com.sequenceiq.cloudbreak.cluster.api.ClusterApi)27 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)20 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)9 Set (java.util.Set)7 ExtendedHostStatuses (com.sequenceiq.cloudbreak.cluster.status.ExtendedHostStatuses)6 ParcelOperationStatus (com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus)5 ClusterApiConnectors (com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors)5 ClusterStatusService (com.sequenceiq.cloudbreak.cluster.api.ClusterStatusService)4 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)4 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)4 InstanceMetaDataService (com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService)4 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)4 Collectors (java.util.stream.Collectors)4 Inject (javax.inject.Inject)4 Test (org.junit.jupiter.api.Test)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 Service (org.springframework.stereotype.Service)4 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)3 HostName (com.sequenceiq.cloudbreak.cloud.model.HostName)3