3
votes

I am actually trying to develop a simple Node.js client, which can be used to query my Hive table on the Cosmos table .

I first tried to use this implementation for Hive using Node.js : https://github.com/wdavidw/node-thrift-hive. My code is the following :

var router = express.Router();
var request = require('request');
var _ = require('lodash');

var hive = require('thrift-hive');
// Client connection
var client = hive.createClient({
  version: '0.7.1-cdh3u3',
  server: '130.206.80.46',
  port: 10000,
  timeout: 1000
});
// Execute call

router.route('/')
  .get(function(req, res, next) {

    client.execute('use default', function(err) {
      // Query call
      client.query('select * from interserre')
      .on('row', function(database) {
        console.log(database);
      })
      .on('error', function(err) {
        console.log(err.message);
        client.end();
      })
      .on('end', function() {
        client.end();
      });
    });
  })


module.exports = router;

I get this error:

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: connect ECONNREFUSED
    at exports._errnoException (util.js:746:11)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)

After that I tried to use the Python example (provided by the documentation just to run a simple test.

http://forge.fiware.org/plugins/mediawiki/wiki/fiware/index.php/BigData_Analysis_-_User_and_Programmer_Guide#Python

I couldn't even connect to the server.

Could not connect to 130.206.80.46:10000

I think the problem come from the fact that we don't provide any information that allow us to connect to the Cosmos portal. With Thrift there is no way to put your credentials. The server can't identify you're a real Cosmos user and reject your connection.

The python was just a test. I'm actually doing a Hackaton and was planning to use Node.js to query the data that I have. Where do you think the problem come from? The module? The Cosmos Portal?

1

1 Answers

2
votes

We are currently adding to Cygnus a suite of Hive client examples for both HiveServer1 and HiveServe2 written in Java, Python and Node.js. This is something appearing in Cygnus 0.9.0, in the meantime you can check for the current status of the work (clients for Java and Python) in the develop branch.

Regarding Node.js, there are libraries allowing connecting to HiveServer1 (node-thrift-hive, node-hive) in a non authenticated way as you have experienced (technically speaking, they only work with a NOSASL configuration of Hive server). Regarding HiveServer2 occurs the same with libraries such as jsh2.