|
|
@ -17,22 +17,26 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.apache.dolphinscheduler.api.service.impl; |
|
|
|
package org.apache.dolphinscheduler.api.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.dolphinscheduler.api.enums.Status; |
|
|
|
import org.apache.dolphinscheduler.api.enums.Status; |
|
|
|
import org.apache.dolphinscheduler.api.service.QueueService; |
|
|
|
import org.apache.dolphinscheduler.api.service.QueueService; |
|
|
|
import org.apache.dolphinscheduler.api.utils.PageInfo; |
|
|
|
import org.apache.dolphinscheduler.api.utils.PageInfo; |
|
|
|
import org.apache.dolphinscheduler.api.utils.Result; |
|
|
|
import org.apache.dolphinscheduler.api.utils.Result; |
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.enums.AuthorizationType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.AuthorizationType; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.enums.UserType; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Queue; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Queue; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.User; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.User; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.QueueMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.QueueMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.UserMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.UserMapper; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
@ -41,11 +45,10 @@ import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.YARN_QUEUE_CREATE; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.YARN_QUEUE_UPDATE; |
|
|
|
|
|
|
|
|
|
|
|
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.*; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* queue service impl |
|
|
|
* queue service impl |
|
|
@ -71,15 +74,13 @@ public class QueueServiceImpl extends BaseServiceImpl implements QueueService { |
|
|
|
public Map<String, Object> queryList(User loginUser) { |
|
|
|
public Map<String, Object> queryList(User loginUser) { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.QUEUE, loginUser.getId(), logger); |
|
|
|
Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.QUEUE, loginUser.getId(), logger); |
|
|
|
if (ids.isEmpty()) { |
|
|
|
if (loginUser.getUserType().equals(UserType.GENERAL_USER)) { |
|
|
|
result.put(Constants.DATA_LIST, Collections.emptyList()); |
|
|
|
ids = ids.isEmpty() ? new HashSet<>() : ids; |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
ids.add(Constants.DEFAULT_QUEUE_ID); |
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
List<Queue> queueList = queueMapper.selectBatchIds(ids); |
|
|
|
List<Queue> queueList = queueMapper.selectBatchIds(ids); |
|
|
|
result.put(Constants.DATA_LIST, queueList); |
|
|
|
result.put(Constants.DATA_LIST, queueList); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -103,7 +104,7 @@ public class QueueServiceImpl extends BaseServiceImpl implements QueueService { |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
Page<Queue> page = new Page<>(pageNo, pageSize); |
|
|
|
Page<Queue> page = new Page<>(pageNo, pageSize); |
|
|
|
IPage<Queue> queueList = queueMapper.queryQueuePaging(page, searchVal); |
|
|
|
IPage<Queue> queueList = queueMapper.queryQueuePaging(page, new ArrayList<>(ids), searchVal); |
|
|
|
Integer count = (int) queueList.getTotal(); |
|
|
|
Integer count = (int) queueList.getTotal(); |
|
|
|
pageInfo.setTotal(count); |
|
|
|
pageInfo.setTotal(count); |
|
|
|
pageInfo.setTotalList(queueList.getRecords()); |
|
|
|
pageInfo.setTotalList(queueList.getRecords()); |
|
|
@ -122,6 +123,7 @@ public class QueueServiceImpl extends BaseServiceImpl implements QueueService { |
|
|
|
* @return create result |
|
|
|
* @return create result |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Map<String, Object> createQueue(User loginUser, String queue, String queueName) { |
|
|
|
public Map<String, Object> createQueue(User loginUser, String queue, String queueName) { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
if (!canOperatorPermissions(loginUser,null, AuthorizationType.QUEUE,YARN_QUEUE_CREATE)) { |
|
|
|
if (!canOperatorPermissions(loginUser,null, AuthorizationType.QUEUE,YARN_QUEUE_CREATE)) { |
|
|
@ -160,7 +162,7 @@ public class QueueServiceImpl extends BaseServiceImpl implements QueueService { |
|
|
|
queueMapper.insert(queueObj); |
|
|
|
queueMapper.insert(queueObj); |
|
|
|
result.put(Constants.DATA_LIST, queueObj); |
|
|
|
result.put(Constants.DATA_LIST, queueObj); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
|
|
|
|
permissionPostHandle(AuthorizationType.QUEUE, loginUser.getId(), Collections.singletonList(queueObj.getId()), logger); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|