use of com.sequenceiq.cloudbreak.client.CloudbreakClient in project cloudbreak by hortonworks.
the class UpdateFailedHandler method reportAmbariServerFailure.
private void reportAmbariServerFailure(Cluster cluster, StackResponse stackResponse, CloudbreakClient cbClient) {
Optional<InstanceMetaDataJson> pgw = stackResponse.getInstanceGroups().stream().flatMap(ig -> ig.getMetadata().stream()).filter(im -> im.getInstanceType() == InstanceMetadataType.GATEWAY_PRIMARY && im.getInstanceStatus() != InstanceStatus.TERMINATED).findFirst();
if (pgw.isPresent()) {
FailureReport failureReport = new FailureReport();
failureReport.setFailedNodes(Collections.singletonList(pgw.get().getDiscoveryFQDN()));
try {
cbClient.clusterEndpoint().failureReport(cluster.getStackId(), failureReport);
} catch (Exception e) {
LOGGER.warn("Exception during failure report", e);
}
}
}
use of com.sequenceiq.cloudbreak.client.CloudbreakClient in project cloudbreak by hortonworks.
the class UpdateFailedHandler method onApplicationEvent.
@Override
public void onApplicationEvent(UpdateFailedEvent event) {
long id = event.getClusterId();
Cluster cluster = clusterService.find(id);
MDCBuilder.buildMdcContext(cluster);
Integer failed = updateFailures.get(id);
if (failed == null) {
updateFailures.put(id, 1);
} else if (RETRY_THRESHOLD - 1 == failed) {
try {
CloudbreakClient cloudbreakClient = cloudbreakClientConfiguration.cloudbreakClient();
StackResponse stackResponse = cloudbreakClient.stackV1Endpoint().get(cluster.getStackId(), new HashSet<>());
String stackStatus = stackResponse.getStatus().name();
String clusterStatus = stackResponse.getCluster().getStatus().name();
if (stackStatus.startsWith(DELETE_STATUSES_PREFIX)) {
clusterService.removeById(id);
LOGGER.info("Delete cluster due to failing update attempts and Cloudbreak stack status");
} else if (stackStatus.equals(AVAILABLE) && clusterStatus.equals(AVAILABLE)) {
// Ambari server is unreacheable but the stack and cluster statuses are "AVAILABLE"
reportAmbariServerFailure(cluster, stackResponse, cloudbreakClient);
suspendCluster(cluster);
} else {
suspendCluster(cluster);
}
} catch (Exception ex) {
LOGGER.warn("Cluster status could not be verified by Cloudbreak for remove.", ex);
suspendCluster(cluster);
}
updateFailures.remove(id);
} else {
updateFailures.put(id, failed + 1);
}
}
use of com.sequenceiq.cloudbreak.client.CloudbreakClient in project cloudbreak by hortonworks.
the class MockSuiteInitializer method cleanUp.
@AfterSuite(alwaysRun = true)
@Parameters("cleanUp")
public void cleanUp(@Optional("true") boolean cleanUp) {
if (isCleanUpNeeded(cleanUp)) {
CloudbreakClient cloudbreakClient = itContext.getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class);
cleanUpService.deleteImageCatalog(cloudbreakClient, MOCK_IMAGE_CATALOG_NAME);
}
}
use of com.sequenceiq.cloudbreak.client.CloudbreakClient in project cloudbreak by hortonworks.
the class MockSuiteInitializer method initSuiteMap.
@BeforeSuite(dependsOnMethods = "initContext")
public void initSuiteMap(ITestContext testContext) {
CloudbreakClient cloudbreakClient = itContext.getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class);
if (cleanUpBeforeStart && isImageCatalogExists(cloudbreakClient.imageCatalogEndpoint(), MOCK_IMAGE_CATALOG_NAME)) {
cleanUpService.deleteImageCatalog(cloudbreakClient, MOCK_IMAGE_CATALOG_NAME);
}
createMockImageCatalog(cloudbreakClient.imageCatalogEndpoint());
}
use of com.sequenceiq.cloudbreak.client.CloudbreakClient in project cloudbreak by hortonworks.
the class CloudbreakTestSuiteInitializer method cleanUp.
@AfterSuite(alwaysRun = true)
@Parameters("cleanUp")
public void cleanUp(@Optional("true") boolean cleanUp) {
if (isCleanUpNeeded(cleanUp)) {
CloudbreakClient cloudbreakClient = itContext.getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class);
String stackId = itContext.getCleanUpParameter(CloudbreakITContextConstants.STACK_ID);
cleanUpService.deleteStackAndWait(cloudbreakClient, stackId);
List<InstanceGroup> instanceGroups = itContext.getCleanUpParameter(CloudbreakITContextConstants.TEMPLATE_ID, List.class);
if (instanceGroups != null && !instanceGroups.isEmpty()) {
Collection<String> deletedTemplates = new HashSet<>();
for (InstanceGroup ig : instanceGroups) {
if (!deletedTemplates.contains(ig.getTemplateId())) {
cleanUpService.deleteTemplate(cloudbreakClient, ig.getTemplateId());
deletedTemplates.add(ig.getTemplateId());
}
}
}
Set<Long> recipeIds = itContext.getContextParam(CloudbreakITContextConstants.RECIPE_ID, Set.class);
if (recipeIds != null) {
for (Long recipeId : recipeIds) {
cleanUpService.deleteRecipe(cloudbreakClient, recipeId);
}
}
cleanUpService.deleteCredential(cloudbreakClient, itContext.getCleanUpParameter(CloudbreakITContextConstants.CREDENTIAL_ID));
cleanUpService.deleteBlueprint(cloudbreakClient, itContext.getCleanUpParameter(CloudbreakITContextConstants.BLUEPRINT_ID));
cleanUpService.deleteNetwork(cloudbreakClient, itContext.getCleanUpParameter(CloudbreakITContextConstants.NETWORK_ID));
cleanUpService.deleteSecurityGroup(cloudbreakClient, itContext.getCleanUpParameter(CloudbreakITContextConstants.SECURITY_GROUP_ID));
cleanUpService.deleteRdsConfigs(cloudbreakClient, itContext.getCleanUpParameter(CloudbreakITContextConstants.RDS_CONFIG_ID));
}
}
Aggregations