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);
}
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);
}
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);
}
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);
}
}
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;
}
Aggregations