use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class ValidateClusterLicenceHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<ValidateClusterLicenceRequest> event) {
Long stackId = event.getData().getResourceId();
Selectable response;
try {
clusterBuilderService.validateLicence(stackId);
response = new ValidateClusterLicenceSuccess(stackId);
} catch (RuntimeException e) {
LOGGER.error("ValidateClusterLicenceHandler step failed with the following message: {}", e.getMessage());
response = new ValidateClusterLicenceFailed(stackId, e);
}
return response;
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class LdapSSOConfigurationHandler method accept.
@Override
public void accept(Event<LdapSSOConfigurationRequest> ldapConfigurationRequestEvent) {
Long stackId = ldapConfigurationRequestEvent.getData().getResourceId();
Selectable response;
try {
Stack stack = stackService.getByIdWithListsInTransaction(stackId);
GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
LdapView ldapView = ldapConfigService.get(stack.getEnvironmentCrn(), stack.getName()).orElse(null);
String environmentCrnForVirtualGroups = environmentConfigProvider.getParentEnvironmentCrn(stack.getEnvironmentCrn());
VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(environmentCrnForVirtualGroups, ldapView != null ? ldapView.getAdminGroup() : "");
clusterApiConnectors.getConnector(stack).clusterSecurityService().setupLdapAndSSO(primaryGatewayConfig.getPublicAddress(), ldapView, virtualGroupRequest);
response = new LdapSSOConfigurationSuccess(stackId);
} catch (Exception e) {
LOGGER.info("Error during LDAP configuration, stackId: " + stackId, e);
response = new LdapSSOConfigurationFailed(stackId, e);
}
eventBus.notify(response.selector(), new Event<>(ldapConfigurationRequestEvent.getHeaders(), response));
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class BootstrapMachineHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<BootstrapMachinesRequest> event) {
BootstrapMachinesRequest request = event.getData();
Selectable response;
try {
if (request.isReBootstrap()) {
LOGGER.info("RE-Bootstrap machines");
clusterBootstrapper.reBootstrapMachines(request.getResourceId());
clusterProxyService.reRegisterCluster(request.getResourceId());
} else {
LOGGER.info("Bootstrap machines");
clusterBootstrapper.bootstrapMachines(request.getResourceId());
}
response = new BootstrapMachinesSuccess(request.getResourceId());
} catch (Exception e) {
LOGGER.warn("Bootstrap machines failed (rebootstrap:{})", request.isReBootstrap(), e);
response = new BootstrapMachinesFailed(request.getResourceId(), e);
}
return response;
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class ClusterProxyGatewayRegistrationHandler method accept.
@Override
public void accept(Event<ClusterProxyGatewayRegistrationRequest> event) {
ClusterProxyGatewayRegistrationRequest request = event.getData();
Selectable response;
try {
if (clusterProxyEnablementService.isClusterProxyApplicable(request.getCloudPlatform())) {
clusterProxyService.registerGatewayConfiguration(request.getResourceId());
response = new ClusterProxyGatewayRegistrationSuccess(request.getResourceId());
} else {
LOGGER.info("Cluster Proxy integration is DISABLED, skipping registering gateway configuration with Cluster Proxy service.");
response = new ClusterProxyGatewayRegistrationSuccess(request.getResourceId());
}
} catch (Exception e) {
LOGGER.error("Error occurred when registering gateway config with cluster proxy", e);
response = new ClusterProxyGatewayRegistrationFailed(request.getResourceId(), e);
}
eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class RemoveHostsHandler method accept.
@Override
public void accept(Event<RemoveHostsRequest> removeHostsRequestEvent) {
RemoveHostsRequest request = removeHostsRequestEvent.getData();
Set<String> hostNames = request.getHostNames();
Selectable result;
try {
Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
if (stack.getPrimaryGatewayInstance() != null && stack.getPrimaryGatewayInstance().isReachable()) {
List<GatewayConfig> allGatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
PollingResult orchestratorRemovalPollingResult = removeHostsFromOrchestrator(stack, new ArrayList<>(hostNames), hostOrchestrator, allGatewayConfigs);
if (!orchestratorRemovalPollingResult.isSuccess()) {
LOGGER.warn("Can not remove hosts from orchestrator: {}", hostNames);
}
} else {
LOGGER.warn("Primary gateway is not reachable, can't remove hosts from orchestrator");
}
result = new RemoveHostsSuccess(request.getResourceId(), request.getHostGroupNames(), hostNames);
} catch (Exception e) {
result = new RemoveHostsFailed(removeHostsRequestEvent.getData().getResourceId(), e, request.getHostGroupNames(), hostNames);
}
eventBus.notify(result.selector(), new Event<>(removeHostsRequestEvent.getHeaders(), result));
}
Aggregations