o(* ̄︶ ̄*)o

  博客园  :: 首页  ::  :: 联系 :: 订阅 订阅  :: 管理

使用thrift2服务连接hbase提示"MaxMessageSize reached"

1. 环境组件

hdp版本 :3.3.2.0

HBase版本: 2.5.10
thrift版本:  0.14.1 

2. demo代码

    try 
    { 
        tsocket.reset(new TSocket(ip, 9090)); 
        ttransport.reset(new TBufferedTransport(tsocket)); 
        tprotocol.reset(new TBinaryProtocol(ttransport)); 

        ttransport->open();
    }
    catch (const TException &tx) 
    { 
        cout << "Connect Hbase error : " << tx.what()<<endl; 
        return false; 
    }
    
    cout << "open OK"<<endl; 
    client = new THBaseServiceClient(tprotocol);

bool tmp = false;
    try
    {
        TPut put;
        TColumnValue pval;

        put.row = g_rowkey;
        pval.family = g_family;
        pval.qualifier = g_qualifiter;
        pval.value = g_value;
        put.columnValues.push_back(pval);

        //client->put(g_table,put);
        tmp = client->checkAndPut(g_table,g_rowkey,g_family,g_qualifiter,g_value,put);
        if(!tmp) 
        {
            client->put(g_table,put);
        }
    }
    catch (const TException &tx)
    {
        cout << "Operate Hbase CheckAndPut Fail : " << tx.what() << endl;
        ttransport->close();
        return false;
    }
    cout << "Operate Hbase CheckAndPut Success : " << g_table << " [" << tmp << "]" << endl;

 

3. 异常提示:"MaxMessageSize reached"

    该提示来源thrift库返回的异常提示(客户端,非服务端返回),客户端本地定义的消息长度,超出了服务段返回的消息长度。

 3.1函数调用顺序

→ checkAndPut
→ recv_put
→ TBinaryProtocolT::readMessageBegin 
→ readString / readI32 
→ TTransport::checkReadBytesAvailable 
→ 抛出"MaxMessageSize reached"错误

4. 处理方案

4.1 回退配置文件

将hbase-site.xml回退原配置。

4.2 .ambari查看提交记录删除修改记录,删除如下AI提供的修改建议:

hbase.regionserver.thrift.https=true
hbase.regionserer.thrift.port=9090
hbase.regionserver.thrift.address=0.0.0.0

 4.3 注意thrift服务对thrift2服务的影响(检查hbase-site.xml),如下配置也会造成"MaxMessageSize reached"异常

hbase.regionserver.thrift.http=true
改成
hbase.regionserver.thrift.http=false

  

 

posted on 2025-06-24 09:43  熊本熊の熊  阅读(27)  评论(0)    收藏  举报