Nepxion Thunder(QQ 1394997)发布在淘宝代码基地 http://code.taobao.org/p/Thunder/
1. 类结构
- 1.1 cluster:负载均衡和远程注册中心集群服务地址同步
1.1.1 consistency:远程服务上下线会产生事件,该模块线程安全维护本地服务列表和注册中心同步。该服务列表将用在负载均衡
1.1.2 loadbalance:负载均衡。consistenthash为一致性Hash算法,random为随机轮循算法,roundrobin为权重轮循算法 - 1.2 common:通用实体类,工具类
1.2.1 callback - 异步回调接口实现
1.2.2 config - 持久化到注册中心的类,包括ApplicationConfig,ServiceConfig,ReferenceConfig
1.2.3 constants - 静态常量定义
1.2.4 container - 缓存和句柄容器定义,包括CacheContainer(线程安全的本地缓存容器,也同时利用它跟注册中心做同步),ExecutorContainer(句柄和运行器容器,对于这两者,在Thunder的实现,对外都是通过接口暴露,而实现类是通过配置文件定义的方式进行反射装载,反射初始化后的对象都保存在ExecutorContainer里)
1.2.5 delegate - 委托类实现,主要是针对Properties,CacheContainer,ExecutorContainer的代理,在Spring扫描线程中将委托类注入到各个FactorBean
1.2.6 entity - 本地实体类
1.2.7 eventbus - 事件驱动和解耦类
1.2.8 invocation - 用于反射调用
1.2.9 object - 对象池的实现
1.2.10 property - 读取本地和远程配置文件的实现
1.2.11 serialization - 快速序列化对象的实现(FST)
1.2.12 thread - 线程池的实现
1.2.13 util - 工具类的实现 - 1.3 framework:Spring扫描线程,初始化,包括对协议初始化,注册中心初始化等
1.3.1 bean - Spring FactoryBean
1.3.2 context - Spring上下文
1.3.3 exception - Spring相关异常
1.3.4 parser - Spring BeanDefinitionParser,用以解析FactoryBean
1.3.5 property - Spring属性解析 - 1.4 monitor:监控中心,包括基于Splunk的日志监控和第三方WebService定义的监控
- 1.5 protocol:协议,中间件的实现,包括Netty,Hessian,MQ的实现
1.5.1 apache:Apache同步和异步调用框架
1.5.2 hessian:Hessian同步和异步Http调用框架
1.5.3 kafka:Kafka消息队列调用通用框架
1.5.4 mq:ActiveMQ和Tibco消息队列调用通用框架
1.5.5 netty :Netty同步和异步Nio调用框架
1.5.6 redis:作为Netty和Hessian发布/订阅调用框架
- 1.6 registry:注册中心的实现
- 1.7 security:安全控制的实现,包括限流,密钥控制,版本控制等
2. 类管理
- Thunder基于Maven来管理
- Thunder构建于JDK 1.7版本,也兼容于JDK 1.6版本(需要重新编译源代码)
- Thunder引用了众多的第三方组件/开源框架,编译时候,需要如下的pom.xml文件做支持。绝大多数第三方组件/开源框架都升级到最新版,因为有些组件只支持JDK 1.7,如果你使用的环境只限于JDK 1.6,需要降级第三方组件/开源框架的版本,并重新编译
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>nepxion</groupId> <artifactId>root</artifactId> <version>1.0.0</version> <packaging>pom</packaging> <name>Nepxion Root</name> <url>http://code.taobao.org/u/Nepxion/</url> <properties> <org.springframework.version>4.2.3.RELEASE</org.springframework.version> <org.apache.logging.log4j.version>2.4.1</org.apache.logging.log4j.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.4</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-collections4</artifactId> <version>4.1</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.4</version> </dependency> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.9.2</version> </dependency> <dependency> <groupId>commons-jxpath</groupId> <artifactId>commons-jxpath</artifactId> <version>1.3</version> </dependency> <dependency> <groupId>commons-validator</groupId> <artifactId>commons-validator</artifactId> <version>1.5.0</version> </dependency> <dependency> <groupId>commons-configuration</groupId> <artifactId>commons-configuration</artifactId> <version>1.10</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> <version>2.4.2</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jms</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${org.springframework.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> <version>4.0.33.Final</version> </dependency> <dependency> <groupId>com.caucho</groupId> <artifactId>hessian</artifactId> <version>4.0.38</version> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-core</artifactId> <version>5.7.0</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-pool</artifactId> <version>5.13.0</version> </dependency> <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka-clients</artifactId> <version>0.9.0.0</version> </dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.8.0</version> </dependency> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-framework</artifactId> <version>2.9.0</version> <exclusions> <exclusion> <groupId>jline</groupId> <artifactId>jline</artifactId> </exclusion> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> <exclusion> <groupId>io.netty</groupId> <artifactId>netty</artifactId> </exclusion> <exclusion> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-recipes</artifactId> <version>2.9.0</version> <exclusions> <exclusion> <groupId>jline</groupId> <artifactId>jline</artifactId> </exclusion> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> <exclusion> <groupId>io.netty</groupId> <artifactId>netty</artifactId> </exclusion> <exclusion> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>de.ruedigermoeller</groupId> <artifactId>fst</artifactId> <version>2.43</version> <exclusions> <exclusion> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>aopalliance</groupId> <artifactId>aopalliance</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>19.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.6.4</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.6.4</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.6.4</version> </dependency> <dependency> <groupId>com.lmax</groupId> <artifactId>disruptor</artifactId> <version>3.3.2</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.1</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpasyncclient</artifactId> <version>4.1.1</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>${org.apache.logging.log4j.version}</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-1.2-api</artifactId> <version>${org.apache.logging.log4j.version}</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-slf4j-impl</artifactId> <version>${org.apache.logging.log4j.version}</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-jcl</artifactId> <version>${org.apache.logging.log4j.version}</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-jul</artifactId> <version>${org.apache.logging.log4j.version}</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-web</artifactId> <version>${org.apache.logging.log4j.version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit-dep</artifactId> <version>4.11</version> </dependency> </dependencies> </project>
- Thunder在第三方运行的时候,只需要引入确定的通信中间件即可。例如采用Netty通信,只需要引入Netty相关的包。当然,一些必要的基础包必须引入,它们包括:
Apache Common包
Spring Framework包
Curator包 (支撑Zookeeper框架)
FST包
Fast Json包
Log4J2包 (异步)
Redis包 (当用Netty和Hessian做发布/订阅功能的时候,需要用到它)
Apache HttpComponents (同步/异步包,当用第三方WebService做监控的时候,需要用到它)
Google Guava包(做EventBus用)
其它基础框架进入的包