Search in sources :

Example 96 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class NodeServicesCheckerConclusionStepTest method checkShouldBeSuccessfulIfNodeStatusReportFailsForOlderImageVersions.

@Test
public void checkShouldBeSuccessfulIfNodeStatusReportFailsForOlderImageVersions() {
    when(nodeStatusService.getServicesReport(eq(1L))).thenThrow(new CloudbreakServiceException("error"));
    Conclusion stepResult = underTest.check(1L);
    assertFalse(stepResult.isFailureFound());
    assertNull(stepResult.getConclusion());
    assertNull(stepResult.getDetails());
    assertEquals(NodeServicesCheckerConclusionStep.class, stepResult.getConclusionStepClass());
    verify(nodeStatusService, times(1)).getServicesReport(eq(1L));
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Test(org.junit.jupiter.api.Test)

Example 97 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class ResourceEncryptionInitializationHandler method initializeEncryptionResources.

private void initializeEncryptionResources(EnvironmentDto environmentDto, Environment environment) {
    String environmentName = environment.getName();
    LOGGER.info("Initializing encryption resources for environment \"{}\".", environmentName);
    try {
        CreatedDiskEncryptionSet createdDiskEncryptionSet = environmentEncryptionService.createEncryptionResources(environmentDto);
        LOGGER.info("Created Disk Encryption Set resource for environment \"{}\": {}", environmentName, createdDiskEncryptionSet);
        AzureParameters azureParameters = (AzureParameters) environment.getParameters();
        azureParameters.setDiskEncryptionSetId(createdDiskEncryptionSet.getDiskEncryptionSetId());
        environment.setStatus(EnvironmentStatus.ENVIRONMENT_ENCRYPTION_RESOURCES_INITIALIZED);
        environment.setStatusReason(null);
        environmentService.save(environment);
        LOGGER.info("Finished initializing encryption resources for environment \"{}\".", environmentName);
    } catch (Exception e) {
        LOGGER.error(String.format("Failed to initialize encryption resources for environment \"%s\"", environmentName), e);
        throw new CloudbreakServiceException("Error occurred while initializing encryption resources: " + e.getMessage(), e);
    }
}
Also used : AzureParameters(com.sequenceiq.environment.parameters.dao.domain.AzureParameters) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CreatedDiskEncryptionSet(com.sequenceiq.cloudbreak.cloud.model.encryption.CreatedDiskEncryptionSet) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

Example 98 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class Flow2HandlerTest method testNewFlowButNotHandled.

@Test
public void testNewFlowButNotHandled() {
    Event<Payload> event = new Event<>(payload);
    event.setKey("KEY");
    CloudbreakServiceException exception = assertThrows(CloudbreakServiceException.class, () -> underTest.accept(event));
    assertEquals("Couldn't start process.", exception.getMessage());
    verify(flowConfigurationMap, times(1)).get(anyString());
    verify(runningFlows, never()).put(any(Flow.class), isNull(String.class));
    verify(flowLogService, never()).save(any(FlowParameters.class), anyString(), anyString(), any(Payload.class), anyMap(), any(), any(FlowState.class));
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Event(reactor.bus.Event) Payload(com.sequenceiq.cloudbreak.common.event.Payload) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 99 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class AdlsGen2ConfigGeneratorTest method testGenerateStorageConfigWhenNoAccountIdInThePath.

@Test
public void testGenerateStorageConfigWhenNoAccountIdInThePath() {
    String loc = "abfs://logs@.dfs.core.windows.net";
    CloudbreakServiceException actual = Assertions.assertThrows(CloudbreakServiceException.class, () -> underTest.generateStorageConfig(loc));
    Assertions.assertEquals("Invalid ADLS storage location: " + loc, actual.getMessage());
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Test(org.junit.jupiter.api.Test)

Example 100 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class ClusterBootstrapper method saveSaltComponent.

private void saveSaltComponent(Stack stack) {
    LOGGER.info("Save salt component for stack: {}", stack.getName());
    ClusterComponent saltComponent = clusterComponentProvider.getComponent(stack.getCluster().getId(), ComponentType.SALT_STATE);
    if (saltComponent == null) {
        try {
            byte[] stateConfigZip = hostOrchestrator.getStateConfigZip();
            saltComponent = createSaltComponent(stack, stateConfigZip);
            clusterComponentProvider.store(saltComponent);
        } catch (IOException e) {
            throw new CloudbreakServiceException(e);
        }
    }
}
Also used : ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) IOException(java.io.IOException)

Aggregations

CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)142 Test (org.junit.jupiter.api.Test)25 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)24 List (java.util.List)20 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)18 IOException (java.io.IOException)18 Map (java.util.Map)18 ApiException (com.cloudera.api.swagger.client.ApiException)17 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)16 Collectors (java.util.stream.Collectors)15 Inject (javax.inject.Inject)15 Logger (org.slf4j.Logger)15 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)14 LoggerFactory (org.slf4j.LoggerFactory)14 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)13 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)12 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)12 ApiHostList (com.cloudera.api.swagger.model.ApiHostList)12 Optional (java.util.Optional)12 Set (java.util.Set)12