use of com.sequenceiq.periscope.domain.PeriscopeUser in project cloudbreak by hortonworks.
the class ClusterCreationEvaluator method createOrUpdateCluster.
private void createOrUpdateCluster(AutoscaleStackResponse stack, Optional<Cluster> clusterOptional) {
AmbariStack resolvedAmbari = createAmbariStack(stack);
Cluster cluster;
boolean sendNotification = false;
if (clusterOptional.isPresent()) {
cluster = clusterOptional.get();
MDCBuilder.buildMdcContext(cluster);
if (PENDING.equals(cluster.getState()) || SUSPENDED.equals(cluster.getState())) {
ambariHealthCheck(cluster.getUser(), resolvedAmbari);
LOGGER.info("Update cluster and set it's state to 'RUNNING' for Ambari host: {}", resolvedAmbari.getAmbari().getHost());
cluster = clusterService.update(cluster.getId(), resolvedAmbari, false, RUNNING, cluster.isAutoscalingEnabled());
sendNotification = true;
}
} else {
PeriscopeUser user = new PeriscopeUser(stack.getOwner(), null, stack.getAccount());
MDCBuilder.buildMdcContext(user, stack.getStackId(), null);
LOGGER.info("Creating cluster for Ambari host: {}", resolvedAmbari.getAmbari().getHost());
ambariHealthCheck(user, resolvedAmbari);
cluster = clusterService.create(user, resolvedAmbari, null);
sendNotification = true;
}
if (sendNotification) {
History history = historyService.createEntry(ScalingStatus.ENABLED, "Autoscaling has been enabled for the cluster.", 0, cluster);
notificationSender.send(history);
}
}
use of com.sequenceiq.periscope.domain.PeriscopeUser in project cloudbreak by hortonworks.
the class ControllerLogContextAspects method buildLogContextForControllerCalls.
@Before("com.sequenceiq.periscope.log.ControllerLogContextAspects.interceptControllerMethodCalls()")
public void buildLogContextForControllerCalls(JoinPoint joinPoint) {
Object[] args = joinPoint.getArgs();
CodeSignature sig = (CodeSignature) joinPoint.getSignature();
String[] paramNames = sig.getParameterNames();
Long clusterId = getClusterId(paramNames, args);
PeriscopeUser user = authenticatedUserService.getPeriscopeUser();
MDCBuilder.buildMdcContext(user, clusterId);
LOGGER.debug("A controller method has been intercepted: {} with params {}, {}, MDC logger context is built.", joinPoint.toShortString(), sig.getParameterNames(), args);
}
use of com.sequenceiq.periscope.domain.PeriscopeUser in project cloudbreak by hortonworks.
the class AutoScaleClusterCommonService method modifyCluster.
public AutoscaleClusterResponse modifyCluster(AutoscaleClusterRequest ambariServer, Long clusterId) {
PeriscopeUser user = authenticatedUserService.getPeriscopeUser();
MDCBuilder.buildMdcContext(user, clusterId);
return setCluster(user, ambariServer, clusterId);
}
use of com.sequenceiq.periscope.domain.PeriscopeUser in project cloudbreak by hortonworks.
the class AutoScaleClusterCommonService method getCluster.
public AutoscaleClusterResponse getCluster(Long clusterId) {
PeriscopeUser user = authenticatedUserService.getPeriscopeUser();
MDCBuilder.buildMdcContext(user, clusterId);
return createClusterJsonResponse(clusterService.findOneById(clusterId));
}
use of com.sequenceiq.periscope.domain.PeriscopeUser in project cloudbreak by hortonworks.
the class AutoScaleClusterCommonService method deleteCluster.
public void deleteCluster(Long clusterId) {
PeriscopeUser user = authenticatedUserService.getPeriscopeUser();
MDCBuilder.buildMdcContext(user, clusterId);
clusterService.removeOne(clusterId);
}
Aggregations