Browse Source

Merge branch 'dev' of https://gitlink.org.cn/ci4s/ci4sManagement-cloud into dev

dev-active_learn
somunslotus 10 months ago
parent
commit
76df8b16f7
9 changed files with 18 additions and 8 deletions
  1. +7
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ResourceOccupy.java
  2. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ResourceOccupyTask.java
  3. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ResourceOccupyService.java
  4. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java
  5. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java
  6. +3
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ResourceOccupyServiceImpl.java
  7. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ServiceServiceImpl.java
  8. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java
  9. +2
    -0
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ResourceOccupy.xml

+ 7
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ResourceOccupy.java View File

@@ -40,9 +40,15 @@ public class ResourceOccupy {
@ApiModelProperty("任务类型")
private String taskType;

@ApiModelProperty("类型id")
@ApiModelProperty("任务id")
private Long taskId;

@ApiModelProperty("任务id")
private Long taskInsId;

@ApiModelProperty("流水线id")
private Long workflowId;

@ApiModelProperty("流水线节点id")
private String nodeId;
}

+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ResourceOccupyTask.java View File

@@ -34,7 +34,7 @@ public class ResourceOccupyTask {
}

// 服务功能扣除积分
@Scheduled(cron = "0 0/10 * * * ?") // 每10分钟执行一次
@Scheduled(cron = "0 0/1 * * * ?") // 每10分钟执行一次
public void serviceDeduceCredit() {
List<ServiceVersion> serviceVersions = serviceDao.getRunning();
for (ServiceVersion serviceVersion : serviceVersions) {


+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ResourceOccupyService.java View File

@@ -11,7 +11,7 @@ public interface ResourceOccupyService {

Boolean haveResource(Integer computingResourceId) throws Exception;

void startDeduce(Integer computingResourceId, String taskType, Long taskId, String nodeId);
void startDeduce(Integer computingResourceId, String taskType, Long taskId, Long taskInsId, Long workflowId, String nodeId);

void endDeduce(String taskType, Long taskId, String nodeId, Date nodeStartTime);



+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java View File

@@ -313,7 +313,7 @@ public class ExperimentServiceImpl implements ExperimentService {
// 记录开始扣积分
for (Map.Entry<String, Map<String, Object>> entry : resourceInfo.entrySet()) {
Map<String, Object> node = entry.getValue();
resourceOccupyService.startDeduce((Integer) node.get("computing_resource_id"), Constant.TaskType_Workflow, Long.valueOf(insert.getId()), entry.getKey());
resourceOccupyService.startDeduce((Integer) node.get("computing_resource_id"), Constant.TaskType_Workflow, Long.valueOf(id), Long.valueOf(insert.getId()), experiment.getWorkflowId(), entry.getKey());
}

} catch (Exception e) {


+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java View File

@@ -206,7 +206,7 @@ public class RayServiceImpl implements RayService {
rayInsDao.insert(rayIns);
rayInsService.updateRayStatus(id);
// 记录开始扣除积分
resourceOccupyService.startDeduce(ray.getComputingResourceId(), Constant.TaskType_Ray, rayIns.getId(), null);
resourceOccupyService.startDeduce(ray.getComputingResourceId(), Constant.TaskType_Ray, id, rayIns.getId(), null, null);
} catch (Exception e) {
throw new RuntimeException(e);
}


+ 3
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ResourceOccupyServiceImpl.java View File

@@ -53,7 +53,7 @@ public class ResourceOccupyServiceImpl implements ResourceOccupyService {

@Override
@Transactional
public void startDeduce(Integer computingResourceId, String taskType, Long taskId, String nodeId) {
public void startDeduce(Integer computingResourceId, String taskType, Long taskId, Long taskInsId, Long workflowId, String nodeId) {
ResourceOccupy resourceOccupy = new ResourceOccupy();
ComputingResource computingResource = computingResourceDao.queryById(computingResourceId);
resourceOccupy.setComputingResourceId(computingResourceId);
@@ -63,6 +63,8 @@ public class ResourceOccupyServiceImpl implements ResourceOccupyService {
resourceOccupy.setDescription(computingResource.getDescription());
resourceOccupy.setTaskType(taskType);
resourceOccupy.setTaskId(taskId);
resourceOccupy.setTaskInsId(taskInsId);
resourceOccupy.setWorkflowId(workflowId);
resourceOccupy.setNodeId(nodeId);
resourceOccupyDao.save(resourceOccupy);



+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ServiceServiceImpl.java View File

@@ -274,7 +274,7 @@ public class ServiceServiceImpl implements ServiceService {
serviceDao.updateServiceVersion(serviceVersion);

// 记录开始扣积分
resourceOccupyService.startDeduce(serviceVersion.getComputingResourceId(), Constant.TaskType_Service, serviceVersion.getId(), null);
resourceOccupyService.startDeduce(serviceVersion.getComputingResourceId(), Constant.TaskType_Service, serviceVersion.getServiceId(), serviceVersion.getId(), null, null);
return "启动成功";
} else {
throw new RuntimeException("启动失败");


+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java View File

@@ -517,7 +517,7 @@ public class K8sClientUtil {
String nodeName = getNodeName(podName, namespace);

// 记录开始扣除积分
resourceOccupyService.startDeduce(devEnvironment.getComputingResourceId(), Constant.TaskType_Dev, Long.valueOf(devEnvironment.getId()), null);
resourceOccupyService.startDeduce(devEnvironment.getComputingResourceId(), Constant.TaskType_Dev, Long.valueOf(devEnvironment.getId()), null, null, null);
}
} catch (ApiException e) {
throw new RuntimeException("创建pod异常:" + e.getResponseBody());


+ 2
- 0
ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ResourceOccupy.xml View File

@@ -3,9 +3,11 @@
<mapper namespace="com.ruoyi.platform.mapper.ResourceOccupyDao">
<insert id="save">
insert into resource_occupy (user_id, computing_resource_id, credit_per_hour, description, task_type, task_id,
task_ins_id, workflow_id,
node_id)
values (#{resourceOccupy.userId}, #{resourceOccupy.computingResourceId}, #{resourceOccupy.creditPerHour},
#{resourceOccupy.description}, #{resourceOccupy.taskType}, #{resourceOccupy.taskId},
#{resourceOccupy.taskInsId}, #{resourceOccupy.workflowId},
#{resourceOccupy.nodeId})
</insert>



Loading…
Cancel
Save