jprante / elasticsearch-jdbc

JDBC importer for Elasticsearch
Apache License 2.0
2.84k stars 709 forks source link

How to suspend or resume JDBC-river? #424

Open zhangmengpl opened 9 years ago

zhangmengpl commented 9 years ago

ElasticSearch version 1.4.2 elasticsearch-river-jdbc vesion is lasted

I haved transportd my data.When I want to stop the river,I try the command "curl 'localhost:9200/_river/jdbc/my_jdbc_river/_suspend'",but the terminal show "No handler found for uri [/_river/jdbc/my_jdbc_river/_suspend] and method [GET]". Who can tell me how to resolve the problem? Thank you!

tolinwei commented 9 years ago

my_jdbc_river should be the name of the actual river that you want to suspend, try to replace it.

bobbyhubbard commented 9 years ago

We are also having this problem and yes we are using the name of the river. Also using es 1.4.2.

jprante commented 9 years ago

To stop the river, you must delete the river

curl -XDELETE 'localhost:9200/_river/my_jdbc_river/'

Suspend/resume is something different and does not stop the river.

bobbyhubbard commented 9 years ago

What exactly does suspend and resume do then?

On Jan 21, 2015 2:46 PM, Jörg Prante notifications@github.com wrote:

To stop the river, you must delete the river

curl -XDELETE 'localhost:9200/_river/my_jdbc_river/'

Suspend/resume is something different and does not stop the river.

— Reply to this email directly or view it on GitHubhttps://github.com/jprante/elasticsearch-river-jdbc/issues/424#issuecomment-70918115.


CONFIDENTIALITY NOTICE: This email and any attachments are for the sole use of the intended recipient(s) and contain information that may be confidential and/or legally privileged. If you have received this email in error, please notify the sender by reply email and delete the message. Any disclosure, copying, distribution or use of this communication (including attachments) by someone other than the intended recipient is prohibited. Thank you.

jprante commented 9 years ago

Suspend forces the thread that fetches rows to sleep endlessly, checking for resume once in a while.

bobbyhubbard commented 9 years ago

ok, that is what i expected. I did a little more digging and I found that the documentation implies the suspend is initiated with a GET (which feels weird anyway), however it is implemented as a POST (yea!) and expects an empty body (oh well). Using Sense, a standard GET or POST with no body results in the error mentioned above "No handler found for uri... ". To get it to work in Sense, I just had to pass in an empty body along with the post.

So these didnt work in sense:

GET _river/jdbc/some_river_name/_suspend
POST _river/jdbc/some_river_name/_suspend

This did work:

POST _river/jdbc/some_river_name/_suspend
{}

Nice! It worked, I checked the _state and it showed suspended true. Fantastic. However, the river still processes new rows on the next scheduled run. And checking the _state again, it now suspended false. ?? I havent been able to dig into the code yet so i cant yet tell why its doing that.

bobbyhubbard commented 9 years ago

Can the suspend feature be used in conjunction with a schedule? Its as if the schedule ignores the suspended thread

jprante commented 9 years ago

The feature is premature, do not expect it works flawlessly. I have disabled it by default in the latest version.

Yes, the river runs again when being scheduled, no matter if suspended or not. The reason is that each scheduled river run is another thread from a thread pool. This continues until all threads in the thread pool are exhausted and sent into a sleep mode. With resume action you can not awake them all, so there are obviously some problems with suspend/resume.

bobbyhubbard commented 9 years ago

Thanks.