3

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.

ryknow
  • 161
  • 1
  • 10
  • This is basically two questions, plus an answer, all rolled into one question. I'd recommend to clean it up. That way it is hardly helpful and not necessarily a good fit for the Q&A model at SO. – JensG Feb 12 '14 at 19:01

2 Answers2

2

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.

ryknow
  • 161
  • 1
  • 10
0

Seems that Accumulo uses the compact protocol, not the binary protocol. It also seems, that there is currently no compact protocol support available for NodeJS.

Please have a look at this SO question as well. It deals with C#, but nevertheless it can be helpful. There are also some solutions out there utilizing RabbitMQ or other message brokers, see here.

Community
  • 1
  • 1
JensG
  • 13,148
  • 4
  • 45
  • 55
  • Do you have a link to where it says that Accumulo only uses the `compact` protocol and can't use the `binary` protocol? It seems like you should be able to change the protocolFactory in the proxy.properties to use the `TBinaryProtocol` – ryknow Feb 11 '14 at 11:44
  • No, sorry. BTW, what is it that you don't like about my answer? – JensG Feb 12 '14 at 18:47
  • Accumulo doesn't require you to use the `compact` protocol. You can switch to using the `TBinaryProtocol` by changing the proxy properties file so it isn't a problem that there is currently no `compact` protocol support available for NodeJS. – ryknow Feb 13 '14 at 14:04
  • The error message from your first question clearly indicates compact is **used**. But I never said, that compact is **required**. If you implied that, that's not my fault. – JensG Feb 13 '14 at 22:18