Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fengjiachun/Jupiter

Jupiter是一款性能非常不错的, 轻量级的分布式服务框架
https://github.com/fengjiachun/Jupiter

cluster distributed-systems hessian high-performance java jupiter kryo microservice netty netty4 nio protostuff rpc rpc-framework service-consumer service-discovery service-provider service-registry socket spring

Last synced: 3 months ago
JSON representation

Jupiter是一款性能非常不错的, 轻量级的分布式服务框架

Awesome Lists containing this project

README

        

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](/LICENSE)
[![Maven Central](https://img.shields.io/maven-central/v/org.jupiter-rpc/jupiter.svg?label=Maven%20Central)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.jupiter-rpc%22%20AND%20jupiter)
[![Build Status](https://travis-ci.org/fengjiachun/Jupiter.svg?branch=master)](https://travis-ci.org/fengjiachun/Jupiter)
[![Code Quality: Java](https://img.shields.io/lgtm/grade/java/g/fengjiachun/Jupiter.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/fengjiachun/Jupiter/context:java)
[![Total Alerts](https://img.shields.io/lgtm/alerts/g/fengjiachun/Jupiter.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/fengjiachun/Jupiter/alerts)

#### Jupiter:
- Jupiter 是一款性能非常不错的, 轻量级的分布式服务框架

#### Jupiter Architecture:

═ ═ ═▷ init ─ ─ ─ ▷ async ──────▶ sync
----------------------------------------------------------------------------------------

┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
┌ ─ ─ ─ ┐ │
─ ─ ─ ─ ─ ─ ─ ─ ─│ Registry Monitor ───────────────────────────┐
│ └ ─ ─ ─ ┘ │ │
└ ─ ─△─ ─ ─ ─ ─△─ ─ ─ ▼
│ ┌ ─ ─ ─ ─
Notify ║ ║ Telnet │
│ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ └ ─ ─ ─ ─
║ ║ ▲
│ Subscribe Register │
║ ║ │
│ ┌ ─ ─ ─ ─ ─ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │
│─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ▷ ┌ ─ ─ ─ ┐ │ │
└ ▷│ Consumer Invoke │ Provider Monitor ─────┘
│────────────────────────▶ └ ─ ─ ─ ┘ │
└ ─ ─ ─ ─ ─ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─

---------------------------------------------------------------------------------------

#### [RELEASE-NOTES](/docs/release-notes.md)

#### 性能:
- 小数据包请求(不带业务)在四核刀片服务器上可达到17w+的tps, 详情见 [Benchmark](https://github.com/fengjiachun/Jupiter/wiki/Benchmark)
- [参考: 多个 RPC 框架的 Benchmark 见这里](https://github.com/hank-whu/rpc-benchmark)

#### 文档:
- [High performance RPC with netty](/docs/static_files/high_performance_rpc_with_netty.md)
- [High performance RPC with netty.pdf](/docs/static_files/high_performance_rpc_with_netty.pdf)
- [Wiki](https://github.com/fengjiachun/Jupiter/wiki)
- [其他文档](https://github.com/fengjiachun/doc/tree/master/jupiter)
- [发展路线](https://github.com/fengjiachun/Jupiter/wiki/RoadMap)

#### 一次 RPC 调用:

感谢 @远墨 提供的图

#### 快速开始:

##### 工程依赖:
+ JDK1.8 或更高版本
+ 依赖管理工具: Maven3.x 版本

##### [最新版本OSS下载](https://oss.sonatype.org/#nexus-search;quick~org.jupiter-rpc)
##### [最新版本Maven中心仓库下载](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.jupiter-rpc%22%20AND%20jupiter)
##### Maven依赖:
```xml

org.jupiter-rpc
jupiter-all
${jupiter.version}

```

##### 简单调用示例:
###### 1. 创建服务接口:

```java
@ServiceProvider(group = "test", name = "serviceTest")
public interface ServiceTest {
String sayHelloString();
}

@ServiceProvider:
- 建议每个服务接口通过此注解来指定服务信息, 如不希望业务代码对jupiter依赖也可以不使用此注解而手动去设置服务信息
+ group: 服务组别(选填, 默认组别为'Jupiter')
+ name: 服务名称(选填, 默认名称为接口全限定名称)
```

###### 2. 创建服务实现:

```java
@ServiceProviderImpl(version = "1.0.0")
public class ServiceTestImpl implements ServiceTest {

@Override
public String sayHelloString() {
return "Hello jupiter";
}
}

@ServiceProviderImpl:
- 建议每个服务实现通过此注解来指定服务版本信息, 如不希望业务代码对jupiter依赖也可以不使用此注解而手动去设置版本信息
+ version: 服务版本号(选填, 默认版本号为'1.0.0')
```

###### 3. 启动注册中心:

###### - 选择1: 使用 jupiter 默认的注册中心:

```java
public class HelloJupiterRegistryServer {

public static void main(String[] args) {
// 注册中心
RegistryServer registryServer = RegistryServer.Default.createRegistryServer(20001, 1);
try {
registryServer.startRegistryServer();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
```

###### - 选择2: 使用 [zookeeper](https://zookeeper.apache.org/doc/trunk/zookeeperStarted.html) 作为注册中心:

```xml
默认注册中心只建议在测试环境使用, 线上建议使用 zookeeper 实现

// 设置使用 zookeeper 作为注册中心
JServer server = new DefaultServer(RegistryService.RegistryType.ZOOKEEPER)
JClient client = new DefaultClient(RegistryService.RegistryType.ZOOKEEPER)

在 server 和 client 中配置 jupiter-registry-zookeeper 依赖(jupiter-all 包含 jupiter-registry-zookeeper)

org.jupiter-rpc
jupiter-registry-zookeeper
${jupiter.version}

```

###### 4. 启动服务提供(Server):

```java
public class HelloJupiterServer {

public static void main(String[] args) throws Exception {
JServer server = new DefaultServer().withAcceptor(new JNettyTcpAcceptor(18090));
// provider
ServiceTestImpl service = new ServiceTestImpl();
// 本地注册
ServiceWrapper provider = server.serviceRegistry()
.provider(service)
.register();
// 连接注册中心
server.connectToRegistryServer("127.0.0.1:20001");
// 向注册中心发布服务
server.publish(provider);
// 启动server
server.start();
}
}
```

###### 5. 启动服务消费者(Client)

```java
public class HelloJupiterClient {

public static void main(String[] args) {
JClient client = new DefaultClient().withConnector(new JNettyTcpConnector());
// 连接RegistryServer
client.connectToRegistryServer("127.0.0.1:20001");
// 自动管理可用连接
JConnector.ConnectionWatcher watcher = client.watchConnections(ServiceTest.class);
// 等待连接可用
if (!watcher.waitForAvailable(3000)) {
throw new ConnectFailedException();
}

ServiceTest service = ProxyFactory.factory(ServiceTest.class)
.version("1.0.0")
.client(client)
.newProxyInstance();

service.sayHelloString();
}
}
```

[Server/Client 代码示例](/jupiter-example/src/main/java/org/jupiter/example/round)

###### 新特性

v1.3 新增 `InvokeType.AUTO`, 当你的接口返回值是一个 `CompletableFuture` 或者它的子类将自动适配为异步调用, 否则为同步调用
[具体 demo 请参考这里](/jupiter-example/src/main/java/org/jupiter/example/round/AutoJupiterClient.java)

##### 结合Spring使用示例:
###### 1. [Server端配置](/jupiter-example/src/main/resources/spring-provider.xml):

```xml

```

###### 2. [Client 端配置](/jupiter-example/src/main/resources/spring-consumer.xml):

```xml










```

[SpringServer/SpringClient 代码示例](/jupiter-example/src/main/java/org/jupiter/example/spring)

##### [更多示例代码](/jupiter-example/src/main/java/org/jupiter/example)

#### 其他
- qq交流群: 397633380
- 邮件交流: [email protected]