mirror of https://github.com/longtai-cn/hippo4j
finish thread pool config change verify (#776)
* init code for verify module * init code for verify module * create application for config modify in thread pool manage * finish rejectModification * finish rejectModification * add todo * finish threadPoolManage accept * finish threadPoolManage accept * finish threadPoolManage config verify * formatting code * optimize ConfigModifyVerifyService * finish config modification verify * finish config modification verify * finish webConfig modification verify * finish webConfig modification verify * finish webConfig modification verify * finish threadPoolInstanceConfig modification verify * finish adapterThreadPoolConfig modification verify * finish adapterThreadPoolConfig modification verify * finish adapterThreadPoolConfig modification verify * optmize ConfigVerifyController * optmize ConfigVerifyController * optmize ConfigVerifyController * fix ConfigModifyVerifyReqDTO * fix bug * optimize verifyController * optimize verifyController * fix request param * finish modify application query page * finish modify application query page * finish modify application query detail * finish modify application query detail * finish thread pool config modification verify module * optimize accept modification logic * formatting code * fix bug * formatting code * formatting code * update sql file * add annotation * add annotation and formatting code * add annotation and formatting code * remove useless code * fix sql Co-authored-by: airoger <czzx201101136>pull/778/head
parent
fbfdecaef1
commit
656d508b35
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.common.constant;
|
||||
|
||||
public class ConfigModifyTypeConstants {
|
||||
|
||||
/**
|
||||
* Thread pool manager change
|
||||
*/
|
||||
public static final int THREAD_POOL_MANAGER = 1;
|
||||
|
||||
/**
|
||||
* Thread pool instance change
|
||||
*/
|
||||
public static final int THREAD_POOL_INSTANCE = 2;
|
||||
|
||||
/**
|
||||
* Web thread pool change
|
||||
*/
|
||||
public static final int WEB_THREAD_POOL = 3;
|
||||
|
||||
/**
|
||||
* Adapter thread pool change
|
||||
*/
|
||||
public static final int ADAPTER_THREAD_POOL = 4;
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.common.enums;
|
||||
|
||||
public enum VerifyEnum {
|
||||
|
||||
/**
|
||||
* unVerify
|
||||
*/
|
||||
TO_VERIFY(0, "待审核"),
|
||||
|
||||
/**
|
||||
* accept
|
||||
*/
|
||||
VERIFY_ACCEPT(1, "审核通过"),
|
||||
|
||||
/**
|
||||
* reject
|
||||
*/
|
||||
VERIFY_REJECT(2, "审核拒绝"),
|
||||
|
||||
/**
|
||||
* invalid
|
||||
*/
|
||||
VERIFY_INVALID(3, "失效");
|
||||
|
||||
private final Integer verifyStatus;
|
||||
|
||||
private final String desc;
|
||||
|
||||
VerifyEnum(Integer verifyStatus, String desc) {
|
||||
this.verifyStatus = verifyStatus;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return this.desc;
|
||||
}
|
||||
|
||||
public Integer getVerifyStatus() {
|
||||
return this.verifyStatus;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.config.mapper;
|
||||
|
||||
import cn.hippo4j.config.model.HisConfigVerifyInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* his config verify info mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface HisConfigVerifyMapper extends BaseMapper<HisConfigVerifyInfo> {
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.config.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* His config verify info
|
||||
*/
|
||||
@Data
|
||||
@TableName("his_config_verify")
|
||||
public class HisConfigVerifyInfo {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* Change type
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* Tenant id
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* Item id
|
||||
*/
|
||||
private String itemId;
|
||||
|
||||
/**
|
||||
* Thread pool id
|
||||
*/
|
||||
private String tpId;
|
||||
|
||||
/**
|
||||
* Thread pool mark
|
||||
*/
|
||||
private String mark;
|
||||
|
||||
/**
|
||||
* Thread pool instance identify
|
||||
*/
|
||||
private String identify;
|
||||
|
||||
/**
|
||||
* Config content
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* Weather modify all thread pool instances
|
||||
*/
|
||||
private Boolean modifyAll = false;
|
||||
|
||||
/**
|
||||
* GmtCreate
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date gmtCreate;
|
||||
|
||||
/**
|
||||
* ModifyUserId
|
||||
*/
|
||||
private String modifyUser;
|
||||
|
||||
/**
|
||||
* Verify status
|
||||
*/
|
||||
private Integer verifyStatus;
|
||||
|
||||
/**
|
||||
* GmtVerify
|
||||
*/
|
||||
private Date gmtVerify;
|
||||
|
||||
/**
|
||||
* VerifyUser
|
||||
*/
|
||||
private String verifyUser;
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.config.model.biz.threadpool;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Config modify query resp
|
||||
*/
|
||||
@Data
|
||||
public class ConfigModificationQueryRespDTO {
|
||||
|
||||
/**
|
||||
* His_config_verify id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Config modify type
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* Thread pool mark
|
||||
*/
|
||||
private String mark;
|
||||
|
||||
/**
|
||||
* Tenant id
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* Item id
|
||||
*/
|
||||
private String itemId;
|
||||
|
||||
/**
|
||||
* Thread pool id
|
||||
*/
|
||||
private String tpId;
|
||||
|
||||
/**
|
||||
* Thread pool identify
|
||||
*/
|
||||
private String identify;
|
||||
|
||||
/**
|
||||
* Weather modify all instances
|
||||
*/
|
||||
private Boolean modifyAll;
|
||||
|
||||
/**
|
||||
* Modify user
|
||||
*/
|
||||
private String modifyUser;
|
||||
|
||||
/**
|
||||
* Verify status
|
||||
*/
|
||||
private Integer verifyStatus;
|
||||
|
||||
/**
|
||||
* GmtCreate
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date gmtCreate;
|
||||
|
||||
/**
|
||||
* GmtVerify
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date gmtVerify;
|
||||
|
||||
/**
|
||||
* Verify user
|
||||
*/
|
||||
private String verifyUser;
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.config.model.biz.threadpool;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@Data
|
||||
public class ConfigModifySaveReqDTO {
|
||||
|
||||
/**
|
||||
* Thread pool config change type.
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* Thread pool instance id
|
||||
*/
|
||||
private String identify;
|
||||
|
||||
/**
|
||||
* Weather modify all instances
|
||||
*/
|
||||
private Boolean modifyAll = false;
|
||||
|
||||
/**
|
||||
* Tenant Id
|
||||
*/
|
||||
@Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* Thread pool id
|
||||
*/
|
||||
@Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
|
||||
private String tpId;
|
||||
|
||||
/**
|
||||
* Item id
|
||||
*/
|
||||
@Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
|
||||
private String itemId;
|
||||
|
||||
/**
|
||||
* Thread pool mark
|
||||
*/
|
||||
private String mark;
|
||||
|
||||
/**
|
||||
* Core pool size
|
||||
*/
|
||||
private Integer corePoolSize;
|
||||
|
||||
/**
|
||||
* Maximum pool size
|
||||
*/
|
||||
private Integer maximumPoolSize;
|
||||
|
||||
/**
|
||||
* Queue type
|
||||
*/
|
||||
private Integer queueType;
|
||||
|
||||
/**
|
||||
* Capacity
|
||||
*/
|
||||
private Integer capacity;
|
||||
|
||||
/**
|
||||
* Keep alive time
|
||||
*/
|
||||
private Integer keepAliveTime;
|
||||
|
||||
/**
|
||||
* Execute time out
|
||||
*/
|
||||
private Long executeTimeOut;
|
||||
|
||||
/**
|
||||
* Is alarm
|
||||
*/
|
||||
private Integer isAlarm;
|
||||
|
||||
/**
|
||||
* Capacity alarm
|
||||
*/
|
||||
private Integer capacityAlarm;
|
||||
|
||||
/**
|
||||
* Liveness alarm
|
||||
*/
|
||||
private Integer livenessAlarm;
|
||||
|
||||
/**
|
||||
* Rejected type
|
||||
*/
|
||||
private Integer rejectedType;
|
||||
|
||||
/**
|
||||
* Allow core thread timeout
|
||||
*/
|
||||
private Integer allowCoreThreadTimeOut;
|
||||
|
||||
/**
|
||||
* ModifyUser
|
||||
*/
|
||||
private String modifyUser;
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.config.model.biz.threadpool;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Config modify verify dto
|
||||
*/
|
||||
@Data
|
||||
public class ConfigModifyVerifyReqDTO {
|
||||
|
||||
/**
|
||||
* His config verify id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Config verify type
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* Tenant id
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* Item id
|
||||
*/
|
||||
private String itemId;
|
||||
|
||||
/**
|
||||
* Instance identify
|
||||
*/
|
||||
private String identify;
|
||||
|
||||
/**
|
||||
* Adapter thread pool mark
|
||||
*/
|
||||
private String mark;
|
||||
|
||||
/**
|
||||
* Adapter thread pool key
|
||||
*/
|
||||
private String threadPoolKey;
|
||||
|
||||
/**
|
||||
* Thread pool id
|
||||
*/
|
||||
@JsonAlias("threadPoolId")
|
||||
private String tpId;
|
||||
|
||||
/**
|
||||
* Weather modify all instances
|
||||
*/
|
||||
private Boolean modifyAll;
|
||||
|
||||
/**
|
||||
* Weather accept config modification
|
||||
*/
|
||||
private Boolean accept;
|
||||
|
||||
/**
|
||||
* Core pool size
|
||||
*/
|
||||
private Integer corePoolSize;
|
||||
|
||||
/**
|
||||
* Maximum pool size
|
||||
*/
|
||||
private Integer maximumPoolSize;
|
||||
|
||||
/**
|
||||
* Queue type
|
||||
*/
|
||||
private Integer queueType;
|
||||
|
||||
/**
|
||||
* Capacity
|
||||
*/
|
||||
private Integer capacity;
|
||||
|
||||
/**
|
||||
* Keep alive time
|
||||
*/
|
||||
private Integer keepAliveTime;
|
||||
|
||||
/**
|
||||
* Execute time out
|
||||
*/
|
||||
private Long executeTimeOut;
|
||||
|
||||
/**
|
||||
* Rejected type
|
||||
*/
|
||||
private Integer rejectedType;
|
||||
|
||||
/**
|
||||
* Is alarm
|
||||
*/
|
||||
private Integer isAlarm;
|
||||
|
||||
/**
|
||||
* Capacity alarm
|
||||
*/
|
||||
private Integer capacityAlarm;
|
||||
|
||||
/**
|
||||
* Liveness alarm
|
||||
*/
|
||||
@JsonAlias("activeAlarm")
|
||||
private Integer livenessAlarm;
|
||||
|
||||
/**
|
||||
* Allow core thread timeout
|
||||
*/
|
||||
private Integer allowCoreThreadTimeOut;
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.config.service.biz;
|
||||
|
||||
import cn.hippo4j.common.model.ThreadPoolParameterInfo;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ConfigModificationQueryRespDTO;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ThreadPoolQueryReqDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
/**
|
||||
* Config modification application query service.
|
||||
*/
|
||||
public interface ConfigModificationQueryService {
|
||||
|
||||
/**
|
||||
* Query config modification application page.
|
||||
*
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
IPage<ConfigModificationQueryRespDTO> queryApplicationPage(ThreadPoolQueryReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* Query config modification detail by application id.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
ThreadPoolParameterInfo queryApplicationDetail(Long id);
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.config.service.biz;
|
||||
|
||||
import cn.hippo4j.config.model.biz.threadpool.ConfigModifySaveReqDTO;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ConfigModifyVerifyReqDTO;
|
||||
|
||||
/**
|
||||
* Config modification verify service.
|
||||
*/
|
||||
public interface ConfigModificationVerifyService {
|
||||
|
||||
/**
|
||||
* Get type.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Integer type();
|
||||
|
||||
/**
|
||||
* Save config change application.
|
||||
*
|
||||
* @param reqDTO
|
||||
*/
|
||||
void saveConfigModifyApplication(ConfigModifySaveReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* Reject config modification.
|
||||
*
|
||||
* @param reqDTO
|
||||
*/
|
||||
void rejectModification(ConfigModifyVerifyReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* Accept config modification.
|
||||
*
|
||||
* @param reqDTO
|
||||
*/
|
||||
void acceptModification(ConfigModifyVerifyReqDTO reqDTO);
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.config.service.biz.impl;
|
||||
|
||||
import cn.hippo4j.common.enums.VerifyEnum;
|
||||
import cn.hippo4j.common.model.InstanceInfo;
|
||||
import cn.hippo4j.common.toolkit.BeanUtil;
|
||||
import cn.hippo4j.common.toolkit.ConditionUtil;
|
||||
import cn.hippo4j.common.toolkit.JSONUtil;
|
||||
import cn.hippo4j.common.toolkit.UserContext;
|
||||
import cn.hippo4j.config.mapper.HisConfigVerifyMapper;
|
||||
import cn.hippo4j.config.model.HisConfigVerifyInfo;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ConfigModifySaveReqDTO;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ConfigModifyVerifyReqDTO;
|
||||
import cn.hippo4j.config.service.biz.ConfigModificationVerifyService;
|
||||
import cn.hippo4j.discovery.core.BaseInstanceRegistry;
|
||||
import cn.hippo4j.discovery.core.Lease;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Abstract config modification verify service.
|
||||
*/
|
||||
public abstract class AbstractConfigModificationVerifyService implements ConfigModificationVerifyService {
|
||||
|
||||
@Resource
|
||||
protected HisConfigVerifyMapper hisConfigVerifyMapper;
|
||||
|
||||
@Resource
|
||||
private BaseInstanceRegistry baseInstanceRegistry;
|
||||
|
||||
@Override
|
||||
public void saveConfigModifyApplication(ConfigModifySaveReqDTO reqDTO) {
|
||||
HisConfigVerifyInfo hisConfigVerifyInfo = BeanUtil.convert(reqDTO, HisConfigVerifyInfo.class);
|
||||
hisConfigVerifyInfo.setContent(JSONUtil.toJSONString(reqDTO));
|
||||
hisConfigVerifyInfo.setVerifyStatus(VerifyEnum.TO_VERIFY.getVerifyStatus());
|
||||
hisConfigVerifyMapper.insert(hisConfigVerifyInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rejectModification(ConfigModifyVerifyReqDTO reqDTO) {
|
||||
LambdaUpdateWrapper<HisConfigVerifyInfo> updateWrapper = new LambdaUpdateWrapper<HisConfigVerifyInfo>()
|
||||
.eq(HisConfigVerifyInfo::getId, Long.parseLong(reqDTO.getId()))
|
||||
.set(HisConfigVerifyInfo::getVerifyStatus, VerifyEnum.VERIFY_REJECT.getVerifyStatus())
|
||||
.set(HisConfigVerifyInfo::getGmtVerify, new Date())
|
||||
.set(HisConfigVerifyInfo::getVerifyUser, UserContext.getUserName());
|
||||
hisConfigVerifyMapper.update(null, updateWrapper);
|
||||
}
|
||||
|
||||
public void acceptModification(ConfigModifyVerifyReqDTO reqDTO) {
|
||||
updateThreadPoolParameter(reqDTO);
|
||||
LambdaUpdateWrapper<HisConfigVerifyInfo> updateWrapper = new LambdaUpdateWrapper<HisConfigVerifyInfo>()
|
||||
.eq(HisConfigVerifyInfo::getId, Long.parseLong(reqDTO.getId()))
|
||||
.set(HisConfigVerifyInfo::getVerifyStatus, VerifyEnum.VERIFY_ACCEPT.getVerifyStatus())
|
||||
.set(HisConfigVerifyInfo::getGmtVerify, new Date())
|
||||
.set(HisConfigVerifyInfo::getVerifyUser, UserContext.getUserName());
|
||||
hisConfigVerifyMapper.update(null, updateWrapper);
|
||||
Date gmtVerify = hisConfigVerifyMapper.selectById(reqDTO.getId()).getGmtVerify();
|
||||
LambdaUpdateWrapper<HisConfigVerifyInfo> invalidUpdateWrapper = new LambdaUpdateWrapper<HisConfigVerifyInfo>()
|
||||
.eq(HisConfigVerifyInfo::getType, reqDTO.getType())
|
||||
.eq(reqDTO.getTenantId() != null, HisConfigVerifyInfo::getTenantId, reqDTO.getTenantId())
|
||||
.eq(reqDTO.getItemId() != null, HisConfigVerifyInfo::getItemId, reqDTO.getItemId())
|
||||
.eq(reqDTO.getTpId() != null, HisConfigVerifyInfo::getTpId, reqDTO.getTpId())
|
||||
.and(reqDTO.getIdentify() != null, wrapper -> wrapper.eq(HisConfigVerifyInfo::getIdentify, reqDTO.getIdentify()).or().eq(HisConfigVerifyInfo::getModifyAll, true))
|
||||
.lt(HisConfigVerifyInfo::getGmtVerify, gmtVerify)
|
||||
.set(HisConfigVerifyInfo::getVerifyStatus, VerifyEnum.VERIFY_INVALID.getVerifyStatus());
|
||||
hisConfigVerifyMapper.update(null, invalidUpdateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get client address.
|
||||
*
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
protected List<String> getClientAddress(ConfigModifyVerifyReqDTO reqDTO) {
|
||||
List<String> clientAddressList = new ArrayList<>();
|
||||
List<Lease<InstanceInfo>> leases = baseInstanceRegistry.listInstance(reqDTO.getItemId());
|
||||
ConditionUtil
|
||||
.condition(reqDTO.getModifyAll(),
|
||||
() -> leases.forEach(lease -> clientAddressList.add(lease.getHolder().getCallBackUrl())),
|
||||
() -> clientAddressList.add(
|
||||
leases.stream()
|
||||
.filter(lease -> lease.getHolder().getIdentify().equals(reqDTO.getIdentify())).findAny().orElseThrow(() -> new RuntimeException("该线程池实例不存在")).getHolder()
|
||||
.getCallBackUrl()));
|
||||
return clientAddressList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update thread pool parameter.
|
||||
*
|
||||
* @param reqDTO
|
||||
*/
|
||||
protected abstract void updateThreadPoolParameter(ConfigModifyVerifyReqDTO reqDTO);
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.config.service.biz.impl;
|
||||
|
||||
import cn.hippo4j.common.constant.ConfigModifyTypeConstants;
|
||||
import cn.hippo4j.common.toolkit.JSONUtil;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ConfigModifyVerifyReqDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* Adapter thread pool config modification verify service impl.
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AdapterThreadPoolConfigModificationVerifyServiceImpl extends AbstractConfigModificationVerifyService {
|
||||
|
||||
private final RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
@Override
|
||||
public Integer type() {
|
||||
return ConfigModifyTypeConstants.ADAPTER_THREAD_POOL;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateThreadPoolParameter(ConfigModifyVerifyReqDTO reqDTO) {
|
||||
for (String each : getClientAddress(reqDTO)) {
|
||||
String urlString = new StringBuilder()
|
||||
.append("http://")
|
||||
.append(each)
|
||||
.append("/adapter/thread-pool/update")
|
||||
.toString();
|
||||
restTemplate.postForObject(urlString, JSONUtil.toJSONString(reqDTO), Object.class);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.config.service.biz.impl;
|
||||
|
||||
import cn.hippo4j.common.model.ThreadPoolParameterInfo;
|
||||
import cn.hippo4j.common.toolkit.BeanUtil;
|
||||
import cn.hippo4j.common.toolkit.JSONUtil;
|
||||
import cn.hippo4j.config.mapper.HisConfigVerifyMapper;
|
||||
import cn.hippo4j.config.model.HisConfigVerifyInfo;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ConfigModificationQueryRespDTO;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ThreadPoolQueryReqDTO;
|
||||
import cn.hippo4j.config.service.biz.ConfigModificationQueryService;
|
||||
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 org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* Config modification query service impl
|
||||
*/
|
||||
@Service
|
||||
public class ConfigModificationQueryServiceImpl implements ConfigModificationQueryService {
|
||||
|
||||
@Resource
|
||||
private HisConfigVerifyMapper hisConfigVerifyMapper;
|
||||
|
||||
@Override
|
||||
public IPage<ConfigModificationQueryRespDTO> queryApplicationPage(ThreadPoolQueryReqDTO reqDTO) {
|
||||
LambdaQueryWrapper<HisConfigVerifyInfo> wrapper = Wrappers.lambdaQuery(HisConfigVerifyInfo.class)
|
||||
.eq(!StringUtils.isBlank(reqDTO.getTenantId()), HisConfigVerifyInfo::getTenantId, reqDTO.getTenantId())
|
||||
.eq(!StringUtils.isBlank(reqDTO.getItemId()), HisConfigVerifyInfo::getItemId, reqDTO.getItemId())
|
||||
.orderByDesc(HisConfigVerifyInfo::getGmtCreate);
|
||||
return hisConfigVerifyMapper.selectPage(reqDTO, wrapper).convert(each -> BeanUtil.convert(each, ConfigModificationQueryRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThreadPoolParameterInfo queryApplicationDetail(Long id) {
|
||||
HisConfigVerifyInfo hisConfigVerifyInfo = hisConfigVerifyMapper.selectById(id);
|
||||
ThreadPoolParameterInfo poolParameterInfo = JSONUtil.parseObject(hisConfigVerifyInfo.getContent(), ThreadPoolParameterInfo.class);
|
||||
poolParameterInfo.setCorePoolSize(poolParameterInfo.corePoolSizeAdapt());
|
||||
poolParameterInfo.setMaximumPoolSize(poolParameterInfo.maximumPoolSizeAdapt());
|
||||
return poolParameterInfo;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.config.service.biz.impl;
|
||||
|
||||
import cn.hippo4j.common.constant.ConfigModifyTypeConstants;
|
||||
import cn.hippo4j.common.toolkit.BeanUtil;
|
||||
import cn.hippo4j.config.model.ConfigAllInfo;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ConfigModifyVerifyReqDTO;
|
||||
import cn.hippo4j.config.service.biz.ConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* Thread pool instance config modification verify service impl.
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ThreadPoolInstanceConfigModificationVerifyServiceImpl extends AbstractConfigModificationVerifyService {
|
||||
|
||||
@Resource
|
||||
private ConfigService configService;
|
||||
|
||||
@Override
|
||||
public Integer type() {
|
||||
return ConfigModifyTypeConstants.THREAD_POOL_INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateThreadPoolParameter(ConfigModifyVerifyReqDTO reqDTO) {
|
||||
ConfigAllInfo config = BeanUtil.convert(reqDTO, ConfigAllInfo.class);
|
||||
config.setCoreSize(reqDTO.getCorePoolSize());
|
||||
config.setMaxSize(reqDTO.getMaximumPoolSize());
|
||||
configService.insertOrUpdate(reqDTO.getIdentify(), true, config);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.config.service.biz.impl;
|
||||
|
||||
import cn.hippo4j.common.constant.ConfigModifyTypeConstants;
|
||||
import cn.hippo4j.common.toolkit.BeanUtil;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ConfigModifyVerifyReqDTO;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ThreadPoolSaveOrUpdateReqDTO;
|
||||
import cn.hippo4j.config.service.biz.ThreadPoolService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* Thread pool manager config modification verify service impl.
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ThreadPoolManageConfigModificationVerifyServiceImpl extends AbstractConfigModificationVerifyService {
|
||||
|
||||
@Resource
|
||||
private ThreadPoolService threadPoolService;
|
||||
|
||||
@Override
|
||||
public Integer type() {
|
||||
return ConfigModifyTypeConstants.THREAD_POOL_MANAGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateThreadPoolParameter(ConfigModifyVerifyReqDTO reqDTO) {
|
||||
ThreadPoolSaveOrUpdateReqDTO saveOrUpdateReqDTO = BeanUtil.convert(reqDTO, ThreadPoolSaveOrUpdateReqDTO.class);
|
||||
saveOrUpdateReqDTO.setCoreSize(reqDTO.getCorePoolSize());
|
||||
saveOrUpdateReqDTO.setMaxSize(reqDTO.getMaximumPoolSize());
|
||||
threadPoolService.saveOrUpdateThreadPoolConfig(null, saveOrUpdateReqDTO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.config.service.biz.impl;
|
||||
|
||||
import cn.hippo4j.common.constant.ConfigModifyTypeConstants;
|
||||
import cn.hippo4j.common.toolkit.JSONUtil;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ConfigModifyVerifyReqDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* Web thread pool config modification verify service impl.
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WebThreadPoolConfigModificationVerifyServiceImpl extends AbstractConfigModificationVerifyService {
|
||||
|
||||
private final RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
@Override
|
||||
public Integer type() {
|
||||
return ConfigModifyTypeConstants.WEB_THREAD_POOL;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateThreadPoolParameter(ConfigModifyVerifyReqDTO reqDTO) {
|
||||
for (String each : getClientAddress(reqDTO)) {
|
||||
String urlString = new StringBuilder()
|
||||
.append("http://")
|
||||
.append(each)
|
||||
.append("/web/update/pool")
|
||||
.toString();
|
||||
restTemplate.postForObject(urlString, JSONUtil.toJSONString(reqDTO), Object.class);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.config.verify;
|
||||
|
||||
import cn.hippo4j.common.config.ApplicationContextHolder;
|
||||
import cn.hippo4j.common.constant.ConfigModifyTypeConstants;
|
||||
import cn.hippo4j.config.service.biz.ConfigModificationVerifyService;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Config change verify service choose
|
||||
*/
|
||||
@Component
|
||||
public class ConfigModificationVerifyServiceChoose implements CommandLineRunner {
|
||||
|
||||
/**
|
||||
* Storage config change verify service container.
|
||||
*/
|
||||
private Map<Integer, ConfigModificationVerifyService> configChangeVerifyServiceChooseMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Choose by type.
|
||||
*
|
||||
* @param type {@link ConfigModifyTypeConstants}
|
||||
* @return
|
||||
*/
|
||||
public ConfigModificationVerifyService choose(Integer type) {
|
||||
ConfigModificationVerifyService verifyService = configChangeVerifyServiceChooseMap.get(type);
|
||||
return verifyService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
Map<String, ConfigModificationVerifyService> configChangeVerifyServiceMap =
|
||||
ApplicationContextHolder.getBeansOfType(ConfigModificationVerifyService.class);
|
||||
configChangeVerifyServiceMap.values().forEach(each -> configChangeVerifyServiceChooseMap.put(each.type(), each));
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.hippo4j.console.controller;
|
||||
|
||||
import cn.hippo4j.common.constant.Constants;
|
||||
import cn.hippo4j.common.model.ThreadPoolParameterInfo;
|
||||
import cn.hippo4j.common.toolkit.ConditionUtil;
|
||||
import cn.hippo4j.common.web.base.Result;
|
||||
import cn.hippo4j.common.web.base.Results;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ConfigModificationQueryRespDTO;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ConfigModifyVerifyReqDTO;
|
||||
import cn.hippo4j.config.model.biz.threadpool.ThreadPoolQueryReqDTO;
|
||||
import cn.hippo4j.config.service.biz.ConfigModificationQueryService;
|
||||
import cn.hippo4j.config.service.biz.ConfigModificationVerifyService;
|
||||
import cn.hippo4j.config.verify.ConfigModificationVerifyServiceChoose;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping(Constants.VERIFY_PATH)
|
||||
public class ConfigVerifyController {
|
||||
|
||||
private final ConfigModificationVerifyServiceChoose serviceChoose;
|
||||
|
||||
private final ConfigModificationQueryService queryService;
|
||||
|
||||
@PostMapping
|
||||
public Result<Void> verifyConfigModification(@RequestBody ConfigModifyVerifyReqDTO reqDTO) {
|
||||
ConfigModificationVerifyService modifyVerifyService = serviceChoose.choose(reqDTO.getType());
|
||||
ConditionUtil
|
||||
.condition(reqDTO.getAccept(),
|
||||
() -> modifyVerifyService.acceptModification(reqDTO),
|
||||
() -> modifyVerifyService.rejectModification(reqDTO));
|
||||
return Results.success();
|
||||
}
|
||||
|
||||
@PostMapping("/query/application/page")
|
||||
public Result<IPage<ConfigModificationQueryRespDTO>> modificationApplicationPage(@RequestBody ThreadPoolQueryReqDTO reqDTO) {
|
||||
return Results.success(queryService.queryApplicationPage(reqDTO));
|
||||
}
|
||||
|
||||
@GetMapping("/query/application/detail")
|
||||
public Result<ThreadPoolParameterInfo> modificationApplicationDetail(@RequestParam("id") String id) {
|
||||
return Results.success(queryService.queryApplicationDetail(Long.parseLong(id)));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue