Search in sources :

Example 11 with BlueprintPreparationObject

use of com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject in project cloudbreak by hortonworks.

the class CentralBlueprintUpdaterNegativeInputTest method testForEmptyJsonInputAsBlueprintText.

@Test
public void testForEmptyJsonInputAsBlueprintText() throws IOException {
    expectedException.expect(BlueprintProcessingException.class);
    BlueprintPreparationObject model = getExtendedPreparedBlueprintBuilder("empty-blueprint.bp").build();
    getUnderTest().getBlueprintText(model);
}
Also used : BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) Test(org.junit.Test)

Example 12 with BlueprintPreparationObject

use of com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject in project cloudbreak by hortonworks.

the class CentralBlueprintUpdaterRollingtest method testGetBlueprintText.

@Test
public void testGetBlueprintText() throws IOException, JSONException {
    BlueprintPreparationObject blueprintPreparationObject = prepareBlueprintPreparationObjectWithBlueprintText();
    JSONObject expected = toJSON(params.value().getOutput().getFileContent());
    JSONObject resultBlueprintText = toJSON(getUnderTest().getBlueprintText(blueprintPreparationObject));
    StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append("The result has not matched with the expected output " + params.value().getOutput().getFileName());
    stringBuffer.append("\nexpected:\n");
    stringBuffer.append(new JSONObject(expected.toString()).toString(4));
    stringBuffer.append("\nactual:\n");
    stringBuffer.append(new JSONObject(resultBlueprintText.toString()).toString(4));
    assertWithExtendedExceptionHandling(stringBuffer.toString(), expected, resultBlueprintText);
}
Also used : JSONObject(org.json.JSONObject) BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) Test(org.junit.Test)

Example 13 with BlueprintPreparationObject

use of com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject in project cloudbreak by hortonworks.

the class StackV2Controller method postStackForBlueprint.

@Override
public GeneratedBlueprintResponse postStackForBlueprint(StackV2Request stackRequest) throws Exception {
    IdentityUser user = authenticatedUserService.getCbUser();
    stackRequest.setAccount(user.getAccount());
    stackRequest.setOwner(user.getUserId());
    BlueprintPreparationObject blueprintPreparationObject = conversionService.convert(stackRequest, BlueprintPreparationObject.class);
    String blueprintText = centralBlueprintUpdater.getBlueprintText(blueprintPreparationObject);
    return new GeneratedBlueprintResponse(blueprintText);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) GeneratedBlueprintResponse(com.sequenceiq.cloudbreak.api.model.GeneratedBlueprintResponse)

Example 14 with BlueprintPreparationObject

use of com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject in project cloudbreak by hortonworks.

the class AmbariClusterSetupService method buildCluster.

@Override
public void buildCluster(Stack stack) {
    Cluster cluster = stack.getCluster();
    try {
        clusterService.updateCreationDateOnCluster(cluster);
        AmbariClient ambariClient = clientFactory.getAmbariClient(stack, stack.getCluster());
        Set<HostGroup> hostGroups = hostGroupService.getByCluster(cluster.getId());
        BlueprintPreparationObject blueprintPreparationObject = conversionService.convert(stack, BlueprintPreparationObject.class);
        Map<String, List<Map<String, String>>> hostGroupMappings = hostGroupAssociationBuilder.buildHostGroupAssociations(hostGroups);
        Set<HostMetadata> hostsInCluster = hostMetadataRepository.findHostsInCluster(cluster.getId());
        recipeEngine.executePostAmbariStartRecipes(stack, hostGroups);
        ambariRepositoryVersionService.setBaseRepoURL(stack.getName(), cluster.getId(), stack.getOrchestrator(), ambariClient);
        String blueprintText = centralBlueprintUpdater.getBlueprintText(blueprintPreparationObject);
        addBlueprint(stack.getId(), ambariClient, blueprintText, cluster.getTopologyValidation());
        cluster.setExtendedBlueprintText(blueprintText);
        clusterService.updateCluster(cluster);
        PollingResult waitForHostsResult = ambariPollingServiceProvider.hostsPollingService(stack, ambariClient, hostsInCluster);
        ambariClusterConnectorPollingResultChecker.checkPollingResult(waitForHostsResult, cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_HOST_JOIN_FAILED.code()));
        ambariClusterTemplateService.addClusterTemplate(cluster, hostGroupMappings, ambariClient);
        Pair<PollingResult, Exception> pollingResult = ambariOperationService.waitForOperationsToStart(stack, ambariClient, singletonMap("INSTALL_START", 1), START_OPERATION_STATE);
        String message = pollingResult.getRight() == null ? cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_INSTALL_FAILED.code()) : pollingResult.getRight().getMessage();
        ambariClusterConnectorPollingResultChecker.checkPollingResult(pollingResult.getLeft(), message);
        Pair<PollingResult, Exception> pollingResultExceptionPair = ambariOperationService.waitForOperations(stack, ambariClient, new HashMap<String, Integer>() {

            {
                put("CLUSTER_INSTALL", 1);
            }
        }, INSTALL_AMBARI_PROGRESS_STATE);
        ambariClusterConnectorPollingResultChecker.checkPollingResult(pollingResultExceptionPair.getLeft(), cloudbreakMessagesService.getMessage(AMBARI_CLUSTER_INSTALL_FAILED.code()));
        recipeEngine.executePostInstall(stack);
        ambariSmartSenseCapturer.capture(0, ambariClient);
        cluster = ambariViewProvider.provideViewInformation(ambariClient, cluster);
        ambariClusterCreationSuccessHandler.handleClusterCreationSuccess(stack, cluster);
    } catch (CancellationException cancellationException) {
        throw cancellationException;
    } catch (HttpResponseException hre) {
        throw new AmbariOperationFailedException("Ambari could not create the cluster: " + AmbariClientExceptionUtil.getErrorMessage(hre), hre);
    } catch (Exception e) {
        LOGGER.error("Error while building the Ambari cluster. Message {}, throwable: {}", e.getMessage(), e);
        throw new AmbariOperationFailedException(e.getMessage(), e);
    }
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) HttpResponseException(groovyx.net.http.HttpResponseException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) HttpResponseException(groovyx.net.http.HttpResponseException) CloudbreakSecuritySetupException(com.sequenceiq.cloudbreak.core.CloudbreakSecuritySetupException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) CloudbreakServiceException(com.sequenceiq.cloudbreak.service.CloudbreakServiceException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) PollingResult(com.sequenceiq.cloudbreak.service.PollingResult) BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) List(java.util.List) AmbariClient(com.sequenceiq.ambari.client.AmbariClient) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Example 15 with BlueprintPreparationObject

use of com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject in project cloudbreak by hortonworks.

the class ReadTestData method getInputOutputData.

public static List<BlueprintDataProvider> getInputOutputData(Map<String, BlueprintPreparationObject> models) throws IOException {
    final List<BlueprintDataProvider> testFiles = new LinkedList<>();
    for (Map.Entry<String, BlueprintPreparationObject> entry : models.entrySet()) {
        try {
            TestFile inputFile = getTestFile(getFileName(BLUEPRINT_UPDATER_TEST_INPUTS, entry.getKey()));
            TestFile outputFile = getTestFile(getFileName(BLUEPRINT_UPDATER_TEST_OUTPUTS, entry.getKey()));
            testFiles.add(new BlueprintDataProvider(inputFile, outputFile, entry.getValue()));
        } catch (Exception ex) {
            throw new IOException(String.format("Unable to locate the desired folder/file in the classpath <%s>, message: %s", entry.getKey(), ex.getMessage()));
        }
    }
    return testFiles;
}
Also used : TestFile(com.sequenceiq.cloudbreak.blueprint.testrepeater.TestFile) BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) IOException(java.io.IOException) Map(java.util.Map) LinkedList(java.util.LinkedList) IOException(java.io.IOException)

Aggregations

BlueprintPreparationObject (com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject)28 Test (org.junit.Test)24 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)11 BlueprintView (com.sequenceiq.cloudbreak.blueprint.template.views.BlueprintView)8 BlueprintStackInfo (com.sequenceiq.cloudbreak.blueprint.templates.BlueprintStackInfo)6 BlueprintTextProcessor (com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor)5 Matchers.anyString (org.mockito.Matchers.anyString)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 GeneralClusterConfigs (com.sequenceiq.cloudbreak.blueprint.templates.GeneralClusterConfigs)4 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)4 Stack (com.sequenceiq.cloudbreak.domain.Stack)4 KerberosConfig (com.sequenceiq.cloudbreak.domain.KerberosConfig)2 Json (com.sequenceiq.cloudbreak.domain.json.Json)2 HashMap (java.util.HashMap)2 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)1 GeneratedBlueprintResponse (com.sequenceiq.cloudbreak.api.model.GeneratedBlueprintResponse)1 HostgroupConfigurations (com.sequenceiq.cloudbreak.blueprint.configuration.HostgroupConfigurations)1 SiteConfigurations (com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfigurations)1 HdfConfigs (com.sequenceiq.cloudbreak.blueprint.nifi.HdfConfigs)1 TestFile (com.sequenceiq.cloudbreak.blueprint.testrepeater.TestFile)1