| @@ -349,6 +349,7 @@ public class SysUser extends BaseEntity { | |||||
| .append("dept", getDept()) | .append("dept", getDept()) | ||||
| .append("gitLinkUsername", getGitLinkUsername()) | .append("gitLinkUsername", getGitLinkUsername()) | ||||
| .append("gitLinkPassword", getGitLinkPassword()) | .append("gitLinkPassword", getGitLinkPassword()) | ||||
| .append("credit", getCredit()) | |||||
| .toString(); | .toString(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -19,6 +19,9 @@ public class ResourceOccupy { | |||||
| @ApiModelProperty("计算资源") | @ApiModelProperty("计算资源") | ||||
| private Integer computingResourceId; | private Integer computingResourceId; | ||||
| @ApiModelProperty("描述") | |||||
| private String description; | |||||
| @ApiModelProperty("积分/小时") | @ApiModelProperty("积分/小时") | ||||
| private Float creditPerHour; | private Float creditPerHour; | ||||
| @@ -36,4 +39,7 @@ public class ResourceOccupy { | |||||
| @ApiModelProperty("类型id") | @ApiModelProperty("类型id") | ||||
| private Long taskId; | private Long taskId; | ||||
| @ApiModelProperty("流水线节点id") | |||||
| private String nodeId; | |||||
| } | } | ||||
| @@ -14,9 +14,9 @@ public interface ResourceOccupyDao { | |||||
| int edit(@Param("resourceOccupy") ResourceOccupy resourceOccupy); | int edit(@Param("resourceOccupy") ResourceOccupy resourceOccupy); | ||||
| ResourceOccupy getResourceOccupyByTask(@Param("taskType") String taskType, @Param("taskId") Long taskId); | |||||
| List<ResourceOccupy> getResourceOccupyByTask(@Param("taskType") String taskType, @Param("taskId") Long taskId, @Param("nodeId") String nodeId); | |||||
| int deduceCredit(@Param("credit") Float credit, @Param("userId") Long userId); | |||||
| int deduceCredit(@Param("credit") Double credit, @Param("userId") Long userId); | |||||
| int updateUsed(@Param("id") Integer id, @Param("used") Integer used); | int updateUsed(@Param("id") Integer id, @Param("used") Integer used); | ||||
| @@ -1,11 +1,13 @@ | |||||
| package com.ruoyi.platform.scheduling; | package com.ruoyi.platform.scheduling; | ||||
| import com.ruoyi.platform.constant.Constant; | |||||
| import com.ruoyi.platform.domain.Experiment; | import com.ruoyi.platform.domain.Experiment; | ||||
| import com.ruoyi.platform.domain.ExperimentIns; | import com.ruoyi.platform.domain.ExperimentIns; | ||||
| import com.ruoyi.platform.mapper.ExperimentDao; | import com.ruoyi.platform.mapper.ExperimentDao; | ||||
| import com.ruoyi.platform.mapper.ExperimentInsDao; | import com.ruoyi.platform.mapper.ExperimentInsDao; | ||||
| import com.ruoyi.platform.service.AimService; | import com.ruoyi.platform.service.AimService; | ||||
| import com.ruoyi.platform.service.ExperimentInsService; | import com.ruoyi.platform.service.ExperimentInsService; | ||||
| import com.ruoyi.platform.service.ResourceOccupyService; | |||||
| import com.ruoyi.platform.utils.JacksonUtil; | import com.ruoyi.platform.utils.JacksonUtil; | ||||
| import com.ruoyi.platform.utils.JsonUtils; | import com.ruoyi.platform.utils.JsonUtils; | ||||
| import com.ruoyi.platform.vo.InsMetricInfoVo; | import com.ruoyi.platform.vo.InsMetricInfoVo; | ||||
| @@ -28,6 +30,8 @@ public class ExperimentInstanceStatusTask { | |||||
| private ExperimentInsDao experimentInsDao; | private ExperimentInsDao experimentInsDao; | ||||
| @Resource | @Resource | ||||
| private AimService aimService; | private AimService aimService; | ||||
| @Resource | |||||
| private ResourceOccupyService resourceOccupyService; | |||||
| private List<Integer> experimentIds = new ArrayList<>(); | private List<Integer> experimentIds = new ArrayList<>(); | ||||
| @@ -44,6 +48,19 @@ public class ExperimentInstanceStatusTask { | |||||
| experimentIns = experimentInsService.queryStatusFromArgo(experimentIns); | experimentIns = experimentInsService.queryStatusFromArgo(experimentIns); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| experimentIns.setStatus("Failed"); | experimentIns.setStatus("Failed"); | ||||
| resourceOccupyService.endDeduce(Constant.TaskType_Workflow, Long.valueOf(experimentIns.getId()), null); | |||||
| } | |||||
| // 扣除积分 | |||||
| Map<String, Object> nodesStatusMap = JsonUtils.jsonToMap(experimentIns.getNodesStatus()); | |||||
| for (String key : nodesStatusMap.keySet()) { | |||||
| Map<String, Object> value = (Map<String, Object>) nodesStatusMap.get(key); | |||||
| Date finishedAt = (Date) value.get("finishedAt"); | |||||
| if (finishedAt == null) { | |||||
| resourceOccupyService.deducing(Constant.TaskType_Workflow, Long.valueOf(experimentIns.getId()), key); | |||||
| } else { | |||||
| resourceOccupyService.endDeduce(Constant.TaskType_Workflow, Long.valueOf(experimentIns.getId()), key); | |||||
| } | |||||
| } | } | ||||
| //运行成功的实验实例记录指标数值 | //运行成功的实验实例记录指标数值 | ||||
| Map<String, Object> metricRecord = JacksonUtil.parseJSONStr2Map(experimentIns.getMetricRecord()); | Map<String, Object> metricRecord = JacksonUtil.parseJSONStr2Map(experimentIns.getMetricRecord()); | ||||
| @@ -43,12 +43,14 @@ public class RayInsStatusTask { | |||||
| try { | try { | ||||
| rayIns = rayInsService.queryStatusFromArgo(rayIns); | rayIns = rayInsService.queryStatusFromArgo(rayIns); | ||||
| if (Constant.Running.equals(rayIns.getStatus())) { | if (Constant.Running.equals(rayIns.getStatus())) { | ||||
| resourceOccupyService.deducing(Constant.TaskType_Ray, rayIns.getId()); | |||||
| } else { | |||||
| resourceOccupyService.endDeduce(Constant.TaskType_Ray, rayIns.getId()); | |||||
| resourceOccupyService.deducing(Constant.TaskType_Ray, rayIns.getId(), null); | |||||
| } else if (Constant.Failed.equals(rayIns.getStatus()) || Constant.Terminated.equals(rayIns.getStatus()) | |||||
| || Constant.Succeeded.equals(rayIns.getStatus())) { | |||||
| resourceOccupyService.endDeduce(Constant.TaskType_Ray, rayIns.getId(), null); | |||||
| } | } | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| rayIns.setStatus(Constant.Failed); | rayIns.setStatus(Constant.Failed); | ||||
| resourceOccupyService.endDeduce(Constant.TaskType_Ray, rayIns.getId(), null); | |||||
| } | } | ||||
| // 线程安全的添加操作 | // 线程安全的添加操作 | ||||
| synchronized (rayIds) { | synchronized (rayIds) { | ||||
| @@ -29,7 +29,7 @@ public class ResourceOccupyTask { | |||||
| public void devDeduceCredit() { | public void devDeduceCredit() { | ||||
| List<DevEnvironment> devEnvironments = devEnvironmentDao.getRunning(); | List<DevEnvironment> devEnvironments = devEnvironmentDao.getRunning(); | ||||
| for (DevEnvironment devEnvironment : devEnvironments) { | for (DevEnvironment devEnvironment : devEnvironments) { | ||||
| resourceOccupyService.deducing(Constant.TaskType_Dev, Long.valueOf(devEnvironment.getId())); | |||||
| resourceOccupyService.deducing(Constant.TaskType_Dev, Long.valueOf(devEnvironment.getId()), null); | |||||
| } | } | ||||
| } | } | ||||
| @@ -38,7 +38,7 @@ public class ResourceOccupyTask { | |||||
| public void serviceDeduceCredit() { | public void serviceDeduceCredit() { | ||||
| List<ServiceVersion> serviceVersions = serviceDao.getRunning(); | List<ServiceVersion> serviceVersions = serviceDao.getRunning(); | ||||
| for (ServiceVersion serviceVersion : serviceVersions) { | for (ServiceVersion serviceVersion : serviceVersions) { | ||||
| resourceOccupyService.deducing(Constant.TaskType_Service, serviceVersion.getId()); | |||||
| resourceOccupyService.deducing(Constant.TaskType_Service, serviceVersion.getId(), null); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -8,11 +8,11 @@ public interface ResourceOccupyService { | |||||
| Boolean haveResource(Integer computingResourceId) throws Exception; | Boolean haveResource(Integer computingResourceId) throws Exception; | ||||
| void startDeduce(Integer computingResourceId, String taskType, Long taskId); | |||||
| void startDeduce(Integer computingResourceId, String taskType, Long taskId, String nodeId); | |||||
| void endDeduce(String taskType, Long taskId); | |||||
| void endDeduce(String taskType, Long taskId, String nodeId); | |||||
| void deducing(String taskType, Long taskId); | |||||
| void deducing(String taskType, Long taskId, String nodeId); | |||||
| Page<ResourceOccupy> queryByPage(PageRequest pageRequest); | Page<ResourceOccupy> queryByPage(PageRequest pageRequest); | ||||
| } | } | ||||
| @@ -10,7 +10,6 @@ import com.ruoyi.platform.domain.*; | |||||
| import com.ruoyi.platform.domain.dependencydomain.ProjectDepency; | import com.ruoyi.platform.domain.dependencydomain.ProjectDepency; | ||||
| import com.ruoyi.platform.domain.dependencydomain.TrainTaskDepency; | import com.ruoyi.platform.domain.dependencydomain.TrainTaskDepency; | ||||
| import com.ruoyi.platform.mapper.ExperimentDao; | import com.ruoyi.platform.mapper.ExperimentDao; | ||||
| import com.ruoyi.platform.mapper.ExperimentInsDao; | |||||
| import com.ruoyi.platform.mapper.ModelDependency1Dao; | import com.ruoyi.platform.mapper.ModelDependency1Dao; | ||||
| import com.ruoyi.platform.service.*; | import com.ruoyi.platform.service.*; | ||||
| import com.ruoyi.platform.utils.HttpUtils; | import com.ruoyi.platform.utils.HttpUtils; | ||||
| @@ -62,6 +61,9 @@ public class ExperimentServiceImpl implements ExperimentService { | |||||
| @Lazy | @Lazy | ||||
| private ExperimentInsService experimentInsService; | private ExperimentInsService experimentInsService; | ||||
| @Resource | |||||
| private ResourceOccupyService resourceOccupyService; | |||||
| @Resource | @Resource | ||||
| private ModelDependency1Dao modelDependency1Dao; | private ModelDependency1Dao modelDependency1Dao; | ||||
| @@ -233,6 +235,14 @@ public class ExperimentServiceImpl implements ExperimentService { | |||||
| } | } | ||||
| Map<String, Object> converMap = JsonUtils.jsonToMap(convertRes); | Map<String, Object> converMap = JsonUtils.jsonToMap(convertRes); | ||||
| // 判断积分和资源是否足够 | |||||
| Map<String, Map<String, Object>> resourceInfo = (Map<String, Map<String, Object>>) converMap.get("resource_info"); | |||||
| for (Map.Entry<String, Map<String, Object>> entry : resourceInfo.entrySet()) { | |||||
| Map<String, Object> node = entry.getValue(); | |||||
| resourceOccupyService.haveResource((Integer) node.get("computing_resource_id")); | |||||
| } | |||||
| // 组装运行接口json | // 组装运行接口json | ||||
| Map<String, Object> runReqMap = new HashMap<>(); | Map<String, Object> runReqMap = new HashMap<>(); | ||||
| runReqMap.put("data", converMap.get("data")); | runReqMap.put("data", converMap.get("data")); | ||||
| @@ -300,6 +310,11 @@ public class ExperimentServiceImpl implements ExperimentService { | |||||
| insertDatasetTempStorage(datasetDependendcy, trainInfo, experiment.getId(), insert.getId(), experiment.getName(), experiment.getWorkflowId()); | insertDatasetTempStorage(datasetDependendcy, trainInfo, experiment.getId(), insert.getId(), experiment.getName(), experiment.getWorkflowId()); | ||||
| } | } | ||||
| // 记录开始扣积分 | |||||
| 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()); | |||||
| } | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new RuntimeException(e); | throw new RuntimeException(e); | ||||
| @@ -134,7 +134,7 @@ public class JupyterServiceImpl implements JupyterService { | |||||
| } | } | ||||
| // 结束扣积分 | // 结束扣积分 | ||||
| resourceOccupyService.endDeduce(Constant.TaskType_Dev, Long.valueOf(id)); | |||||
| resourceOccupyService.endDeduce(Constant.TaskType_Dev, Long.valueOf(id), null); | |||||
| // 使用 Kubernetes API 删除 Pod | // 使用 Kubernetes API 删除 Pod | ||||
| String deleteResult = k8sClientUtil.deletePod(podName, namespace); | String deleteResult = k8sClientUtil.deletePod(podName, namespace); | ||||
| @@ -168,7 +168,7 @@ public class RayInsServiceImpl implements RayInsService { | |||||
| rayInsDao.update(ins); | rayInsDao.update(ins); | ||||
| updateRayStatus(rayIns.getRayId()); | updateRayStatus(rayIns.getRayId()); | ||||
| // 结束扣积分 | // 结束扣积分 | ||||
| resourceOccupyService.endDeduce(Constant.TaskType_Ray, id); | |||||
| resourceOccupyService.endDeduce(Constant.TaskType_Ray, id, null); | |||||
| return true; | return true; | ||||
| } else { | } else { | ||||
| return false; | return false; | ||||
| @@ -205,7 +205,7 @@ public class RayServiceImpl implements RayService { | |||||
| rayIns.setResultPath(outputPath); | rayIns.setResultPath(outputPath); | ||||
| rayInsDao.insert(rayIns); | rayInsDao.insert(rayIns); | ||||
| rayInsService.updateRayStatus(id); | rayInsService.updateRayStatus(id); | ||||
| resourceOccupyService.startDeduce(ray.getComputingResourceId(), Constant.TaskType_Ray, rayIns.getId()); | |||||
| resourceOccupyService.startDeduce(ray.getComputingResourceId(), Constant.TaskType_Ray, rayIns.getId(), null); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new RuntimeException(e); | throw new RuntimeException(e); | ||||
| } | } | ||||
| @@ -15,6 +15,7 @@ import org.springframework.stereotype.Service; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | |||||
| @Service("resourceOccupyService") | @Service("resourceOccupyService") | ||||
| public class ResourceOccupyServiceImpl implements ResourceOccupyService { | public class ResourceOccupyServiceImpl implements ResourceOccupyService { | ||||
| @@ -48,15 +49,17 @@ public class ResourceOccupyServiceImpl implements ResourceOccupyService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void startDeduce(Integer computingResourceId, String taskType, Long taskId) { | |||||
| public void startDeduce(Integer computingResourceId, String taskType, Long taskId, String nodeId) { | |||||
| ResourceOccupy resourceOccupy = new ResourceOccupy(); | ResourceOccupy resourceOccupy = new ResourceOccupy(); | ||||
| ComputingResource computingResource = computingResourceDao.queryById(computingResourceId); | ComputingResource computingResource = computingResourceDao.queryById(computingResourceId); | ||||
| resourceOccupy.setComputingResourceId(computingResourceId); | resourceOccupy.setComputingResourceId(computingResourceId); | ||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| resourceOccupy.setUserId(loginUser.getUserid()); | resourceOccupy.setUserId(loginUser.getUserid()); | ||||
| resourceOccupy.setCreditPerHour(computingResource.getCreditPerHour()); | resourceOccupy.setCreditPerHour(computingResource.getCreditPerHour()); | ||||
| resourceOccupy.setDescription(computingResource.getDescription()); | |||||
| resourceOccupy.setTaskType(taskType); | resourceOccupy.setTaskType(taskType); | ||||
| resourceOccupy.setTaskId(taskId); | resourceOccupy.setTaskId(taskId); | ||||
| resourceOccupy.setNodeId(nodeId); | |||||
| resourceOccupyDao.save(resourceOccupy); | resourceOccupyDao.save(resourceOccupy); | ||||
| if (Constant.Computing_Resource_GPU.equals(computingResource.getComputingResource())) { | if (Constant.Computing_Resource_GPU.equals(computingResource.getComputingResource())) { | ||||
| @@ -67,31 +70,35 @@ public class ResourceOccupyServiceImpl implements ResourceOccupyService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void endDeduce(String taskType, Long taskId) { | |||||
| ResourceOccupy resourceOccupy = resourceOccupyDao.getResourceOccupyByTask(taskType, taskId); | |||||
| deducing(taskType, taskId); | |||||
| resourceOccupy.setState(Constant.State_invalid); | |||||
| resourceOccupyDao.edit(resourceOccupy); | |||||
| public void endDeduce(String taskType, Long taskId, String nodeId) { | |||||
| List<ResourceOccupy> resourceOccupys = resourceOccupyDao.getResourceOccupyByTask(taskType, taskId, nodeId); | |||||
| for (ResourceOccupy resourceOccupy : resourceOccupys) { | |||||
| deducing(taskType, taskId, nodeId); | |||||
| resourceOccupy.setState(Constant.State_invalid); | |||||
| resourceOccupyDao.edit(resourceOccupy); | |||||
| ComputingResource computingResource = computingResourceDao.queryById(resourceOccupy.getComputingResourceId()); | |||||
| if (Constant.Computing_Resource_GPU.equals(computingResource.getComputingResource())) { | |||||
| resourceOccupyDao.updateUnUsed(computingResource.getResourceId(), computingResource.getGpuNums()); | |||||
| } else { | |||||
| resourceOccupyDao.updateUnUsed(computingResource.getResourceId(), computingResource.getCpuCores()); | |||||
| ComputingResource computingResource = computingResourceDao.queryById(resourceOccupy.getComputingResourceId()); | |||||
| if (Constant.Computing_Resource_GPU.equals(computingResource.getComputingResource())) { | |||||
| resourceOccupyDao.updateUnUsed(computingResource.getResourceId(), computingResource.getGpuNums()); | |||||
| } else { | |||||
| resourceOccupyDao.updateUnUsed(computingResource.getResourceId(), computingResource.getCpuCores()); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void deducing(String taskType, Long taskId) { | |||||
| ResourceOccupy resourceOccupy = resourceOccupyDao.getResourceOccupyByTask(taskType, taskId); | |||||
| long timeDifferenceMillis = new Date().getTime() - resourceOccupy.getDeduceLastTime().getTime(); | |||||
| Float hours = (float) (timeDifferenceMillis / (1000 * 60 * 60)); | |||||
| public void deducing(String taskType, Long taskId, String nodeId) { | |||||
| List<ResourceOccupy> resourceOccupys = resourceOccupyDao.getResourceOccupyByTask(taskType, taskId, nodeId); | |||||
| for (ResourceOccupy resourceOccupy : resourceOccupys) { | |||||
| long timeDifferenceMillis = new Date().getTime() - resourceOccupy.getDeduceLastTime().getTime(); | |||||
| Double hours = (double) timeDifferenceMillis / (1000 * 60 * 60); | |||||
| float deduceCredit = resourceOccupy.getCreditPerHour() * hours; | |||||
| resourceOccupyDao.deduceCredit(deduceCredit, resourceOccupy.getUserId()); | |||||
| Double deduceCredit = resourceOccupy.getCreditPerHour() * hours; | |||||
| resourceOccupyDao.deduceCredit(deduceCredit, resourceOccupy.getUserId()); | |||||
| resourceOccupy.setDeduceLastTime(new Date()); | |||||
| resourceOccupyDao.edit(resourceOccupy); | |||||
| resourceOccupy.setDeduceLastTime(new Date()); | |||||
| resourceOccupyDao.edit(resourceOccupy); | |||||
| } | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -258,7 +258,7 @@ public class ServiceServiceImpl implements ServiceService { | |||||
| if (StringUtils.isNotEmpty(req)) { | if (StringUtils.isNotEmpty(req)) { | ||||
| Map<String, Object> reqMap = JacksonUtil.parseJSONStr2Map(req); | Map<String, Object> reqMap = JacksonUtil.parseJSONStr2Map(req); | ||||
| if ((Integer) reqMap.get("code") == 200) { | if ((Integer) reqMap.get("code") == 200) { | ||||
| resourceOccupyService.startDeduce(serviceVersion.getComputingResourceId(), Constant.TaskType_Service, serviceVersion.getId()); | |||||
| resourceOccupyService.startDeduce(serviceVersion.getComputingResourceId(), Constant.TaskType_Service, serviceVersion.getId(), null); | |||||
| Map<String, String> data = (Map<String, String>) reqMap.get("data"); | Map<String, String> data = (Map<String, String>) reqMap.get("data"); | ||||
| serviceVersion.setUrl(data.get("url")); | serviceVersion.setUrl(data.get("url")); | ||||
| serviceVersion.setDeploymentName(data.get("deployment_name")); | serviceVersion.setDeploymentName(data.get("deployment_name")); | ||||
| @@ -286,7 +286,7 @@ public class ServiceServiceImpl implements ServiceService { | |||||
| serviceVersion.setRunState(Constant.Stopped); | serviceVersion.setRunState(Constant.Stopped); | ||||
| serviceDao.updateServiceVersion(serviceVersion); | serviceDao.updateServiceVersion(serviceVersion); | ||||
| // 结束扣积分 | // 结束扣积分 | ||||
| resourceOccupyService.endDeduce(Constant.TaskType_Service, id); | |||||
| resourceOccupyService.endDeduce(Constant.TaskType_Service, id, null); | |||||
| return "停止成功"; | return "停止成功"; | ||||
| } else { | } else { | ||||
| throw new RuntimeException("停止失败"); | throw new RuntimeException("停止失败"); | ||||
| @@ -1,6 +1,5 @@ | |||||
| package com.ruoyi.platform.utils; | package com.ruoyi.platform.utils; | ||||
| import com.alibaba.fastjson2.JSON; | |||||
| import com.ruoyi.platform.constant.Constant; | import com.ruoyi.platform.constant.Constant; | ||||
| import com.ruoyi.platform.domain.ComputingResource; | import com.ruoyi.platform.domain.ComputingResource; | ||||
| import com.ruoyi.platform.domain.DevEnvironment; | import com.ruoyi.platform.domain.DevEnvironment; | ||||
| @@ -11,7 +10,6 @@ import io.kubernetes.client.custom.IntOrString; | |||||
| import io.kubernetes.client.custom.Quantity; | import io.kubernetes.client.custom.Quantity; | ||||
| import io.kubernetes.client.openapi.ApiClient; | import io.kubernetes.client.openapi.ApiClient; | ||||
| import io.kubernetes.client.openapi.ApiException; | import io.kubernetes.client.openapi.ApiException; | ||||
| import io.kubernetes.client.openapi.apis.AppsV1Api; | |||||
| import io.kubernetes.client.openapi.apis.CoreV1Api; | import io.kubernetes.client.openapi.apis.CoreV1Api; | ||||
| import io.kubernetes.client.openapi.models.*; | import io.kubernetes.client.openapi.models.*; | ||||
| import io.kubernetes.client.util.ClientBuilder; | import io.kubernetes.client.util.ClientBuilder; | ||||
| @@ -19,7 +17,6 @@ import io.kubernetes.client.util.Config; | |||||
| import io.kubernetes.client.util.credentials.AccessTokenAuthentication; | import io.kubernetes.client.util.credentials.AccessTokenAuthentication; | ||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.commons.lang.StringUtils; | import org.apache.commons.lang.StringUtils; | ||||
| import org.json.JSONObject; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
| import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
| @@ -519,7 +516,7 @@ public class K8sClientUtil { | |||||
| pod = api.createNamespacedPod(namespace, pod, null, null, null); | pod = api.createNamespacedPod(namespace, pod, null, null, null); | ||||
| String nodeName = getNodeName(podName, namespace); | String nodeName = getNodeName(podName, namespace); | ||||
| resourceOccupyService.startDeduce(devEnvironment.getComputingResourceId(), Constant.TaskType_Dev, Long.valueOf(devEnvironment.getId())); | |||||
| resourceOccupyService.startDeduce(devEnvironment.getComputingResourceId(), Constant.TaskType_Dev, Long.valueOf(devEnvironment.getId()), null); | |||||
| } | } | ||||
| } catch (ApiException e) { | } catch (ApiException e) { | ||||
| throw new RuntimeException("创建pod异常:" + e.getResponseBody()); | throw new RuntimeException("创建pod异常:" + e.getResponseBody()); | ||||
| @@ -2,8 +2,11 @@ | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||
| <mapper namespace="com.ruoyi.platform.mapper.ResourceOccupyDao"> | <mapper namespace="com.ruoyi.platform.mapper.ResourceOccupyDao"> | ||||
| <insert id="save"> | <insert id="save"> | ||||
| insert into resource_occupy (user_id, computing_resource_id, credit_per_hour) | |||||
| values (#{resourceOccupy.userId}, #{resourceOccupy.computingResourceId}, #{resourceOccupy.creditPerHour}) | |||||
| insert into resource_occupy (user_id, computing_resource_id, credit_per_hour, description, task_type, task_id, | |||||
| node_id) | |||||
| values (#{resourceOccupy.userId}, #{resourceOccupy.computingResourceId}, #{resourceOccupy.creditPerHour}, | |||||
| #{resourceOccupy.description}, #{resourceOccupy.taskType}, #{resourceOccupy.taskId}, | |||||
| #{resourceOccupy.nodeId}) | |||||
| </insert> | </insert> | ||||
| <update id="edit"> | <update id="edit"> | ||||
| @@ -46,8 +49,12 @@ | |||||
| <select id="getResourceOccupyByTask" resultType="com.ruoyi.platform.domain.ResourceOccupy"> | <select id="getResourceOccupyByTask" resultType="com.ruoyi.platform.domain.ResourceOccupy"> | ||||
| select * | select * | ||||
| from resource_occupy | from resource_occupy | ||||
| where task_type = #{task_type} | |||||
| and task_id = #{task_id} | |||||
| where task_type = #{taskType} | |||||
| and task_id = #{taskId} | |||||
| <if test="nodeId != null and nodeId !=''"> | |||||
| node_id = #{nodeId}, | |||||
| </if> | |||||
| and state = 1 | |||||
| </select> | </select> | ||||
| <select id="count" resultType="java.lang.Long"> | <select id="count" resultType="java.lang.Long"> | ||||