Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to Accumulo from NodeJS

I have been trying to connect to Accumulo from NodeJS through the Thrift proxy, but have been unsuccessful.

var thrift = require("thrift");
var AccumuloClient = require("./AccumuloProxy");

var transport = thrift.TFramedTransport;
var protocol = thrift.TBinaryProtocol;

var connection = thrift.createConnection("localhost", 42424, {
    transport: transport,
    protocol: protocol
});

var client = thrift.createClient(AccumuloClient, connection);

client.login("root", {'password': "password"});

When I try to login I get

org.apache.thrift.protocol.TProtocolException: Expected protocol id ffffff82 but got ffffff80

Is anyone able to help me out and give me an idea of what I'm doing wrong here?


UPDATE:

I modified protocolFactory line in the proxy.properties file located in Accumulo and restarted the proxy.

protocolFactory=org.apache.thrift.protocol.TBinaryProtocol$Factory

I performed the same steps as above, but added a callback to the createClient call.

var login;
var client = thrift.createClient(AccumuloClient, connection, 
    function(err, success) { login = success });

This populates the login variable. I then try to use that login variable to execute other functions

client.listTables(login, function(a) { console.log(a) })

results in

{name: 'TApplicationException', 
 type: 6,
 message: 'Internal error processing listTables'}

Trying to create a table

client.createTable(login, "testTable", 1, "", function(a) { console.log(a)})

results in

{name: 'AccumuloSecurityException',
 msg: 'org.apache.accumulo.core.client.AccumuloSecurityException: Error SERIALIZATION_ERROR for user unknown - Unknown security exception'}

See answer below.

like image 732
ryknow Avatar asked Nov 27 '25 06:11

ryknow


1 Answers

It turns out that the problem existed because of the handling of the response back from Accumulo. In the AccumuloProxy.js file when the login result is received and read in AccumuloProxy_login_result.prototype.read it will set the success as this.success = input.readString()

The readString() function will take the Buffer and call toString() using the utf8 encoding. This was resulting in characters showing up incorrectly.

I modified the AccumuloProxy_login_result.prototype.read function to set success as this.success = input.readBinary() so that a Buffer is returned. This Buffer can be passed in to the other function calls and will get a correct result back from Accumulo instead of an Exception.

This was put in as an issue with Thrift here and has apparently been fixed in the master branch.

like image 166
ryknow Avatar answered Nov 29 '25 21:11

ryknow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!