use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class UpdateServiceConfigHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<UpdateServiceConfigRequest> event) {
UpdateServiceConfigRequest request = event.getData();
Stack stack = request.getStack();
requireNonNull(stack);
requireNonNull(stack.getCluster());
try {
LOGGER.debug("Gathering entries for Hue knox_proxyhosts property.");
Set<String> proxyhosts = new HashSet<>();
if (StringUtils.isNotEmpty(stack.getPrimaryGatewayInstance().getDiscoveryFQDN())) {
proxyhosts.add(stack.getPrimaryGatewayInstance().getDiscoveryFQDN());
}
if (StringUtils.isNotEmpty(stack.getPrimaryGatewayInstance().getDiscoveryFQDN())) {
proxyhosts.add(stack.getCluster().getFqdn());
}
String loadBalancerFqdn = loadBalancerConfigService.getLoadBalancerUserFacingFQDN(stack.getId());
if (StringUtils.isNotEmpty(loadBalancerFqdn)) {
proxyhosts.add(loadBalancerFqdn);
}
LOGGER.debug("Hue knox_proxyhosts setting will be updated to {}", proxyhosts);
ClusterApi clusterApi = clusterApiConnectors.getConnector(stackService.getByIdWithListsInTransaction(event.getData().getResourceId()));
clusterApi.clusterModificationService().updateServiceConfigAndRestartService(HUE_SERVICE, HUE_KNOX_PROXYHOSTS, String.join(",", proxyhosts));
LOGGER.debug("Updating CM frontend URL with load balancer DNS");
clusterHostServiceRunner.updateClusterConfigs(stack, stack.getCluster());
LOGGER.debug("Service config update was successful");
return new UpdateServiceConfigSuccess(stack);
} catch (Exception e) {
LOGGER.warn("Error updating HUE and CM service configuration.", e);
return new UpdateServiceConfigFailure(request.getResourceId(), e);
}
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class ClusterUpgradeHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeRequest> event) {
LOGGER.debug("Accepting Cluster upgrade event..");
ClusterUpgradeRequest request = event.getData();
Long stackId = request.getResourceId();
Selectable result;
try {
Stack stack = stackService.getByIdWithClusterInTransaction(stackId);
Optional<String> remoteDataContext = getRemoteDataContext(stack);
ClusterApi connector = clusterApiConnectors.getConnector(stack);
Set<ClusterComponent> components = parcelService.getParcelComponentsByBlueprint(stack);
connector.upgradeClusterRuntime(components, request.isPatchUpgrade(), remoteDataContext);
ParcelOperationStatus parcelOperationStatus = parcelService.removeUnusedParcelComponents(stack, components);
if (parcelOperationStatus.getFailed().isEmpty()) {
result = new ClusterUpgradeSuccess(request.getResourceId());
} else {
LOGGER.info("There are failed parcel removals: {}", parcelOperationStatus);
CloudbreakException exception = new CloudbreakException(format("Failed to remove the following parcels: %s", parcelOperationStatus.getFailed()));
result = new ClusterUpgradeFailedEvent(request.getResourceId(), exception, DetailedStackStatus.CLUSTER_UPGRADE_FAILED);
}
} catch (Exception e) {
LOGGER.error("Cluster upgrade event failed", e);
result = new ClusterUpgradeFailedEvent(request.getResourceId(), e, DetailedStackStatus.CLUSTER_UPGRADE_FAILED);
}
return result;
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class ClusterService method updateClusterMetadata.
public Cluster updateClusterMetadata(Long stackId) {
Stack stack = stackService.getById(stackId);
ClusterApi connector = clusterApiConnectors.getConnector(stack);
if (!connector.clusterStatusService().isClusterManagerRunning()) {
Set<InstanceMetaData> notTerminatedInstanceMetaDatas = instanceMetaDataService.findNotTerminatedAndNotZombieForStack(stackId);
InstanceMetaData cmInstance = updateClusterManagerHostStatus(notTerminatedInstanceMetaDatas);
eventService.fireCloudbreakEvent(stack.getId(), AVAILABLE.name(), CLUSTER_HOST_STATUS_UPDATED, Arrays.asList(cmInstance.getDiscoveryFQDN(), cmInstance.getInstanceStatus().name()));
return stack.getCluster();
} else {
ExtendedHostStatuses extendedHostStatuses = connector.clusterStatusService().getExtendedHostStatuses(runtimeVersionService.getRuntimeVersion(stack.getCluster().getId()));
updateClusterCertExpirationState(stack.getCluster(), extendedHostStatuses.isAnyCertExpiring());
try {
return transactionService.required(() -> {
Set<InstanceMetaData> notTerminatedInstanceMetaDatas = instanceMetaDataService.findNotTerminatedAndNotZombieForStack(stackId);
List<InstanceMetaData> updatedInstanceMetaData = updateInstanceStatuses(notTerminatedInstanceMetaDatas, extendedHostStatuses);
instanceMetaDataService.saveAll(updatedInstanceMetaData);
fireHostStatusUpdateNotification(stack, updatedInstanceMetaData);
return stack.getCluster();
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class VmStatusCheckerConclusionStep method checkCMForInstanceStatuses.
private Conclusion checkCMForInstanceStatuses(ClusterApi connector, Set<InstanceMetaData> runningInstances, Long clusterId) {
ExtendedHostStatuses extendedHostStatuses = connector.clusterStatusService().getExtendedHostStatuses(runtimeVersionService.getRuntimeVersion(clusterId));
Map<HostName, Set<HealthCheck>> hostStatuses = extendedHostStatuses.getHostsHealth();
Map<String, String> unhealthyHosts = hostStatuses.keySet().stream().filter(hostName -> !extendedHostStatuses.isHostHealthy(hostName)).collect(Collectors.toMap(StringType::value, extendedHostStatuses::statusReasonForHost));
Set<String> noReportHosts = runningInstances.stream().map(InstanceMetaData::getDiscoveryFQDN).filter(Objects::nonNull).filter(discoveryFQDN -> !hostStatuses.containsKey(hostName(discoveryFQDN))).collect(toSet());
if (!unhealthyHosts.isEmpty() || !noReportHosts.isEmpty()) {
String conclusion = String.format("Unhealthy and/or unknown VMs found based on CM status. Unhealthy VMs: %s, unknown VMs: %s. " + "Please check the instances on your cloud provider for further details.", unhealthyHosts, noReportHosts);
String details = String.format("Unhealthy and/or unknown VMs found based on CM status. Unhealthy VMs: %s, unknown VMs: %s", unhealthyHosts, noReportHosts);
LOGGER.warn(details);
return failed(conclusion, details);
} else {
return succeeded();
}
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.
the class VmStatusCheckerConclusionStep method check.
@Override
public Conclusion check(Long resourceId) {
Stack stack = stackService.getById(resourceId);
ClusterApi connector = clusterApiConnectors.getConnector(stack);
Set<InstanceMetaData> runningInstances = instanceMetaDataService.findNotTerminatedAndNotZombieForStack(stack.getId());
if (isClusterManagerRunning(stack, connector)) {
return checkCMForInstanceStatuses(connector, runningInstances, stack.getCluster().getId());
} else {
return checkProviderForInstanceStatuses(stack, runningInstances);
}
}
Aggregations