mirror of https://github.com/longtai-cn/hippo4j
parent
4f3d59b187
commit
a096dd89d9
@ -0,0 +1,43 @@
|
||||
package io.dynamic.threadpool.server.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.dynamic.threadpool.common.constant.Constants;
|
||||
import io.dynamic.threadpool.common.web.base.Result;
|
||||
import io.dynamic.threadpool.common.web.base.Results;
|
||||
import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolQueryReqDTO;
|
||||
import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolRespDTO;
|
||||
import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolSaveOrUpdateReqDTO;
|
||||
import io.dynamic.threadpool.server.service.biz.ThreadPoolService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* Thread Pool Controller.
|
||||
*
|
||||
* @author chen.ma
|
||||
* @date 2021/6/30 20:54
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(Constants.BASE_PATH)
|
||||
public class ThreadPoolController {
|
||||
|
||||
@Autowired
|
||||
private ThreadPoolService threadPoolService;
|
||||
|
||||
@PostMapping("/thread/pool/query/page")
|
||||
public Result<IPage<ThreadPoolRespDTO>> queryNameSpacePage(@RequestBody ThreadPoolQueryReqDTO reqDTO) {
|
||||
return Results.success(threadPoolService.queryThreadPoolPage(reqDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/thread/pool/query}")
|
||||
public Result<ThreadPoolRespDTO> queryNameSpace(@RequestBody ThreadPoolQueryReqDTO reqDTO) {
|
||||
return Results.success(threadPoolService.getThreadPool(reqDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/thread/pool/save_or_update")
|
||||
public Result saveOrUpdateThreadPoolConfig(@RequestBody ThreadPoolSaveOrUpdateReqDTO reqDTO) {
|
||||
threadPoolService.saveOrUpdateThreadPoolConfig(reqDTO);
|
||||
return Results.success();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package io.dynamic.threadpool.server.model.biz.threadpool;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Thread Pool Query Req DTO.
|
||||
*
|
||||
* @author chen.ma
|
||||
* @date 2021/6/30 21:22
|
||||
*/
|
||||
@Data
|
||||
public class ThreadPoolQueryReqDTO extends Page {
|
||||
|
||||
private String tenantId;
|
||||
|
||||
private String itemId;
|
||||
|
||||
private String tpId;
|
||||
|
||||
private String tpName;
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package io.dynamic.threadpool.server.model.biz.threadpool;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Thread Pool Resp DTO.
|
||||
*
|
||||
* @author chen.ma
|
||||
* @date 2021/6/30 21:23
|
||||
*/
|
||||
@Data
|
||||
public class ThreadPoolRespDTO {
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package io.dynamic.threadpool.server.model.biz.threadpool;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Thread Pool Save Or Update Req DTO.
|
||||
*
|
||||
* @author chen.ma
|
||||
* @date 2021/6/30 21:23
|
||||
*/
|
||||
@Data
|
||||
public class ThreadPoolSaveOrUpdateReqDTO {
|
||||
|
||||
/**
|
||||
* namespace
|
||||
*/
|
||||
private String namespace;
|
||||
|
||||
/**
|
||||
* TpId
|
||||
*/
|
||||
private String tpId;
|
||||
|
||||
/**
|
||||
* ItemId
|
||||
*/
|
||||
private String itemId;
|
||||
|
||||
/**
|
||||
* 核心线程数
|
||||
*/
|
||||
private Integer coreSize;
|
||||
|
||||
/**
|
||||
* 最大线程数
|
||||
*/
|
||||
private Integer maxSize;
|
||||
|
||||
/**
|
||||
* 队列类型
|
||||
*/
|
||||
private Integer queueType;
|
||||
|
||||
/**
|
||||
* 队列长度
|
||||
*/
|
||||
private Integer capacity;
|
||||
|
||||
/**
|
||||
* 线程存活时长
|
||||
*/
|
||||
private Integer keepAliveTime;
|
||||
|
||||
/**
|
||||
* 是否告警
|
||||
*/
|
||||
private Integer isAlarm;
|
||||
|
||||
/**
|
||||
* 容量告警
|
||||
*/
|
||||
private Integer capacityAlarm;
|
||||
|
||||
/**
|
||||
* 活跃度告警
|
||||
*/
|
||||
private Integer livenessAlarm;
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package io.dynamic.threadpool.server.service;
|
||||
package io.dynamic.threadpool.server.service.biz;
|
||||
|
||||
import io.dynamic.threadpool.server.model.ConfigAllInfo;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package io.dynamic.threadpool.server.service;
|
||||
package io.dynamic.threadpool.server.service.biz;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.dynamic.threadpool.server.model.biz.item.ItemQueryReqDTO;
|
@ -1,4 +1,4 @@
|
||||
package io.dynamic.threadpool.server.service;
|
||||
package io.dynamic.threadpool.server.service.biz;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.dynamic.threadpool.server.model.biz.tenant.TenantQueryReqDTO;
|
@ -0,0 +1,39 @@
|
||||
package io.dynamic.threadpool.server.service.biz;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolQueryReqDTO;
|
||||
import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolRespDTO;
|
||||
import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolSaveOrUpdateReqDTO;
|
||||
|
||||
/**
|
||||
* Thread Pool Service.
|
||||
*
|
||||
* @author chen.ma
|
||||
* @date 2021/6/30 21:26
|
||||
*/
|
||||
public interface ThreadPoolService {
|
||||
|
||||
/**
|
||||
* 分页查询线程池
|
||||
*
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
IPage<ThreadPoolRespDTO> queryThreadPoolPage(ThreadPoolQueryReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* 查询线程池配置
|
||||
*
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
ThreadPoolRespDTO getThreadPool(ThreadPoolQueryReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* 新增或修改线程池配置
|
||||
*
|
||||
* @param reqDTO
|
||||
*/
|
||||
void saveOrUpdateThreadPoolConfig(ThreadPoolSaveOrUpdateReqDTO reqDTO);
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package io.dynamic.threadpool.server.service.biz.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import io.dynamic.threadpool.server.mapper.ConfigInfoMapper;
|
||||
import io.dynamic.threadpool.server.model.ConfigAllInfo;
|
||||
import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolQueryReqDTO;
|
||||
import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolRespDTO;
|
||||
import io.dynamic.threadpool.server.model.biz.threadpool.ThreadPoolSaveOrUpdateReqDTO;
|
||||
import io.dynamic.threadpool.server.service.biz.ConfigService;
|
||||
import io.dynamic.threadpool.server.service.biz.ThreadPoolService;
|
||||
import io.dynamic.threadpool.server.toolkit.BeanUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* Thread Pool Service Impl.
|
||||
*
|
||||
* @author chen.ma
|
||||
* @date 2021/6/30 21:26
|
||||
*/
|
||||
@Service
|
||||
public class ThreadPoolServiceImpl implements ThreadPoolService {
|
||||
|
||||
@Autowired
|
||||
private ConfigService configService;
|
||||
|
||||
@Resource
|
||||
private ConfigInfoMapper configInfoMapper;
|
||||
|
||||
@Override
|
||||
public IPage<ThreadPoolRespDTO> queryThreadPoolPage(ThreadPoolQueryReqDTO reqDTO) {
|
||||
LambdaQueryWrapper<ConfigAllInfo> wrapper = Wrappers.lambdaQuery(ConfigAllInfo.class)
|
||||
.eq(!StringUtils.isBlank(reqDTO.getTenantId()), ConfigAllInfo::getNamespace, reqDTO.getTenantId())
|
||||
.eq(!StringUtils.isBlank(reqDTO.getItemId()), ConfigAllInfo::getItemId, reqDTO.getItemId())
|
||||
.eq(!StringUtils.isBlank(reqDTO.getTpId()), ConfigAllInfo::getTpId, reqDTO.getTpId());
|
||||
return configInfoMapper.selectPage(reqDTO, wrapper).convert(each -> BeanUtil.convert(each, ThreadPoolRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThreadPoolRespDTO getThreadPool(ThreadPoolQueryReqDTO reqDTO) {
|
||||
ConfigAllInfo configAllInfo = configService.findConfigAllInfo(reqDTO.getTpId(), reqDTO.getItemId(), reqDTO.getTenantId());
|
||||
return BeanUtil.convert(configAllInfo, ThreadPoolRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveOrUpdateThreadPoolConfig(ThreadPoolSaveOrUpdateReqDTO reqDTO) {
|
||||
configService.insertOrUpdate(BeanUtil.convert(reqDTO, ConfigAllInfo.class));
|
||||
}
|
||||
}
|
Loading…
Reference in new issue