hadoop - TApplicationException : Required field 'client_protocol' is unset

标签 hadoop hive thrift thrift-protocol

我正在开发一个节俭的客户,

我已经在我的机器上构建了一个节俭的配置单元服务器(apache-hive-0.14.0),并且还可以访问 Cloudera Dist Hive 4.6.0

当我将 Thrift 客户端连接到 CDH 客户端时,会出现以下错误:

TApplicationException: Required field 'client_protocol' is unset!
Struct:TOpenSessionReq(client_protocol:null, username:

我正在将正确的协议(protocol)传递给服务器,但似乎有些事情已经过时了......

此外,如果我指向本地主机(我运行配置单元服务器的地方),一切似乎都运行良好......

请让我知道这里出了什么问题....

代码:

       var socket = new TSocket("XXX.XXX.XXX.XXX", 10000);

        TStreamTransport sTransport = (TStreamTransport)socket;

        var transport = new TBufferedTransport(socket);

        underlyingTransport = transport;

        var proto = new TBinaryProtocol(transport);
        var client = new TCLIService.Client(proto);
        transport.Open();

        TOpenSessionReq req = new TOpenSessionReq(TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6);
        req.Username = "hive";
        req.Password = "hive";

        TOpenSessionResp oSResponse = client.OpenSession(req);
        TSessionHandle sessionHandle = oSResponse.SessionHandle;

        TExecuteStatementReq execReq = new TExecuteStatementReq(sessionHandle, "select * from emp");
        TExecuteStatementResp exeRes= client.ExecuteStatement(execReq);
        TOperationHandle operationHandle = exeRes.OperationHandle;

        TFetchResultsReq fechReq = new TFetchResultsReq(operationHandle,TFetchOrientation.FETCH_FIRST, 1);
        TFetchResultsResp fechRes = client.FetchResults(fechReq);

        TRowSet results = fechRes.Results;
        List<TRow> resultRows = results.Rows;
        foreach (var row in resultRows)
        {
            var val = row.ColVals[0];
            System.Console.WriteLine(val.StringVal);
        }

        TCloseOperationReq closeOprReq = new TCloseOperationReq(operationHandle);
        client.CloseOperation(closeOprReq);

        TCloseSessionReq creq = new TCloseSessionReq(sessionHandle);
        client.CloseSession(creq);

最佳答案

我相信这是 hive-jdbc 版本的问题。此解决方案可能会解决您的问题:Required field 'client_protocol' is unset

关于hadoop - TApplicationException : Required field 'client_protocol' is unset,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26300643/

相关文章:

hadoop - 合并 Hive 表上的重复记录

java - 如何发送未在 Thrift 中定义结构的 Java 对象

javascript - javascript 客户端中的 Thrift 传输

尽管 mapred.output.compress=true,hadoop 流仍会生成未压缩的文件

hadoop - HIVE 查询问题(选择计数 (*))

hadoop - 在 HDFS Hadoop 的文件更改所有者期间获取文件 inode?

json - 在 Hive 中创建外部表以保存 JSON 数据时出错

enums - 使用枚举的节俭常量结构

hadoop - 关于输入分割长度的 Tez 容器大小估计

java - Flume:org.apache.avro.ipc.NettyServer:来自下游的意外异常。 java.nio.channels.ClosedChannelException