T get(String key) {
+ Object result = SINGLE_OBJECT_POOL.get(key);
+ return result == null ? null : (T) result;
+ }
+
+ /**
+ * Get a singleton object by key.
+ *
+ * When empty, build a singleton object through supplier and put it into the container.
+ *
+ * @param key
+ * @param supplier
+ * @param
+ * @return
+ */
+ public static T get(String key, Supplier supplier) {
+ Object result = SINGLE_OBJECT_POOL.get(key);
+ if (result == null && (result = supplier.get()) != null) {
+ SINGLE_OBJECT_POOL.put(key, result);
+ }
+ return result != null ? (T) result : null;
+ }
+
+ /**
+ * Object into container.
+ *
+ * @param value
+ */
+ public static void put(Object value) {
+ put(value.getClass().getName(), value);
+ }
+
+ /**
+ * Object into container.
+ *
+ * @param key
+ * @param value
+ */
+ public static void put(String key, Object value) {
+ SINGLE_OBJECT_POOL.put(key, value);
+ }
+}
diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/StringUtil.java b/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/StringUtil.java
new file mode 100644
index 00000000..13bdb67c
--- /dev/null
+++ b/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/StringUtil.java
@@ -0,0 +1,161 @@
+/*
+ * 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.toolkit;
+
+/**
+ * String util.
+ */
+public class StringUtil {
+
+ public static final String EMPTY = "";
+
+ public static final char UNDERLINE = '_';
+
+ /**
+ * Is blank.
+ *
+ * @param str
+ * @return
+ */
+ public static boolean isBlank(CharSequence str) {
+ int length;
+ if ((str == null) || ((length = str.length()) == 0)) {
+ return true;
+ }
+ for (int i = 0; i < length; i++) {
+ char c = str.charAt(i);
+ boolean charNotBlank = Character.isWhitespace(c) || Character.isSpaceChar(c) || c == '\ufeff' || c == '\u202a';
+ if (charNotBlank == false) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Is empty.
+ *
+ * @param str
+ * @return
+ */
+ public static boolean isEmpty(CharSequence str) {
+ return str == null || str.length() == 0;
+ }
+
+ /**
+ * Is not empty.
+ *
+ * @param str
+ * @return
+ */
+ public static boolean isNotEmpty(CharSequence str) {
+ return !isEmpty(str);
+ }
+
+ /**
+ * Is not blank.
+ *
+ * @param str
+ * @return
+ */
+ public static boolean isNotBlank(CharSequence str) {
+ return isBlank(str) == false;
+ }
+
+ /**
+ * Is all not empty.
+ *
+ * @param args
+ * @return
+ */
+ public static boolean isAllNotEmpty(CharSequence... args) {
+ return false == hasEmpty(args);
+ }
+
+ /**
+ * Has empty.
+ *
+ * @param strList
+ * @return
+ */
+ public static boolean hasEmpty(CharSequence... strList) {
+ if (ArrayUtil.isEmpty(strList)) {
+ return true;
+ }
+
+ for (CharSequence str : strList) {
+ if (isEmpty(str)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * To underline case.
+ *
+ * @param str
+ * @return
+ */
+ public static String toUnderlineCase(CharSequence str) {
+ return toSymbolCase(str, UNDERLINE);
+ }
+
+ /**
+ * To symbol case.
+ *
+ * @param str
+ * @param symbol
+ * @return
+ */
+ public static String toSymbolCase(CharSequence str, char symbol) {
+ if (str == null) {
+ return null;
+ }
+
+ final int length = str.length();
+ final StringBuilder sb = new StringBuilder();
+ char c;
+ for (int i = 0; i < length; i++) {
+ c = str.charAt(i);
+ final Character preChar = (i > 0) ? str.charAt(i - 1) : null;
+ if (Character.isUpperCase(c)) {
+ final Character nextChar = (i < str.length() - 1) ? str.charAt(i + 1) : null;
+ if (null != preChar && Character.isUpperCase(preChar)) {
+ sb.append(c);
+ } else if (null != nextChar && Character.isUpperCase(nextChar)) {
+ if (null != preChar && symbol != preChar) {
+ sb.append(symbol);
+ }
+ sb.append(c);
+ } else {
+ if (null != preChar && symbol != preChar) {
+ sb.append(symbol);
+ }
+ sb.append(Character.toLowerCase(c));
+ }
+ } else {
+ if (sb.length() > 0 && Character.isUpperCase(sb.charAt(sb.length() - 1)) && symbol != c) {
+ sb.append(symbol);
+ }
+ sb.append(c);
+ }
+ }
+ return sb.toString();
+ }
+}
diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/ThreadUtil.java b/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/ThreadUtil.java
new file mode 100644
index 00000000..faf39c49
--- /dev/null
+++ b/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/ThreadUtil.java
@@ -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.common.toolkit;
+
+/**
+ * Thread util.
+ */
+public class ThreadUtil {
+
+ /**
+ * New thread.
+ *
+ * @param runnable
+ * @param name
+ * @param isDaemon
+ * @return {@link Thread}
+ */
+ public static Thread newThread(Runnable runnable, String name, boolean isDaemon) {
+ Thread t = new Thread(null, runnable, name);
+ t.setDaemon(isDaemon);
+ return t;
+ }
+
+ /**
+ * Suspend the current thread.
+ *
+ * @param millis
+ * @return
+ */
+ public static boolean sleep(long millis) {
+ if (millis > 0) {
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException e) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/UserContext.java b/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/UserContext.java
index 8cb19ed5..5b433671 100644
--- a/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/UserContext.java
+++ b/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/UserContext.java
@@ -1,21 +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.toolkit;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Optional;
+
/**
* User context (Transition scheme).
- *
- * @author chen.ma
- * @date 2021/11/17 21:13
*/
public class UserContext {
- private static String username;
+ private static final ThreadLocal USER_THREAD_LOCAL = new ThreadLocal();
- public static void setUserName(String username) {
- UserContext.username = username;
+ public static void setUserInfo(String username, String userRole) {
+ USER_THREAD_LOCAL.set(new User(username, userRole));
}
public static String getUserName() {
- return username;
+ return Optional.ofNullable(USER_THREAD_LOCAL.get()).map(User::getUsername).orElse("");
}
+ public static String getUserRole() {
+ return Optional.ofNullable(USER_THREAD_LOCAL.get()).map(User::getUserRole).orElse("");
+ }
+
+ public static void clear() {
+ USER_THREAD_LOCAL.remove();
+ }
+
+ @Data
+ @NoArgsConstructor
+ @AllArgsConstructor
+ static class User {
+
+ private String username;
+
+ private String userRole;
+ }
}
diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/web/base/Result.java b/hippo4j-common/src/main/java/cn/hippo4j/common/web/base/Result.java
index e9909d59..73237e14 100644
--- a/hippo4j-common/src/main/java/cn/hippo4j/common/web/base/Result.java
+++ b/hippo4j-common/src/main/java/cn/hippo4j/common/web/base/Result.java
@@ -1,3 +1,20 @@
+/*
+ * 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.web.base;
import lombok.Data;
@@ -7,9 +24,6 @@ import java.io.Serializable;
/**
* Result.
- *
- * @author chen.ma
- * @date 2021/3/19 16:12
*/
@Data
@Accessors(chain = true)
@@ -17,16 +31,32 @@ public class Result implements Serializable {
private static final long serialVersionUID = -4408341719434417427L;
+ /**
+ * Correct return code.
+ */
public static final String SUCCESS_CODE = "0";
+ /**
+ * Return code.
+ */
private String code;
+ /**
+ * Message.
+ */
private String message;
+ /**
+ * Response data.
+ */
private T data;
+ /**
+ * Is success.
+ *
+ * @return
+ */
public boolean isSuccess() {
return SUCCESS_CODE.equals(code);
}
-
}
diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/web/base/Results.java b/hippo4j-common/src/main/java/cn/hippo4j/common/web/base/Results.java
index 2adc23bb..f3dd8402 100644
--- a/hippo4j-common/src/main/java/cn/hippo4j/common/web/base/Results.java
+++ b/hippo4j-common/src/main/java/cn/hippo4j/common/web/base/Results.java
@@ -1,13 +1,30 @@
+/*
+ * 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.web.base;
+import cn.hippo4j.common.web.exception.AbstractException;
+import cn.hippo4j.common.web.exception.ErrorCode;
import cn.hippo4j.common.web.exception.ErrorCodeEnum;
-import cn.hippo4j.common.web.exception.ServiceException;
+
+import java.util.Optional;
/**
* Results.
- *
- * @author chen.ma
- * @date 2021/3/19 16:12
*/
public final class Results {
@@ -22,9 +39,17 @@ public final class Results {
.setData(data);
}
- public static Result failure(ServiceException serviceException) {
- return new Result().setCode(ErrorCodeEnum.SERVICE_ERROR.getCode())
- .setMessage(serviceException.getMessage());
+ public static Result failure() {
+ return failure(ErrorCodeEnum.SERVICE_ERROR.getCode(), ErrorCodeEnum.SERVICE_ERROR.getMessage());
+ }
+
+ public static Result failure(AbstractException abstractException) {
+ String errorCode = Optional.ofNullable(abstractException.getErrorCode())
+ .map(ErrorCode::getCode)
+ .orElse(ErrorCodeEnum.SERVICE_ERROR.getCode());
+
+ return new Result().setCode(errorCode)
+ .setMessage(abstractException.getMessage());
}
public static Result failure(Throwable throwable) {
@@ -32,16 +57,13 @@ public final class Results {
.setMessage(throwable.getMessage());
}
- public static Result failure(String code, String message) {
- return new Result()
- .setCode(code)
- .setMessage(message);
+ public static Result failure(ErrorCode errorCode) {
+ return failure(errorCode.getCode(), errorCode.getMessage());
}
- public static Result failure(ErrorCodeEnum errorCode) {
- return new Result()
- .setCode(errorCode.getCode())
- .setMessage(errorCode.getMessage());
+ public static Result failure(String code, String message) {
+ return new Result()
+ .setCode(code)
+ .setMessage(message);
}
-
}
diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/AbstractException.java b/hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/AbstractException.java
new file mode 100644
index 00000000..22ccaec5
--- /dev/null
+++ b/hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/AbstractException.java
@@ -0,0 +1,34 @@
+/*
+ * 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.web.exception;
+
+import lombok.Getter;
+
+/**
+ * Abstract exception.
+ */
+public class AbstractException extends RuntimeException {
+
+ @Getter
+ public final ErrorCode errorCode;
+
+ public AbstractException(String message, Throwable throwable, ErrorCode errorCode) {
+ super(message, throwable);
+ this.errorCode = errorCode;
+ }
+}
diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/ErrorCode.java b/hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/ErrorCode.java
new file mode 100644
index 00000000..4f220641
--- /dev/null
+++ b/hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/ErrorCode.java
@@ -0,0 +1,38 @@
+/*
+ * 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.web.exception;
+
+/**
+ * Error code abstract interface.
+ */
+public interface ErrorCode {
+
+ /**
+ * Get code.
+ *
+ * @return
+ */
+ String getCode();
+
+ /**
+ * Get message.
+ *
+ * @return
+ */
+ String getMessage();
+}
diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/ErrorCodeEnum.java b/hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/ErrorCodeEnum.java
index 85924109..63116639 100644
--- a/hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/ErrorCodeEnum.java
+++ b/hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/ErrorCodeEnum.java
@@ -1,14 +1,32 @@
+/*
+ * 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.web.exception;
/**
* Error code enum.
- *
- * @author chen.ma
- * @date 2021/3/19 16:07
*/
-public enum ErrorCodeEnum {
+public enum ErrorCodeEnum implements ErrorCode {
+ /**
+ * UNKNOWN_ERROR
+ */
UNKNOWN_ERROR {
+
@Override
public String getCode() {
return "1";
@@ -20,7 +38,11 @@ public enum ErrorCodeEnum {
}
},
+ /**
+ * VALIDATION_ERROR
+ */
VALIDATION_ERROR {
+
@Override
public String getCode() {
return "2";
@@ -32,7 +54,11 @@ public enum ErrorCodeEnum {
}
},
+ /**
+ * SERVICE_ERROR
+ */
SERVICE_ERROR {
+
@Override
public String getCode() {
return "3";
@@ -44,7 +70,11 @@ public enum ErrorCodeEnum {
}
},
+ /**
+ * NOT_FOUND
+ */
NOT_FOUND {
+
@Override
public String getCode() {
return "404";
@@ -54,10 +84,21 @@ public enum ErrorCodeEnum {
public String getMessage() {
return "NOT_FOUND";
}
- };
+ },
- public abstract String getCode();
+ /**
+ * LOGIN_TIMEOUT
+ */
+ LOGIN_TIMEOUT {
- public abstract String getMessage();
+ @Override
+ public String getCode() {
+ return "A000004";
+ }
+ @Override
+ public String getMessage() {
+ return "登录时间过长, 请退出重新登录";
+ }
+ }
}
diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/ServiceException.java b/hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/ServiceException.java
index 9527812a..79d03838 100644
--- a/hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/ServiceException.java
+++ b/hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/ServiceException.java
@@ -1,47 +1,67 @@
+/*
+ * 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.web.exception;
-import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Service exception.
- *
- * @author chen.ma
- * @date 2021/3/19 16:14
*/
-@Data
@EqualsAndHashCode(callSuper = true)
-public class ServiceException extends RuntimeException {
+public class ServiceException extends AbstractException {
- private static final long serialVersionUID = -8667394300356618037L;
+ public ServiceException() {
+ this(ErrorCodeEnum.SERVICE_ERROR);
+ }
- private String detail;
+ public ServiceException(ErrorCode errorCode) {
+ this(errorCode.getMessage(), null, errorCode);
+ }
public ServiceException(String message) {
- super(message);
+ this(message, null, ErrorCodeEnum.SERVICE_ERROR);
}
- public ServiceException(String message, String detail) {
- super(message);
- this.detail = detail;
+ public ServiceException(Throwable cause) {
+ this(cause, cause.getMessage());
}
public ServiceException(String message, Throwable cause) {
- super(message, cause);
- this.detail = cause.getMessage();
+ this(message, cause, ErrorCodeEnum.SERVICE_ERROR);
+ }
+
+ public ServiceException(Throwable cause, String message) {
+ this(message, cause, ErrorCodeEnum.SERVICE_ERROR);
}
- public ServiceException(String message, String detail, Throwable cause) {
- super(message, cause);
- this.detail = detail;
+ public ServiceException(Throwable cause, ErrorCode errorCode) {
+ this(errorCode.getMessage(), cause, errorCode);
+ }
+
+ public ServiceException(String message, Throwable cause, ErrorCode errorCode) {
+ super(message, cause, errorCode);
}
@Override
public String toString() {
return "ServiceException{" +
- "message='" + getMessage() + "'," +
- "detail='" + getDetail() + "'" +
+ "code='" + errorCode.getCode() + "'," +
+ "message='" + errorCode.getMessage() + "'" +
'}';
}
-
}
diff --git a/hippo4j-config/.gitignore b/hippo4j-config/.gitignore
deleted file mode 100644
index 549e00a2..00000000
--- a/hippo4j-config/.gitignore
+++ /dev/null
@@ -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/
diff --git a/hippo4j-config/pom.xml b/hippo4j-config/pom.xml
index 2c187126..a183212c 100644
--- a/hippo4j-config/pom.xml
+++ b/hippo4j-config/pom.xml
@@ -2,18 +2,12 @@
4.0.0
-
cn.hippo4j
hippo4j-all
${revision}
-
hippo4j-config
- jar
-
- ${project.artifactId}
- ${project.artifactId}
true
@@ -49,11 +43,7 @@
cn.hippo4j
hippo4j-common
-
-
-
- com.alibaba
- fastjson
+ ${revision}
@@ -68,8 +58,17 @@
cn.hippo4j
- log-record-tool
+ hippo4j-adapter-base
-
+
+ io.netty
+ netty-all
+
+
+
+ org.hibernate.validator
+ hibernate-validator
+
+
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/config/CommonConfig.java b/hippo4j-config/src/main/java/cn/hippo4j/config/config/CommonConfig.java
index 63e5d14a..b8ec6643 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/config/CommonConfig.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/config/CommonConfig.java
@@ -1,21 +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.config;
import cn.hippo4j.common.config.ApplicationContextHolder;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import static cn.hippo4j.common.constant.Constants.AVAILABLE_PROCESSORS;
/**
* Common config.
- *
- * @author chen.ma
- * @date 2021/7/19 21:03
*/
@Configuration
public class CommonConfig {
@Bean
- public ApplicationContextHolder simpleApplicationContextHolder() {
+ @ConditionalOnMissingBean
+ public ApplicationContextHolder hippo4JApplicationContextHolder() {
return new ApplicationContextHolder();
}
+ @Bean
+ @Primary
+ public ThreadPoolTaskExecutor monitorThreadPoolTaskExecutor() {
+ ThreadPoolTaskExecutor monitorThreadPool = new ThreadPoolTaskExecutor();
+ monitorThreadPool.setThreadNamePrefix("server.monitor.executor.");
+ monitorThreadPool.setCorePoolSize(AVAILABLE_PROCESSORS);
+ monitorThreadPool.setMaxPoolSize(AVAILABLE_PROCESSORS << 1);
+ monitorThreadPool.setQueueCapacity(4096);
+ monitorThreadPool.setAllowCoreThreadTimeOut(true);
+ monitorThreadPool.setAwaitTerminationMillis(5000);
+ return monitorThreadPool;
+ }
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/config/MyMetaObjectHandler.java b/hippo4j-config/src/main/java/cn/hippo4j/config/config/MyMetaObjectHandler.java
index 8f28c75c..0a1a2771 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/config/MyMetaObjectHandler.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/config/MyMetaObjectHandler.java
@@ -1,6 +1,23 @@
+/*
+ * 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.config;
-import cn.hippo4j.config.enums.DelEnum;
+import cn.hippo4j.common.enums.DelEnum;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
@@ -10,9 +27,6 @@ import java.util.Date;
/**
* Meta object handler.
- *
- * @author chen.ma
- * @date 2021/7/1 22:43
*/
@Slf4j
@Component
@@ -22,13 +36,11 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
public void insertFill(MetaObject metaObject) {
this.strictInsertFill(metaObject, "gmtCreate", Date.class, new Date());
this.strictInsertFill(metaObject, "gmtModified", Date.class, new Date());
-
this.strictInsertFill(metaObject, "delFlag", Integer.class, DelEnum.NORMAL.getIntCode());
}
@Override
public void updateFill(MetaObject metaObject) {
- this.strictInsertFill(metaObject, "gmtModified", Date.class, new Date());
+ this.strictUpdateFill(metaObject, "gmtModified", Date.class, new Date());
}
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/config/MybatisPlusConfig.java b/hippo4j-config/src/main/java/cn/hippo4j/config/config/MybatisPlusConfig.java
index 2e7c5b92..82455fdd 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/config/MybatisPlusConfig.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/config/MybatisPlusConfig.java
@@ -1,3 +1,20 @@
+/*
+ * 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.config;
import com.baomidou.mybatisplus.annotation.DbType;
@@ -8,9 +25,6 @@ import org.springframework.context.annotation.Configuration;
/**
* Mybatis plus config.
- *
- * @author chen.ma
- * @date 2021/6/29 20:22
*/
@Configuration
public class MybatisPlusConfig {
@@ -21,5 +35,4 @@ public class MybatisPlusConfig {
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/config/NettyServerConfig.java b/hippo4j-config/src/main/java/cn/hippo4j/config/config/NettyServerConfig.java
new file mode 100644
index 00000000..92fdea43
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/config/NettyServerConfig.java
@@ -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.config;
+
+import cn.hippo4j.config.netty.MonitorNettyServer;
+import cn.hippo4j.config.service.biz.HisRunDataService;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Netty server config.
+ */
+@Configuration
+@ConditionalOnProperty(name = "hippo4j.core.monitor.report-type", havingValue = "netty")
+public class NettyServerConfig {
+
+ @Bean
+ public EventLoopGroup bossGroup() {
+ return new NioEventLoopGroup();
+ }
+
+ @Bean
+ public EventLoopGroup workGroup() {
+ return new NioEventLoopGroup();
+ }
+
+ @Bean
+ @SuppressWarnings("all")
+ public MonitorNettyServer monitorNettyServer(ServerBootstrapProperties serverBootstrapProperties,
+ HisRunDataService hisRunDataService,
+ EventLoopGroup bossGroup,
+ EventLoopGroup workGroup) {
+ return new MonitorNettyServer(serverBootstrapProperties, hisRunDataService, bossGroup, workGroup);
+ }
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/config/ServerBootstrapProperties.java b/hippo4j-config/src/main/java/cn/hippo4j/config/config/ServerBootstrapProperties.java
new file mode 100644
index 00000000..d8d855f7
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/config/ServerBootstrapProperties.java
@@ -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.config;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Server bootstrap properties.
+ */
+@Slf4j
+@Getter
+@Setter
+@Configuration
+@ConfigurationProperties(prefix = ServerBootstrapProperties.PREFIX)
+public class ServerBootstrapProperties {
+
+ public final static String PREFIX = "hippo4j.core";
+
+ /**
+ * Whether to start the background task of cleaning up thread pool history data.
+ */
+ private Boolean cleanHistoryDataEnable = Boolean.TRUE;
+
+ /**
+ * Regularly clean up the historical running data of thread pool. unit: minute.
+ */
+ private Integer cleanHistoryDataPeriod = 30;
+
+ /**
+ * Netty server port.
+ */
+ private String nettyServerPort = "8899";
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/controller/ConfigController.java b/hippo4j-config/src/main/java/cn/hippo4j/config/controller/ConfigController.java
index 620d5d3b..5c0fe84f 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/controller/ConfigController.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/controller/ConfigController.java
@@ -1,14 +1,32 @@
+/*
+ * 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.controller;
+import cn.hippo4j.common.constant.Constants;
+import cn.hippo4j.common.model.register.DynamicThreadPoolRegisterWrapper;
+import cn.hippo4j.common.web.base.Result;
+import cn.hippo4j.common.web.base.Results;
import cn.hippo4j.config.model.ConfigAllInfo;
import cn.hippo4j.config.model.ConfigInfoBase;
import cn.hippo4j.config.service.ConfigCacheService;
import cn.hippo4j.config.service.ConfigServletInner;
-import cn.hippo4j.config.toolkit.Md5ConfigUtil;
import cn.hippo4j.config.service.biz.ConfigService;
-import cn.hippo4j.common.constant.Constants;
-import cn.hippo4j.common.web.base.Result;
-import cn.hippo4j.common.web.base.Results;
+import cn.hippo4j.config.toolkit.Md5ConfigUtil;
import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
@@ -22,9 +40,6 @@ import java.util.Map;
/**
* Server configuration controller.
- *
- * @author chen.ma
- * @date 2021/6/20 13:53
*/
@RestController
@AllArgsConstructor
@@ -36,19 +51,18 @@ public class ConfigController {
private final ConfigServletInner configServletInner;
@GetMapping
- public Result detailConfigInfo(
- @RequestParam("tpId") String tpId,
- @RequestParam("itemId") String itemId,
- @RequestParam(value = "namespace") String namespace) {
-
- ConfigAllInfo configAllInfo = configService.findConfigAllInfo(tpId, itemId, namespace);
+ public Result detailConfigInfo(@RequestParam("tpId") String tpId,
+ @RequestParam("itemId") String itemId,
+ @RequestParam("namespace") String namespace,
+ @RequestParam(value = "instanceId", required = false) String instanceId) {
+ ConfigAllInfo configAllInfo = configService.findConfigRecentInfo(tpId, itemId, namespace, instanceId);
return Results.success(configAllInfo);
}
@PostMapping
public Result publishConfig(@RequestParam(value = "identify", required = false) String identify,
@RequestBody ConfigAllInfo config) {
- configService.insertOrUpdate(identify, config);
+ configService.insertOrUpdate(identify, true, config);
return Results.success(true);
}
@@ -56,21 +70,17 @@ public class ConfigController {
@PostMapping("/listener")
public void listener(HttpServletRequest request, HttpServletResponse response) {
request.setAttribute("org.apache.catalina.ASYNC_SUPPORTED", true);
-
String probeModify = request.getParameter(Constants.LISTENING_CONFIGS);
if (StringUtils.isEmpty(probeModify)) {
throw new IllegalArgumentException("invalid probeModify");
}
-
probeModify = URLDecoder.decode(probeModify, Constants.ENCODE);
-
Map clientMd5Map;
try {
clientMd5Map = Md5ConfigUtil.getClientMd5Map(probeModify);
} catch (Throwable e) {
throw new IllegalArgumentException("invalid probeModify");
}
-
configServletInner.doPollingConfig(request, response, clientMd5Map, probeModify.length());
}
@@ -80,8 +90,12 @@ public class ConfigController {
if (StrUtil.isNotBlank(groupKey)) {
ConfigCacheService.removeConfigCache(groupKey);
}
-
return Results.success();
}
+ @PostMapping("/register")
+ public Result register(@RequestBody DynamicThreadPoolRegisterWrapper registerWrapper) {
+ configService.register(registerWrapper);
+ return Results.success();
+ }
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/controller/MonitorController.java b/hippo4j-config/src/main/java/cn/hippo4j/config/controller/MonitorController.java
new file mode 100644
index 00000000..29c64afa
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/controller/MonitorController.java
@@ -0,0 +1,75 @@
+/*
+ * 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.controller;
+
+import cn.hippo4j.common.constant.Constants;
+import cn.hippo4j.common.monitor.Message;
+import cn.hippo4j.common.monitor.MessageWrapper;
+import cn.hippo4j.common.toolkit.MessageConvert;
+import cn.hippo4j.common.web.base.Result;
+import cn.hippo4j.common.web.base.Results;
+import cn.hippo4j.config.model.biz.monitor.MonitorActiveRespDTO;
+import cn.hippo4j.config.model.biz.monitor.MonitorQueryReqDTO;
+import cn.hippo4j.config.model.biz.monitor.MonitorRespDTO;
+import cn.hippo4j.config.monitor.QueryMonitorExecuteChoose;
+import cn.hippo4j.config.service.biz.HisRunDataService;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * Monitor controller.
+ */
+@Slf4j
+@RestController
+@AllArgsConstructor
+@RequestMapping(Constants.BASE_PATH + "/monitor")
+public class MonitorController {
+
+ private final HisRunDataService hisRunDataService;
+
+ private final QueryMonitorExecuteChoose queryMonitorExecuteChoose;
+
+ private final ThreadPoolTaskExecutor monitorThreadPoolTaskExecutor;
+
+ @GetMapping
+ public Result> queryMonitor(MonitorQueryReqDTO reqDTO) {
+ List monitorRespList = hisRunDataService.query(reqDTO);
+ return Results.success(monitorRespList);
+ }
+
+ @PostMapping("/info")
+ public Result queryInfoThreadPoolMonitor(@RequestBody MonitorQueryReqDTO reqDTO) {
+ MonitorActiveRespDTO monitorRespList = hisRunDataService.queryInfoThreadPoolMonitor(reqDTO);
+ return Results.success(monitorRespList);
+ }
+
+ @PostMapping("/last/task/count")
+ public Result queryThreadPoolLastTaskCount(@RequestBody MonitorQueryReqDTO reqDTO) {
+ MonitorRespDTO resultDTO = hisRunDataService.queryThreadPoolLastTaskCount(reqDTO);
+ return Results.success(resultDTO);
+ }
+
+ @PostMapping
+ public Result dataCollect(@RequestBody MessageWrapper messageWrapper) {
+ return hisRunDataService.dataCollect(messageWrapper);
+ }
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/controller/ThreadPoolAdapterController.java b/hippo4j-config/src/main/java/cn/hippo4j/config/controller/ThreadPoolAdapterController.java
new file mode 100644
index 00000000..112630e4
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/controller/ThreadPoolAdapterController.java
@@ -0,0 +1,47 @@
+/*
+ * 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.controller;
+
+import cn.hippo4j.adapter.base.ThreadPoolAdapterCacheConfig;
+import cn.hippo4j.common.web.base.Result;
+import cn.hippo4j.common.web.base.Results;
+import cn.hippo4j.config.service.ThreadPoolAdapterService;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+import static cn.hippo4j.common.constant.Constants.REGISTER_ADAPTER_PATH;
+
+/**
+ * Thread-pool adapter controller.
+ */
+@RestController
+@AllArgsConstructor
+public class ThreadPoolAdapterController {
+
+ private final ThreadPoolAdapterService threadPoolAdapterService;
+
+ @PostMapping(REGISTER_ADAPTER_PATH)
+ public Result registerAdapterThreadPool(@RequestBody List requestParameter) {
+ threadPoolAdapterService.register(requestParameter);
+ return Results.success();
+ }
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/enums/DelEnum.java b/hippo4j-config/src/main/java/cn/hippo4j/config/enums/DelEnum.java
deleted file mode 100644
index df1af116..00000000
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/enums/DelEnum.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package cn.hippo4j.config.enums;
-
-/**
- * Del enum.
- *
- * @author chen.ma
- * @date 2021/3/26 18:45
- */
-public enum DelEnum {
-
- /**
- * Normal state
- */
- NORMAL("0"),
-
- /**
- * Deleted state
- */
- DELETE("1");
-
- private final String statusCode;
-
- DelEnum(String statusCode) {
- this.statusCode = statusCode;
- }
-
- public String getCode() {
- return this.statusCode;
- }
-
- public Integer getIntCode() {
- return Integer.parseInt(this.statusCode);
- }
-
- @Override
- public String toString() {
- return statusCode;
- }
-
-}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/event/AbstractEvent.java b/hippo4j-config/src/main/java/cn/hippo4j/config/event/AbstractEvent.java
new file mode 100644
index 00000000..3c35831a
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/event/AbstractEvent.java
@@ -0,0 +1,40 @@
+/*
+ * 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.event;
+
+import java.io.Serializable;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * An abstract class for event.
+ */
+public abstract class AbstractEvent implements Serializable {
+
+ private static final AtomicLong SEQUENCE = new AtomicLong(0);
+
+ private final long sequence = SEQUENCE.getAndIncrement();
+
+ /**
+ * Event sequence number, which can be used to handle the sequence of events.
+ *
+ * @return sequence num, It's best to make sure it's monotone.
+ */
+ public long sequence() {
+ return sequence;
+ }
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/event/AbstractSlowEvent.java b/hippo4j-config/src/main/java/cn/hippo4j/config/event/AbstractSlowEvent.java
new file mode 100644
index 00000000..48fa70e5
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/event/AbstractSlowEvent.java
@@ -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.event;
+
+/**
+ * Slow event.
+ */
+public abstract class AbstractSlowEvent extends AbstractEvent {
+
+ @Override
+ public long sequence() {
+ return 0;
+ }
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/event/ConfigDataChangeEvent.java b/hippo4j-config/src/main/java/cn/hippo4j/config/event/ConfigDataChangeEvent.java
index 2e3ba3aa..0c3cd1e1 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/event/ConfigDataChangeEvent.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/event/ConfigDataChangeEvent.java
@@ -1,14 +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.config.event;
import org.springframework.util.StringUtils;
/**
* Config data change event.
- *
- * @author chen.ma
- * @date 2021/6/24 23:35
*/
-public class ConfigDataChangeEvent extends Event {
+public class ConfigDataChangeEvent extends AbstractEvent {
public final String tenantId;
@@ -22,11 +36,9 @@ public class ConfigDataChangeEvent extends Event {
if (StringUtils.isEmpty(tenantId) || StringUtils.isEmpty(itemId) || StringUtils.isEmpty(tpId)) {
throw new IllegalArgumentException("DataId is null or group is null");
}
-
this.tenantId = tenantId;
this.itemId = itemId;
this.tpId = tpId;
this.lastModifiedTs = gmtModified;
}
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/event/Event.java b/hippo4j-config/src/main/java/cn/hippo4j/config/event/Event.java
deleted file mode 100644
index c4e8f133..00000000
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/event/Event.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package cn.hippo4j.config.event;
-
-import java.io.Serializable;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * An abstract class for event.
- *
- * @author chen.ma
- * @date 2021/6/23 18:59
- */
-public abstract class Event implements Serializable {
-
- private static final AtomicLong SEQUENCE = new AtomicLong(0);
-
- private final long sequence = SEQUENCE.getAndIncrement();
-
- /**
- * Event sequence number, which can be used to handle the sequence of events.
- *
- * @return sequence num, It's best to make sure it's monotone.
- */
- public long sequence() {
- return sequence;
- }
-
-}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/event/LocalDataChangeEvent.java b/hippo4j-config/src/main/java/cn/hippo4j/config/event/LocalDataChangeEvent.java
index 1cb5a639..652d2daa 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/event/LocalDataChangeEvent.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/event/LocalDataChangeEvent.java
@@ -1,20 +1,34 @@
+/*
+ * 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.event;
/**
* Local data change event.
- *
- * @author chen.ma
- * @date 2021/6/23 19:13
*/
-public class LocalDataChangeEvent extends Event {
+public class LocalDataChangeEvent extends AbstractEvent {
/**
- * 租户+项目+线程池
+ * Tenant + Item + Thread-pool
*/
public final String groupKey;
/**
- * 客户端实例唯一标识
+ * Client instance unique identifier
*/
public final String identify;
@@ -22,5 +36,4 @@ public class LocalDataChangeEvent extends Event {
this.identify = identify;
this.groupKey = groupKey;
}
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/event/SlowEvent.java b/hippo4j-config/src/main/java/cn/hippo4j/config/event/SlowEvent.java
deleted file mode 100644
index deab7c80..00000000
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/event/SlowEvent.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package cn.hippo4j.config.event;
-
-/**
- * Slow event.
- *
- * @author chen.ma
- * @date 2021/6/23 19:05
- */
-public abstract class SlowEvent extends Event {
-
- @Override
- public long sequence() {
- return 0;
- }
-
-}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/ConfigInfoMapper.java b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/ConfigInfoMapper.java
index 7a319c85..32184624 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/ConfigInfoMapper.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/ConfigInfoMapper.java
@@ -1,3 +1,20 @@
+/*
+ * 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.ConfigAllInfo;
@@ -6,9 +23,6 @@ import org.apache.ibatis.annotations.Mapper;
/**
* Config info mapper.
- *
- * @author chen.ma
- * @date 2021/6/29 22:44
*/
@Mapper
public interface ConfigInfoMapper extends BaseMapper {
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/ConfigInstanceMapper.java b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/ConfigInstanceMapper.java
new file mode 100644
index 00000000..39eecfa9
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/ConfigInstanceMapper.java
@@ -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.ConfigInstanceInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * Config instance mapper.
+ */
+@Mapper
+public interface ConfigInstanceMapper extends BaseMapper {
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/DashboardMapper.java b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/DashboardMapper.java
new file mode 100644
index 00000000..d4957d95
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/DashboardMapper.java
@@ -0,0 +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.config.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * Dashboard mapper.
+ */
+@Mapper
+public interface DashboardMapper {
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/HisRunDataMapper.java b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/HisRunDataMapper.java
new file mode 100644
index 00000000..7918828a
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/HisRunDataMapper.java
@@ -0,0 +1,100 @@
+/*
+ * 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.HisRunDataInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import lombok.Data;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+/**
+ * His run data mapper.
+ */
+@Mapper
+public interface HisRunDataMapper extends BaseMapper {
+
+ /**
+ * Query thread pool task sum ranking.
+ *
+ * @param startTime
+ * @param endTime
+ * @return
+ */
+ @Select("SELECT " +
+ "tenant_id, item_id, tp_id, max(completed_task_count) as max_completed_task_count " +
+ "FROM his_run_data " +
+ "where timestamp between #{startTime} and #{endTime} " +
+ "group by tenant_id, item_id, tp_id " +
+ "order by max_completed_task_count desc " +
+ "limit 8")
+ List queryThreadPoolTaskSumRanking(@Param("startTime") Long startTime, @Param("endTime") Long endTime);
+
+ /**
+ * Query thread pool task sum ranking.
+ *
+ * @param startTime
+ * @param endTime
+ * @return
+ */
+ @Select("SELECT " +
+ "tenant_id, item_id, tp_id, max(queue_size) as max_queue_size, max(reject_count) as max_reject_count, max(completed_task_count) as max_completed_task_count " +
+ "FROM his_run_data " +
+ "where timestamp between #{startTime} and #{endTime} " +
+ "group by tenant_id, item_id, tp_id " +
+ "order by max_completed_task_count desc " +
+ "limit 4")
+ List queryThreadPoolMaxRanking(@Param("startTime") Long startTime, @Param("endTime") Long endTime);
+
+ @Data
+ class ThreadPoolTaskRanking {
+
+ /**
+ * Tenant id
+ */
+ private String tenantId;
+
+ /**
+ * Item id
+ */
+ private String itemId;
+
+ /**
+ * Tp id
+ */
+ private String tpId;
+
+ /**
+ * Max completed task count
+ */
+ private Long maxCompletedTaskCount;
+
+ /**
+ * Max queue size
+ */
+ private Long maxQueueSize;
+
+ /**
+ * Max reject count
+ */
+ private Long maxRejectCount;
+ }
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/ItemInfoMapper.java b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/ItemInfoMapper.java
index b8915728..6fbe8617 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/ItemInfoMapper.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/ItemInfoMapper.java
@@ -1,3 +1,20 @@
+/*
+ * 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 com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -6,9 +23,6 @@ import org.apache.ibatis.annotations.Mapper;
/**
* Item info mapper.
- *
- * @author chen.ma
- * @date 2021/6/29 21:53
*/
@Mapper
public interface ItemInfoMapper extends BaseMapper {
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/LogRecordMapper.java b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/LogRecordMapper.java
deleted file mode 100644
index e64d6749..00000000
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/LogRecordMapper.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package cn.hippo4j.config.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import cn.hippo4j.tools.logrecord.model.LogRecordInfo;
-import org.apache.ibatis.annotations.Mapper;
-
-/**
- * Log record mapper.
- *
- * @author chen.ma
- * @date 2021/10/24 21:01
- */
-@Mapper
-public interface LogRecordMapper extends BaseMapper {
-}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/NotifyInfoMapper.java b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/NotifyInfoMapper.java
index a683848b..04f5fe5c 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/NotifyInfoMapper.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/NotifyInfoMapper.java
@@ -1,3 +1,20 @@
+/*
+ * 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.NotifyInfo;
@@ -6,9 +23,6 @@ import org.apache.ibatis.annotations.Mapper;
/**
* Notify info mapper.
- *
- * @author chen.ma
- * @date 2021/11/17 22:04
*/
@Mapper
public interface NotifyInfoMapper extends BaseMapper {
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/OperationLogMapper.java b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/OperationLogMapper.java
new file mode 100644
index 00000000..2c9d60ea
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/OperationLogMapper.java
@@ -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.LogRecordInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * Operation log mapper.
+ */
+@Mapper
+public interface OperationLogMapper extends BaseMapper {
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/TenantInfoMapper.java b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/TenantInfoMapper.java
index ff3cb1e7..f6da4213 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/TenantInfoMapper.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/mapper/TenantInfoMapper.java
@@ -1,3 +1,20 @@
+/*
+ * 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 com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -6,9 +23,6 @@ import org.apache.ibatis.annotations.Mapper;
/**
* Tenant info mapper.
- *
- * @author chen.ma
- * @date 2021/6/29 22:44
*/
@Mapper
public interface TenantInfoMapper extends BaseMapper {
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/CacheItem.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/CacheItem.java
index 8f7af161..c397fed3 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/CacheItem.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/CacheItem.java
@@ -1,3 +1,20 @@
+/*
+ * 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 cn.hippo4j.common.toolkit.Md5Util;
@@ -9,9 +26,6 @@ import lombok.Setter;
/**
* Cache item.
- *
- * @author chen.ma
- * @date 2021/6/24 21:23
*/
@Getter
@Setter
@@ -41,5 +55,4 @@ public class CacheItem {
this.md5 = Md5Util.getTpContentMd5(configAllInfo);
this.groupKey = SingletonRepository.DataIdGroupIdCache.getSingleton(groupKey);
}
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigAllInfo.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigAllInfo.java
index 7792cfc9..5c8f74e3 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigAllInfo.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigAllInfo.java
@@ -1,46 +1,60 @@
+/*
+ * 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.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.annotation.JSONField;
+import cn.hippo4j.common.model.ThreadPoolParameter;
+import cn.hippo4j.common.toolkit.JSONUtil;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
-import cn.hippo4j.common.model.PoolParameter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.util.Date;
/**
* Config all info.
- *
- * @author chen.ma
- * @date 2021/6/20 15:14
*/
@Data
@TableName("config")
-public class ConfigAllInfo extends ConfigInfo implements PoolParameter {
+public class ConfigAllInfo extends ConfigInfo implements ThreadPoolParameter {
private static final long serialVersionUID = -2417394244017463665L;
/**
* desc
*/
- @JSONField(serialize = false)
+ @JsonIgnore
@TableField(exist = false, fill = FieldFill.UPDATE)
private String desc;
/**
* gmtCreate
*/
- @JSONField(serialize = false)
+ @JsonIgnore
@TableField(fill = FieldFill.INSERT)
private Date gmtCreate;
/**
* gmtModified
*/
- @JSONField(serialize = false)
+ @JsonIgnore
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date gmtModified;
@@ -48,13 +62,12 @@ public class ConfigAllInfo extends ConfigInfo implements PoolParameter {
* delFlag
*/
@TableLogic
- @JSONField(serialize = false)
+ @JsonIgnore
@TableField(fill = FieldFill.INSERT)
private Integer delFlag;
@Override
public String toString() {
- return JSON.toJSONString(this);
+ return JSONUtil.toJSONString(this);
}
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigInfo.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigInfo.java
index df96539e..7bafc089 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigInfo.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigInfo.java
@@ -1,16 +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.model;
import lombok.Data;
/**
* Config info.
- *
- * @author chen.ma
- * @date 2021/6/20 15:59
*/
@Data
public class ConfigInfo extends ConfigInfoBase {
private static final long serialVersionUID = -3504960832191834675L;
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigInfoBase.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigInfoBase.java
index ba11acce..60eddf3d 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigInfoBase.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigInfoBase.java
@@ -1,17 +1,32 @@
+/*
+ * 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.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable;
/**
* Config info base.
- *
- * @author chen.ma
- * @date 2021/6/20 14:05
*/
@Data
public class ConfigInfoBase implements Serializable {
@@ -42,11 +57,13 @@ public class ConfigInfoBase implements Serializable {
/**
* coreSize
*/
+ @JsonAlias("corePoolSize")
private Integer coreSize;
/**
* maxSize
*/
+ @JsonAlias("maximumPoolSize")
private Integer maxSize;
/**
@@ -84,16 +101,20 @@ public class ConfigInfoBase implements Serializable {
*/
private Integer livenessAlarm;
+ /**
+ * allowCoreThreadTimeOut
+ */
+ private Integer allowCoreThreadTimeOut;
+
/**
* MD5
*/
- @JSONField(serialize = false)
+ @JsonIgnore
private String md5;
/**
* content
*/
- @JSONField(serialize = false)
+ @JsonIgnore
private String content;
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigInstanceInfo.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigInstanceInfo.java
new file mode 100644
index 00000000..7d4b52a1
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigInstanceInfo.java
@@ -0,0 +1,73 @@
+/*
+ * 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 lombok.Data;
+
+import java.util.Date;
+
+/**
+ * Config instance info.
+ */
+@Data
+@TableName("inst_config")
+public class ConfigInstanceInfo {
+
+ /**
+ * ID
+ */
+ @TableId(type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * tenantId
+ */
+ private String tenantId;
+
+ /**
+ * itemId
+ */
+ private String itemId;
+
+ /**
+ * tpId
+ */
+ private String tpId;
+
+ /**
+ * instanceId
+ */
+ private String instanceId;
+
+ /**
+ * MD5
+ */
+ private String md5;
+
+ /**
+ * content
+ */
+ private String content;
+
+ /**
+ * gmtCreate
+ */
+ @TableField(fill = FieldFill.INSERT)
+ private Date gmtCreate;
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/HisRunDataInfo.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/HisRunDataInfo.java
new file mode 100644
index 00000000..80c9f758
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/HisRunDataInfo.java
@@ -0,0 +1,119 @@
+/*
+ * 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 lombok.Data;
+
+import java.util.Date;
+
+/**
+ * His run data info.
+ */
+@Data
+@TableName("his_run_data")
+public class HisRunDataInfo {
+
+ /**
+ * id
+ */
+ @TableId(type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 租户id
+ */
+ private String tenantId;
+
+ /**
+ * 项目id
+ */
+ private String itemId;
+
+ /**
+ * 实例id
+ */
+ private String instanceId;
+
+ /**
+ * 线程池id
+ */
+ private String tpId;
+
+ /**
+ * 当前负载
+ */
+ private Long currentLoad;
+
+ /**
+ * 峰值负载
+ */
+ private Long peakLoad;
+
+ /**
+ * 线程数
+ */
+ private Long poolSize;
+
+ /**
+ * 活跃线程数
+ */
+ private Long activeSize;
+
+ /**
+ * 队列容量
+ */
+ private Long queueCapacity;
+
+ /**
+ * 队列元素
+ */
+ private Long queueSize;
+
+ /**
+ * 队列剩余容量
+ */
+ private Long queueRemainingCapacity;
+
+ /**
+ * 已完成任务计数
+ */
+ private Long completedTaskCount;
+
+ /**
+ * 拒绝次数
+ */
+ private Long rejectCount;
+
+ /**
+ * 时间戳
+ */
+ private Long timestamp;
+
+ /**
+ * 创建时间
+ */
+ @TableField(fill = FieldFill.INSERT)
+ private Date gmtCreate;
+
+ /**
+ * 修改时间
+ */
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private Date gmtModified;
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/ItemInfo.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/ItemInfo.java
index cedb767e..90995085 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/ItemInfo.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/ItemInfo.java
@@ -1,3 +1,20 @@
+/*
+ * 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.*;
@@ -7,9 +24,6 @@ import java.util.Date;
/**
* Item info.
- *
- * @author chen.ma
- * @date 2021/6/29 21:53
*/
@Data
@TableName("item")
@@ -64,5 +78,4 @@ public class ItemInfo {
@TableLogic
@TableField(fill = FieldFill.INSERT)
private Integer delFlag;
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/LogRecordInfo.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/LogRecordInfo.java
new file mode 100644
index 00000000..5edef209
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/LogRecordInfo.java
@@ -0,0 +1,85 @@
+/*
+ * 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.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+/**
+ * Log record info.
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@TableName("log_record_info")
+public class LogRecordInfo {
+
+ /**
+ * ID
+ */
+ @TableId(type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * Tenant
+ */
+ private String tenant;
+
+ /**
+ * Biz key
+ */
+ private String bizKey;
+
+ /**
+ * Biz no
+ */
+ private String bizNo;
+
+ /**
+ * Operator
+ */
+ private String operator;
+
+ /**
+ * Action
+ */
+ private String action;
+
+ /**
+ * Category
+ */
+ private String category;
+
+ /**
+ * Detail
+ */
+ private String detail;
+
+ /**
+ * Create time
+ */
+ private Date createTime;
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/NotifyInfo.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/NotifyInfo.java
index 0fde98f0..aaabc6e8 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/NotifyInfo.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/NotifyInfo.java
@@ -1,17 +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.model;
-import com.baomidou.mybatisplus.annotation.FieldFill;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
/**
- * 通知管理.
- *
- * @author chen.ma
- * @date 2021/11/17 22:03
+ * Notify info.
*/
@Data
@TableName("notify")
@@ -20,6 +32,7 @@ public class NotifyInfo {
/**
* id
*/
+ @TableId(type = IdType.AUTO)
private Long id;
/**
@@ -85,5 +98,4 @@ public class NotifyInfo {
*/
@TableField(fill = FieldFill.INSERT)
private Integer delFlag;
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/TenantInfo.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/TenantInfo.java
index 077df416..768d988b 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/TenantInfo.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/TenantInfo.java
@@ -1,3 +1,20 @@
+/*
+ * 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.*;
@@ -7,9 +24,6 @@ import java.util.Date;
/**
* Tenant info.
- *
- * @author chen.ma
- * @date 2021/6/29 22:04
*/
@Data
@TableName("tenant")
@@ -58,5 +72,4 @@ public class TenantInfo {
*/
@TableField(fill = FieldFill.INSERT)
private Integer delFlag;
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/adapter/ThreadPoolAdapterReqDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/adapter/ThreadPoolAdapterReqDTO.java
new file mode 100644
index 00000000..e55b4571
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/adapter/ThreadPoolAdapterReqDTO.java
@@ -0,0 +1,69 @@
+/*
+ * 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.adapter;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * Thread-pool adapter req DTO.
+ */
+@Data
+public class ThreadPoolAdapterReqDTO {
+
+ /**
+ * Mark
+ */
+ private String mark;
+
+ /**
+ * Tenant
+ */
+ private String tenant;
+
+ /**
+ * Item
+ */
+ private String item;
+
+ /**
+ * Thread pool key
+ */
+ private String threadPoolKey;
+
+ /**
+ * Identify
+ */
+ private String identify;
+
+ /**
+ * Core pool size
+ */
+ private Integer corePoolSize;
+
+ /**
+ * Maximum pool size
+ */
+ private Integer maximumPoolSize;
+
+ /**
+ * Client address list
+ */
+ private List clientAddressList;
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/adapter/ThreadPoolAdapterRespDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/adapter/ThreadPoolAdapterRespDTO.java
new file mode 100644
index 00000000..bf13e0d4
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/adapter/ThreadPoolAdapterRespDTO.java
@@ -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.model.biz.adapter;
+
+import lombok.Data;
+
+/**
+ * Thread-pool adapter resp DTO.
+ */
+@Data
+public class ThreadPoolAdapterRespDTO {
+
+ /**
+ * Identify
+ */
+ private String identify;
+
+ /**
+ * Active
+ */
+ private String active;
+
+ /**
+ * Client address
+ */
+ private String clientAddress;
+
+ /**
+ * Thread pool key
+ */
+ private String threadPoolKey;
+
+ /**
+ * Core size
+ */
+ private Integer coreSize;
+
+ /**
+ * Maximum size
+ */
+ private Integer maximumSize;
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemQueryReqDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemQueryReqDTO.java
index bec92e4a..570125d9 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemQueryReqDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemQueryReqDTO.java
@@ -1,3 +1,20 @@
+/*
+ * 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.item;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -5,31 +22,32 @@ import lombok.Data;
/**
* Item query req dto.
- *
- * @author chen.ma
- * @date 2021/6/29 22:28
*/
@Data
public class ItemQueryReqDTO extends Page {
/**
- * tenantId
+ * Tenant id
*/
private String tenantId;
/**
- * itemId
+ * Item id
*/
private String itemId;
/**
- * itemName
+ * Item name
*/
private String itemName;
/**
- * owner
+ * Owner
*/
private String owner;
+ /**
+ * Desc
+ */
+ private Boolean desc;
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemRespDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemRespDTO.java
index 303db8ee..706c56b9 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemRespDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemRespDTO.java
@@ -1,3 +1,20 @@
+/*
+ * 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.item;
import com.fasterxml.jackson.annotation.JsonFormat;
@@ -7,9 +24,6 @@ import java.util.Date;
/**
* Item resp dto.
- *
- * @author chen.ma
- * @date 2021/6/29 21:15
*/
@Data
public class ItemRespDTO {
@@ -20,38 +34,38 @@ public class ItemRespDTO {
private Integer id;
/**
- * tenantId
+ * Tenant id
*/
private String tenantId;
/**
- * itemId
+ * Item id
*/
private String itemId;
/**
- * itemName
+ * Item name
*/
private String itemName;
/**
- * itemDesc
+ * Item desc
*/
private String itemDesc;
/**
- * owner
+ * Owner
*/
private String owner;
/**
- * gmtCreate
+ * Gmt create
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtCreate;
/**
- * gmtModified
+ * Gmt modified
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtModified;
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemSaveReqDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemSaveReqDTO.java
index 25acbdca..e7b92784 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemSaveReqDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemSaveReqDTO.java
@@ -1,39 +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.config.model.biz.item;
import lombok.Data;
+import javax.validation.constraints.Pattern;
+
/**
* Item save req dto.
- *
- * @author chen.ma
- * @date 2021/6/29 22:05
*/
@Data
public class ItemSaveReqDTO {
/**
- * tenantId
+ * Tenant id
*/
+ @Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
private String tenantId;
/**
- * itemId
+ * Item id
*/
+ @Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
private String itemId;
/**
- * itemName
+ * Item name
*/
private String itemName;
/**
- * itemDesc
+ * Item desc
*/
private String itemDesc;
/**
- * owner
+ * Owner
*/
private String owner;
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemUpdateReqDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemUpdateReqDTO.java
index 455c44d2..1d85d6d6 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemUpdateReqDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemUpdateReqDTO.java
@@ -1,12 +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.config.model.biz.item;
import lombok.Data;
/**
* Item update req dto.
- *
- * @author chen.ma
- * @date 2021/6/29 22:05
*/
@Data
public class ItemUpdateReqDTO {
@@ -20,5 +34,4 @@ public class ItemUpdateReqDTO {
private String itemDesc;
private String owner;
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/log/LogRecordQueryReqDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/log/LogRecordQueryReqDTO.java
index 2bbb7518..757a840b 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/log/LogRecordQueryReqDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/log/LogRecordQueryReqDTO.java
@@ -1,3 +1,20 @@
+/*
+ * 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.log;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -5,26 +22,22 @@ import lombok.Data;
/**
* 日志记录查询.
- *
- * @author chen.ma
- * @date 2021/11/17 21:43
*/
@Data
public class LogRecordQueryReqDTO extends Page {
/**
- * 业务标识
+ * Biz no
*/
private String bizNo;
/**
- * 业务类型
+ * Category
*/
private String category;
/**
- * 操作人
+ * Operator
*/
private String operator;
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/log/LogRecordRespDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/log/LogRecordRespDTO.java
index c904b893..ac881619 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/log/LogRecordRespDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/log/LogRecordRespDTO.java
@@ -1,3 +1,20 @@
+/*
+ * 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.log;
import com.fasterxml.jackson.annotation.JsonFormat;
@@ -6,36 +23,33 @@ import lombok.Data;
import java.util.Date;
/**
- * 日志记录返回.
- *
- * @author chen.ma
- * @date 2021/11/17 21:37
+ * Log record resp DTO.
*/
@Data
public class LogRecordRespDTO {
/**
- * 业务标识
+ * Biz no
*/
private String bizNo;
/**
- * 日志内容
+ * Action
*/
private String action;
/**
- * 操作人
+ * Operator
*/
private String operator;
/**
- * 业务类型
+ * Category
*/
private String category;
/**
- * gmtCreate
+ * Gmt create
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/monitor/MonitorActiveRespDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/monitor/MonitorActiveRespDTO.java
new file mode 100644
index 00000000..83c4b6b2
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/monitor/MonitorActiveRespDTO.java
@@ -0,0 +1,78 @@
+/*
+ * 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.monitor;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+/**
+ * Monitor active resp dto.
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class MonitorActiveRespDTO {
+
+ /**
+ * Times
+ */
+ private List times;
+
+ /**
+ * Pool size list
+ */
+ private List poolSizeList;
+
+ /**
+ * Active size list
+ */
+ private List activeSizeList;
+
+ /**
+ * Queue size list
+ */
+ private List queueSizeList;
+
+ /**
+ * Completed task count list
+ */
+ private List completedTaskCountList;
+
+ /**
+ * Reject count list
+ */
+ private List rejectCountList;
+
+ /**
+ * Queue remaining capacity list
+ */
+ private List queueRemainingCapacityList;
+
+ /**
+ * Current load list
+ */
+ private List currentLoadList;
+
+ /**
+ * Queue capacity list
+ */
+ private List queueCapacityList;
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/monitor/MonitorQueryReqDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/monitor/MonitorQueryReqDTO.java
new file mode 100644
index 00000000..f5e4e119
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/monitor/MonitorQueryReqDTO.java
@@ -0,0 +1,47 @@
+/*
+ * 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.monitor;
+
+import lombok.Data;
+
+/**
+ * Monitor query req DTO.
+ */
+@Data
+public class MonitorQueryReqDTO {
+
+ /**
+ * Tenant id
+ */
+ private String tenantId;
+
+ /**
+ * Item id
+ */
+ private String itemId;
+
+ /**
+ * Thread-pool id
+ */
+ private String tpId;
+
+ /**
+ * Instance id
+ */
+ private String instanceId;
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/monitor/MonitorRespDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/monitor/MonitorRespDTO.java
new file mode 100644
index 00000000..3c2215ee
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/monitor/MonitorRespDTO.java
@@ -0,0 +1,92 @@
+/*
+ * 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.monitor;
+
+import lombok.Data;
+
+/**
+ * Monitor resp DTO.
+ */
+@Data
+public class MonitorRespDTO {
+
+ /**
+ * Tenant id
+ */
+ private String tenantId;
+
+ /**
+ * Item id
+ */
+ private String itemId;
+
+ /**
+ * Instance id
+ */
+ private String instanceId;
+
+ /**
+ * Completed task count
+ */
+ private String completedTaskCount;
+
+ /**
+ * Thread-pool id
+ */
+ private String tpId;
+
+ /**
+ * Current load
+ */
+ private String currentLoad;
+
+ /**
+ * Peak load
+ */
+ private String peakLoad;
+
+ /**
+ * Pool size
+ */
+ private String poolSize;
+
+ /**
+ * Active size
+ */
+ private String activeSize;
+
+ /**
+ * Queue capacity
+ */
+ private String queueCapacity;
+
+ /**
+ * Queue size
+ */
+ private String queueSize;
+
+ /**
+ * Queue remaining capacity
+ */
+ private String queueRemainingCapacity;
+
+ /**
+ * Reject count
+ */
+ private String rejectCount;
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyListRespDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyListRespDTO.java
index ce34d053..f22fff9d 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyListRespDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyListRespDTO.java
@@ -1,3 +1,20 @@
+/*
+ * 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.notify;
import cn.hippo4j.config.model.NotifyInfo;
@@ -8,22 +25,18 @@ import java.util.List;
/**
* Notify list resp dto.
- *
- * @author chen.ma
- * @date 2021/11/17 22:53
*/
@Data
@AllArgsConstructor
public class NotifyListRespDTO {
/**
- * 通知 Key
+ * Notify key
*/
private String notifyKey;
/**
- * 通知配置
+ * Notify list
*/
private List notifyList;
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyQueryReqDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyQueryReqDTO.java
index c9b14954..259bd0bb 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyQueryReqDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyQueryReqDTO.java
@@ -1,3 +1,20 @@
+/*
+ * 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.notify;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -6,32 +23,28 @@ import lombok.Data;
import java.util.List;
/**
- * Notify query req dto.
- *
- * @author chen.ma
- * @date 2021/11/17 22:52
+ * Notify query req DTO.
*/
@Data
public class NotifyQueryReqDTO extends Page {
/**
- * groupKeys
+ * Group keys
*/
private List groupKeys;
/**
- * 租户id
+ * Tenant id
*/
private String tenantId;
/**
- * 项目id
+ * Item id
*/
private String itemId;
/**
- * 线程池id
+ * Thread-pool id
*/
private String tpId;
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyReqDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyReqDTO.java
index f97aa15e..3c5a41b4 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyReqDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyReqDTO.java
@@ -1,9 +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.config.model.biz.notify;
import lombok.Data;
/**
- * 消息通知入参实体.
+ * Notify req DTO.
*
* @author chen.ma
* @date 2021/11/18 20:15
@@ -12,53 +29,62 @@ import lombok.Data;
public class NotifyReqDTO {
/**
- * id
+ * ID
*/
private String id;
/**
- * 租户id
+ * Ids
+ */
+ private String ids;
+
+ /**
+ * Tenant id
*/
private String tenantId;
/**
- * 项目id
+ * Item id
*/
private String itemId;
/**
- * 线程池id
+ * Thread-pool id
*/
private String tpId;
/**
- * 通知平台
+ * Platform
*/
private String platform;
/**
- * 通知类型
+ * Config type
*/
- private String type;
+ private Boolean configType;
/**
- * 密钥
+ * Alarm type
+ */
+ private Boolean alarmType;
+
+ /**
+ * Secret key
*/
private String secretKey;
/**
- * 报警间隔
+ * Interval
*/
private Integer interval;
/**
- * 接收者
+ * Receives
*/
private String receives;
/**
- * 是否启用
+ * Enable
*/
private Integer enable;
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyRespDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyRespDTO.java
index c3cf7771..b10c7899 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyRespDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyRespDTO.java
@@ -1,64 +1,107 @@
+/*
+ * 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.notify;
+import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
+import java.util.Date;
+
/**
- * 消息通知返回.
- *
- * @author chen.ma
- * @date 2021/11/18 20:07
+ * Notify resp DTO.
*/
@Data
public class NotifyRespDTO {
/**
- * id
+ * ID
*/
private String id;
/**
- * 租户id
+ * Ids
+ */
+ private String ids;
+
+ /**
+ * Tenant id
*/
private String tenantId;
/**
- * 项目id
+ * Item id
*/
private String itemId;
/**
- * 线程池id
+ * Thread-pool id
*/
private String tpId;
/**
- * 通知平台
+ * Platform
*/
private String platform;
/**
- * 通知类型
+ * Type
*/
private String type;
/**
- * 密钥
+ * Config type
+ */
+ private Boolean configType;
+
+ /**
+ * Alarm type
+ */
+ private Boolean alarmType;
+
+ /**
+ * Secret key
*/
private String secretKey;
/**
- * 报警间隔
+ * Interval
*/
private Integer interval;
/**
- * 接收者
+ * Receives
*/
private String receives;
/**
- * 是否启用
+ * Enable
*/
private Integer enable;
+ /**
+ * gmtCreate
+ */
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+ private Date gmtCreate;
+
+ /**
+ * gmtModified
+ */
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+ private Date gmtModified;
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantQueryReqDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantQueryReqDTO.java
index bd76dc6c..aeb674f4 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantQueryReqDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantQueryReqDTO.java
@@ -1,30 +1,48 @@
+/*
+ * 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.tenant;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
/**
- * Tenant query req dto.
- *
- * @author chen.ma
- * @date 2021/6/29 22:28
+ * Tenant query req DTO.
*/
@Data
public class TenantQueryReqDTO extends Page {
/**
- * tenantId
+ * Tenant id
*/
private String tenantId;
/**
- * tenantName
+ * Tenant name
*/
private String tenantName;
/**
- * owner
+ * Owner
*/
private String owner;
+ /**
+ * Desc
+ */
+ private Boolean desc;
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantRespDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantRespDTO.java
index 0c9982c7..aec3e3be 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantRespDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantRespDTO.java
@@ -1,3 +1,20 @@
+/*
+ * 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.tenant;
import com.fasterxml.jackson.annotation.JsonFormat;
@@ -6,10 +23,7 @@ import lombok.Data;
import java.util.Date;
/**
- * Tenant resp dto.
- *
- * @author chen.ma
- * @date 2021/6/29 21:16
+ * Tenant resp DTO.
*/
@Data
public class TenantRespDTO {
@@ -20,33 +34,33 @@ public class TenantRespDTO {
private Integer id;
/**
- * tenantId
+ * Tenant id
*/
private String tenantId;
/**
- * tenantName
+ * Tenant name
*/
private String tenantName;
/**
- * tenantDesc
+ * Tenant desc
*/
private String tenantDesc;
/**
- * owner
+ * Owner
*/
private String owner;
/**
- * gmtCreate
+ * Gmt create
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtCreate;
/**
- * gmtModified
+ * Gmt modified
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtModified;
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantSaveReqDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantSaveReqDTO.java
index de6d0540..d857746e 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantSaveReqDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantSaveReqDTO.java
@@ -1,34 +1,51 @@
+/*
+ * 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.tenant;
import lombok.Data;
+import javax.validation.constraints.Pattern;
+
/**
- * Tenant save req dto.
- *
- * @author chen.ma
- * @date 2021/6/29 20:40
+ * Tenant save req DTO.
*/
@Data
public class TenantSaveReqDTO {
/**
- * tenantId
+ * Tenant id
*/
+ @Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
private String tenantId;
/**
- * tenantName
+ * Tenant mame
*/
+ @Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
private String tenantName;
/**
- * tenantDesc
+ * Tenant desc
*/
private String tenantDesc;
/**
- * owner
+ * Owner
*/
private String owner;
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantUpdateReqDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantUpdateReqDTO.java
index 884b54b8..48630991 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantUpdateReqDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantUpdateReqDTO.java
@@ -1,45 +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.config.model.biz.tenant;
-import com.alibaba.fastjson.JSON;
+import cn.hippo4j.common.toolkit.JSONUtil;
import lombok.Data;
/**
- * Tenant save req dto.
- *
- * @author chen.ma
- * @date 2021/6/29 20:40
+ * Tenant save req DTO.
*/
@Data
public class TenantUpdateReqDTO {
/**
- * id
+ * ID
*/
private Long id;
/**
- * tenantId
+ * Tenant id
*/
private String tenantId;
/**
- * tenantName
+ * Tenant name
*/
private String tenantName;
/**
- * tenantDesc
+ * Tenant desc
*/
private String tenantDesc;
/**
- * owner
+ * Owner
*/
private String owner;
@Override
public String toString() {
- return JSON.toJSONString(this);
+ return JSONUtil.toJSONString(this);
}
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolDelReqDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolDelReqDTO.java
index b4e8b18e..3c638c9b 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolDelReqDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolDelReqDTO.java
@@ -1,29 +1,42 @@
+/*
+ * 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;
/**
* ThreadPool del req dto.
- *
- * @author chen.ma
- * @date 2021/11/11 21:40
*/
@Data
public class ThreadPoolDelReqDTO {
/**
- * tenantId
+ * Tenant id
*/
private String tenantId;
/**
- * itemId
+ * Item id
*/
private String itemId;
/**
- * tpId
+ * Thread-pool id
*/
private String tpId;
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolQueryReqDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolQueryReqDTO.java
index 19027869..1864cfc4 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolQueryReqDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolQueryReqDTO.java
@@ -1,30 +1,48 @@
+/*
+ * 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
/**
- * Thread pool query req dto.
- *
- * @author chen.ma
- * @date 2021/6/30 21:22
+ * Thread pool query req DTO.
*/
@Data
public class ThreadPoolQueryReqDTO extends Page {
/**
- * tenantId
+ * Tenant id
*/
private String tenantId;
/**
- * itemId
+ * Item id
*/
private String itemId;
/**
- * tpId
+ * Thread pool id
*/
private String tpId;
+ /**
+ * Desc
+ */
+ private Boolean desc;
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolRespDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolRespDTO.java
index 3c564e4f..3c4fa030 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolRespDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolRespDTO.java
@@ -1,3 +1,20 @@
+/*
+ * 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;
@@ -6,92 +23,94 @@ import lombok.Data;
import java.util.Date;
/**
- * Thread pool resp dto.
- *
- * @author chen.ma
- * @date 2021/6/30 21:23
+ * Thread pool resp DTO.
*/
@Data
public class ThreadPoolRespDTO {
/**
- * id
+ * ID
*/
private String id;
/**
- * tenantId
+ * Tenant id
*/
private String tenantId;
/**
- * itemId
+ * Iem id
*/
private String itemId;
/**
- * tpId
+ * Thread-pool id
*/
private String tpId;
/**
- * coreSize
+ * Core size
*/
private Integer coreSize;
/**
- * maxSize
+ * Max size
*/
private Integer maxSize;
/**
- * queueType
+ * Queue type
*/
private Integer queueType;
/**
- * queueName
+ * Queue name
*/
private String queueName;
/**
- * capacity
+ * Capacity
*/
private Integer capacity;
/**
- * keepAliveTime
+ * Keep alive time
*/
private Integer keepAliveTime;
/**
- * isAlarm
+ * Is alarm
*/
private Integer isAlarm;
/**
- * capacityAlarm
+ * Capacity alarm
*/
private Integer capacityAlarm;
/**
- * livenessAlarm
+ * Liveness alarm
*/
private Integer livenessAlarm;
/**
- * rejectedType
+ * Rejected type
*/
private Integer rejectedType;
/**
- * gmtCreate
+ * AllowCore thread timeout
+ */
+ private Integer allowCoreThreadTimeOut;
+
+ /**
+ * Gmt create
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtCreate;
/**
- * gmtModified
+ * Gmt modified
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date gmtModified;
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolSaveOrUpdateReqDTO.java b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolSaveOrUpdateReqDTO.java
index f54c9330..fe25cdaf 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolSaveOrUpdateReqDTO.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolSaveOrUpdateReqDTO.java
@@ -1,74 +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 lombok.Data;
+import javax.validation.constraints.Pattern;
+
/**
- * Thread pool save or update req dto.
- *
- * @author chen.ma
- * @date 2021/6/30 21:23
+ * Thread pool save or update req DTO.
*/
@Data
public class ThreadPoolSaveOrUpdateReqDTO {
/**
- * tenantId
+ * TenantId
*/
+ @Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
private String tenantId;
/**
- * TpId
+ * Thread-pool id
*/
+ @Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
private String tpId;
/**
- * ItemId
+ * Item id
*/
+ @Pattern(regexp = "^((?!\\+).)*$", message = "租户、项目、线程池 ID 包含+号")
private String itemId;
/**
- * coreSize
+ * Core size
*/
private Integer coreSize;
/**
- * maxSize
+ * Max size
*/
private Integer maxSize;
/**
- * queueType
+ * Queue type
*/
private Integer queueType;
/**
- * capacity
+ * Capacity
*/
private Integer capacity;
/**
- * keepAliveTime
+ * Keep alive time
*/
private Integer keepAliveTime;
/**
- * isAlarm
+ * Is alarm
*/
private Integer isAlarm;
/**
- * capacityAlarm
+ * Capacity alarm
*/
private Integer capacityAlarm;
/**
- * livenessAlarm
+ * Liveness alarm
*/
private Integer livenessAlarm;
/**
- * rejectedType
+ * Rejected type
*/
private Integer rejectedType;
+ /**
+ * Allow core thread timeout
+ */
+ private Integer allowCoreThreadTimeOut;
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/AbstractMonitorDataExecuteStrategy.java b/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/AbstractMonitorDataExecuteStrategy.java
new file mode 100644
index 00000000..ae0dc032
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/AbstractMonitorDataExecuteStrategy.java
@@ -0,0 +1,40 @@
+/*
+ * 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.monitor;
+
+import cn.hippo4j.common.monitor.Message;
+
+/**
+ * Abstract monitor data execute strategy.
+ */
+public abstract class AbstractMonitorDataExecuteStrategy {
+
+ /**
+ * Mark.
+ *
+ * @return
+ */
+ public abstract String mark();
+
+ /**
+ * Execute.
+ *
+ * @param message
+ */
+ public abstract void execute(T message);
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/DefaultMonitorDataResolver.java b/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/DefaultMonitorDataResolver.java
new file mode 100644
index 00000000..97b909ac
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/DefaultMonitorDataResolver.java
@@ -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.config.monitor;
+
+import cn.hippo4j.common.monitor.Message;
+import cn.hippo4j.common.monitor.MessageTypeEnum;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * Default monitor data resolver.
+ */
+@Slf4j
+@Component
+public class DefaultMonitorDataResolver extends AbstractMonitorDataExecuteStrategy {
+
+ @Override
+ public String mark() {
+ return MessageTypeEnum.DEFAULT.name();
+ }
+
+ @Override
+ public void execute(Message message) {
+ log.warn("There is no suitable monitoring data storage actuator.");
+ }
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/QueryMonitorExecuteChoose.java b/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/QueryMonitorExecuteChoose.java
new file mode 100644
index 00000000..5aedb340
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/QueryMonitorExecuteChoose.java
@@ -0,0 +1,81 @@
+/*
+ * 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.monitor;
+
+import cn.hippo4j.common.config.ApplicationContextHolder;
+import cn.hippo4j.common.monitor.Message;
+import cn.hippo4j.common.monitor.MessageTypeEnum;
+import com.google.common.collect.Maps;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+/**
+ * Query monitor execute choose.
+ */
+@Component
+public class QueryMonitorExecuteChoose implements CommandLineRunner {
+
+ /**
+ * Storage monitoring data execution container.
+ */
+ private Map monitorDataExecuteStrategyChooseMap = Maps.newHashMap();
+
+ /**
+ * Choose by {@link cn.hippo4j.common.monitor.MessageTypeEnum}.
+ *
+ * @param messageTypeEnum {@link cn.hippo4j.common.monitor.MessageTypeEnum}
+ * @return
+ */
+ public AbstractMonitorDataExecuteStrategy choose(MessageTypeEnum messageTypeEnum) {
+ return choose(messageTypeEnum.name());
+ }
+
+ /**
+ * Choose by mark type.
+ *
+ * @param markType {@link cn.hippo4j.common.monitor.MessageTypeEnum#name()}
+ * @return
+ */
+ public AbstractMonitorDataExecuteStrategy choose(String markType) {
+ AbstractMonitorDataExecuteStrategy executeStrategy = monitorDataExecuteStrategyChooseMap.get(markType);
+ if (executeStrategy == null) {
+ executeStrategy = monitorDataExecuteStrategyChooseMap.get(MessageTypeEnum.DEFAULT.name());
+ }
+ return executeStrategy;
+ }
+
+ /**
+ * Choose and execute.
+ *
+ * @param message {@link Message}
+ */
+ public void chooseAndExecute(Message message) {
+ MessageTypeEnum messageType = message.getMessageType();
+ AbstractMonitorDataExecuteStrategy executeStrategy = choose(messageType);
+ executeStrategy.execute(message);
+ }
+
+ @Override
+ public void run(String... args) throws Exception {
+ Map monitorDataExecuteStrategyMap =
+ ApplicationContextHolder.getBeansOfType(AbstractMonitorDataExecuteStrategy.class);
+ monitorDataExecuteStrategyMap.values().forEach(each -> monitorDataExecuteStrategyChooseMap.put(each.mark(), each));
+ }
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/RuntimeDataResolver.java b/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/RuntimeDataResolver.java
new file mode 100644
index 00000000..eb089f56
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/RuntimeDataResolver.java
@@ -0,0 +1,46 @@
+/*
+ * 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.monitor;
+
+import cn.hippo4j.common.monitor.MessageTypeEnum;
+import cn.hippo4j.common.monitor.RuntimeMessage;
+import cn.hippo4j.config.service.biz.HisRunDataService;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * Runtime data resolver.
+ */
+@Slf4j
+@Component
+@AllArgsConstructor
+public class RuntimeDataResolver extends AbstractMonitorDataExecuteStrategy {
+
+ private final HisRunDataService hisRunDataService;
+
+ @Override
+ public String mark() {
+ return MessageTypeEnum.RUNTIME.name();
+ }
+
+ @Override
+ public void execute(RuntimeMessage message) {
+ hisRunDataService.save(message);
+ }
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/TimeCleanHistoryDataTask.java b/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/TimeCleanHistoryDataTask.java
new file mode 100644
index 00000000..6aa4df3f
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/monitor/TimeCleanHistoryDataTask.java
@@ -0,0 +1,71 @@
+/*
+ * 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.monitor;
+
+import cn.hippo4j.common.executor.ExecutorFactory;
+import cn.hippo4j.config.config.ServerBootstrapProperties;
+import cn.hippo4j.config.model.HisRunDataInfo;
+import cn.hippo4j.config.service.biz.HisRunDataService;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import lombok.NonNull;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import static cn.hippo4j.common.constant.Constants.DEFAULT_GROUP;
+
+/**
+ * Regularly clean up the historical running data of thread pool.
+ */
+@Component
+@RequiredArgsConstructor
+public class TimeCleanHistoryDataTask implements Runnable, InitializingBean {
+
+ @NonNull
+ private final ServerBootstrapProperties properties;
+
+ @NonNull
+ private final HisRunDataService hisRunDataService;
+
+ private ScheduledExecutorService cleanHistoryDataExecutor;
+
+ @Override
+ public void run() {
+ Date currentDate = new Date();
+ DateTime offsetMinuteDateTime = DateUtil.offsetMinute(currentDate, -properties.getCleanHistoryDataPeriod());
+ LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(HisRunDataInfo.class)
+ .le(HisRunDataInfo::getTimestamp, offsetMinuteDateTime.getTime());
+ hisRunDataService.remove(queryWrapper);
+ }
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ if (properties.getCleanHistoryDataEnable()) {
+ cleanHistoryDataExecutor = ExecutorFactory.Managed
+ .newSingleScheduledExecutorService(DEFAULT_GROUP, r -> new Thread(r, "clean-history-data"));
+ cleanHistoryDataExecutor.scheduleWithFixedDelay(this, 0, 1, TimeUnit.MINUTES);
+ }
+ }
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/netty/MonitorNettyServer.java b/hippo4j-config/src/main/java/cn/hippo4j/config/netty/MonitorNettyServer.java
new file mode 100644
index 00000000..8ad536ef
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/netty/MonitorNettyServer.java
@@ -0,0 +1,89 @@
+/*
+ * 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.netty;
+
+import cn.hippo4j.config.config.ServerBootstrapProperties;
+import cn.hippo4j.config.service.biz.HisRunDataService;
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelPipeline;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.handler.codec.serialization.ClassResolvers;
+import io.netty.handler.codec.serialization.ObjectDecoder;
+import io.netty.handler.codec.serialization.ObjectEncoder;
+import io.netty.handler.logging.LogLevel;
+import io.netty.handler.logging.LoggingHandler;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+/**
+ * Netty monitor netty server.
+ */
+@Slf4j
+@AllArgsConstructor
+public class MonitorNettyServer {
+
+ private ServerBootstrapProperties serverBootstrapProperties;
+
+ private HisRunDataService hisRunDataService;
+
+ private EventLoopGroup bossGroup;
+
+ private EventLoopGroup workGroup;
+
+ @PostConstruct
+ public void nettyServerInit() {
+ new Thread(() -> {
+ try {
+ ServerBootstrap serverBootstrap = new ServerBootstrap();
+ serverBootstrap.group(bossGroup, workGroup)
+ .channel(NioServerSocketChannel.class)
+ .handler(new LoggingHandler(LogLevel.INFO))
+ // BossGroup the Thread group is responsible for connection events.
+ // WorkGroup the thread group is responsible for read and write events.
+ .childHandler(new ChannelInitializer() {
+
+ @Override
+ protected void initChannel(SocketChannel ch) throws Exception {
+ ChannelPipeline pipeline = ch.pipeline();
+ pipeline.addLast(new ObjectEncoder());
+ pipeline.addLast(new ObjectDecoder(Integer.MAX_VALUE,
+ ClassResolvers.cacheDisabled(null)));
+ pipeline.addLast(new ServerHandler(hisRunDataService));
+ }
+ });
+ ChannelFuture channelFuture = serverBootstrap.bind(Integer.parseInt(serverBootstrapProperties.getNettyServerPort())).sync();
+ channelFuture.channel().closeFuture().sync();
+ } catch (Exception e) {
+ log.error("nettyServerInit error", e);
+ }
+ }, "nettyServerInit thread").start();
+ }
+
+ @PreDestroy
+ public void destroy() {
+ bossGroup.shutdownGracefully();
+ workGroup.shutdownGracefully();
+ }
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/netty/ServerHandler.java b/hippo4j-config/src/main/java/cn/hippo4j/config/netty/ServerHandler.java
new file mode 100644
index 00000000..a6a75a1e
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/netty/ServerHandler.java
@@ -0,0 +1,40 @@
+/*
+ * 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.netty;
+
+import cn.hippo4j.common.monitor.MessageWrapper;
+import cn.hippo4j.config.service.biz.HisRunDataService;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * Server handler.
+ */
+@Slf4j
+@AllArgsConstructor
+public class ServerHandler extends SimpleChannelInboundHandler {
+
+ private HisRunDataService hisRunDataService;
+
+ @Override
+ protected void channelRead0(ChannelHandlerContext ctx, MessageWrapper msg) throws Exception {
+ hisRunDataService.dataCollect(msg);
+ }
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultPublisher.java b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultPublisher.java
index 1de56d31..6c2860ff 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultPublisher.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultPublisher.java
@@ -1,8 +1,25 @@
+/*
+ * 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.notify;
+import cn.hippo4j.config.event.AbstractEvent;
import cn.hutool.core.collection.ConcurrentHashSet;
-import cn.hippo4j.config.notify.listener.Subscriber;
-import cn.hippo4j.config.event.Event;
+import cn.hippo4j.config.notify.listener.AbstractSubscriber;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
@@ -13,16 +30,13 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
/**
* The default event publisher implementation.
- *
- * @author chen.ma
- * @date 2021/6/23 19:06
*/
@Slf4j
public class DefaultPublisher extends Thread implements EventPublisher {
- protected final ConcurrentHashSet subscribers = new ConcurrentHashSet();
+ protected final ConcurrentHashSet subscribers = new ConcurrentHashSet();
- private BlockingQueue queue;
+ private BlockingQueue queue;
private volatile boolean initialized = false;
@@ -36,7 +50,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
.newUpdater(DefaultPublisher.class, Long.class, "lastEventSequence");
@Override
- public void init(Class extends Event> type, int bufferSize) {
+ public void init(Class extends AbstractEvent> type, int bufferSize) {
setDaemon(true);
setName("dynamic.thread-pool.publisher-" + type.getName());
this.queueMaxSize = bufferSize;
@@ -64,7 +78,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
private void openEventHandler() {
try {
int waitTimes = 60;
- for (; ; ) {
+ for (;;) {
if (shutdown || hasSubscriber() || waitTimes <= 0) {
break;
}
@@ -75,30 +89,29 @@ public class DefaultPublisher extends Thread implements EventPublisher {
}
waitTimes--;
}
-
- for (; ; ) {
+ for (;;) {
if (shutdown) {
break;
}
- final Event event = queue.take();
+ final AbstractEvent event = queue.take();
receiveEvent(event);
UPDATER.compareAndSet(this, lastEventSequence, Math.max(lastEventSequence, event.sequence()));
}
} catch (Throwable ex) {
- log.error("Event listener exception :: {}", ex);
+ log.error("Event listener exception: {}", ex);
}
}
@Override
- public void addSubscriber(Subscriber subscriber) {
+ public void addSubscriber(AbstractSubscriber subscriber) {
subscribers.add(subscriber);
}
@Override
- public boolean publish(Event event) {
+ public boolean publish(AbstractEvent event) {
boolean success = this.queue.offer(event);
if (!success) {
- log.warn("Unable to plug in due to interruption, synchronize sending time, event :: {}", event);
+ log.warn("Unable to plug in due to interruption, synchronize sending time, event: {}", event);
receiveEvent(event);
return true;
}
@@ -106,7 +119,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
}
@Override
- public void notifySubscriber(Subscriber subscriber, Event event) {
+ public void notifySubscriber(AbstractSubscriber subscriber, AbstractEvent event) {
final Runnable job = () -> subscriber.onEvent(event);
final Executor executor = subscriber.executor();
@@ -117,7 +130,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
try {
job.run();
} catch (Throwable e) {
- log.error("Event callback exception :: {}", e);
+ log.error("Event callback exception: {}", e);
}
}
}
@@ -126,10 +139,9 @@ public class DefaultPublisher extends Thread implements EventPublisher {
return !CollectionUtils.isEmpty(subscribers);
}
- void receiveEvent(Event event) {
- for (Subscriber subscriber : subscribers) {
+ void receiveEvent(AbstractEvent event) {
+ for (AbstractSubscriber subscriber : subscribers) {
notifySubscriber(subscriber, event);
}
}
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultSharePublisher.java b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultSharePublisher.java
index 903e1b82..b877bfbb 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultSharePublisher.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultSharePublisher.java
@@ -1,9 +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.config.notify;
+import cn.hippo4j.config.event.AbstractEvent;
import cn.hutool.core.collection.ConcurrentHashSet;
-import cn.hippo4j.config.notify.listener.Subscriber;
-import cn.hippo4j.config.event.Event;
-import cn.hippo4j.config.event.SlowEvent;
+import cn.hippo4j.config.notify.listener.AbstractSubscriber;
+import cn.hippo4j.config.event.AbstractSlowEvent;
import java.util.Map;
import java.util.Set;
@@ -13,27 +30,23 @@ import java.util.concurrent.locks.ReentrantLock;
/**
* Default share publisher.
- *
- * @author chen.ma
- * @date 2021/6/23 19:05
*/
public class DefaultSharePublisher extends DefaultPublisher {
- private final Map, Set> subMappings = new ConcurrentHashMap();
+ private final Map, Set> subMappings = new ConcurrentHashMap();
- protected final ConcurrentHashSet subscribers = new ConcurrentHashSet();
+ protected final ConcurrentHashSet subscribers = new ConcurrentHashSet();
private final Lock lock = new ReentrantLock();
- public void addSubscriber(Subscriber subscriber, Class extends Event> subscribeType) {
- Class extends SlowEvent> subSlowEventType = (Class extends SlowEvent>) subscribeType;
+ public void addSubscriber(AbstractSubscriber subscriber, Class extends AbstractEvent> subscribeType) {
+ Class extends AbstractSlowEvent> subSlowEventType = (Class extends AbstractSlowEvent>) subscribeType;
subscribers.add(subscriber);
-
lock.lock();
try {
- Set sets = subMappings.get(subSlowEventType);
+ Set sets = subMappings.get(subSlowEventType);
if (sets == null) {
- Set newSet = new ConcurrentHashSet();
+ Set newSet = new ConcurrentHashSet();
newSet.add(subscriber);
subMappings.put(subSlowEventType, newSet);
return;
@@ -43,5 +56,4 @@ public class DefaultSharePublisher extends DefaultPublisher {
lock.unlock();
}
}
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/EventPublisher.java b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/EventPublisher.java
index 093c1ed5..858b30f2 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/EventPublisher.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/EventPublisher.java
@@ -1,13 +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.config.notify;
-import cn.hippo4j.config.notify.listener.Subscriber;
-import cn.hippo4j.config.event.Event;
+import cn.hippo4j.config.event.AbstractEvent;
+import cn.hippo4j.config.notify.listener.AbstractSubscriber;
/**
* Event publisher.
- *
- * @author chen.ma
- * @date 2021/6/23 18:58
*/
public interface EventPublisher {
@@ -17,14 +31,14 @@ public interface EventPublisher {
* @param type
* @param bufferSize
*/
- void init(Class extends Event> type, int bufferSize);
+ void init(Class extends AbstractEvent> type, int bufferSize);
/**
* Add subscriber.
*
* @param subscriber
*/
- void addSubscriber(Subscriber subscriber);
+ void addSubscriber(AbstractSubscriber subscriber);
/**
* Publish.
@@ -32,7 +46,7 @@ public interface EventPublisher {
* @param event
* @return
*/
- boolean publish(Event event);
+ boolean publish(AbstractEvent event);
/**
* Notify subscriber.
@@ -40,6 +54,5 @@ public interface EventPublisher {
* @param subscriber
* @param event
*/
- void notifySubscriber(Subscriber subscriber, Event event);
-
+ void notifySubscriber(AbstractSubscriber subscriber, AbstractEvent event);
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/NotifyCenter.java b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/NotifyCenter.java
index 3e6e1e82..bd5d04fa 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/NotifyCenter.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/NotifyCenter.java
@@ -1,11 +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.config.notify;
-import cn.hippo4j.config.notify.listener.SmartSubscriber;
-import cn.hippo4j.config.notify.listener.Subscriber;
+import cn.hippo4j.config.event.AbstractEvent;
+import cn.hippo4j.config.notify.listener.AbstractSmartSubscriber;
+import cn.hippo4j.config.notify.listener.AbstractSubscriber;
import cn.hippo4j.config.toolkit.ClassUtil;
import cn.hippo4j.config.toolkit.MapUtil;
-import cn.hippo4j.config.event.Event;
-import cn.hippo4j.config.event.SlowEvent;
+import cn.hippo4j.config.event.AbstractSlowEvent;
import lombok.extern.slf4j.Slf4j;
import java.util.Map;
@@ -14,9 +31,6 @@ import java.util.function.BiFunction;
/**
* Unified event notify center.
- *
- * @author chen.ma
- * @date 2021/6/23 18:58
*/
@Slf4j
public class NotifyCenter {
@@ -33,7 +47,7 @@ public class NotifyCenter {
private static EventPublisher eventPublisher = new DefaultPublisher();
- private static BiFunction, Integer, EventPublisher> publisherFactory = null;
+ private static BiFunction, Integer, EventPublisher> publisherFactory = null;
private final Map publisherMap = new ConcurrentHashMap(16);
@@ -44,19 +58,18 @@ public class NotifyCenter {
publisher.init(cls, buffer);
return publisher;
} catch (Throwable ex) {
- log.error("Service class newInstance has error :: {}", ex);
+ log.error("Service class newInstance has error: {}", ex);
throw new RuntimeException(ex);
}
};
-
INSTANCE.sharePublisher = new DefaultSharePublisher();
- INSTANCE.sharePublisher.init(SlowEvent.class, shareBufferSize);
+ INSTANCE.sharePublisher.init(AbstractSlowEvent.class, shareBufferSize);
}
- public static void registerSubscriber(final Subscriber consumer) {
- if (consumer instanceof SmartSubscriber) {
- for (Class extends Event> subscribeType : ((SmartSubscriber) consumer).subscribeTypes()) {
- if (ClassUtil.isAssignableFrom(SlowEvent.class, subscribeType)) {
+ public static void registerSubscriber(final AbstractSubscriber consumer) {
+ if (consumer instanceof AbstractSmartSubscriber) {
+ for (Class extends AbstractEvent> subscribeType : ((AbstractSmartSubscriber) consumer).subscribeTypes()) {
+ if (ClassUtil.isAssignableFrom(AbstractSlowEvent.class, subscribeType)) {
INSTANCE.sharePublisher.addSubscriber(consumer, subscribeType);
} else {
addSubscriber(consumer, subscribeType);
@@ -64,17 +77,15 @@ public class NotifyCenter {
}
return;
}
-
- final Class extends Event> subscribeType = consumer.subscribeType();
- if (ClassUtil.isAssignableFrom(SlowEvent.class, subscribeType)) {
+ final Class extends AbstractEvent> subscribeType = consumer.subscribeType();
+ if (ClassUtil.isAssignableFrom(AbstractSlowEvent.class, subscribeType)) {
INSTANCE.sharePublisher.addSubscriber(consumer, subscribeType);
return;
}
-
addSubscriber(consumer, subscribeType);
}
- private static void addSubscriber(final Subscriber consumer, Class extends Event> subscribeType) {
+ private static void addSubscriber(final AbstractSubscriber consumer, Class extends AbstractEvent> subscribeType) {
final String topic = ClassUtil.getCanonicalName(subscribeType);
synchronized (NotifyCenter.class) {
MapUtil.computeIfAbsent(INSTANCE.publisherMap, topic, publisherFactory, subscribeType, ringBufferSize);
@@ -83,22 +94,20 @@ public class NotifyCenter {
publisher.addSubscriber(consumer);
}
- public static boolean publishEvent(final Event event) {
+ public static boolean publishEvent(final AbstractEvent event) {
try {
return publishEvent(event.getClass(), event);
} catch (Throwable ex) {
- log.error("There was an exception to the message publishing :: {}", ex);
+ log.error("There was an exception to the message publishing: {}", ex);
return false;
}
}
- private static boolean publishEvent(final Class extends Event> eventType, final Event event) {
- if (ClassUtil.isAssignableFrom(SlowEvent.class, eventType)) {
+ private static boolean publishEvent(final Class extends AbstractEvent> eventType, final AbstractEvent event) {
+ if (ClassUtil.isAssignableFrom(AbstractSlowEvent.class, eventType)) {
return INSTANCE.sharePublisher.publish(event);
}
-
final String topic = ClassUtil.getCanonicalName(eventType);
-
EventPublisher publisher = INSTANCE.publisherMap.get(topic);
if (publisher != null) {
return publisher.publish(event);
@@ -107,16 +116,14 @@ public class NotifyCenter {
return false;
}
- public static EventPublisher registerToPublisher(final Class extends Event> eventType, final int queueMaxSize) {
- if (ClassUtil.isAssignableFrom(SlowEvent.class, eventType)) {
+ public static EventPublisher registerToPublisher(final Class extends AbstractEvent> eventType, final int queueMaxSize) {
+ if (ClassUtil.isAssignableFrom(AbstractSlowEvent.class, eventType)) {
return INSTANCE.sharePublisher;
}
-
final String topic = ClassUtil.getCanonicalName(eventType);
synchronized (NotifyCenter.class) {
MapUtil.computeIfAbsent(INSTANCE.publisherMap, topic, publisherFactory, eventType, queueMaxSize);
}
return INSTANCE.publisherMap.get(topic);
}
-
}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/listener/AbstractSmartSubscriber.java b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/listener/AbstractSmartSubscriber.java
new file mode 100644
index 00000000..38d74efb
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/listener/AbstractSmartSubscriber.java
@@ -0,0 +1,35 @@
+/*
+ * 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.notify.listener;
+
+import cn.hippo4j.config.event.AbstractEvent;
+
+import java.util.List;
+
+/**
+ * Subscribers to multiple events can be listened to.
+ */
+public abstract class AbstractSmartSubscriber extends AbstractSubscriber {
+
+ /**
+ * Subscribe types.
+ *
+ * @return
+ */
+ public abstract List> subscribeTypes();
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/listener/AbstractSubscriber.java b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/listener/AbstractSubscriber.java
new file mode 100644
index 00000000..16357b47
--- /dev/null
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/listener/AbstractSubscriber.java
@@ -0,0 +1,46 @@
+/*
+ * 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.notify.listener;
+
+import cn.hippo4j.config.event.AbstractEvent;
+
+import java.util.concurrent.Executor;
+
+/**
+ * An abstract subscriber class for subscriber interface.
+ */
+public abstract class AbstractSubscriber {
+
+ /**
+ * Event callback.
+ *
+ * @param event
+ */
+ public abstract void onEvent(T event);
+
+ /**
+ * Type of this subscriber's subscription.
+ *
+ * @return
+ */
+ public abstract Class extends AbstractEvent> subscribeType();
+
+ public Executor executor() {
+ return null;
+ }
+}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/listener/SmartSubscriber.java b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/listener/SmartSubscriber.java
deleted file mode 100644
index 67214616..00000000
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/listener/SmartSubscriber.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package cn.hippo4j.config.notify.listener;
-
-import cn.hippo4j.config.event.Event;
-
-import java.util.List;
-
-/**
- * Subscribers to multiple events can be listened to.
- *
- * @author chen.ma
- * @date 2021/6/23 19:02
- */
-public abstract class SmartSubscriber extends Subscriber {
-
- /**
- * Subscribe types.
- *
- * @return
- */
- public abstract List> subscribeTypes();
-
-}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/listener/Subscriber.java b/hippo4j-config/src/main/java/cn/hippo4j/config/notify/listener/Subscriber.java
deleted file mode 100644
index 424c4b8a..00000000
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/notify/listener/Subscriber.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package cn.hippo4j.config.notify.listener;
-
-import cn.hippo4j.config.event.Event;
-
-import java.util.concurrent.Executor;
-
-/**
- * An abstract subscriber class for subscriber interface.
- *
- * @author chen.ma
- * @date 2021/6/23 19:02
- */
-public abstract class Subscriber {
-
- /**
- * Event callback.
- *
- * @param event
- */
- public abstract void onEvent(T event);
-
- /**
- * Type of this subscriber's subscription.
- *
- * @return
- */
- public abstract Class extends Event> subscribeType();
-
- public Executor executor() {
- return null;
- }
-
-}
diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/service/ConfigCacheService.java b/hippo4j-config/src/main/java/cn/hippo4j/config/service/ConfigCacheService.java
index 1ba1bebf..194e1811 100644
--- a/hippo4j-config/src/main/java/cn/hippo4j/config/service/ConfigCacheService.java
+++ b/hippo4j-config/src/main/java/cn/hippo4j/config/service/ConfigCacheService.java
@@ -1,49 +1,73 @@
+/*
+ * 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;
-import cn.hippo4j.config.notify.NotifyCenter;
-import cn.hutool.core.collection.CollUtil;
-import cn.hippo4j.config.service.biz.ConfigService;
import cn.hippo4j.common.config.ApplicationContextHolder;
import cn.hippo4j.common.constant.Constants;
+import cn.hippo4j.common.design.observer.AbstractSubjectCenter;
+import cn.hippo4j.common.design.observer.Observer;
+import cn.hippo4j.common.design.observer.ObserverMessage;
+import cn.hippo4j.common.toolkit.CollectionUtil;
+import cn.hippo4j.common.toolkit.JSONUtil;
import cn.hippo4j.common.toolkit.Md5Util;
import cn.hippo4j.config.event.LocalDataChangeEvent;
import cn.hippo4j.config.model.CacheItem;
import cn.hippo4j.config.model.ConfigAllInfo;
+import cn.hippo4j.config.notify.NotifyCenter;
+import cn.hippo4j.config.service.biz.ConfigService;
import cn.hippo4j.config.toolkit.MapUtil;
-import com.alibaba.fastjson.JSON;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static cn.hippo4j.common.constant.Constants.GROUP_KEY_DELIMITER;
+import static cn.hippo4j.common.constant.Constants.GROUP_KEY_DELIMITER_TRANSLATION;
/**
* Config cache service.
- *
- * @author chen.ma
- * @date 2021/6/24 21:19
*/
@Slf4j
public class ConfigCacheService {
- private static ConfigService configService = null;
+ private static ConfigService CONFIG_SERVICE;
+
+ static {
+ AbstractSubjectCenter.register(AbstractSubjectCenter.SubjectType.CLEAR_CONFIG_CACHE, new ClearConfigCache());
+ }
/**
- * TODO: 数据结构、客户端停机时 remove 操作待重构
- *
- * key: message-produce+dynamic-threadpool-example+prescription+192.168.20.227:8088
+ * key: message-produce+dynamic-threadpool-example+prescription+192.168.20.227:8088_xxx
* val:
- * key: 192.168.20.227:8088
+ * key: 192.168.20.227:8088_xxx
* val: {@link CacheItem}
*/
- private static final ConcurrentHashMap> CACHE = new ConcurrentHashMap();
+ private static final ConcurrentHashMap> CLIENT_CONFIG_CACHE = new ConcurrentHashMap();
- public static boolean isUpdateData(String groupKey, String md5, String ip) {
- String contentMd5 = ConfigCacheService.getContentMd5IsNullPut(groupKey, ip);
+ public static boolean isUpdateData(String groupKey, String md5, String clientIdentify) {
+ String contentMd5 = ConfigCacheService.getContentMd5IsNullPut(groupKey, clientIdentify);
return Objects.equals(contentMd5, md5);
}
@@ -51,92 +75,122 @@ public class ConfigCacheService {
* Get Md5.
*
* @param groupKey
- * @param ip
+ * @param clientIdentify
* @return
*/
- private synchronized static String getContentMd5IsNullPut(String groupKey, String ip) {
- Map cacheItemMap = Optional.ofNullable(CACHE.get(groupKey)).orElse(Maps.newHashMap());
-
+ private synchronized static String getContentMd5IsNullPut(String groupKey, String clientIdentify) {
+ Map cacheItemMap = Optional.ofNullable(CLIENT_CONFIG_CACHE.get(groupKey)).orElse(Maps.newHashMap());
CacheItem cacheItem = null;
- if (CollUtil.isNotEmpty(cacheItemMap) && (cacheItem = cacheItemMap.get(ip)) != null) {
+ if (CollUtil.isNotEmpty(cacheItemMap) && (cacheItem = cacheItemMap.get(clientIdentify)) != null) {
return cacheItem.md5;
}
-
- if (configService == null) {
- configService = ApplicationContextHolder.getBean(ConfigService.class);
+ if (CONFIG_SERVICE == null) {
+ CONFIG_SERVICE = ApplicationContextHolder.getBean(ConfigService.class);
}
- String[] split = groupKey.split("\\+");
-
- ConfigAllInfo config = configService.findConfigAllInfo(split[0], split[1], split[2]);
- if (config != null && !StringUtils.isEmpty(config.getTpId())) {
+ String[] params = groupKey.split(GROUP_KEY_DELIMITER_TRANSLATION);
+ ConfigAllInfo config = CONFIG_SERVICE.findConfigRecentInfo(params);
+ if (config != null && StrUtil.isNotBlank(config.getTpId())) {
cacheItem = new CacheItem(groupKey, config);
- cacheItemMap.put(ip, cacheItem);
- CACHE.put(groupKey, cacheItemMap);
+ cacheItemMap.put(clientIdentify, cacheItem);
+ CLIENT_CONFIG_CACHE.put(groupKey, cacheItemMap);
}
return (cacheItem != null) ? cacheItem.md5 : Constants.NULL;
}
public static String getContentMd5(String groupKey) {
- if (configService == null) {
- configService = ApplicationContextHolder.getBean(ConfigService.class);
+ if (CONFIG_SERVICE == null) {
+ CONFIG_SERVICE = ApplicationContextHolder.getBean(ConfigService.class);
}
-
- String[] split = groupKey.split("\\+");
- ConfigAllInfo config = configService.findConfigAllInfo(split[0], split[1], split[2]);
+ String[] params = groupKey.split(GROUP_KEY_DELIMITER_TRANSLATION);
+ ConfigAllInfo config = CONFIG_SERVICE.findConfigRecentInfo(params);
if (config == null || StringUtils.isEmpty(config.getTpId())) {
- String errorMessage = String.format("config is null. tpId :: %s, itemId :: %s, tenantId :: %s", split[0], split[1], split[2]);
+ String errorMessage = String.format("config is null. tpId: %s, itemId: %s, tenantId: %s", params[0], params[1], params[2]);
throw new RuntimeException(errorMessage);
}
-
return Md5Util.getTpContentMd5(config);
}
- public static void updateMd5(String groupKey, String ip, String md5) {
- CacheItem cache = makeSure(groupKey, ip);
+ public static void updateMd5(String groupKey, String identify, String md5) {
+ CacheItem cache = makeSure(groupKey, identify);
if (cache.md5 == null || !cache.md5.equals(md5)) {
cache.md5 = md5;
- String[] split = groupKey.split("\\+");
- ConfigAllInfo config = configService.findConfigAllInfo(split[0], split[1], split[2]);
+ String[] params = groupKey.split(GROUP_KEY_DELIMITER_TRANSLATION);
+ ConfigAllInfo config = CONFIG_SERVICE.findConfigRecentInfo(params);
cache.configAllInfo = config;
cache.lastModifiedTs = System.currentTimeMillis();
- NotifyCenter.publishEvent(new LocalDataChangeEvent(ip, groupKey));
+ NotifyCenter.publishEvent(new LocalDataChangeEvent(identify, groupKey));
}
}
public synchronized static CacheItem makeSure(String groupKey, String ip) {
- Map ipCacheItemMap = CACHE.get(groupKey);
- CacheItem item = ipCacheItemMap.get(ip);
- if (null != item) {
+ Map ipCacheItemMap = CLIENT_CONFIG_CACHE.get(groupKey);
+ CacheItem item;
+ if (ipCacheItemMap != null && (item = ipCacheItemMap.get(ip)) != null) {
return item;
}
-
CacheItem tmp = new CacheItem(groupKey);
Map cacheItemMap = Maps.newHashMap();
cacheItemMap.put(ip, tmp);
- CACHE.putIfAbsent(groupKey, cacheItemMap);
-
+ CLIENT_CONFIG_CACHE.putIfAbsent(groupKey, cacheItemMap);
return tmp;
}
public static Map getContent(String identification) {
- List identificationList = MapUtil.parseMapForFilter(CACHE, identification);
+ List identificationList = MapUtil.parseMapForFilter(CLIENT_CONFIG_CACHE, identification);
Map returnStrCacheItemMap = Maps.newHashMap();
- identificationList.forEach(each -> returnStrCacheItemMap.putAll(CACHE.get(each)));
+ identificationList.forEach(each -> returnStrCacheItemMap.putAll(CLIENT_CONFIG_CACHE.get(each)));
return returnStrCacheItemMap;
}
+ public static synchronized Integer getTotal() {
+ AtomicInteger total = new AtomicInteger();
+ CLIENT_CONFIG_CACHE.forEach((key, val) -> total.addAndGet(val.values().size()));
+ return total.get();
+ }
+
+ public static List getIdentifyList(String tenantId, String itemId, String threadPoolId) {
+ List identifyList = null;
+ String buildKey = Joiner.on(GROUP_KEY_DELIMITER).join(Lists.newArrayList(threadPoolId, itemId, tenantId));
+ List keys = MapUtil.parseMapForFilter(CLIENT_CONFIG_CACHE, buildKey);
+ if (CollectionUtil.isNotEmpty(keys)) {
+ identifyList = new ArrayList(keys.size());
+ for (String each : keys) {
+ String[] keyArray = each.split(GROUP_KEY_DELIMITER_TRANSLATION);
+ if (keyArray != null && keyArray.length > 2) {
+ identifyList.add(keyArray[3]);
+ }
+ }
+ }
+ return identifyList;
+ }
+
/**
* Remove config cache.
*
- * @param groupKey 租户 + 项目 + IP
+ * @param groupKey tenant + item + IP
*/
- public synchronized static void removeConfigCache(String groupKey) {
- // 模糊搜索
- List