Makes most fields of ElectionContext final.
Performance optimizations for best-first selector

Mostly revolving around finding single paths. This gives a good
improvement when calling PathFinder#findSinglePath for those graph
algorithms using the traversal framework and more specifically the
BestFirstSelector. Currently this will benefit Dijkstra and A*, although
the default implementation of A* is a custom non-traversal-framework
version that only supports single paths anyways so already has got a
similar performance behaviour. Look at TraversalAStar for a A* version
that uses the traversal framework.

(cherry picked from commit 059bb13af0d492a95c68a5027e746ae07153bbd2)
Merge pull request #1368 from rickardoberg/masterfix

Refactoring of MasterImpl and BackupImpl to have SPI, so that they are testable
In order to shutdown properly we have introduced an AccessGuard, which will be checked on beginTx(). The different reasons why starting a tx might not be possible (e.g. database not started) will be setting it's state by granting or denying access. it's implemented with a backing AtomicInteger for performance mainly.