- 浏览: 232752 次
文章分类
- 全部博客 (160)
- java语言基础 (67)
- jsp基础 (2)
- eclipse使用 (2)
- java源码解读 (6)
- 计算机基础 (3)
- eclipse插件 (0)
- 网络基础 (8)
- 算法 (2)
- linux (0)
- 英语 (0)
- C语言 (4)
- JavaScript (17)
- 数学 (0)
- struts2 (2)
- 自然哲学 (0)
- Servlet (1)
- HttpServer (2)
- ext (1)
- 个人 (1)
- dojo (27)
- spring (2)
- hibernate (4)
- css (3)
- 多线程 (0)
- chrome插件开发 (0)
- svn (0)
- thrift (2)
- phonegap (1)
- java线程 (1)
- 不是很熟悉的css属性 (0)
- 数据库性能调优 (0)
- 项目管理 (1)
- ios (0)
- 软件工程 (0)
- db2 (0)
- 词汇管理 (0)
- zhenyan (0)
- 计划 (0)
- android (0)
- ssss (0)
- 是的 (0)
- dsada (0)
- 泛点是 (0)
- fds (0)
- cxzc (0)
- 权限 (0)
- dfsfds (0)
- http://www.cnblogs.com/kingboy2008/p/5261771.html (0)
- sss (0)
- ddd (0)
- fdsfdsf (0)
- sso (0)
- nginx (0)
- 分布式数据一致性 (0)
- mysql (0)
- ios永久存储 (0)
- js匿名函数 (0)
- 打印机qqq (0)
最新评论
package org.apache.thrift.transport; public abstract class TTransport { /** * Queries whether the transport is open. * * @return True if the transport is open. */ public abstract boolean isOpen(); /** * Is there more data to be read? * * @return True if the remote side is still alive and feeding us */ public boolean peek() { return isOpen(); } /** * Opens the transport for reading/writing. * * @throws TTransportException if the transport could not be opened */ public abstract void open() throws TTransportException; /** * Closes the transport. */ public abstract void close(); /** * Reads up to len bytes into buffer buf, starting at offset off. * * @param buf Array to read into * @param off Index to start reading at * @param len Maximum number of bytes to read * @return The number of bytes actually read * @throws TTransportException if there was an error reading data */ public abstract int read(byte[] buf, int off, int len) throws TTransportException; /** * Guarantees that all of len bytes are actually read off the transport. * * @param buf Array to read into * @param off Index to start reading at * @param len Maximum number of bytes to read * @return The number of bytes actually read, which must be equal to len * @throws TTransportException if there was an error reading data */ public int readAll(byte[] buf, int off, int len) throws TTransportException { int got = 0; int ret = 0; while (got < len) { ret = read(buf, off+got, len-got); if (ret <= 0) { throw new TTransportException( "Cannot read. Remote side has closed. Tried to read " + len + " bytes, but only got " + got + " bytes. (This is often indicative of an internal error on the server side. Please check your server logs.)"); } got += ret; } return got; } /** * Writes the buffer to the output * * @param buf The output data buffer * @throws TTransportException if an error occurs writing data */ public void write(byte[] buf) throws TTransportException { write(buf, 0, buf.length); } /** * Writes up to len bytes from the buffer. * * @param buf The output data buffer * @param off The offset to start writing from * @param len The number of bytes to write * @throws TTransportException if there was an error writing data */ public abstract void write(byte[] buf, int off, int len) throws TTransportException; /** * Flush any pending data out of a transport buffer. * * @throws TTransportException if there was an error writing out data. */ public void flush() throws TTransportException {} /** * Access the protocol's underlying buffer directly. If this is not a * buffered transport, return null. * @return protocol's Underlying buffer */ public byte[] getBuffer() { return null; } /** * Return the index within the underlying buffer that specifies the next spot * that should be read from. * @return index within the underlying buffer that specifies the next spot * that should be read from */ public int getBufferPosition() { return 0; } /** * Get the number of bytes remaining in the underlying buffer. Returns -1 if * this is a non-buffered transport. * @return the number of bytes remaining in the underlying buffer. <br> Returns -1 if * this is a non-buffered transport. */ public int getBytesRemainingInBuffer() { return -1; } /** * Consume len bytes from the underlying buffer. * @param len */ public void consumeBuffer(int len) {} }
发表评论
-
ProcessFunction
2012-07-14 22:27 0public abstract class Proces ... -
TBaseProcessor
2012-07-14 22:25 0public abstract class TBaseP ... -
TProcessor
2012-07-14 22:19 0/** * A processor is a gen ... -
TBase
2012-07-14 22:17 0/** * Generic base interfa ... -
TJSONProtocol
2012-07-14 22:16 0/** * JSON protocol implem ... -
TMessage
2012-07-14 21:13 0/** * Helper class that en ... -
TProtocol
2012-07-14 21:12 0/** * Protocol interface d ... -
TNonblockingTransport
2012-07-14 21:02 0public abstract class TNonbl ... -
TNonblockingSocket
2012-07-14 21:02 0/** * Transport for use wi ... -
TFileTransport
2012-07-14 20:57 0/** * FileTransport implem ... -
AutoExpandingBufferReadTransport
2012-07-14 20:48 0/** * TTransport for readi ... -
AutoExpandingBuffer
2012-07-14 20:46 0/** * Helper class that wr ... -
TServerTransport
2012-07-14 20:43 0/** * Server transport. Ob ... -
TServerSocket
2012-07-14 20:43 0/** * Wrapper around Serve ... -
TIOStreamTransport
2012-07-14 20:40 0/** * This is the most com ... -
TSocket
2012-07-14 20:38 5028import org.slf4j.Logger; im ...
相关推荐
2. **TServer**:服务器端的核心,它使用TServerTransport创建TTransport,通过TTransportFactory和TProtocolFactory生成TTransport和TProtocol实例,最后调用TProcessor处理请求。 在实际应用中,Thrift通过`...
TTransport(负则传输的模块,就是底层I/O的实现):每一种传输方式都对应一个该模块,比如TSocket负则Socket通信,负责传输的对象就是Message。 TProtocol:这个就是协议模块,因为对Message的传输需要统一,否则就...
在客户端,我们同样需要创建一个`TTransport`和`TProtocol`,然后通过`HelloWorldClient`与服务器建立连接并调用服务方法。例如: ```cpp std::shared_ptr<TTransport> transport(new TSocket("localhost", 9090));...
`TTransport`和`TProtocol`是Thrift框架的核心组件,它们负责建立与Thrift服务的连接以及数据的序列化和反序列化。`Hbase.Client`对象是与HBase进行交互的接口,提供了一系列方法来执行读写操作。\n\n注意,实际使用...
transport = TTransport.TBufferedTransport(transport) protocol = TBinaryProtocol.TBinaryProtocol(transport) client = Hbase.Client(protocol) try: transport.open() # 创建表 tablename = 'myTable' ...
然后,创建一个TTransport实例,如TFramedTransport,以及一个TProtocol实例,如TBinaryProtocol。使用这些实例创建Thrift的客户端,调用服务方法进行通信。 在Java中,这个过程可能看起来像这样: ```java ...
客户端则创建一个`TTransport`对象(如`TSocket`)连接到服务器,然后构建一个`TProtocol`,并通过`TestService$Client`与服务交互: ```java public class Client { public static void main(String[] args) ...
在架构上,Thrift 分为多个层次,包括业务逻辑代码、IDL生成的代码、传输协议(TProtocol)、传输层(TTransport)以及底层I/O通信。用户定义的业务逻辑位于最高层,通过Thrift编译器生成的代码与中间层交互,这个...
在客户端,同样使用生成的Java代码,创建`ThriftService.Client`实例,通过`TTransport`连接到服务器,调用服务方法。例如: ```java public static void main(String[] args) throws Exception { TTransport ...
在客户端,你需要创建一个`TTransport`实例(如`TBufferedTransport`)和一个`TProtocol`实例(如`TBinaryProtocol`),然后使用这些实例创建一个`IServiceClient`对象。之后,就可以通过这个客户端调用服务端的方法...
客户端也需要使用Thrift编译器生成的代码,创建一个`TTransport`对象,然后创建`TProtocol`和`TestService.Client`对象,以便调用服务: ```java TTransport transport = new TSocket("localhost", 9090); ...
5. **创建客户端**:在客户端,我们需要创建一个`TTransport`对象,一个`TProtocol`对象,然后实例化服务的客户端类。例如: ```java TTransport transport = new TSocket("localhost", 9090); TProtocol ...
参考Hbase源码安装包中的`examples/thrift/DemoClient.cpp`示例,创建一个连接到Hbase服务器的`TSocket`对象,如`boost::shared_ptr<TTransport> socket(new TSocket("localhost", 9090))`。接着,需要一个`...
客户端通过创建TTransport对象,然后构造TProtocol和客户端代理对象,调用服务端的方法: ```java public class CalculatorClient { public static void main(String[] args) throws Exception { TTransport ...
from thrift import TTransport, TSocket, TException from thrift.protocol import TBinaryProtocol from gen_py.hbase.ttypes import * # 创建socket连接 transport = TSocket.TSocket('localhost', 9090) ...
tfactory = TTransport.TBufferedTransportFactory() pfactory = TBinaryProtocol.TBinaryProtocolFactory() server = TServer.TSimpleServer(processor, transport, tfactory, pfactory) print("Starting the ...
TTransport transport = new TSocket("localhost", 9090); TBinaryProtocol protocol = new TBinaryProtocol(transport); Something.Client client = new Something.Client(protocol); transport.open(); ...