mirror of https://github.com/longtai-cn/hippo4j
pull/1133/head
parent
0550dbc3a1
commit
382ff3a0ec
@ -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.message.request;
|
||||||
|
|
||||||
|
import cn.hippo4j.message.request.base.BaseNotifyRequest;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change parameter notify request for web thread pool.
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class WebChangeParameterNotifyRequest extends BaseNotifyRequest {
|
||||||
|
|
||||||
|
private String active;
|
||||||
|
|
||||||
|
private String appName;
|
||||||
|
|
||||||
|
private String identify;
|
||||||
|
|
||||||
|
private Integer beforeCorePoolSize;
|
||||||
|
|
||||||
|
private Integer nowCorePoolSize;
|
||||||
|
|
||||||
|
private Integer beforeMaximumPoolSize;
|
||||||
|
|
||||||
|
private Integer nowMaximumPoolSize;
|
||||||
|
|
||||||
|
private Long beforeKeepAliveTime;
|
||||||
|
|
||||||
|
private Long nowKeepAliveTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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.message.service;
|
||||||
|
|
||||||
|
import cn.hippo4j.common.api.ThreadPoolConfigChange;
|
||||||
|
import cn.hippo4j.common.toolkit.StringUtil;
|
||||||
|
import cn.hippo4j.core.toolkit.IdentifyUtil;
|
||||||
|
import cn.hippo4j.message.request.ChangeParameterNotifyRequest;
|
||||||
|
import cn.hippo4j.message.request.WebChangeParameterNotifyRequest;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web thread-pool config change handler.
|
||||||
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class WebThreadPoolConfigChangeHandler implements ThreadPoolConfigChange<WebChangeParameterNotifyRequest> {
|
||||||
|
|
||||||
|
@Value("${spring.application.name:UNKNOWN}")
|
||||||
|
private String applicationName;
|
||||||
|
|
||||||
|
private final Hippo4jSendMessageService hippo4jSendMessageService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send pool config change.
|
||||||
|
*
|
||||||
|
* @param requestParam change parameter notify request
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendPoolConfigChange(WebChangeParameterNotifyRequest requestParam) {
|
||||||
|
try {
|
||||||
|
requestParam.setAppName(applicationName);
|
||||||
|
requestParam.setIdentify(IdentifyUtil.getIdentify());
|
||||||
|
hippo4jSendMessageService.sendChangeMessage(requestParam);
|
||||||
|
} catch (Throwable th) {
|
||||||
|
log.error("send web thread pool config change message failed.", th);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* 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.springboot.starter.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for thread pool configuration.
|
||||||
|
*/
|
||||||
|
public interface IExecutorProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Core pool size
|
||||||
|
*/
|
||||||
|
Integer getCorePoolSize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum pool size
|
||||||
|
*/
|
||||||
|
Integer getMaximumPoolSize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keep alive time
|
||||||
|
*/
|
||||||
|
Long getKeepAliveTime();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify configs
|
||||||
|
*/
|
||||||
|
DynamicThreadPoolNotifyProperties getNotify();
|
||||||
|
}
|
Loading…
Reference in new issue