为什么HBase Thrift API总是返回节俭的客户端连接 [英] Why does the HBase Thrift API always return a thrift client connection

查看:150
本文介绍了为什么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}

这篇关于为什么HBase Thrift API总是返回节俭的客户端连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆