Introduce pooling of KernelTransactions.
Fix a page cache bug that can lead to lost updates

The problem was in the MuninnPageCache#evictPages method, in that we released
the write lock on the newly evicted page before we attempted to grab the write
lock on the translation table, for removing the evicted page. This left open a
window where another thread can do a look-up in the translation table, observe
the page that we have just evicted, complete a page fault, and then the
eviction thread would get the lock on the translation table and remove the page
that was just faulted in. This is the bug.
Later, another thread would find that the translation table does not have an
entry for the page it wants, so it faults it in. Now we have two cache pages
that are bound to the same file pages. If both are written two, then one will
overwrite the other when they are evicted. This is the symptom we observed in
our tests.
Increase the potential parallelism of page faulting

... by releasing the write lock on the translation table sooner. This way,
other page faults to the same stripe can proceed, while page faults and lookups
for the specific page will wait like they've always done. Except now they're
waiting on the lock on the page itself, instead of waiting on the lock for the
translation table. We ensure this by grabbing the write lock on the page we are
faulting into, before we add it to the translation table and release the lock
on the translation table.
Add additional tests for X-Forwarded-Host

Against Cypher REST response, and slash redirects
Changed the code so that the transactional endpoint creates URIs based on the request URI (rather than the server's URI). This is better (the server doesn't usually know it's own URI, whereas clients do) and enables X-Forward headers to work, fixing the problem identified in https://gist.github.com/albertoperdomo/6f3d7ffcb1351e5c61ce

However, /db/data and /db/manage (note: no trailing slashes) are not fixed here. That is a different bit of code to tame.
Reduces contention in ArrayQueueOutOfOrderSequence#get

by removing synchronized on the method and letting the member variable
containing the high id by volatile.
Make Rewriter a total function (AnyRef => AnyRef) rather than (AnyRef => Option[AnyRef])

In practice, some combinators already made assumptions about it being the case.
There doesn't seem to be a benefit for the partiality other than a short-circuit in repeat().
However, we rely on identity equality to be roughly as performant as a runtime check
for whether Option[AnyRef] is Some(_) or None.
Various optimisations in planning of hot spots found when profiling
Merge pull request #3209 from jakewins/2.2-txpool

[2.2] Introduce pooling of KernelTransactions.
Merge pull request #3273 from tinwelint/2.2-reduce-ooos-contention

[2.2] Reduces contention in ArrayQueueOutOfOrderSequence#get
Removed the integration tests pertaining to the correct use of X-Forward-* when redirecting from URIs that don't end in slash to ones that do*.

This is because there is some subtle interaction between Jetty and Jersey that screws this up. We've been through the Jetty code trying to see where this happens, but it's high cost for low value. Therefore when you don't correctly specify (say) /db/mabage/ and instead specify /db/manage then you will likely get incorrect URIs in the 302 response. the solution is not to use the wrong URI.

* This is a dumb decision by Jetty/Jersey. It is clear that http://example.com/foo/ and http://example.com/foo are not the same URI. Meh.
Merge pull request #3270 from pontusmelke/profiling-changes

[2.2] Change Rewriter to be a total function
Merge pull request #3277 from jimwebber/master

[2.2] X-Forward Support for Transactional Endpoint
Merge pull request #3271 from chrisvest/2.2-pagecache-stress

[2.2] Fix a page cache bug that can lead to lost updates
Expose a way to ask a lucene index to sample index selectivity

o Scan a sample of index entries and compute uniqueSampledValues / sampleSize
Add a new CountsKey for index entry counts
Maintain index update counts from index proxies

o OnlineIndexProxy will ensure that the index counts are updated
o Fix bug when generate LazyIndexUpdates to never construct 'overlapping updates'
o Cleanup code in LazyIndexUpdates
o Make sure we update index update counts during population
Add minor version to CountsStore such that we can flush safely on index flip (outside of log rotation)

o Ensure we compare CountsKeys correctly by type
o Fix reading of index keys
o Add flushIndexCounts() to IndexStoreView
Remove index counts when dropping an index
Make index stats part of SchemaRead and add indexNumberOfEntries

Rationale: For planning to be sane, indices shouldn't appear or disappear out of nowhere, hence we need to be tied to the schema read lock