I need a way shutting down the Xodus environment so that
So far we tried something like this
if (env.isOpen()) {
env.clear();
env.close();
}
but I am not sure that it does exactly the right thing, I still get exceptions thrown from env.close()
from time to time. So what is the proper way to do that?
First of all, note that Environment#clear()
just clears all the data in your environment.
Minor: you don't have to check whether your environment is open before closing it.
If you don't care much of the application state then you can set the exodus.env.closeForcedly
option on Environment creation:
Environment env = Environments.newInstance("db path", new EnvironmentConfig().setEnvCloseForcedly(true));
In that case, close()
method reports in logs the number of not finished at the moment transactions and does close the environment anyway.