0
votes

I have just started using Apache Phoenix on HBase. We have a setup where Phoenix is working when invoked from within the cluster nodes (We are able to CRUD in tables cleanly). Now, we want an application running outside the network (say a system hosting a mobile app) to be able to query Phoenix table. For that, one of the options we are trying is using Phoenix Query Server (PQS). I have ensured that the port 8765 is accessible from outside network and so, when we use below CURL command, we expect the desired result:

[root@externalsystem ~]# curl -XPOST -H 'request:{"request":"prepareAndExecute","connectionId":"000000-0000-0000-00000000","statementId": 12345,"sql": "SELECT * FROM QUESTTWEETS1","maxRowCount":1}' http://here.comes.external.ip:8765/

But the response which we get is:

{"response":"executeResults","missingStatement":true,"rpcMetadata":{"response":"rpcMetadata","serverAddress":"viper.quest.com:8765"},"results":null}

We are using HDP 2.3.4.7-4 and aligned versions of HBase and PQS.

Very clearly, I am passing the SQL as one of the keys in the request. Can somebody please help me understand what am I doing wrong here? Additionally, since the goal of this is to provide a way to access Phoenix tables at high concurrency (which moble apps can demand), is PQS a decent solution or there are any better options to access Phoenix tables? Since I am a newbie in using HBase and Phoenix, please let me know if there are any other details required.

2

2 Answers

2
votes

Found out the answer for the question and giving it here for any other newbees' help. I should have known more about how JDBC works in general. Below are the detailed steps for getting PQS working for you:

Step 1: curl -XPOST -H 'request:{"request":"openConnection","connectionId":"000000-0000-0000-00000000"}' URL

Sample response: {"response":"openConnection","rpcMetadata":{"response":"rpcMetadata","serverAddress":"viper.quest.com:8765"}}

Step 2: curl -XPOST -H 'request:{"request":"createStatement","connectionId":"000000-0000-0000-00000000"}' URL

Sample response: {"response":"createStatement","connectionId":"000000-0000-0000-00000000","statementId":1,"rpcMetadata":{"response":"rpcMetadata","serverAddress":"viper.quest.com:8765"}}

Step 3: curl -XPOST -H 'request:{"request":"prepareAndExecute","connectionId":"000000-0000-0000-00000000","statementId": 1,"sql": "SELECT * FROM QUESTTWEETS1","maxRowCount":-1}' URL

Sample response: JSON with the data

Step 4: curl -XPOST -H 'request:{"request":"closeStatement","connectionId":"000000-0000-0000-00000000","statementId": 1}' URL

Sample response: {"response":"closeStatement","rpcMetadata":{"response":"rpcMetadata","serverAddress":"viper.quest.com:8765"}}

Step 5: curl -XPOST -H 'request:{"request":"closeConnection","connectionId":"000000-0000-0000-00000000"}' URL

Sample response: {"response":"closeConnection","rpcMetadata":{"response":"rpcMetadata","serverAddress":"viper.quest.com:8765"}}

Where URL is of form - http://external.ip.of.pqs:8765/

Hope this helps.

0
votes

You can use jdbc to connect to phoenix as same as mysql.---http://phoenix.apache.org/index.html