Why does the HBase Thrift API always return a thrift client connection

扶醉桌前 提交于 2019-12-13 04:26:42

问题


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

erlang example:

% 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. Should I always use the returned connection or just the first one ?
  2. Are these connections the same ?
  3. Will this pass-along-connection approach cause connection leaks ?
  4. Is there a way to close these connections or they have their own lifecycle for every type of API call that uses them ?

回答1:


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}


来源:https://stackoverflow.com/questions/15718811/why-does-the-hbase-thrift-api-always-return-a-thrift-client-connection

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!