use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent in project cloudbreak by hortonworks.
the class RemoveServersResponseToDownscaleFailureEventConverter method convert.
@Override
public DownscaleFailureEvent convert(Object payload) {
RemoveServersResponse removeServersResponse = (RemoveServersResponse) payload;
DownscaleFailureEvent event = new DownscaleFailureEvent(removeServersResponse.getResourceId(), "Server removal", Set.of(), Map.of(), new Exception("Payload failed: " + payload));
return event;
}
use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent in project cloudbreak by hortonworks.
the class CollectAdditionalHostnamesHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<CollectAdditionalHostnamesRequest> event) {
CollectAdditionalHostnamesRequest request = event.getData();
Selectable result;
try {
Long stackId = request.getResourceId();
Set<String> fqdns = getHostnamesFromFreeIpaServers(stackId);
result = new CollectAdditionalHostnamesResponse(request.getResourceId(), fqdns);
} catch (Exception e) {
LOGGER.error("Collecting additional hostnames failed", e);
result = new DownscaleFailureEvent(DOWNSCALE_COLLECT_ADDITIONAL_HOSTNAMES_FAILED_EVENT.event(), request.getResourceId(), "Downscale Collect Additional Hostnames", Set.of(), Map.of(), e);
}
return result;
}
use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent in project cloudbreak by hortonworks.
the class RemoveHostsHandler method accept.
@Override
public void accept(Event<RemoveHostsFromOrchestrationRequest> removeHostsRequestEvent) {
RemoveHostsFromOrchestrationRequest request = removeHostsRequestEvent.getData();
Set<String> hostNames = request.getHosts();
Selectable result;
try {
if (!hostNames.isEmpty()) {
Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
PollingResult orchestratorRemovalPollingResult = removeHostsFromOrchestrator(stack, new ArrayList<>(hostNames));
if (!orchestratorRemovalPollingResult.isSuccess()) {
LOGGER.warn("Can not remove hosts from orchestrator: {}", hostNames);
}
// rebootstrap to update the minion's multi-master configuration
List<String> remainingInstanceIds = stack.getNotDeletedInstanceMetaDataList().stream().filter(metadata -> Objects.nonNull(metadata.getDiscoveryFQDN())).filter(metadata -> !hostNames.contains(metadata.getDiscoveryFQDN())).map(InstanceMetaData::getInstanceId).collect(Collectors.toList());
bootstrapService.bootstrap(stack.getId(), remainingInstanceIds);
}
result = new RemoveHostsFromOrchestrationSuccess(request.getResourceId());
} catch (Exception e) {
LOGGER.error("Failed to remove hosts from orchestration", e);
result = new DownscaleFailureEvent(REMOVE_HOSTS_FROM_ORCHESTRATION_FAILED_EVENT.event(), request.getResourceId(), "Removing host from orchestration", Set.of(), Map.of(), e);
}
eventBus.notify(result.selector(), new Event<>(removeHostsRequestEvent.getHeaders(), result));
}
use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent in project cloudbreak by hortonworks.
the class UpdateDnsSoaRecordsHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<UpdateDnsSoaRecordsRequest> event) {
UpdateDnsSoaRecordsRequest request = event.getData();
Selectable result;
try {
Long stackId = request.getResourceId();
Set<String> fqdns = request.getHosts().stream().map(hostname -> StringUtils.appendIfMissing(hostname, ".")).collect(Collectors.toSet());
updateSoaRecords(stackId, fqdns);
result = new UpdateDnsSoaRecordsResponse(request.getResourceId());
} catch (Exception e) {
LOGGER.error("Downscale updating DNS SOA records failed", e);
result = new DownscaleFailureEvent(DOWNSCALE_UPDATE_DNS_SOA_RECORDS_FAILED_EVENT.event(), request.getResourceId(), "Downscale Update DNS SOA Records", Set.of(), Map.of(), e);
}
return result;
}
Aggregations