package com.protobuf.test.grpc.client;
import com.protobuf.test.grpc.demo.dto.*;
import com.protobuf.test.grpc.demo.service.DemoServiceGrpc;
import io.grpc.ChannelImpl;
import io.grpc.netty.NegotiationType;
import io.grpc.netty.NettyChannelBuilder;
import java.util.concurrent.TimeUnit;
/**
* Created by liuzhimeng on 2017/10/31.
*/
public class DemoServiceClient {
private final ChannelImpl channel;
private final DemoServiceGrpc.DemoServiceBlockingStub blockingStub;
public DemoServiceClient(String host, int port) {
channel =
NettyChannelBuilder.forAddress(host, port).negotiationType(NegotiationType.PLAINTEXT)
.build();
blockingStub = DemoServiceGrpc.newBlockingStub(channel);
}
public void shutdown() throws InterruptedException {
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
}
public void ping(String name) {
try {
System.out.println("Will try to ping " + name + " ...");
PingRequest request = PingRequest.newBuilder().setIn(name).build();
PingResponse response = blockingStub.ping(request);
System.out.println("ping: " + response.getOut());
} catch (RuntimeException e) {
System.out.println("RPC failed:" + e.getMessage());
return;
}
}
public void getPersonList(QueryParameter parameter) {
try {
System.out.println("Will try to getPersonList " + parameter + " ...");
PersonList response = blockingStub.getPersonList(parameter);
System.out.println("items count: " + response.getItemsCount());
for (Person p : response.getItemsList()) {
System.out.println(p);
}
} catch (RuntimeException e) {
System.out.println("RPC failed:" + e.getMessage());
return;
}
}
public static void main(String[] args) throws Exception {
DemoServiceClient client = new DemoServiceClient("localhost", 50051);
try {
client.ping("a");
int max =1;
Long start = System.currentTimeMillis();
for (int i = 0; i < max; i++) {
client.getPersonList(getParameter());
}
Long end = System.currentTimeMillis();
Long elapse = end - start;
int perform = Double.valueOf(max / (elapse / 1000d)).intValue();
System.out.print("rgpc " + max + " 次NettyServer调用,耗时:" + elapse + "毫秒,平均" + perform + "次/秒");
} finally {
client.shutdown();
}
}
private static QueryParameter getParameter() {
return QueryParameter.newBuilder().setAgeStart(5).setAgeEnd(6).build();
}
}
启动server端后测试:
Will try to ping a ... ping: pong => a Will try to getPersonList ageStart: 5 ageEnd: 6 ... items count: 1 age: 5 name: "test5" sex: true childrenCount: 5
Edo Interactive在几年前遇到一个大问题:公司使用交易数据来帮助零售商和餐馆进行个性化促销,但其数据仓库没有足够时间去处理所有的信用卡和借记卡交易数据
“我们要花费27小时来处理每日的数据量,”Edo主管基础设施和信息系统的高级副总裁Tim Garnto说道:“所以在2013年,我们放弃了现有的基于PostgreSQL的关系型数据库系统,使用了Hadoop集群作为公司的数
例如我们把scott.dept表生成文本文件的语句写成dept.sql,内容如下:
set pages 50000;
set lines 200;
set trims on;
set heading off;
spool /oracle_backup/log/test/dept.lst;
select deptno||','||dname||','||loc
1. Download and unzip the SonarQube distribution
2. Starting the Web Server
The default port is "9000" and the context path is "/". These values can be changed in &l
昨天在为了把laravel升级到最新的版本,突然之间就出现了如下错误:
ErrorException thrown with message "Declaration of Illuminate\View\Engines\CompilerEngine::handleViewException() should be compatible with Illuminate\View\Eng
import java.util.Arrays;
import java.util.Random;
public class Nim {
/**编程之美 NIM游戏分析
问题:
有N块石头和两个玩家A和B,玩家A先将石头随机分成若干堆,然后按照BABA...的顺序不断轮流取石头,
能将剩下的石头一次取光的玩家获胜,每次取石头时,每个玩家只能从若干堆石头中任选一堆,
今天在测试环境使用yum安装,遇到一个问题:
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
处理很简单,修改文件“/etc/yum.repos.d/epel.repo”, 将baseurl的注释取消, mirrorlist注释掉。即可。
&n
今天在linux下做hbase集群的时候,发现hmaster启动成功了,但是用hbase命令进入shell的时候报了一个错误 PleaseHoldException: Master is initializing,查看了日志,大致意思是说master和slave时间不同步,没办法,只好找一种手动同步一下,后来发现一共部署了10来台机器,手动同步偏差又比较大,所以还是从网上找现成的解决方