Skip to content

Commit

Permalink
Merge branch 'jd-opensource:main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
scy251147 authored Oct 29, 2024
2 parents 95e5fb1 + 6a37deb commit 746c2a4
Show file tree
Hide file tree
Showing 279 changed files with 8,766 additions and 3,180 deletions.
3 changes: 2 additions & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ Please visit this web site for more information of this project:
The Apache Software License, Version 2.0.
================================================================

This software includes code from Spring boot:
This software includes code from Spring projects:

Please visit this web site for more information of this project:
* https://github.com/spring-projects/spring-boot
* https://github.com/spring-projects/spring-framework
================================================================

This software includes code from AhoCorasickDoubleArrayTrie:
Expand Down
22 changes: 19 additions & 3 deletions RELEASE-zh.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# 发布历史

## 1.3.3

1. 修复字节码拦截器没有抛出异常的问题。

## 1.3.2

1. 修复认证过滤器空指针问题。

## 1.3.1
1. 修复Spring Gateway请求的默认重试策略。
2. 支持Spring Cloud Gateway仅启用多活和泳道功能。
3. 添加认证和权限策略。
4. 修复FailsafeClusterInvoker响应。
5. 修复反应式的断路器问题。
6. 修复UnreadyInboundFilter过滤链调用错误。
7. 修复对实时异常缺乏统一处理的问题。

## 1.3.0
1. 在分区容错的时候支持本云优先,减少专线带宽
2. 熔断和重试,支持采用JsonPath从应答体中提取异常码
Expand Down Expand Up @@ -35,9 +52,8 @@
4. 支持泳道流量路由
5. 支持微服务治理,包括集群重试策略,限流策略,负载均衡算法,标签路由策略,多活策略、泳道策略、优雅启动和下线。
6. 支持常用的框架,包括:

1. 微服务治理:Spring cloud 3,Spring gateway 3,Dubbo 2.6/2.7/3,SofaRpc
2. 链路透传:Spring cloud 3,Spring gateway 3,Dubbo 2.6/2.7/3,SofaRpc,Grpc,Rocketmq 4/5,Kafka 3,Http client 3/4,Http servlet,Okhttp 1/3,JDK http connection,Thread pool。
- 微服务治理:Spring cloud 3,Spring gateway 3,Dubbo 2.6/2.7/3,SofaRpc
- 链路透传:Spring cloud 3,Spring gateway 3,Dubbo 2.6/2.7/3,SofaRpc,Grpc,Rocketmq 4/5,Kafka 3,Http client 3/4,Http servlet,Okhttp 1/3,JDK http connection,Thread pool。
7. 发布配套的云原生多活控制器

## 限制
Expand Down
22 changes: 19 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Release History

## 1.3.3

1. Fixed the problem that bytecode interceptors did not throw exceptions

## 1.3.2

1. Fix a Null Pointer Exception (NPE).

## 1.3.1
1. Fix the default retry policy from spring gateway request.
2. Support spring cloud gateway only enable multi-live and lane feature.
3. Add auth and permission policy.
4. Fix FailsafeClusterInvoker response.
5. Fix circuit breaker for reactive.
6. Fix Unready inbound filter error.
7. Fixing the lack of unified handling for live exceptions.

## 1.3.0
1. Support for local cloud priority during cell fault tolerance, reducing dedicated line bandwidth usage.
2. Circuit breaker and retry, supporting the use of JsonPath to extract exception codes from response bodies.
Expand Down Expand Up @@ -35,9 +52,8 @@
4. Supported lane-based traffic routing.
5. Supported microservices governance, including cluster retry strategies, rate limiting strategies, load balancing algorithms, tag-based routing strategies, active-active strategies, lane strategies, graceful startup, and shutdown.
6. Supported common frameworks, including:

1. Microservices governance: Spring Cloud 3, Spring Gateway 3, Dubbo 2.6/2.7/3, SofaRpc.
2. Trace propagation: Spring Cloud 3, Spring Gateway 3, Dubbo 2.6/2.7/3, SofaRpc, Grpc, RocketMQ 4/5, Kafka 3, HttpClient 3/4, HttpServlet, OkHttp 1/3, JDK HttpConnection, ThreadPool.
- Microservices governance: Spring Cloud 3, Spring Gateway 3, Dubbo 2.6/2.7/3, SofaRpc.
- Trace propagation: Spring Cloud 3, Spring Gateway 3, Dubbo 2.6/2.7/3, SofaRpc, Grpc, RocketMQ 4/5, Kafka 3, HttpClient 3/4, HttpServlet, OkHttp 1/3, JDK HttpConnection, ThreadPool.
7. Released the accompanying cloud-native active-active controller.

## Limitations
Expand Down
4 changes: 2 additions & 2 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.AtclauseOrderCheck">
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF"/>
<property name="tagOrder"
value="@param, @author, @since, @see, @version, @serial, @deprecated"/>
value="@param, @author, @version, @see, @since, @serial, @deprecated"/>
</module>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.AtclauseOrderCheck">
<property name="target" value="METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
<property name="tagOrder"
value="@param, @return, @throws, @since, @deprecated, @see"/>
value="@param, @return, @throws, @see, @since, @deprecated"/>
</module>

<!-- Miscellaneous -->
Expand Down
15 changes: 7 additions & 8 deletions docs/cn/governance.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,13 @@

```mermaid
stateDiagram-v2
Closed --> Open : fail [threshold reached]
Closed --> Closed : fail [under threshold]
Open --> HalfOpen : reset timeout
HalfOpen --> Closed : success
HalfOpen --> Open : fail
Closed --> Closed : success
Open --> Open : call / raise circuit open
DIRECTION BT
关闭 --> 开启 : 失败达到阈值
开启 --> 半开 : 达到超时
半开 --> 关闭 : 成功
半开 --> 开启 : 失败
关闭 --> 关闭 : 成功/失败未到阈值
开启 --> 开启 : 调用抛出异常
```

| 元素 | 说明 |
Expand Down
9 changes: 5 additions & 4 deletions docs/cn/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

#### 1.1.1 下载二进制包

[Release](https://github.com/jd-opensource/joylive-agent/releases)中下载最新的二进制包
-[Release](https://github.com/jd-opensource/joylive-agent/releases)中下载最新的二进制包(zip 或tar.gz)
-[Maven-1](https://mvnrepository.com/artifact/com.jd.live/joylive-package)[Maven-2](https://search.maven.org/search?q=g:com.jd.live%20AND%20a:joylive-package)仓库下载最新的二进制包(zip 或tar.gz)

#### 1.1.2 手动编译

Expand All @@ -21,15 +22,15 @@
### 1.2 获取Demo程序
编译`joylive-agent`,获取`joylive-demo/joylive-demo-springcloud3`下各项目的二进制包
编译`joylive-agent`,获取`joylive-demo/joylive-demo-springcloud2021`下各项目的二进制包
- 网关
`joylive-demo-springcloud3-gateway` Spring Cloud Gateway网关demo
`joylive-demo-springcloud2021-gateway` Spring Cloud Gateway网关demo
- 应用
`joylive-demo-springcloud3-provider` Spring Cloud应用demo
`joylive-demo-springcloud2021-provider` Spring Cloud应用demo
### 1.3 修改配置
Expand Down
Binary file modified docs/image/weixin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Quick Start

##### 1.1.1 Download the Binary Package

Download the latest binary package from the [Release](https://github.com/jd-opensource/joylive-agent/releases) page.
- Download the latest binary package from the [Release](https://github.com/jd-opensource/joylive-agent/releases) page (zip or tar.gz)
- Download the latest binary package from the [Maven-1](https://mvnrepository.com/artifact/com.jd.live/joylive-package) or [Maven-2](https://search.maven.org/search?q=g:com.jd.live%20AND%20a:joylive-package) (zip or tar.gz)


##### 1.1.2 Manual Compilation

Expand All @@ -20,15 +22,15 @@ Download the latest binary package from the [Release](https://github.com/jd-open
### 1.2 Obtain the Demo Program
Compile `joylive-agent` and obtain the binary packages of various projects under `joylive-demo/joylive-demo-springcloud3`.
Compile `joylive-agent` and obtain the binary packages of various projects under `joylive-demo/joylive-demo-springcloud2021`.
- Gateway
`joylive-demo-springcloud3-gateway` Spring Cloud Gateway demo
`joylive-demo-springcloud2021-gateway` Spring Cloud Gateway demo
- Application
`joylive-demo-springcloud3-provider` Spring Cloud application demo
`joylive-demo-springcloud2021-provider` Spring Cloud application demo
### 1.3 Modify the Configuration
Expand Down
2 changes: 1 addition & 1 deletion joylive-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</scm>

<properties>
<revision>1.3.0</revision>
<revision>1.4.0-SNAPSHOT</revision>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiConsumer;

import static com.jd.live.agent.bootstrap.bytekit.advice.ExceptionHandler.EMPTY_EXCEPTION_HANDLER;

/**
* A handler class for managing advices and their associated interceptors. Provides static methods
* for handling entry and exit points of method execution contexts, as well as managing advice lifecycle.
Expand Down Expand Up @@ -60,29 +58,27 @@ public static <T extends ExecutableContext> void onEnter(T context, String advic
AdviceDesc adviceDesc = advices.get(adviceKey);
List<Interceptor> interceptors = adviceDesc == null ? null : adviceDesc.getInterceptors();
if (interceptors != null) {
onEnter(context, interceptors, EMPTY_EXCEPTION_HANDLER);
onEnter(context, interceptors);
}
}

/**
* Handles the entry point for a given execution context and a list of interceptors.
*
* @param <T> the type of the execution context
* @param context the execution context
* @param interceptors the list of interceptors to be executed
* @param exceptionHandler the handler for exceptions
* @param <T> the type of the execution context
* @param context the execution context
* @param interceptors the list of interceptors to be executed
* @throws Throwable if any exception occurs during interception
*/
public static <T extends ExecutableContext> void onEnter(T context,
List<Interceptor> interceptors,
ExceptionHandler exceptionHandler) throws Throwable {
List<Interceptor> interceptors) throws Throwable {
if (context == null || interceptors == null)
return;
for (Interceptor interceptor : interceptors) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("enter [%s], interceptor is [%s].", context.getDescription(), interceptor.getClass().getName()));
}
handle(context, interceptor, Interceptor::onEnter, exceptionHandler, "enter");
handle(context, interceptor, Interceptor::onEnter, "enter");
if (!context.isSuccess()) {
throw context.getThrowable();
} else if (context.isSkip()) {
Expand All @@ -104,60 +100,57 @@ public static <T extends ExecutableContext> void onExit(T context, String advice
AdviceDesc adviceDesc = advices.get(adviceKey);
List<Interceptor> interceptors = adviceDesc == null ? null : adviceDesc.getInterceptors();
if (interceptors != null) {
onExit(context, interceptors, EMPTY_EXCEPTION_HANDLER);
onExit(context, interceptors);
}
}

/**
* Handles the exit point for a given execution context and a list of interceptors.
*
* @param <T> the type of the execution context
* @param context the execution context
* @param interceptors the list of interceptors to be executed
* @param exceptionHandler the handler for exceptions
* @param <T> the type of the execution context
* @param context the execution context
* @param interceptors the list of interceptors to be executed
* @throws Throwable if any exception occurs during interception
*/
public static <T extends ExecutableContext> void onExit(T context,
List<Interceptor> interceptors,
ExceptionHandler exceptionHandler) throws Throwable {
List<Interceptor> interceptors) throws Throwable {
if (context == null || interceptors == null)
return;
for (Interceptor interceptor : interceptors) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("exit [%s], interceptor is [%s].", context.getDescription(), interceptor.getClass().getName()));
}
if (context.isSuccess()) {
handle(context, interceptor, Interceptor::onSuccess, exceptionHandler, "success");
handle(context, interceptor, Interceptor::onSuccess, "success");
} else {
handle(context, interceptor, Interceptor::onError, exceptionHandler, "recover");
handle(context, interceptor, Interceptor::onError, "recover");
}
handle(context, interceptor, Interceptor::onExit, exceptionHandler, "exit");
handle(context, interceptor, Interceptor::onExit, "exit");
}
}

/**
* Generic method for handling interception actions.
*
* @param <T> the type of the execution context
* @param context the execution context
* @param interceptor the interceptor to be executed
* @param consumer the action to be performed by the interceptor
* @param errorHandler the handler for exceptions
* @param action the name of the action being performed
* @param <T> the type of the execution context
* @param context the execution context
* @param interceptor the interceptor to be executed
* @param consumer the action to be performed by the interceptor
* @param action the name of the action being performed
* @throws Throwable if any exception occurs during interception
*/
private static <T extends ExecutableContext> void handle(T context,
Interceptor interceptor,
BiConsumer<Interceptor, T> consumer,
ExceptionHandler errorHandler,
String action) throws Throwable {
try {
consumer.accept(interceptor, context);
} catch (Throwable t) {
logger.error(String.format("failed to %s %s, caused by %s", action, context.getDescription(), t.getMessage()), t);
if (errorHandler != null) {
ExceptionHandler exceptionHandler = interceptor.getExceptionHandler();
if (exceptionHandler != null) {
try {
errorHandler.handle(context, interceptor, t);
exceptionHandler.handle(context, interceptor, t);
} catch (Throwable e) {
logger.error(String.format("failed to handle %s %s error, caused by %s", action, context.getDescription(), t.getMessage()), t);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright © ${year} ${owner} (${email})
*
* Licensed 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 com.jd.live.agent.bootstrap.exception;

import lombok.Getter;

/**
* FaultException
*
* @since 1.4.0
*/
@Getter
public class FaultException extends LiveException implements Unretryable {

private final Integer code;

public FaultException(int code, String message) {
super(message, null, false, false);
this.code = code;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @since 1.0.0
*/
public class RejectException extends LiveException {
public class RejectException extends LiveException implements Unretryable {

public RejectException() {
super(null, null, false, false);
Expand Down Expand Up @@ -129,7 +129,7 @@ public RejectUnitException(Throwable cause) {
/**
* RejectEscapeException
*/
public static class RejectEscapeException extends RejectUnitException {
public static class RejectEscapeException extends RejectException {

public RejectEscapeException() {
}
Expand All @@ -148,6 +148,28 @@ public RejectEscapeException(Throwable cause) {

}

/**
* RejectPermissionException
*/
public static class RejectPermissionException extends RejectException {

public RejectPermissionException() {
}

public RejectPermissionException(String message) {
super(message);
}

public RejectPermissionException(String message, Throwable cause) {
super(message, cause);
}

public RejectPermissionException(Throwable cause) {
super(cause);
}

}

/**
* RejectAuthException
*/
Expand Down
Loading

0 comments on commit 746c2a4

Please sign in to comment.