蜂巢-节俭-readMessageBegin中缺少版本,旧客户端?
您好,我正在尝试构建一个使用Thrift查询我的Hive数据库的nodejs客户端,但是我面临一个奇怪的问题…我已经thrift -r --gen
js:node TCLIService.thrift用Thrift
生成了我的nodejs客户端API(TCLIService是定义Hive服务的Thrift文件)现在我尝试连接到Hive,但是我的OpenSession正在等待中……也许我没有进行正确的呼叫,但是我在网上找不到任何最新消息(每个节俭/节点/
hive项目都已经有4或5年的历史了)。您能看看我是否做错了吗?谢谢
TCLIService.thrift:
// OpenSession()//
// Open a session (connection) on the server against
// which operations may be executed.
struct TOpenSessionReq {
// The version of the HiveServer2 protocol that the client is using.
1: required TProtocolVersion client_protocol = TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8
// Username and password for authentication.
// Depending on the authentication scheme being used,
// this information may instead be provided by a lower
// protocol layer, in which case these fields may be
// left unset.
2: optional string username
3: optional string password
// Configuration overlay which is applied when the session is
// first created.
4: optional map<string, string> configuration
}
service TCLIService {
TOpenSessionResp OpenSession(1:TOpenSessionReq req);
}
Node.js代码:var sessionHandle =’‘;
function openSession(config) { openSessReq = new ttypes.TOpenSessionReq();
openSessReq.client_protocol = ttypes.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8;
openSessReq.username = config.hiveUser;
openSessReq.password = config.hivePassword;
console.log("openSessReq = " + JSON.stringify(openSessReq));
console.log("Before OpenSession : sessionHandle = " + sessionHandle);
sessionHandle = client.OpenSession(openSessReq, function (err, result){
console.log('handler fired ... ');
if (err) {
console.error("error : " + err);
} else {
console.log("result : " + result);
}
});
console.log("After OpenSession : sessionHandle = " + sessionHandle);
}
connection.on('error', function(err) {
/*Error detected, print the error*/
console.error(err);
/*Close the program with error code*/
process.exit(1)
});
console.log('Error handler registered ...')
connection.on('connect', function(){
console.log('Connected ...');
/*Init session*/
console.log(client);
openSession(config);
}
我的输出如下:
CreateConnection DONE ...Error handler registered ...
Connect handler registered ...
Connected ...
{ output:
TBufferedTransport {
defaultReadBufferSize: 1024,
writeBufferSize: 512,
inBuf: <Buffer e8 19 2b 03 00 00 00 00 b0 1a 2b 03 00 00 00 00 e8 18 2b 03 00 00 00 00 f0 18 2b 03 00 00 00 00 b0 19 2b 03 00 00 00 00 78 1a 2b 03 00 00 00 00 70 1d ... >,
readCursor: 0,
writeCursor: 0,
outBuffers: [],
outCount: 0,
onFlush: [Function],
client: [Circular] },
pClass: [Function: TBinaryProtocol],
_seqid: 0,
_reqs: {} }
openSessReq = {"client_protocol":7,"username":"root","password":"root","configuration":null}
Before OpenSession : sessionHandle =
After OpenSession : sessionHandle = undefined
^C
脚本会无限期地运行…如果更改端口或关闭HiveServer,则会遇到错误,因此连接正常,但是我无法找出openSession为何不起作用!谢谢你的帮助
编辑:我已经检查了我的日志,并且NOSASL标识是问题…我已解决(我认为)此问题,现在收到以下错误:
客户:
{ [Error: write EPIPE] code: 'EPIPE',
errno: 'EPIPE',
syscall: 'write',
address: undefined }
服务器:
2016-02-17 13:36:37,152 ERROR org.apache.thrift.server.TThreadPoolServer: [HiveServer2-Handler-Pool: Thread-24]: Thrift error occurred during processing of message. org.apache.thrift.protocol.TProtocolException: Missing version in readMessageBegin, old client?
at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:228)
at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:27)
at org.apache.hive.service.auth.TSetIpAddressProcessor.process(TSetIpAddressProcessor.java:56)
at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:285)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
我已经读到必须通过使用错误的协议层来提出问题…我正在使用TBinaryProtocol,这是一个问题吗?
回答:
我通过执行以下操作解决了我的问题:
通过使用beewax检查我的HiveServer2的协议版本,并查询我的HiveServer2(带有Hue)并检查HiveServer2日志(我发现Hive
0.15.0是HIVE_CLI_SERVICE_PROTOCOL_V7)
通过修改hive-site.xml在我的HiveServer2上启用NOSASL身份验证
以上是 蜂巢-节俭-readMessageBegin中缺少版本,旧客户端? 的全部内容, 来源链接: utcz.com/qa/423777.html