mirror of https://github.com/longtai-cn/hippo4j
parent
9fdf96841f
commit
4715394b91
@ -1,33 +0,0 @@
|
|||||||
HELP.md
|
|
||||||
target/
|
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
|
||||||
!**/src/main/**/target/
|
|
||||||
!**/src/test/**/target/
|
|
||||||
|
|
||||||
### STS ###
|
|
||||||
.apt_generated
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.project
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
.sts4-cache
|
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
|
||||||
.idea
|
|
||||||
*.iws
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
|
|
||||||
### NetBeans ###
|
|
||||||
/nbproject/private/
|
|
||||||
/nbbuild/
|
|
||||||
/dist/
|
|
||||||
/nbdist/
|
|
||||||
/.nb-gradle/
|
|
||||||
build/
|
|
||||||
!**/src/main/**/build/
|
|
||||||
!**/src/test/**/build/
|
|
||||||
|
|
||||||
### VS Code ###
|
|
||||||
.vscode/
|
|
@ -1,24 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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.auth.model.biz.role;
|
package cn.hippo4j.auth.model.biz.role;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Role resp dto.
|
* Role resp dto.
|
||||||
*
|
|
||||||
* @author chen.ma
|
|
||||||
* @date 2021/10/30 22:49
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class RoleRespDTO {
|
public class RoleRespDTO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* role
|
* Role
|
||||||
*/
|
*/
|
||||||
private String role;
|
private String role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* userName
|
* User name
|
||||||
*/
|
*/
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
HELP.md
|
|
||||||
target/
|
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
|
||||||
!**/src/main/**/target/
|
|
||||||
!**/src/test/**/target/
|
|
||||||
|
|
||||||
### STS ###
|
|
||||||
.apt_generated
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.project
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
.sts4-cache
|
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
|
||||||
.idea
|
|
||||||
*.iws
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
|
|
||||||
### NetBeans ###
|
|
||||||
/nbproject/private/
|
|
||||||
/nbbuild/
|
|
||||||
/dist/
|
|
||||||
/nbdist/
|
|
||||||
/.nb-gradle/
|
|
||||||
build/
|
|
||||||
!**/src/main/**/build/
|
|
||||||
!**/src/test/**/build/
|
|
||||||
|
|
||||||
### VS Code ###
|
|
||||||
.vscode/
|
|
@ -1,20 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* 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.design.builder;
|
package cn.hippo4j.common.design.builder;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder pattern interface definition.
|
* Builder pattern interface definition.
|
||||||
*
|
|
||||||
* @author chen.ma
|
|
||||||
* @date 2021/7/5 21:39
|
|
||||||
*/
|
*/
|
||||||
public interface Builder<T> extends Serializable {
|
public interface Builder<T> extends Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
* Build.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
T build();
|
T build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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.design.observer;
|
package cn.hippo4j.common.design.observer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message notifying observer.
|
* Message notifying observer.
|
||||||
*
|
|
||||||
* @author chen.ma
|
|
||||||
* @date 2021/12/25 19:54
|
|
||||||
*/
|
*/
|
||||||
public interface ObserverMessage<T> {
|
public interface ObserverMessage<T> {
|
||||||
|
|
||||||
/**
|
|
||||||
* Message.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
T message();
|
T message();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* 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.function;
|
package cn.hippo4j.common.function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher.
|
* Matcher.
|
||||||
*
|
|
||||||
* @author chen.ma
|
|
||||||
* @date 2022/1/9 13:29
|
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface Matcher<T> {
|
public interface Matcher<T> {
|
||||||
|
|
||||||
/**
|
|
||||||
* Match.
|
|
||||||
*
|
|
||||||
* @param t
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
boolean match(T t);
|
boolean match(T t);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* 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.function;
|
package cn.hippo4j.common.function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 无参消费者.
|
* No args consumer.
|
||||||
*
|
|
||||||
* @author chen.ma
|
|
||||||
* @date 2021/11/9 00:06
|
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface NoArgsConsumer {
|
public interface NoArgsConsumer {
|
||||||
|
|
||||||
/**
|
|
||||||
* 方法执行
|
|
||||||
*/
|
|
||||||
void accept();
|
void accept();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
package cn.hippo4j.common.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Many pool run state info.
|
|
||||||
*
|
|
||||||
* @author chen.ma
|
|
||||||
* @date 2022/1/8 12:54
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class ManyPoolRunStateInfo extends PoolRunStateInfo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* identify
|
|
||||||
*/
|
|
||||||
private String identify;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* active
|
|
||||||
*/
|
|
||||||
private String active;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* state
|
|
||||||
*/
|
|
||||||
private String state;
|
|
||||||
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
package cn.hippo4j.common.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pool base info.
|
|
||||||
*
|
|
||||||
* @author chen.ma
|
|
||||||
* @date 2022/1/22 12:10
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Accessors(chain = true)
|
|
||||||
public class PoolBaseInfo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* coreSize
|
|
||||||
*/
|
|
||||||
private Integer coreSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* maximumSize
|
|
||||||
*/
|
|
||||||
private Integer maximumSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* queueType
|
|
||||||
*/
|
|
||||||
private String queueType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* queueCapacity
|
|
||||||
*/
|
|
||||||
private Integer queueCapacity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* rejectedName
|
|
||||||
*/
|
|
||||||
private String rejectedName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* keepAliveTime
|
|
||||||
*/
|
|
||||||
private Long keepAliveTime;
|
|
||||||
|
|
||||||
}
|
|
@ -1,102 +0,0 @@
|
|||||||
package cn.hippo4j.common.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pool parameter.
|
|
||||||
*
|
|
||||||
* @author chen.ma
|
|
||||||
* @date 2021/6/24 16:04
|
|
||||||
*/
|
|
||||||
public interface PoolParameter {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* tenantId
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
String getTenantId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* itemId
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
String getItemId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* tpId
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
String getTpId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* coreSize
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getCoreSize();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* maxSize
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getMaxSize();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* queueType
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getQueueType();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* capacity
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getCapacity();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* keepAliveTime
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getKeepAliveTime();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* rejectedType
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getRejectedType();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* isAlarm
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getIsAlarm();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* capacityAlarm
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getCapacityAlarm();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* livenessAlarm
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getLivenessAlarm();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* allowCoreThreadTimeOut
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getAllowCoreThreadTimeOut();
|
|
||||||
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
package cn.hippo4j.common.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Thread pool parameter info.
|
|
||||||
*
|
|
||||||
* @author chen.ma
|
|
||||||
* @date 2021/6/16 23:18
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Accessors(chain = true)
|
|
||||||
public class PoolParameterInfo implements PoolParameter, Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -7123935122108553864L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* tenantId
|
|
||||||
*/
|
|
||||||
private String tenantId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* itemId
|
|
||||||
*/
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* tpId
|
|
||||||
*/
|
|
||||||
private String tpId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* content
|
|
||||||
*/
|
|
||||||
private String content;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* coreSize
|
|
||||||
*/
|
|
||||||
private Integer coreSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* maxSize
|
|
||||||
*/
|
|
||||||
private Integer maxSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* queueType
|
|
||||||
*/
|
|
||||||
private Integer queueType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* capacity
|
|
||||||
*/
|
|
||||||
private Integer capacity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* keepAliveTime
|
|
||||||
*/
|
|
||||||
private Integer keepAliveTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* rejectedType
|
|
||||||
*/
|
|
||||||
private Integer rejectedType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* isAlarm
|
|
||||||
*/
|
|
||||||
private Integer isAlarm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* capacityAlarm
|
|
||||||
*/
|
|
||||||
private Integer capacityAlarm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* livenessAlarm
|
|
||||||
*/
|
|
||||||
private Integer livenessAlarm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* allowCoreThreadTimeOut
|
|
||||||
*/
|
|
||||||
private Integer allowCoreThreadTimeOut;
|
|
||||||
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
package cn.hippo4j.common.model;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pool run state info.
|
|
||||||
*
|
|
||||||
* @author chen.ma
|
|
||||||
* @date 2021/7/7 18:57
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class PoolRunStateInfo extends PoolBaseInfo implements Serializable {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* currentLoad
|
|
||||||
*/
|
|
||||||
private String currentLoad;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* peakLoad
|
|
||||||
*/
|
|
||||||
private String peakLoad;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* tpId
|
|
||||||
*/
|
|
||||||
private String tpId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* activeCount
|
|
||||||
*/
|
|
||||||
private Integer activeCount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* poolSize
|
|
||||||
*/
|
|
||||||
private Integer poolSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* activeSize
|
|
||||||
*/
|
|
||||||
private Integer activeSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum number of threads that enter the thread pool at the same time
|
|
||||||
*/
|
|
||||||
private Integer largestPoolSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* queueSize
|
|
||||||
*/
|
|
||||||
private Integer queueSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* queueRemainingCapacity
|
|
||||||
*/
|
|
||||||
private Integer queueRemainingCapacity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* completedTaskCount
|
|
||||||
*/
|
|
||||||
private Long completedTaskCount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* rejectCount
|
|
||||||
*/
|
|
||||||
private Long rejectCount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* host
|
|
||||||
*/
|
|
||||||
private String host;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* memoryProportion
|
|
||||||
*/
|
|
||||||
private String memoryProportion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* freeMemory
|
|
||||||
*/
|
|
||||||
private String freeMemory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clientLastRefreshTime
|
|
||||||
*/
|
|
||||||
private String clientLastRefreshTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* timestamp
|
|
||||||
*/
|
|
||||||
private Long timestamp;
|
|
||||||
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
package cn.hippo4j.common.notify;
|
|
||||||
|
|
||||||
import cn.hippo4j.common.api.NotifyConfigBuilder;
|
|
||||||
import cn.hippo4j.common.config.ApplicationContextHolder;
|
|
||||||
import cn.hippo4j.common.notify.request.AlarmNotifyRequest;
|
|
||||||
import cn.hippo4j.common.notify.request.ChangeParameterNotifyRequest;
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.boot.CommandLineRunner;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base send message service impl.
|
|
||||||
*
|
|
||||||
* @author chen.ma
|
|
||||||
* @date 2022/2/22 21:32
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class BaseSendMessageServiceImpl implements HippoSendMessageService, CommandLineRunner {
|
|
||||||
|
|
||||||
private final NotifyConfigBuilder notifyConfigBuilder;
|
|
||||||
|
|
||||||
private final AlarmControlHandler alarmControlHandler;
|
|
||||||
|
|
||||||
private final Map<String, List<NotifyConfigDTO>> notifyConfigs = Maps.newHashMap();
|
|
||||||
|
|
||||||
private final Map<String, SendMessageHandler> sendMessageHandlers = Maps.newHashMap();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendAlarmMessage(NotifyTypeEnum typeEnum, AlarmNotifyRequest alarmNotifyRequest) {
|
|
||||||
String threadPoolId = alarmNotifyRequest.getThreadPoolId();
|
|
||||||
String buildKey = StrUtil.builder(threadPoolId, "+", "ALARM").toString();
|
|
||||||
List<NotifyConfigDTO> notifyList = notifyConfigs.get(buildKey);
|
|
||||||
if (CollUtil.isEmpty(notifyList)) {
|
|
||||||
log.warn("Please configure alarm notification on the server. key :: [{}]", threadPoolId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyList.forEach(each -> {
|
|
||||||
try {
|
|
||||||
SendMessageHandler messageHandler = sendMessageHandlers.get(each.getPlatform());
|
|
||||||
if (messageHandler == null) {
|
|
||||||
log.warn("Please configure alarm notification on the server. key :: [{}]", threadPoolId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSendAlarm(each.getThreadPoolId(), each.setTypeEnum(typeEnum))) {
|
|
||||||
messageHandler.sendAlarmMessage(each, alarmNotifyRequest);
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.warn("Failed to send thread pool alarm notification. key :: [{}]", threadPoolId, ex);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendChangeMessage(ChangeParameterNotifyRequest changeParameterNotifyRequest) {
|
|
||||||
String threadPoolId = changeParameterNotifyRequest.getThreadPoolId();
|
|
||||||
String buildKey = StrUtil.builder(threadPoolId, "+", "CONFIG").toString();
|
|
||||||
List<NotifyConfigDTO> notifyList = notifyConfigs.get(buildKey);
|
|
||||||
if (CollUtil.isEmpty(notifyList)) {
|
|
||||||
log.warn("Please configure alarm notification on the server. key :: [{}]", threadPoolId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyList.forEach(each -> {
|
|
||||||
try {
|
|
||||||
SendMessageHandler messageHandler = sendMessageHandlers.get(each.getPlatform());
|
|
||||||
if (messageHandler == null) {
|
|
||||||
log.warn("Please configure alarm notification on the server. key :: [{}]", threadPoolId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
messageHandler.sendChangeMessage(each, changeParameterNotifyRequest);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.warn("Failed to send thread pool change notification. key :: [{}]", threadPoolId, ex);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is send alarm.
|
|
||||||
*
|
|
||||||
* @param threadPoolId
|
|
||||||
* @param notifyInfo
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean isSendAlarm(String threadPoolId, NotifyConfigDTO notifyInfo) {
|
|
||||||
AlarmControlDTO alarmControl = AlarmControlDTO.builder()
|
|
||||||
.threadPool(threadPoolId)
|
|
||||||
.platform(notifyInfo.getPlatform())
|
|
||||||
.typeEnum(notifyInfo.getTypeEnum())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
return alarmControlHandler.isSendAlarm(alarmControl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(String... args) throws Exception {
|
|
||||||
Map<String, SendMessageHandler> sendMessageHandlerMap =
|
|
||||||
ApplicationContextHolder.getBeansOfType(SendMessageHandler.class);
|
|
||||||
sendMessageHandlerMap.values().forEach(each -> sendMessageHandlers.put(each.getType(), each));
|
|
||||||
|
|
||||||
Map<String, List<NotifyConfigDTO>> buildNotify = notifyConfigBuilder.buildNotify();
|
|
||||||
notifyConfigs.putAll(buildNotify);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,10 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* 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.notify.request.base;
|
package cn.hippo4j.common.notify.request.base;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify request.
|
* Notify request.
|
||||||
*
|
|
||||||
* @author chen.ma
|
|
||||||
* @date 2022/2/22 19:38
|
|
||||||
*/
|
*/
|
||||||
public interface NotifyRequest {
|
public interface NotifyRequest {
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue