1
 I am running Apache Drill in Window 8.1 OS, having latest version of Drill (1.7). 

I want to enable or disable storage plugin programatically (using C# code).

Is there any way to do so.?

Sanjiv
  • 980
  • 2
  • 11
  • 29

2 Answers2

2

You can update drill plugin via REST API.

I am taking MongoDB plugin as an example.

Enable

curl -X POST -H "Content-Type: application/json" -d '{"name":"mongoPlugin", "config":{"type":"mongo","enabled":true,"connection":"mongodb://localhost:27017/"}}' http://localhost:8047/storage/mongoPlugin.json

Change "enabled" to false to disable it.

Disable

curl -X POST -H "Content-Type: application/json" -d '{"name":"mongoPlugin", "config":{"type":"mongo","enabled":false,"connection":"mongodb://localhost:27017/"}}' http://localhost:8047/storage/mongoPlugin.json

Check drill docs for more details.

You already answered about creating plugins using C#. Just change payload as mentioned above.

Community
  • 1
  • 1
Dev
  • 13,492
  • 19
  • 81
  • 174
  • :- In previous version of drill (i.e:- 1.6), Enabling & Disabling working fine through code. but in latest version (i.e:- 1.7) , Its not working properly, Even though its not giving any error. – Sanjiv Jul 28 '16 at 06:05
  • :- Can you please tell me curl command for creating storage plugin for MYSQL. – Sanjiv Jul 28 '16 at 07:04
  • @Sanjiv command is common for create/update. Use same above mentioned command – Dev Jul 28 '16 at 07:34
  • :- While creating plugin for MySQL database using same command , its showing error:- curl: (6) Could not resolve host: jdbc,could not resolve host: driver, could not resolve host: com.mysql.jdbc.Driver,url.....etc – Sanjiv Jul 28 '16 at 07:44
  • :- This is my code:- curl -X POST -H "Content-Type: application/json" -d '{"name":"myplug","type": "jdbc", "driver": "com.mysql.jdbc.Driver","url": "jdbc:mysql://localhost:3306","username": "root","password": "*****","enabled": true}}' http://localhost:8047/storage/myplug.json – Sanjiv Jul 28 '16 at 07:46
  • You forgot config. Use- `curl -X POST -H "Content-Type: application/json" -d '{"name":"myplug", "config":{"type": "jdbc", "driver": "com.mysql.jdbc.Driver","url": "jdbc:mysql://localhost:3306","username": "root","password": "*****","enabled": true}}' localhost:8047/storage/myplug.json ` – Dev Jul 28 '16 at 07:50
  • but other command are working fine. I fire command for enabling and disabling storage plugin its working fine. here command for enabling storage plugin:- curl http://localhost:8047/storage/DemoMySQl/enable/true (Enabling) – Sanjiv Jul 28 '16 at 07:51
  • @Sanjiv check my last comment – Dev Jul 28 '16 at 07:52
  • its response can be `{"result" : "success"}` or `{"result" : "error (unable to create/ update storage)"}` – Dev Jul 28 '16 at 07:57
  • :- Then What this error means: curl: (3) [globbing] unmatched brace in column 8 curl: (6) Could not resolve host: jdbc, curl: (6) Could not resolve host: driver curl: (6) Could not resolve host: com.mysql.jdbc.Driver,url curl: (6) Could not resolve host: jdbc:mysql curl: (3) [globbing] unmatched close brace/bracket in column 5 Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [Source: org.glassfish.jersey.message.internal.EntityInputStream@478ce1c2; line: 1, column: 2 – Sanjiv Jul 28 '16 at 08:02
  • :- Select Query is also not working through curl :--- Query:- curl -X POST -H "Content-Type: application/json" -d '{"queryType":"SQL", "query": "select * from cp.`employee.json` limit 10"}' http://localhost:8047/query.json – Sanjiv Jul 28 '16 at 11:34
  • @Sanjiv If given solution is not working no need to accept/upvote the answer. I am not here for reputations. – Dev Jul 28 '16 at 11:50
  • :- See Dev your command for enabling or disabling plugins are working file. But check my question.. I am asking different curl command question(i.e:- for select query ). I am not giving you any points or reputation. I am accepting your answer beacuse if other user facing this problem, they can refer your answer. – Sanjiv Jul 28 '16 at 11:57
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/118540/discussion-between-sanjiv-and-dev-). – Sanjiv Jul 28 '16 at 12:07
1

For Enabling or Disabling Storage Plugin in Window Environment. First we have to download curl.exe file from Download Curl . Set the path of curl.exe file in Environment Variable:-

Follow these steps:- Download curl zip Extract the contents (if you have downloaded the correct version you should find curl.exe) Place curl.exe in a folder where you keep your software (e.g. D:\software\curl\curl.exe) To run curl from the command line

a) Right-hand-click on "My Computer" icon

b) Select Properties

c) Click 'Advanced system settings' link

d) Go to tab [Advanced] - 'Environment Variables' button

e) Under System variable select 'Path' and Edit button

f) Add a semicolon followed by the path to where you placed your curl.exe (e.g. ;D:\software\curl).

Now Open Command Prompt and run following command:-

For Disabling Storage Plugin:-

curl http://localhost:8047/storage/DemoMySQl/enable/false

For Enabling:-

curl http://localhost:8047/storage/DemoMySQl/enable/true

Note:- DemoMySQl is storage plugin name.

Sanjiv
  • 980
  • 2
  • 11
  • 29