Pregunta

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.

¿Fue útil?

Solución

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.

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top