mirror of https://github.com/longtai-cn/hippo4j
Refactor notification alerts and jar dependencies (#911)
parent
ca560d6cf8
commit
f19ec20c57
@ -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.common.api;
|
||||
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* Thread-pol check alarm.
|
||||
*
|
||||
* <p>Dynamic thread pool check and send logic wait for refactoring,
|
||||
* Try not to rely on this component for custom extensions, because it is undefined.
|
||||
*/
|
||||
public interface ThreadPoolCheckAlarm extends CommandLineRunner {
|
||||
|
||||
/**
|
||||
* Check pool capacity alarm.
|
||||
*
|
||||
* @param threadPoolId thread-pool id
|
||||
* @param threadPoolExecutor thread-pool executor
|
||||
*/
|
||||
void checkPoolCapacityAlarm(String threadPoolId, ThreadPoolExecutor threadPoolExecutor);
|
||||
|
||||
/**
|
||||
* Check pool activity alarm.
|
||||
*
|
||||
* @param threadPoolId thread-pool id
|
||||
* @param threadPoolExecutor thread-pool executor
|
||||
*/
|
||||
void checkPoolActivityAlarm(String threadPoolId, ThreadPoolExecutor threadPoolExecutor);
|
||||
|
||||
/**
|
||||
* Async send rejected alarm.
|
||||
*
|
||||
* @param threadPoolId thread-pool id
|
||||
*/
|
||||
void asyncSendRejectedAlarm(String threadPoolId);
|
||||
|
||||
/**
|
||||
* Async send execute time-out alarm.
|
||||
*
|
||||
* @param threadPoolId thread-pool id
|
||||
* @param executeTime execute time
|
||||
* @param executeTimeOut execute time-out
|
||||
* @param threadPoolExecutor thread-pool executor
|
||||
*/
|
||||
void asyncSendExecuteTimeOutAlarm(String threadPoolId, long executeTime, long executeTimeOut, ThreadPoolExecutor threadPoolExecutor);
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
/**
|
||||
* Thread-pool config change.
|
||||
*/
|
||||
public interface ThreadPoolConfigChange<T extends NotifyRequest> {
|
||||
|
||||
/**
|
||||
* Send pool config change.
|
||||
*
|
||||
* @param requestParam request param
|
||||
*/
|
||||
void sendPoolConfigChange(T requestParam);
|
||||
}
|
@ -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.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 lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
/**
|
||||
* Default thread-pool config change handler.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class DefaultThreadPoolConfigChangeHandler implements ThreadPoolConfigChange<ChangeParameterNotifyRequest> {
|
||||
|
||||
@Value("${spring.profiles.active:UNKNOWN}")
|
||||
private String active;
|
||||
|
||||
@Value("${spring.dynamic.thread-pool.item-id:}")
|
||||
private String itemId;
|
||||
|
||||
@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(ChangeParameterNotifyRequest requestParam) {
|
||||
requestParam.setActive(active.toUpperCase());
|
||||
String appName = StringUtil.isBlank(itemId) ? applicationName : itemId;
|
||||
requestParam.setAppName(appName);
|
||||
requestParam.setIdentify(IdentifyUtil.getIdentify());
|
||||
hippo4jSendMessageService.sendChangeMessage(requestParam);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue