I'm using the java datastax driver. I have a ServletContextListener that closes the datastax Cluster object on context destroyed by calling Cluster.shutdown(). The problem is that it takes shutdown() several minutes to return.
Cluster.shutdown() have an override where you can specify a timeout value. I can't seem to find any documentation for NOT using the shutdown value, and when I specify a timeout of one millisecond, the cluster shuts down more or less instantly (as expected).
So, my question is, if I'm only shutting down the cluster when the servlet is shutting down anyway, is there a reason I should wait for the return? It seems that by specifying the timeout, it's essentially calling an asynchronous shutdown, which should be ok, but I don't want to introduce a memory leak or any instability.
I'm pretty new to Cassandra/datastax so if information about using the timeout is spelled out somewhere, pointing me in that direction would be great!
TIA, wbj
If you do specify a short timeout, the method will initiate the shutdown but only wait on the completion of the shutdown for as long as asked. So yes, a short timeout won't interfere with the shutdown per-se which will continue asynchronously. If you don't care about knowing when the shutdown is complete (i.e. when exactly all resources have been properly closed), then there is no particular downside to using a timeout (and you can even use 0 for the timeout to make that intention clear).
I'll not that version 2.x of the driver changes the shutdown API slightly, making it asynchronous by default but returning a future on the shutdown completion. Which hopefully makes it more clear what happens.