Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改curator客户端,解决zookeeper宕机重启CuratorWatcherImpl中的process方法异常的问题 #215

Open
wants to merge 70 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
f43d9ca
修改curator客户端,解决zookeeper宕机重启无法自动重连的问题
YanXs Oct 26, 2016
99b1242
为ApplicationConfig添加close方法,在spring context容器销毁时调用该方法释放资源
YanXs Dec 22, 2016
8c7c008
okhttpclient
YanXs Jan 2, 2017
4b3b12b
add rpcTracker and zipkin componets
YanXs Jan 9, 2017
d18fc2c
add servletFilter and create braveRpcTracker
Jan 11, 2017
5320668
TrackerConfig
Jan 12, 2017
b4e8085
add rpc request ...
Jan 13, 2017
529ac47
add OkHttpInvokerRequestExecutor
Jan 16, 2017
9f5b46d
confused
YanXs Jan 16, 2017
fe8ac45
add request builder,response builder, PendingReply
Jan 17, 2017
3ab7c85
HeaderExchangeChannelV2
YanXs Jan 17, 2017
28acaf1
add TrackerEngine...
Jan 18, 2017
4bc35da
BraveRpcTrackerEngineFactory
YanXs Jan 18, 2017
54b5cb7
rpc tracker component
Jan 19, 2017
663c0be
GroupingCluster
Jan 20, 2017
f2eb260
add execute request
YanXs Jan 22, 2017
437a269
move package
Jan 23, 2017
822e3e8
modify TrackerConfig and dubbo.xsd
YanXs Feb 5, 2017
f50b1bd
modify zipkin annotations
Feb 7, 2017
0855387
add DubboRequestInterceptorBuilder,HttpRequestResponseInterceptorBuilder
YanXs Feb 13, 2017
5a2d8a5
add BraveServletFilter
Feb 14, 2017
df19474
modify README.md, change collector to transport in TrackerConfig and …
YanXs Feb 14, 2017
50afcb2
modify README.md
YanXs Feb 14, 2017
1e7613d
内置tomcat容器添加Filter
Feb 15, 2017
9c7f031
修改了consumer,provider没有配置tracker引起的空指针bug
YanXs Feb 17, 2017
4247d17
1.修改TrackerConfig,添加ref属性可以引用外部Brave
YanXs Feb 21, 2017
ac44a8f
修改RpcTrackerManager初始化方法
YanXs Feb 22, 2017
549e320
修改README.md
YanXs Feb 25, 2017
807d46d
README.md
YanXs Apr 1, 2017
d860ed1
README.md
YanXs Apr 1, 2017
0c625a1
修改bug,没有配置链路追踪时会出现空指针
Apr 7, 2017
5181619
修改InvokerInvocationHandler
Apr 13, 2017
cbbd606
修改dubbo异步调用方式,删掉相关的类,Defuture,ResponseFuture.java, ResponseCallback.j…
Apr 14, 2017
0f88395
增加AsyncContext, AsyncableInvocationHandler支持客户端异步调用
Apr 14, 2017
896ad21
add TraceId and TraceIdReporter, update version to 3.0.1
YanXs Apr 16, 2017
35d68cd
README.md
YanXs Apr 16, 2017
ec7babb
README.md
YanXs Apr 16, 2017
cdf1594
TraceId TraceIdReporter
YanXs Apr 17, 2017
ecc2704
change the thread in AsyncContext to daemon
YanXs Apr 17, 2017
681d73b
add equals and hashCode methods in TraceId
Apr 18, 2017
af709d5
添加异步处理类, AsyncTarget, AsyncListener
Apr 21, 2017
c88d511
修复JettyHttpServer中因servletFilter没有配置引起的空指针bug
YanXs Apr 22, 2017
a45f6bc
增加NotifyCluster,NotifyClusterInvoker采用异步并行的方式,替换BroadcastCluster实现广播
YanXs Apr 23, 2017
cf6a508
修改AsyncContext
YanXs Apr 23, 2017
bac84ec
add AsyncInvocation extends AsyncTarget and AsyncListener
YanXs Apr 23, 2017
1231258
update README.md
Apr 25, 2017
a8febf6
修改 NotifyClusterInvoker AsyncContext
Apr 25, 2017
0b6919a
修改AsyncContext
Apr 26, 2017
6f23f92
添加 ReplyManager 修改 PendingReply
May 5, 2017
5631d96
修改 DubboRequest DubboResponse
May 8, 2017
53b9dd3
修改 DubboResponse
May 9, 2017
9cf1be5
README.md
YanXs May 11, 2017
4b9adc2
README.md
YanXs May 13, 2017
6a1281f
异步任务修改
May 17, 2017
dc8f29c
add AsyncRunnable
May 17, 2017
99b021b
Merge branch 'master' of https://github.com/YanXs/dubbo3
May 17, 2017
17683a6
修改测试 notifyCluster
May 17, 2017
64d2f42
add HystrixFilter using Hystrix
YanXs May 21, 2017
f28f3dd
add threads attribute for HystrixFilter
YanXs May 21, 2017
0ef50a1
重新设计 AsyncCommand 增加 ListenableAsyncCommand
YanXs May 22, 2017
8d9a6fc
NotifyClusterInvoker
YanXs May 22, 2017
43be42f
AsyncCommand ListenableAsyncCommand 修改
May 23, 2017
caeb633
add CommandExecutor CommandExecutorFactory
YanXs May 23, 2017
2fa1c90
LruCache
YanXs May 27, 2017
162736c
add ByteBuddyProxyFactory
YanXs May 28, 2017
7621ac1
drop ByteBuddyProxyFactory , udpate AsyncableInvocationHandler JdkPro…
May 31, 2017
6142f26
修改 AsyncCommand README.md
Jun 1, 2017
d11d1bd
add MethodCache
Jun 6, 2017
aadd1ae
修改 MethodCache
Jun 7, 2017
ef55ee6
修复 MethodCacheKey 计算错误BUG
YanXs Jun 7, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
263 changes: 102 additions & 161 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,202 +1,143 @@
Dubbox now means Dubbo eXtensions. If you know java, javax and dubbo, you know what dubbox is :)
# dubbo3

Dubbox adds features like RESTful remoting, Kyro/FST serialization, etc to the popular [dubbo service framework](http://github.com/alibaba/dubbo). It's been used by several projects of [dangdang.com](http://www.dangdang.com), which is one of the major e-commerce companies in China.
dubbo3 基于 [dubbox 2.8.4] (https://github.com/dangdangdotcom/dubbox) 修改
具体的使用方法请参考[dubbox 2.8.4] (https://github.com/dangdangdotcom/dubbox)

## 主要贡献者
## dubbo3修改和增加的功能

* 沈理 [当当网](http://www.dangdang.com/) [email protected]
* 王宇轩 [当当网](http://www.dangdang.com/) [email protected]
* 马金凯 [韩都衣舍](http://www.handu.com/) [email protected]
* Dylan 独立开发者 [email protected]
* Kangfoo 独立开发者
* 重新设计实现了consumer端的异步实现方式,支持guava的ListenableFuture,使用异步调用api更加简单

有技术问题请移步此处讨论 https://github.com/dangdangdotcom/dubbox/issues
* 添加NotifyCluster和NotifyClusterInvoker代替BroadcastCluster和BroadcastClusterInvoker实现广播

## Dubbox当前的主要功能
* 实现基于dubbo、hessian、http协议的分布式服务链路监控和追踪功能,可以将服务链路信息报告给[Zipkin](http://zipkin.io/),Zipkin的用户界面可以浏览全链路每一个服务的延迟

* **支持REST风格远程调用(HTTP + JSON/XML)**:基于非常成熟的JBoss [RestEasy](http://resteasy.jboss.org/)框架,在dubbo中实现了REST风格(HTTP + JSON/XML)的远程调用,以显著简化企业内部的跨语言交互,同时显著简化企业对外的Open API、无线API甚至AJAX服务端等等的开发。事实上,这个REST调用也使得Dubbo可以对当今特别流行的“微服务”架构提供基础性支持。 另外,REST调用也达到了比较高的性能,在基准测试下,HTTP + JSON与Dubbo 2.x默认的RPC协议(即TCP + Hessian2二进制序列化)之间只有1.5倍左右的差距,详见文档中的基准测试报告。
* 修改了ExchangeChannel中同步调用的接口,增加Interceptor接口拦截request记录服务调用信息

* **支持基于Kryo和FST的Java高效序列化实现**:基于当今比较知名的[Kryo](https://github.com/EsotericSoftware/kryo)和[FST](https://github.com/RuedigerMoeller/fast-serialization)高性能序列化库,为Dubbo默认的RPC协议添加新的序列化实现,并优化调整了其序列化体系,比较显著的提高了Dubbo RPC的性能,详见文档中的基准测试报告。
* 添加了okhttp3支持hessian协议、http协议,目前对这两种协议的拦截基于OkhttpClient的Interceptor机制

* **支持基于Jackson的JSON序列化**:基于业界应用最广泛的[Jackson](http://jackson.codehaus.org/)序列化库,为Dubbo默认的RPC协议添加新的JSON序列化实现。
### consumer异步调用

* **支持基于嵌入式Tomcat的HTTP remoting体系**:基于嵌入式tomcat实现dubbo的HTTP remoting体系(即dubbo-remoting-http),用以逐步取代Dubbo中旧版本的嵌入式Jetty,可以显著的提高REST等的远程调用性能,并将Servlet API的支持从2.5升级到3.1。(注:除了REST,dubbo中的WebServices、Hessian、HTTP Invoker等协议都基于这个HTTP remoting体系)。
#### Example 1: 基于guava ListenableFuture示例
```java
ListenableFuture<Complex> future = simpleService.async_getComplex("abc");
Futures.addCallback(future, new FutureCallback<Complex>() {
@Override
public void onSuccess(Complex result) {

}

* **升级Spring**:将dubbo中Spring由2.x升级到目前最常用的3.x版本,减少版本冲突带来的麻烦。
@Override
public void onFailure(Throwable t) {

* **升级ZooKeeper客户端**:将dubbo中的zookeeper客户端升级到最新的版本,以修正老版本中包含的bug。

* **支持完全基于Java代码的Dubbo配置**:基于Spring的Java Config,实现完全无XML的纯Java代码方式来配置dubbo

* **调整Demo应用**:暂时将dubbo的demo应用调整并改写以主要演示REST功能、Dubbo协议的新序列化方式、基于Java代码的Spring配置等等。

* **修正了dubbo的bug** 包括配置、序列化、管理界面等等的bug。

**注:dubbox和dubbo 2.x是兼容的,没有改变dubbo的任何已有的功能和配置方式(除了升级了spring之类的版本)**

## 文档资料

[在Dubbo中开发REST风格的远程调用(RESTful Remoting)](http://dangdangdotcom.github.io/dubbox/rest.html)

[在Dubbo中使用高效的Java序列化(Kryo和FST)](http://dangdangdotcom.github.io/dubbox/serialization.html)

[使用JavaConfig方式配置dubbox](http://dangdangdotcom.github.io/dubbox/java-config.html)

[Dubbo Jackson序列化使用说明](http://dangdangdotcom.github.io/dubbox/jackson.html)

[Demo应用简单运行指南](http://dangdangdotcom.github.io/dubbox/demo.html)

[Dubbox@InfoQ](http://www.infoq.com/cn/news/2014/10/dubbox-open-source)

[Dubbox Wiki](https://github.com/dangdangdotcom/dubbox/wiki) (由社区志愿者自由编辑的)

## 版本
}
});
```
dubbo3中异步实现思路是为同步接口生成对应的异步接口,consumer和provider使用生成的接口
在客户端的代理InvocationHandler中调用同步接口, 具体实现参考AsyncableInvocationHandler
origin interface:
```java
@AutoAsync
public interface SimpleService {
@Asyncable
Complex getComplex(String id);
}
```
async interface:(使用auto-async自动生成)
```java
@AutoGenerated(
value = "net.auto.async.processor.AutoAsyncProcessor"
)
public interface Unified_SimpleService extends SimpleService {
ListenableFuture<Complex> async_getComplex(String id);
}
```
consumer配置
```xml
<dubbo:reference id="service" interface="Unified_SimpleService"/>
```
provider配置
```xml
<dubbo:service id="service" interface="Unified_SimpleService"/>
```

详见:https://github.com/dangdangdotcom/dubbox/releases
#### auto-async自动生成异步接口
自动生成async interface需要使用[auto-async] (https://github.com/YanXs/auto-async)
```xml
<dependency>
<groupId>net.vakilla</groupId>
<artifactId>auto-async</artifactId>
<version>1.0.0</version>
</dependency>
```
### NotifyCluster广播
dubbo中使用BroadcastCluster实现广播功能,实现方式是顺序调用所有的invoker。这种方式带来的问题是效率低,时间复杂度O(m*n),m代表invoker数量,n代表方法执行时间
NotifyCluster采用异步模式并行调用invoker,时间复杂度可以接近O(n),当然取决于线程数量和invoker的数量,但是相比于BroadcastCluster线性调用性能高出很多

* **dubbox-2.8.0**:主要支持REST风格远程调用、支持Kryo和FST序列化、升级了Spring和Zookeeper客户端、调整了demo应用等等
* **dubbox-2.8.1**:主要支持基于嵌入式tomcat的http-remoting,优化了REST客户端性能,在REST中支持限制服务端接纳的最大HTTP连接数等等
* **dubbox-2.8.2**:
* 支持REST中的HTTP logging,包括HTTP header的字段和HTTP body中的消息体,方便调试、日志纪录等等
* 提供辅助类便于REST的中文处理
* 改变使用`@Reference` annotation配置时的异常处理方式,即当用annotation配置时,过去dubbo在启动期间不抛出依赖服务找不到的异常,而是在具体调用时抛出NPE,这与用XML配置时的行为不一致。
* 较大的充实了Dubbo REST的文档
* **dubbox-2.8.3**:
* 在REST中支持dubbo统一的方式用bean validation annotation作参数校验(沈理)
* 在RpcContext上支持获取底层协议的Request/Response(沈理)
* 支持采用Spring的Java Config方式配置dubbo(马金凯)
* 在Dubbo协议中支持基于Jackson的json序列化(Dylan)
* 在Spring AOP代理过的对象上支持dubbo annotation配置(Dylan)
* 修正Dubbo管理界面中没有consumer时出现空指针异常(马金凯)
* 修正@Reference annotation中protocol设置不起作用的bug(沈理)
* 修正@Reference annotation放在setter方法上即会出错的bug(Dylan)
使用方式与broadcastCluster相同,只需要cluster=notify即可
具体实现参考NotifyClusterInvoker

## 依赖

从dubbox-2.8.4开始,所有依赖库的使用方式将和dubbo原来的一样:即如果要使用REST、Kyro、FST、Jackson等功能,需要用户自行手工添加相关的依赖。例如:
### rpcTracker分布式链路追踪

### REST风格远程调用
目前tracker的使用方式只支持spring xml配置,目前有如下两种方式

方式一:
```xml
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.0.7.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.0.7.Final</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<dubbo:tracker address="zipkin://127.0.0.1:9411" transport="http" sampler="counting" samplerate="1.0" flushinterval="2"/>
```

<!-- 如果要使用json序列化 -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>3.0.7.Final</version>
</dependency>
* address: zipkin transport address
* collector(transport): http\kafka\scribe
* sampler:采样器
* samplerate:采样率
* flushinterval:数据刷新频率

<!-- 如果要使用xml序列化 -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>3.0.7.Final</version>
</dependency>
方式二:
使用方式一在dubbo内部创建tracker对象,因为目前只支持zipkin,tracker对应Brave,没有办法同其他系统,比如数据库的监控结合起来,推荐使用下面的方式
配置

<!-- 如果要使用netty server -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-netty</artifactId>
<version>3.0.7.Final</version>
</dependency>
```xml
<dubbo:tracker id="trackerEngine" protocol="zipkin" ref="braveRpcTrackerEngine"/>

<!-- 如果要使用Sun HTTP server -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jdk-http</artifactId>
<version>3.0.7.Final</version>
</dependency>
<bean id="braveRpcTrackerEngine" class="brave.spring.BraveRpcTrackerEngineFactoryBean">
<property name="brave" ref="brave"/>
</bean>

<!-- 如果要使用tomcat server -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>8.0.11</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-logging-juli</artifactId>
<version>8.0.11</version>
</dependency>
<bean id="brave" class="brave.spring.BraveFactoryBean">
<property name="serviceName" value="demo-provider"/>
<property name="transport" value="http"/>
<property name="transportAddress" value="127.0.0.1:9411"/>
</bean>
```

### Kyro序列化

```xml
<dependency>
<groupId>com.esotericsoftware.kryo</groupId>
<artifactId>kryo</artifactId>
<version>2.24.0</version>
</dependency>
<dependency>
<groupId>de.javakaffee</groupId>
<artifactId>kryo-serializers</artifactId>
<version>0.26</version>
</dependency>
```
## 依赖

### FST序列化
服务链路追踪主要基于Zipkin的 [brave] (https://github.com/openzipkin/brave)
链路追踪功能参考另一个项目 [nightawk] (https://github.com/YanXs/nighthawk)
项目中需要引用

```xml
<dependency>
<groupId>de.ruedigermoeller</groupId>
<artifactId>fst</artifactId>
<version>1.55</version>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>3.0.1</version>
</dependency>
```

### Jackson序列化

```xml
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.3.3</version>
<groupId>io.vakilla.nightawk</groupId>
<artifactId>nightawk-core</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.3.3</version>
<groupId>io.vakilla.nightawk</groupId>
<artifactId>nightawk-dubbo3</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
```

## FAQ(暂存)

### Dubbox需要什么版本的JDK?

目前最好在JDK 1.7以上运行

### Dubbo REST的服务能和Dubbo注册中心、监控中心集成吗?

可以的,而且是自动集成的,也就是你在dubbo中开发的所有REST服务都会自动注册到服务册中心和监控中心,可以通过它们做管理。

但是,只有当REST的消费端也是基于dubbo的时候,注册中心中的许多服务治理操作才能完全起作用。而如果消费端是非dubbo的,自然不受注册中心管理,所以其中很多操作是不会对消费端起作用的。

### Dubbo REST中如何实现负载均衡和容错(failover)?

如果dubbo REST的消费端也是dubbo的,则Dubbo REST和其他dubbo远程调用协议基本完全一样,由dubbo框架透明的在消费端做load balance、failover等等。

如果dubbo REST的消费端是非dubbo的,甚至是非java的,则最好配置服务提供端的软负载均衡机制,目前可考虑用LVS、HAProxy、 Nginx等等对HTTP请求做负载均衡。

### JAX-RS中重载的方法能够映射到同一URL地址吗?
以上依赖需要自己使用maven编译打包(以后会提交到maven中央库)

http://stackoverflow.com/questions/17196766/can-resteasy-choose-method-based-on-query-params

### JAX-RS中作POST的方法能够接收多个参数吗?

http://stackoverflow.com/questions/5553218/jax-rs-post-multiple-objects
2 changes: 1 addition & 1 deletion dubbo-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
<version>2.8.4</version>
<version>3.0.1</version>
</parent>
<artifactId>dubbo-admin</artifactId>
<packaging>war</packaging>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Project: dubbo.registry.server-1.1.0-SNAPSHOT
*
* <p/>
* File Created at 2010-10-21
* $Id: LoadBalance.java 181192 2012-06-21 05:05:47Z tony.chenl $
*
* <p/>
* Copyright 2008 Alibaba.com Croporation Limited.
* All rights reserved.
*
* <p/>
* This software is the confidential and proprietary information of
* Alibaba Company. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
Expand All @@ -20,27 +20,27 @@
* @author rain.chenjr
*
*/
public class LoadBalance extends Entity{
public class LoadBalance extends Entity {

private static final long serialVersionUID = -6050324375352581440L;

public static final String ALL_METHOD = "*";

private String service; /* 服务名称 */
private String method; /* 方法名称 */
private String strategy; /*负载均衡策略*/
private String username; /*用户名*/
private String service; /* 服务名称 */

private String method; /* 方法名称 */

private String strategy; /*负载均衡策略*/

private String username; /*用户名*/

public LoadBalance() {
}

public LoadBalance(Long id) {
super(id);
}

public String getService() {
return service;
}
Expand Down Expand Up @@ -73,5 +73,5 @@ public void setUsername(String username) {
this.username = username;
}


}
Loading