Search in sources :

Example 6 with PeriscopeUser

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);
    }
}
Also used : AmbariStack(com.sequenceiq.periscope.model.AmbariStack) PeriscopeUser(com.sequenceiq.periscope.domain.PeriscopeUser) Cluster(com.sequenceiq.periscope.domain.Cluster) History(com.sequenceiq.periscope.domain.History)

Example 7 with PeriscopeUser

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);
}
Also used : PeriscopeUser(com.sequenceiq.periscope.domain.PeriscopeUser) CodeSignature(org.aspectj.lang.reflect.CodeSignature) Before(org.aspectj.lang.annotation.Before)

Example 8 with PeriscopeUser

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);
}
Also used : PeriscopeUser(com.sequenceiq.periscope.domain.PeriscopeUser)

Example 9 with PeriscopeUser

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));
}
Also used : PeriscopeUser(com.sequenceiq.periscope.domain.PeriscopeUser)

Example 10 with PeriscopeUser

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);
}
Also used : PeriscopeUser(com.sequenceiq.periscope.domain.PeriscopeUser)

Aggregations

PeriscopeUser (com.sequenceiq.periscope.domain.PeriscopeUser)12 Cluster (com.sequenceiq.periscope.domain.Cluster)4 UserFilterField (com.sequenceiq.cloudbreak.common.service.user.UserFilterField)1 History (com.sequenceiq.periscope.domain.History)1 SecurityConfig (com.sequenceiq.periscope.domain.SecurityConfig)1 AmbariStack (com.sequenceiq.periscope.model.AmbariStack)1 Field (java.lang.reflect.Field)1 Before (org.aspectj.lang.annotation.Before)1 CodeSignature (org.aspectj.lang.reflect.CodeSignature)1