【问题标题】:Why does the HBase Thrift API always return a thrift client connection为什么 HBase Thrift API 总是返回 Thrift 客户端连接
【发布时间】:2013-03-21 01:45:44
【问题描述】:

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

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()]),

这引发了以下相关查询:

  1. 我应该始终使用返回的连接还是只使用第一个?
  2. 这些连接是否相同?
  3. 这种传递连接方法会导致连接泄漏吗?
  4. 有没有办法关闭这些连接或者它们有自己的 使用它们的每种 API 调用的生命周期?

【问题讨论】:

    标签: hbase thrift


    【解决方案1】:

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

    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}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-01
      • 1970-01-01
      相关资源
      最近更新 更多