为什么HBase Thrift API总是返回节俭的客户端连接

为什么HBase Thrift API总是返回节俭的客户端连接

问题描述:

对于每个节俭的API调用(在Erlang中使用HBase Thrift),API返回一个节俭连接:

For every thrift API call ( using HBase Thrift in Erlang )the API returns a thrift connection:

erlang示例:

% creating the initial connection

{ok, TFactory}          = thrift_socket_transport:new_transport_factory( "localhost", 9090, []),
{ok, PFactory}          = thrift_binary_protocol:new_protocol_factory(TFactory, []),
{ok, Protocol}          = PFactory(),
{ok, ThiftConnection1}  = thrift_client:new(Protocol, hbase_thrift),    

%calling a row mutation

{ThriftConnection2, Result} = thrift_client:call( ThriftConnection1, mutateRow, ["MYTABLE", Row1Id, MutationList1, dict:new()]),
{ThriftConnection3, Result} = thrift_client:call( ThriftConnection2, mutateRow, ["MYTABLE", Row2Id, MutationList2, dict:new()]),

这引发了下面的相关问题:

This raises the related inquiries below:


    我应该总是使用返回的连接或只是第一个?
  1. 这些连接是否相同?

  2. 这种传递连接方法会导致连接泄漏吗?
  3. 是否有关闭这些连接的方法,或者对于使用它们的每种类型的API调用,它们都有自己的
    生命周期?


我意识到这不是一个连接,而是一个节俭运输的参考。我将它们相互比较,它们是相同的。在Erlang中,打印他们的内容(序列化)关于每个结果的事实表明它们是相同的

I realized this is not a connection but a thrift-transport reference. I compared them to each other and they are identical. In Erlang, printing their content (serializing) the facts about each of those results indicate they are the same

ThriftConnection2 :
{tclient,hbase_thrift,
 {protocol,thrift_binary_protocol,
    {binary_protocol,
        {transport,thrift_buffered_transport,
            {buffered_transport,
                {transport,thrift_socket_transport,
                    {data,#Port<0.25469>,infinity}},
                []}},
        true,true}},
    0}

ThriftConnection3 :
{tclient,hbase_thrift,
{protocol,thrift_binary_protocol,
    {binary_protocol,
        {transport,thrift_buffered_transport,
            {buffered_transport,
                {transport,thrift_socket_transport,
                    {data,#Port<0.25469>,infinity}},
                []}},
        true,true}},
    0}