- 授权协议: GPL
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: http://git.oschina.net/sandyfog/zrpc
- 软件文档: http://git.oschina.net/sandyfog/zrpc
软件介绍
ZRPC
基于Netty实现的RPC框架
服务端
RpcServer server = new RpcServer("127.0.0.1",1234);
HelloServiceImpl impl = new HelloServiceImpl();
server.export(HelloService.class, impl);客户端
RpcClient client = new RpcClient("127.0.0.1",1234);
HelloService service = client.refer(HelloService.class);
//同步调用
System.out.println(service.hello("test rpc"));异步调用
默认的远程调用都是同步的,发起异步调用需要设置RpcContext.setAsync(true),异步调用有两种方式:Future方式、callback方式,可以单独使用也可以混合使用
Future方式
RpcClient client = new RpcClient("127.0.0.1",1234);
HelloService service = client.refer(HelloService.class);
RpcContext ctx = RpcContext.getContext();
ctx.setAsync(true);
String obj=service.hello("test rpc");
System.out.println(obj==null);
Future<String> f =ctx.getFuture();
System.out.println(f.get());callback方式
RpcClient client = new RpcClient("127.0.0.1",1234);
HelloService service = client.refer(HelloService.class);
RpcContext ctx = RpcContext.getContext();
ctx.setAsync(true);
ctx.setCallback(new Callback() {
@Override
public void onSuccess(Object result) {
System.out.println("success "+ result);
}
@Override
public void onError(Throwable thr) {
System.out.println("error");
thr.printStackTrace();
}
});
String obj=service.hello("test rpc");
System.out.println(obj==null);单向调用
单向调用是一种特殊类型的异步调用,意味着客户端对本次调用不期待服务端的响应结果。实际上服务端对于单向调用请求也不会作出响应。对于特定场景单向调用性能更好,但并不那么可靠。
//单向调用
RpcContext ctx = RpcContext.getContext();
ctx.setOneway(true);
System.out.println(service.hello("test rpc")==null);
算法设计与应用
迈克尔 T. 古德里奇(Michael T. Goodrich)、罗伯特·塔马契亚(Roberto Tamas / 乔海燕、李悫炜、王烁程 / 机械工业出版社 / 2017-11-20 / CNY 139.00
本书全面系统地介绍算法设计和算法应用的各个领域,内容涵盖经典数据结构、经典算法、算法分析方法、算法设计方法以及算法在各个领域的应用,还包含一些高级主题。本书采用应用驱动的方法引入各章内容,内容编排清晰合理,讲解由浅入深。此外,各章都附有巩固练习、创新练习和应用练习三种类型的题目,为读者理解和掌握算法设计和应用提供了很好的素材。 本书可作为高等院校计算机及相关专业“数据结构和算法”课程的本科生......一起来看看 《算法设计与应用》 这本书的介绍吧!
