资源简介
GRPC简单应用(Java+Python),java和python版本的grpc调用实现,附文档
代码片段和文件信息
/*
* Copyright 2015 gRPC Authors All rights reserved.
*
* Licensed under the Apache License Version 2.0 (the “License“);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing software
* distributed under the License is distributed on an “AS IS“ BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.taidi.nlp.ner.grpc;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.taidi.nlp.ner.grpc.DeepNerRequest.Builder;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.StatusRuntimeException;
/**
* A simple client that requests a greeting from the {@link HelloWorldServer}.
*/
public class DeepNerClient {
private static final Logger logger = Logger.getLogger(DeepNerClient.class.getName());
private final ManagedChannel channel;
private final QueryRpcGrpc.QueryRpcBlockingStub blockingStub;
/** Construct client connecting to HelloWorld server at {@code host:port}. */
public DeepNerClient(String host int port) {
this(ManagedChannelBuilder.forAddress(host port)
// Channels are secure by default (via SSL/TLS). For the example we disable TLS to avoid
// needing certificates.
.usePlaintext(true)
.build());
}
/** Construct client for accessing RouteGuide server using the existing channel. */
DeepNerClient(ManagedChannel channel) {
this.channel = channel;
blockingStub = QueryRpcGrpc.newBlockingStub(channel);
}
public void shutdown() throws InterruptedException {
channel.shutdown().awaitTermination(5 TimeUnit.SECONDS);
}
/** Say hello to server. */
public void query(String name) {
logger.info(“Will try to greet “ + name + “ ...“);
Builder request = DeepNerRequest.newBuilder();
request.setQuery(“听听他们的歌“);
request.setDomain(“music“);
String[] str = {“False song False False False False False False False False False False False False False False False False False False False“
“False song False False False False False False False False False False False False False False False False False False False“
“False song False anaphor False False album False False False False False anaphor_song False False False False False False False False“
“False song False anaphor False False album False False False False False anaphor_song False False False False False False False False“
“False False False anaphor False False False False False False False False anaphor_song False False False False False False False False“
相关资源
- 微博系统(Java源码,servlet+jsp),适
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
- 基于jsp的bbs论坛 非常详细
评论
共有 条评论