Search in sources :

Example 6 with Queue

use of com.dtstack.taier.dao.domain.Queue in project Taier by DTStack.

the class TenantService method bindingQueue.

/**
 * 绑定/切换队列
 */
@Transactional(rollbackFor = Exception.class)
public void bindingQueue(String queueName, Long clusterId, Long tenantId) {
    List<Queue> queues = consoleQueueMapper.listByClusterId(clusterId);
    Optional<Queue> queueOptional = queues.stream().filter(queue -> queue.getQueueName().equals(queueName)).findFirst();
    if (!queueOptional.isPresent()) {
        throw new RdosDefineException("Queue does not exist", ErrorCode.DATA_NOT_FIND);
    }
    Queue queue = queueOptional.get();
    Long queueId = queue.getId();
    try {
        LOGGER.info("switch queue, tenantId:{} queueId:{} queueName:{} clusterId:{}", tenantId, queueId, queue.getQueueName(), queue.getClusterId());
        updateTenantQueue(tenantId, queue.getClusterId(), queueId);
    } catch (Exception e) {
        LOGGER.error("", e);
        throw new RdosDefineException("Failed to switch queue");
    }
}
Also used : ClusterTenantMapper(com.dtstack.taier.dao.mapper.ClusterTenantMapper) LoggerFactory(org.slf4j.LoggerFactory) PageResult(com.dtstack.taier.dao.pager.PageResult) Autowired(org.springframework.beans.factory.annotation.Autowired) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) BooleanUtils(org.apache.commons.lang3.BooleanUtils) TenantMapper(com.dtstack.taier.dao.mapper.TenantMapper) Tenant(com.dtstack.taier.dao.domain.Tenant) ConsoleQueueMapper(com.dtstack.taier.dao.mapper.ConsoleQueueMapper) TenantTransfer(com.dtstack.taier.develop.mapstruct.console.TenantTransfer) ComponentService(com.dtstack.taier.scheduler.service.ComponentService) Queue(com.dtstack.taier.dao.domain.Queue) Component(com.dtstack.taier.dao.domain.Component) Service(org.springframework.stereotype.Service) ClusterTransfer(com.dtstack.taier.develop.mapstruct.console.ClusterTransfer) Map(java.util.Map) ClusterService(com.dtstack.taier.scheduler.service.ClusterService) TenantComponent(com.dtstack.taier.dao.domain.TenantComponent) ErrorCode(com.dtstack.taier.common.exception.ErrorCode) Wrappers(com.baomidou.mybatisplus.core.toolkit.Wrappers) Logger(org.slf4j.Logger) BatchCatalogueService(com.dtstack.taier.develop.service.develop.impl.BatchCatalogueService) Timestamp(java.sql.Timestamp) ClusterTenant(com.dtstack.taier.dao.domain.ClusterTenant) DatasourceService(com.dtstack.taier.develop.service.datasource.impl.DatasourceService) MultiEngineServiceFactory(com.dtstack.taier.develop.service.develop.MultiEngineServiceFactory) DevelopTenantComponentService(com.dtstack.taier.develop.service.develop.impl.DevelopTenantComponentService) Sort(com.dtstack.taier.dao.pager.Sort) ComponentBindDBDTO(com.dtstack.taier.develop.dto.devlop.ComponentBindDBDTO) ClusterTenantVO(com.dtstack.taier.develop.vo.console.ClusterTenantVO) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) EComponentType(com.dtstack.taier.common.enums.EComponentType) Objects(java.util.Objects) List(java.util.List) JSON(com.alibaba.fastjson.JSON) ComponentVO(com.dtstack.taier.scheduler.vo.ComponentVO) PageQuery(com.dtstack.taier.dao.pager.PageQuery) Optional(java.util.Optional) ComponentMultiTestResult(com.dtstack.taier.scheduler.impl.pojo.ComponentMultiTestResult) ComponentBindDBVO(com.dtstack.taier.develop.vo.console.ComponentBindDBVO) Deleted(com.dtstack.taier.common.enums.Deleted) IComponentService(com.dtstack.taier.develop.service.develop.IComponentService) ComponentTypeToEScheduleJobMapping(com.dtstack.taier.develop.utils.develop.mapping.ComponentTypeToEScheduleJobMapping) Transactional(org.springframework.transaction.annotation.Transactional) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) Queue(com.dtstack.taier.dao.domain.Queue) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with Queue

use of com.dtstack.taier.dao.domain.Queue in project Taier by DTStack.

the class ConsoleClusterService method getClusterEngine.

public ClusterEngineVO getClusterEngine(Long clusterId) {
    Cluster cluster = clusterMapper.selectById(clusterId);
    List<com.dtstack.taier.dao.domain.Component> components = componentService.listAllComponents(clusterId);
    Map<Long, Set<MultiEngineType>> clusterEngineMapping = new HashMap<>();
    if (CollectionUtils.isNotEmpty(components)) {
        clusterEngineMapping = components.stream().filter(c -> {
            MultiEngineType multiEngineType = EComponentType.getEngineTypeByComponent(EComponentType.getByCode(c.getComponentTypeCode()), c.getDeployType());
            return null != multiEngineType && !MultiEngineType.COMMON.equals(multiEngineType);
        }).collect(Collectors.groupingBy(com.dtstack.taier.dao.domain.Component::getClusterId, Collectors.mapping(c -> EComponentType.getEngineTypeByComponent(EComponentType.getByCode(c.getComponentTypeCode()), c.getDeployType()), Collectors.toSet())));
    }
    List<com.dtstack.taier.dao.domain.Queue> queues = consoleQueueMapper.listByClusterWithLeaf(clusterId);
    Map<Long, List<com.dtstack.taier.dao.domain.Queue>> engineQueueMapping = queues.stream().collect(Collectors.groupingBy(Queue::getClusterId));
    return fillEngineQueueInfo(clusterEngineMapping, engineQueueMapping, cluster);
}
Also used : java.util(java.util) QueueVO(com.dtstack.taier.develop.vo.console.QueueVO) IComponentVO(com.dtstack.taier.scheduler.vo.IComponentVO) KerberosConfig(com.dtstack.taier.dao.domain.KerberosConfig) com.dtstack.taier.dao.mapper(com.dtstack.taier.dao.mapper) Autowired(org.springframework.beans.factory.annotation.Autowired) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) HashBasedTable(com.google.common.collect.HashBasedTable) StringUtils(org.apache.commons.lang3.StringUtils) ComponentService(com.dtstack.taier.scheduler.service.ComponentService) Queue(com.dtstack.taier.dao.domain.Queue) CollectionUtils(org.apache.commons.collections.CollectionUtils) EComponentScheduleType(com.dtstack.taier.common.enums.EComponentScheduleType) ClusterVO(com.dtstack.taier.develop.vo.console.ClusterVO) DEFAULT_CLUSTER_ID(com.dtstack.taier.pluginapi.constrant.ConfigConstant.DEFAULT_CLUSTER_ID) ErrorCode(com.dtstack.taier.common.exception.ErrorCode) Wrappers(com.baomidou.mybatisplus.core.toolkit.Wrappers) Cluster(com.dtstack.taier.dao.domain.Cluster) ClusterTenant(com.dtstack.taier.dao.domain.ClusterTenant) ClusterEngineVO(com.dtstack.taier.develop.vo.console.ClusterEngineVO) SchedulingVo(com.dtstack.taier.scheduler.vo.SchedulingVo) Collectors(java.util.stream.Collectors) EComponentType(com.dtstack.taier.common.enums.EComponentType) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) Component(org.springframework.stereotype.Component) ComponentVO(com.dtstack.taier.scheduler.vo.ComponentVO) MultiEngineType(com.dtstack.taier.common.enums.MultiEngineType) ComponentConfigService(com.dtstack.taier.scheduler.service.ComponentConfigService) IPage(com.baomidou.mybatisplus.core.metadata.IPage) Table(com.google.common.collect.Table) Deleted(com.dtstack.taier.common.enums.Deleted) EngineVO(com.dtstack.taier.develop.vo.console.EngineVO) MultiEngineType(com.dtstack.taier.common.enums.MultiEngineType) Cluster(com.dtstack.taier.dao.domain.Cluster) Component(org.springframework.stereotype.Component) Queue(com.dtstack.taier.dao.domain.Queue)

Example 8 with Queue

use of com.dtstack.taier.dao.domain.Queue in project Taier by DTStack.

the class JobComputeResourcePlain method buildJobClientGroupName.

private void buildJobClientGroupName(JobClient jobClient) {
    Long clusterId = clusterTenantMapper.getClusterIdByTenantId(jobClient.getTenantId());
    if (null == clusterId) {
        return;
    }
    Cluster cluster = clusterMapper.getOne(clusterId);
    if (null == cluster) {
        return;
    }
    String clusterName = cluster.getClusterName();
    // %s_default
    String groupName = clusterName + SPLIT + RESOURCE_NAMESPACE_OR_QUEUE_DEFAULT;
    Queue queue = clusterService.getQueue(jobClient.getTenantId(), clusterId);
    if (null != queue) {
        groupName = clusterName + SPLIT + queue.getQueueName();
    }
    jobClient.setGroupName(groupName);
}
Also used : Cluster(com.dtstack.taier.dao.domain.Cluster) Queue(com.dtstack.taier.dao.domain.Queue)

Aggregations

Queue (com.dtstack.taier.dao.domain.Queue)8 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)6 EComponentType (com.dtstack.taier.common.enums.EComponentType)3 Wrappers (com.baomidou.mybatisplus.core.toolkit.Wrappers)2 Deleted (com.dtstack.taier.common.enums.Deleted)2 ErrorCode (com.dtstack.taier.common.exception.ErrorCode)2 Cluster (com.dtstack.taier.dao.domain.Cluster)2 ClusterTenant (com.dtstack.taier.dao.domain.ClusterTenant)2 ComponentTestResult (com.dtstack.taier.pluginapi.pojo.ComponentTestResult)2 ComponentService (com.dtstack.taier.scheduler.service.ComponentService)2 ComponentVO (com.dtstack.taier.scheduler.vo.ComponentVO)2 Collectors (java.util.stream.Collectors)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 JSON (com.alibaba.fastjson.JSON)1 JSONObject (com.alibaba.fastjson.JSONObject)1 IPage (com.baomidou.mybatisplus.core.metadata.IPage)1 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1 EComponentScheduleType (com.dtstack.taier.common.enums.EComponentScheduleType)1 EScheduleJobType (com.dtstack.taier.common.enums.EScheduleJobType)1 MultiEngineType (com.dtstack.taier.common.enums.MultiEngineType)1