Skip to content

Commit e3ee209

Browse files
committed
* Bugfix pathname
* Add option runAsync * Add TODO.md * Change cluster.json.sample
1 parent 8765faa commit e3ee209

10 files changed

+97
-57
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ JSHS2
33

44
# Introduction
55
jsHS2 is a node.js client driver for hive server 2. See test/ConnectionTest.js, for an example of how to use it.
6-
jsHS2 reference from pyhs2 after rewrite javascript. But some feature modify suitable for javascript(ex> Promise support).
6+
jsHS2 reference from pyhs2 after rewrite javascript. But some feature modify suitable for javascript(ex> Promise support).
77

88
jsHS2 include IDL(Interface Description Language). For example, Thrift_0.9.2_Hive_1.1.0 in idl directory.
99

10+
11+
1012
## I need help!
1113
And I need your help. jsHS2 is not implementation SASL. I hope that someone add SASL on this project.
1214
Contact imjuni@gmail.com with questions

TODO.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
JSHS2
2+
====
3+
4+
# 0.3.0
5+
* Add SASL protocol handshake
6+
* Re-compile idl using by Thrift 0.9.3
7+
* Remove callback interface
8+
* Because, latest LTS version 4.2.2, that have promise
9+
* Thrift 0.9.3 compile idl, compiled idl already use Promise

changelog.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ ChangeLog jsHS2
2424
differents IdlContainer for execute multi version executing
2525
* Change ConnectionTest
2626

27-
2827
# 0.2.2
2928
* Change changelog.md
3029

@@ -37,4 +36,17 @@ ChangeLog jsHS2
3736
* rename ConnectionTest.js -> PromiseTest.js
3837

3938
# 0.2.9
40-
* Bug-fix on CConnection.js (not called thriftConnection.end())
39+
* Bug-fix on CConnection.js (not called thriftConnection.end())
40+
41+
# 0.2.10
42+
* Add option runAsync in execute
43+
* This options for cli script
44+
* Fix idlFactory module loading bug (path problem, fixed it)
45+
* Fix cluster.json.sample
46+
* cluster.json.sample so hard readable, that is fix more readable and easy
47+
* cp cluster.json.sample cluster.json
48+
* Remove comment (that is starts with '//') and write your environment
49+
* deps: co@^4.6.0
50+
* deps: mocha@^2.3.4
51+
* deps: thrift@^0.9.3
52+
* deps: lodash@^3.10.1

cluster.json.sample

+27-17
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
{
2-
"Impala": {
3-
"ConnectionString": "jdbc:hive2://#{{URI}}/;auth=noSasl;impersonnation_enable=true;",
4-
"LoginTimeout": 10000,
5-
"Port": 1234,
6-
"Servers": [
7-
"011.022.033.044"
8-
],
9-
"query": "SELECT * FROM test.test_table limit ${{limit}}"
2+
"use": "HiveOnCDH", // Use Configuration
3+
"HiveOnCDH": {
4+
"auth": "NOSASL",
5+
"host": "my-hive.com", // hive server hostname
6+
"port": 13333, // port number
7+
"timeout": 10000, // timeout number(important, timeout is must be integer value)
8+
"username": "ironman", // username
9+
"hiveType": 1, // hive type number, (hive 0, cdh hive 1 see below HS2Util.js)
10+
"hiveVer": "0.13.1", // hive version
11+
"cdhVer": "5.3.0", // cdh version
12+
"thriftVer": "0.9.2", // thrift version
13+
"maxRows": 5120, // max row
14+
"nullStr": "NULL" // NULL field replace to this string
1015
},
11-
"Hive": {
12-
"ConnectionString": "jdbc:hive2://#{{URI}}/;impersonnation_enable=true;",
13-
"LoginTimeout": 10000,
14-
"Port": 1234,
15-
"Servers": [
16-
"011.022.033.044"
17-
],
18-
"username": "superman",
19-
"query": "SELECT * FROM test.test_table limit ${{limit}}"
16+
"ApacheHive": {
17+
"auth": "NOSASL",
18+
"host": "172.22.212.70",
19+
"port": 10200,
20+
"timeout": 10000,
21+
"username": "1002099",
22+
"hiveType": 0,
23+
"hiveVer": "1.1.0",
24+
"thriftVer": "0.9.2",
25+
"maxRows": 5120,
26+
"nullStr": "NULL"
27+
},
28+
"Query": {
29+
"query": "select * from default.something where part_date > '20141111'" // Enter your query
2030
}
2131
}

lib/CCursor.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,20 @@
5353
});
5454
};
5555

56-
CCursor.prototype.execute = function execute (hql, callback) {
56+
CCursor.prototype.execute = function execute (hql, runAsync, callback) {
5757
var that = this;
5858
var serviceType = that.getConfigure().getServiceType();
5959
var client = that.getClient();
6060

61+
if (arguments.length === 2) {
62+
callback = runAsync;
63+
runAsync = true;
64+
}
65+
6166
var req = new serviceType.TExecuteStatementReq({
6267
sessionHandle: that.getSessionHandle(),
6368
statement: hql,
64-
runAsync: true
69+
runAsync: runAsync
6570
});
6671

6772
debug('ExecuteStatement start -> async, ', hql);

lib/Common/IdlFactory.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
IdlFactory.prototype.cb$serviceFactory = function cb$serviceFactory (configure, callback) {
4646
try {
4747
var factoryConfig = this.extractConfig(configure);
48-
var service = require(path.join('..', '..', 'idl', factoryConfig.path, 'TCLIService.js'));
48+
var service = require(path.join(__dirname, '..', '..', 'idl', factoryConfig.path, 'TCLIService.js'));
4949

5050
callback(null, service);
5151
} catch (err) {
@@ -71,7 +71,7 @@
7171
IdlFactory.prototype.cb$serviceTypeFactory = function cb$serviceTypeFactory (configure, callback) {
7272
try {
7373
var factoryConfig = this.extractConfig(configure);
74-
var serviceType = require(path.join('..', '..', 'idl', factoryConfig.path, 'TCLIService_types.js'));
74+
var serviceType = require(path.join(__dirname, '..', '..', 'idl', factoryConfig.path, 'TCLIService_types.js'));
7575

7676
callback(null, serviceType);
7777
} catch (err) {

lib/PCursor.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
2727
});
2828
};
2929

30-
PCursor.prototype.execute = function execute (hql) {
30+
PCursor.prototype.execute = function execute (hql, runAsync) {
3131
var that = this;
3232

33+
runAsync = (!!runAsync) ? runAsync : true;
34+
3335
return new Promise(function (resolve, reject) {
34-
PCursor.super_.prototype.execute.call(that, hql, function (err, result) {
36+
PCursor.super_.prototype.execute.call(that, hql, runAsync, function (err, result) {
3537
if (err) {
3638
reject(err);
3739
} else {

package.json

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jshs2",
3-
"version": "0.2.9",
3+
"version": "0.2.10",
44
"description": "Hive Server2 Driver for Javascript",
55
"keywords": [
66
"Hive",
@@ -21,21 +21,19 @@
2121
},
2222
"private": false,
2323
"engines": {
24-
"iojs": ">=1.1.0",
2524
"node": ">=0.10.23"
2625
},
2726
"dependencies": {
28-
"co": "^4.5.4",
2927
"debug": "^2.1.1",
30-
"lodash": "^3.1.0",
28+
"lodash": "^3.10.1",
3129
"node-int64": "^0.3.3",
3230
"promise": "^7.0.1",
33-
"thrift": "^0.9.2"
31+
"thrift": "^0.9.3"
3432
},
3533
"devDependencies": {
3634
"async": "^0.9.0",
3735
"chai": "^1.10.0",
38-
"co": "^4.5.4",
39-
"mocha": "^2.1.0"
36+
"co": "^4.6.0",
37+
"mocha": "^2.3.4"
4038
}
4139
}

test/CallbackTest.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,18 @@ describe('ThriftDriverTest', function () {
129129
});
130130
},
131131
function configurationStep (testEnv, callback) {
132-
options.auth = 'NOSASL';
133-
options.host = _.first(testEnv.Hive.Servers);
134-
options.port = testEnv.Hive.Port;
135-
options.timeout = testEnv.Hive.LoginTimeout;
136-
options.username = testEnv.Hive.username;
137-
options.hiveType = hs2util.HIVE_TYPE.HIVE;
138-
options.hiveVer = '1.1.0';
139-
options.thriftVer = '0.9.2';
140-
141-
options.maxRows = 5120;
142-
options.nullStr = 'NULL';
132+
options.auth = testEnv[testEnv.use].auth;
133+
options.host = testEnv[testEnv.use].host;
134+
options.port = testEnv[testEnv.use].port;
135+
options.timeout = testEnv[testEnv.use].timeout;
136+
options.username = testEnv[testEnv.use].username;
137+
options.hiveType = testEnv[testEnv.use].hiveType;
138+
options.hiveVer = testEnv[testEnv.use].hiveVer;
139+
options.cdhVer = testEnv[testEnv.use].cdhVer;
140+
options.thriftVer = testEnv[testEnv.use].thriftVer;
141+
142+
options.maxRows = testEnv[testEnv.use].maxRows;
143+
options.nullStr = testEnv[testEnv.use].nullStr;
143144

144145
var configuration = new Configuration(options);
145146

@@ -163,7 +164,7 @@ describe('ThriftDriverTest', function () {
163164
});
164165
},
165166
function executeStep (testEnv, configuration, connection, cursor, callback) {
166-
cursor.execute(testEnv.Hive.query, function (err, result) {
167+
cursor.execute(testEnv.Query.query, false, function (err, result) {
167168
debug('Execute, hasMoreRow -> ', result);
168169

169170
if (err) {

test/PromiseTest.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,18 @@ describe('ThriftDriverTest', function () {
124124

125125
var options = {};
126126

127-
options.auth = 'NOSASL';
128-
options.host = _.first(config.Hive.Servers);
129-
options.port = config.Hive.Port;
130-
options.timeout = config.Hive.LoginTimeout;
131-
options.username = config.Hive.username;
132-
options.hiveType = hs2util.HIVE_TYPE.HIVE;
133-
options.hiveVer = '1.1.0';
134-
options.thriftVer = '0.9.2';
135-
136-
options.maxRows = 5120;
137-
options.nullStr = 'NULL';
127+
options.auth = config[config.use].auth;
128+
options.host = config[config.use].host;
129+
options.port = config[config.use].port;
130+
options.timeout = config[config.use].timeout;
131+
options.username = config[config.use].username;
132+
options.hiveType = config[config.use].hiveType;
133+
options.hiveVer = config[config.use].hiveVer;
134+
options.cdhVer = config[config.use].cdhVer;
135+
options.thriftVer = config[config.use].thriftVer;
136+
137+
options.maxRows = config[config.use].maxRows;
138+
options.nullStr = config[config.use].nullStr;
138139

139140
var configuration = new Configuration(options);
140141

@@ -143,7 +144,7 @@ describe('ThriftDriverTest', function () {
143144
var connection = new Connection(configuration);
144145
var cursor = yield connection.connect();
145146

146-
yield cursor.execute(config.Hive.query);
147+
yield cursor.execute(config.Query.query);
147148
yield waitAndLog(cursor);
148149

149150
var schema = yield cursor.getSchema();

0 commit comments

Comments
 (0)