/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.slimsmart.thrift.rpc.demo;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-3-7")
public class EchoSerivce {
public interface Iface {
public String echo(String msg) throws org.apache.thrift.TException;
}
public interface AsyncIface {
public void echo(String msg, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
}
public static class Client extends org.apache.thrift.TServiceClient implements Iface {
public static class Factory implements org.apache.thrift.TServiceClientFactory<Client> {
public Factory() {}
public Client getClient(org.apache.thrift.protocol.TProtocol prot) {
return new Client(prot);
}
public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
return new Client(iprot, oprot);
}
}
public Client(org.apache.thrift.protocol.TProtocol prot)
{
super(prot, prot);
}
public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
super(iprot, oprot);
}
public String echo(String msg) throws org.apache.thrift.TException
{
send_echo(msg);
return recv_echo();
}
public void send_echo(String msg) throws org.apache.thrift.TException
{
echo_args args = new echo_args();
args.setMsg(msg);
sendBase("echo", args);
}
public String recv_echo() throws org.apache.thrift.TException
{
echo_result result = new echo_result();
receiveBase(result, "echo");
if (result.isSetSuccess()) {
return result.success;
}
throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "echo failed: unknown result");
}
}
public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {
private org.apache.thrift.async.TAsyncClientManager clientManager;
private org.apache.thrift.protocol.TProtocolFactory protocolFactory;
public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) {
this.clientManager = clientManager;
this.protocolFactory = protocolFactory;
}
public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) {
return new AsyncClient(protocolFactory, clientManager, transport);
}
}
public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) {
super(protocolFactory, clientManager, transport);
}
public void echo(String msg, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
checkReady();
echo_call method_call = new echo_call(msg, resultHandler, this, ___protocolFactory, ___transport);
this.___currentMethod = method_call;
___manager.call(method_call);
}
public static class echo_call extends org.apache.thrift.async.TAsyncMethodCall {
private String msg;
public echo_call(String msg, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
super(client, protocolFactory, transport, resultHandler, false);
this.msg = msg;
}
public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("echo", org.apache.thrift.protocol.TMessageType.CALL, 0));
echo_args args = new echo_args();
args.setMsg(msg);
args.write(prot);
prot.writeMessageEnd();
}
public String getResult() throws org.apache.thrift.TException {
if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
throw new IllegalStateException("Method call not finished!");
}
org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
return (new Client(prot)).recv_echo();
}
}
}
public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor {
private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
public Processor(I iface) {
super(iface, getProcessMap(new HashMap<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>()));
}
protected Processor(I iface, Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
super(iface, getProcessMap(processMap));
}
private static <I extends Iface> Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
processMap.put("echo", new echo());
return processMap;
}
public static class echo<I extends Iface> extends org.apache.thrift.ProcessFunction<I, echo_args> {
public echo() {
super("echo");
}
public echo_args getEmptyArgsInstance() {
return new echo_args();
}
protected boolean isOneway() {
return false;
}
public echo_result getResult(I iface, echo_args args) throws org.apache.thrift.TException {
echo_result result = new echo_result();
result.success = iface.echo(args.msg);
return result;
}
}
}
public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> {
private static final Logger LOGGER = LoggerFactory.getLogger(AsyncProcessor.class.getName());
public AsyncProcessor(I iface) {
super(iface, getProcessMap(new HashMap<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>>()));
}
protected AsyncProcessor(I iface, Map<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> processMap) {
super(iface, ge
没有合适的资源?快使用搜索试试~ 我知道了~
thrift-zookeeper-rpc
共23个文件
java:16个
xml:3个
thrift:1个
5星 · 超过95%的资源 需积分: 9 143 下载量 186 浏览量
2015-03-08
01:23:56
上传
评论 7
收藏 1.23MB RAR 举报
温馨提示
对于Thrift服务化的改造,主要是客户端,可以从如下几个方面进行: 1.服务端的服务注册,客户端自动发现,无需手工修改配置,这里我们使用zookeeper,但由于zookeeper本身提供的客户端使用较为复杂,因此采用curator-recipes工具类进行处理服务的注册与发现。 2.客户端使用连接池对服务调用进行管理,提升性能,这里我们使用Apache Commons项目commons-pool,可以大大减少代码的复杂度。 3.关于Failover/LoadBalance,由于zookeeper的watcher,当服务端不可用是及时通知客户端,并移除不可用的服务节点,而LoadBalance有很多算法,这里我们采用随机加权方式,也是常有的负载算法,至于其他的算法介绍参考:常见的负载均衡的基本算法。
资源推荐
资源详情
资源评论
收起资源包目录
thrift-zookeeper-rpc.rar (23个子文件)
pom.xml 1KB
thrift-0.9.2.exe 4.66MB
src
test
resources
spring-context-thrift-client.xml 2KB
log4j.properties 337B
spring-context-thrift-server.xml 3KB
java
cn
slimsmart
thrift
rpc
demo
Server.java 392B
EchoSerivceImpl.java 255B
EchoSerivce.java 32KB
Client.java 2KB
main
resources
EchoSerivce.thrift 100B
java
cn
slimsmart
thrift
rpc
ThriftServiceClientProxyFactory.java 3KB
zookeeper
FixedAddressProvider.java 2KB
ThriftServerAddressProviderZookeeper.java 6KB
ThriftServerAddressProvider.java 599B
ThriftServerIpLocalNetworkResolve.java 2KB
ThriftServerAddressRegisterZookeeper.java 2KB
ZookeeperFactory.java 2KB
ThriftServerAddressRegister.java 468B
ThriftServerIpResolve.java 474B
ThriftServiceServerFactory.java 5KB
ThriftException.java 419B
ThriftClientPoolFactory.java 3KB
thrift.bat 132B
共 23 条
- 1
slimina
- 粉丝: 423
- 资源: 66
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- STM32参考资料文档应用文档UM0427-基于ARM的32位MCU STM32F101xx 和 STM32F103xx固件库
- STM32参考资料文档应用文档UM0424-STM32F10xxx USB开发工具包
- STM32参考资料文档应用文档UM0306-STM32F10XXX使用手册
- STM32参考资料文档应用文档UIP协议的中文介绍
- STM32参考资料文档应用文档uip1.0
- STM32参考资料文档应用文档STM32中文参考手册-V10
- STM32参考资料文档应用文档STM32中断优先级相关概念与使用笔记
- Delphi XE10.3 FMX 画图程序资源文件介绍
- STM32参考资料文档应用文档STM32在马达控制中的应用
- MapWinGIS.ocx is a FREE and OPEN SOURCE C++ based geographic inf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页