use of com.dtstack.taier.dao.domain.Queue in project Taier by DTStack.
the class ClusterService method pluginInfoJSON.
/**
* 内部使用
*/
public JSONObject pluginInfoJSON(Long tenantId, Integer taskType, Integer deployMode, String componentVersion) {
EScheduleJobType engineJobType = EScheduleJobType.getByTaskType(taskType);
EComponentType componentType = engineJobType.getComponentType();
if (componentType == null) {
return null;
}
Long clusterId = clusterTenantMapper.getClusterIdByTenantId(tenantId);
if (null == clusterId) {
clusterId = DEFAULT_CLUSTER_ID;
}
JSONObject clusterConfigJson = buildClusterConfig(clusterId, componentVersion, componentType);
JSONObject pluginJson = convertPluginInfo(clusterConfigJson, componentType, clusterId, deployMode);
if (pluginJson == null) {
throw new RdosDefineException(format("The cluster is not configured [%s] engine", componentType));
}
Queue queue = getQueue(tenantId, clusterId);
pluginJson.put(QUEUE, queue == null ? "" : queue.getQueueName());
setComponentSftpDir(clusterId, clusterConfigJson, pluginJson, componentType);
return pluginJson;
}
use of com.dtstack.taier.dao.domain.Queue in project Taier by DTStack.
the class ClusterService method getQueue.
public Queue getQueue(Long tenantId, Long clusterId) {
// 先获取绑定的
Long queueId = clusterTenantMapper.getQueueIdByTenantId(tenantId);
Queue queue = consoleQueueMapper.selectById(queueId);
if (queue != null) {
return queue;
}
List<Queue> queues = consoleQueueMapper.listByClusterWithLeaf(clusterId);
if (CollectionUtils.isEmpty(queues)) {
return null;
}
// 没有绑定集群和队列时,返回第一个队列
return queues.get(0);
}
use of com.dtstack.taier.dao.domain.Queue in project Taier by DTStack.
the class QueueService method updateAddQueue.
private void updateAddQueue(Map<String, Queue> existQueueMap, Long clusterId, Long parentQueueId, List<ComponentTestResult.QueueDescription> descriptions) {
// 不会有空队列的
if (CollectionUtils.isNotEmpty(descriptions)) {
for (ComponentTestResult.QueueDescription queueDescription : descriptions) {
Queue queue = new Queue();
queue.setQueueName(queueDescription.getQueueName());
queue.setClusterId(clusterId);
queue.setMaxCapacity(queueDescription.getMaximumCapacity());
queue.setCapacity(queueDescription.getCapacity());
queue.setQueueState(queueDescription.getQueueState());
queue.setQueuePath(queueDescription.getQueuePath());
Queue oldQueue = existQueueMap.get(queueDescription.getQueuePath());
if (oldQueue != null) {
if (oldQueue.baseEquals(queue)) {
existQueueMap.remove(queueDescription.getQueuePath());
} else if (queue.getQueueName().equals(oldQueue.getQueueName())) {
oldQueue.setQueueState(queue.getQueueState());
oldQueue.setCapacity(queue.getCapacity());
oldQueue.setMaxCapacity(queue.getMaxCapacity());
consoleQueueMapper.updateById(oldQueue);
existQueueMap.remove(queueDescription.getQueuePath());
}
queue.setId(oldQueue.getId());
} else {
queue.setParentQueueId(parentQueueId);
Integer insert = consoleQueueMapper.insert(queue);
if (insert != 1) {
throw new RdosDefineException("operation failed");
}
}
// todo 递归调用,当没有子队列后就停止递归
updateAddQueue(existQueueMap, clusterId, queue.getId(), queueDescription.getChildQueues());
}
}
}
use of com.dtstack.taier.dao.domain.Queue in project Taier by DTStack.
the class QueueService method newAddQueue.
private void newAddQueue(Long clusterId, Long parentQueueId, List<ComponentTestResult.QueueDescription> descriptions) {
if (CollectionUtils.isNotEmpty(descriptions)) {
for (ComponentTestResult.QueueDescription queueDescription : descriptions) {
Queue queue = new Queue();
queue.setQueueName(queueDescription.getQueueName());
queue.setClusterId(clusterId);
queue.setMaxCapacity(queueDescription.getMaximumCapacity());
queue.setCapacity(queueDescription.getCapacity());
queue.setQueueState(queueDescription.getQueueState());
queue.setParentQueueId(parentQueueId);
queue.setQueuePath(queueDescription.getQueuePath());
Integer insert = consoleQueueMapper.insert(queue);
if (insert != 1) {
throw new RdosDefineException("operation failed");
}
newAddQueue(clusterId, queue.getId(), queueDescription.getChildQueues());
}
}
}
use of com.dtstack.taier.dao.domain.Queue in project Taier by DTStack.
the class QueueService method updateQueue.
public void updateQueue(Long clusterId, ComponentTestResult.ClusterResourceDescription description) {
List<Queue> queues = consoleQueueMapper.listByClusterId(clusterId);
if (CollectionUtils.isEmpty(queues)) {
newAddQueue(clusterId, ROOT_QUEUE_ID, description.getQueueDescriptions());
} else {
Map<String, Queue> existQueueMap = new HashMap<>(queues.size());
for (Queue queue : queues) {
existQueueMap.put(queue.getQueuePath(), queue);
}
updateAddQueue(existQueueMap, clusterId, ROOT_QUEUE_ID, description.getQueueDescriptions());
if (!existQueueMap.isEmpty()) {
Integer delete = consoleQueueMapper.deleteByIds(existQueueMap.values().stream().map(BaseEntity::getId).collect(Collectors.toList()), clusterId);
if (delete != existQueueMap.size()) {
throw new RdosDefineException("operation failed");
}
}
}
}
Aggregations