use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.
the class ChangePrimaryGatewayHandler method accept.
@Override
public void accept(Event<ChangePrimaryGatewayRequest> event) {
ChangePrimaryGatewayRequest request = event.getData();
Selectable response;
try {
response = new ChangePrimaryGatewaySuccess(request.getStackId(), clusterServiceRunner.changePrimaryGateway(request.getStackId()));
} catch (Exception e) {
response = new ChangePrimaryGatewayFailed(request.getStackId(), e);
}
eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.
the class HostMetadataSetupHandler method accept.
@Override
public void accept(Event<HostMetadataSetupRequest> event) {
StackEvent request = event.getData();
Selectable response;
try {
hostMetadataSetup.setupHostMetadata(request.getStackId());
response = new HostMetadataSetupSuccess(request.getStackId());
} catch (Exception e) {
response = new HostMetadataSetupFailed(request.getStackId(), e);
}
eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.
the class StartAmbariServicesHandler method accept.
@Override
public void accept(Event<StartAmbariServicesRequest> event) {
Long stackId = event.getData().getStackId();
Selectable response;
try {
clusterServiceRunner.runAmbariServices(stackId);
response = new StartAmbariServicesSuccess(stackId);
} catch (Exception e) {
response = new StartAmbariServicesFailed(stackId, e);
}
eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.
the class StackPreTerminationHandler method accept.
@Override
public void accept(Event<StackPreTerminationRequest> requestEvent) {
StackPreTerminationRequest request = requestEvent.getData();
Stack stack = stackService.getByIdWithLists(request.getStackId());
try {
Cluster cluster = stack.getCluster();
if (cluster != null) {
Set<HostGroup> hostGroups = hostGroupService.getByCluster(cluster.getId());
recipeEngine.executePreTerminationRecipes(stack, hostGroups);
}
} catch (Exception ex) {
LOGGER.error("Pre-termination failed: {}", ex.getMessage(), ex);
}
Selectable result = new StackPreTerminationSuccess(stack.getId());
eventBus.notify(result.selector(), new Event<>(requestEvent.getHeaders(), result));
}
use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.
the class UploadRecipesHandler method accept.
@Override
public void accept(Event<UploadRecipesRequest> event) {
UploadRecipesRequest request = event.getData();
Selectable result;
Long stackId = request.getStackId();
try {
Stack stack = stackService.getByIdWithLists(stackId);
Set<HostGroup> hostGroups = hostGroupService.getByCluster(stack.getCluster().getId());
recipeEngine.uploadRecipes(stack, hostGroups);
result = new UploadRecipesSuccess(stackId);
} catch (Exception e) {
LOGGER.error("Failed to upload recipes", e);
result = new UploadRecipesFailed(stackId, e);
}
eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Aggregations