Attached patch will allow to close the phoenix driver and re-use it later on.
I ran into this because I have a testcase where I start an HBaseTestingUtility, do some tests, stop it, and start it again to run the same tests with some different configs. This happens in one testcase because I want to compare the results of the two runs.
Since the 'cluster' is stopped between the two runs, I need to stop the Phoenix driver as well using PhoenixDriver.INSTANCE.close() (If I don't do this, it works as well but takes tons of time, I think because HBase needs to figure out it needs to create a new ZK connection). Previously this worked fine, but was recently broke likely because "services.getExecutor().shutdownNow()" was added.
The proposed patch sets services to null after the services are closed, so that they will be reopened the next time the driver is used.
Now, this change might lead to unexpected behavior: you call close(), and if after that some other thread still does something with Phoenix, the effect of the close call would be cancelled.
Besides this, if you currently try to use the driver after it is closed, it gives a rather confusing message:
- I introduced a closed flag so that we can check if the driver is closed and throw an exception if it is used after closing
- I introduced a softClose() method for the case where you want to close current resources but want to allow continued use of the driver.