FunctionScore: RandomScoreFunction now accepts long, as well a strings.

closes #8267
closes #8311
Return 0 instead of -1 for unknown/non-exposed ramBytesUsed()

The accountable interface specifies that such values are illegal

Fixes #8239
Internal: when corruption strikes, don't create exceptions with circular references

Closes #8331
Fix missing word in upgrade docs.
[Aggregations] Meta data support

This commit adds the ability to associate a bit of state with each
individual aggregation.

The aggregation response can be hard to stitch back together without
having a reference to the aggregation request. In many cases this is not
available, many json serializer frameworks cache types globally or have a
static deserialisation override mechanism. In these cases making the
original request available, if at all possible, would be a hack.

The old facets returned `_type` which was just enough metadata to know
what the originating facet type in the request was.

This PR takes `_type` one step further by introducing ANY arbitrary meta
data. This could be further <strike>ab</strike>used for instance by
generic/automated aggregations that include UI state (color information,
thresholds, user input states, etc) per aggregation.
Discovery: Improve the lifecycle management of the join control thread in zen discovery.

Also added:
* Better exception handling in UnicastZenPing#ping and MulticastZenPing#ping
* In the join thread that runs the innerJoinCluster loop, remember the last known exception and throw that when assertions are enabled. We loop until inner join has completed and if continues exceptions are thrown we should fail the test, because the exception shouldn't occur in production (at least not too often).
Applied feedback 3

Closes #8327
Tests: Do not index dummy documents in ExistsMissingTests.

This way we make sure that there is only one mapping for
_field_names.
[TEST] exclude org.elasticsearch.test.test package from test-jar

The package was only excluded during test-jar sources generation but ended up in the actual jar.
[STORE] Remove special file handling from DistributorDirecotry

This commit removes all special file handling from DistributorDirectory
that assigned certain files to the primary directory. This special handling
was added to ensure that files that are written more than once are essentially
overwritten. Yet this implementation is consistent all the time and doesn't need
this special handling for files that are written through this directory. Writes
to the underlying directory not going through the distributor directory are not
and have never been supported.

Note: this commit also fixes the problem of adding directories to the distributor
during restart where the primary can suddenly change and file mappings are by-passed.

Closes #8276
Test: MinimumMasterNodesTests.testCanNotBringClusterDown didn't check for cluster health properly

Also reduced the number of nodes the test uses
Test: ClusterServiceTetsts.testLocalNodeMasterListenerCallbacks should verify cluster state is applied

The test verifies the correct behavior of a listener but we only call the listener after publishing a new cluster state. Only checking on the publishing of the state introduces a racing condition.
[TEST] move NettyTransport*Tests to org.elasticsearch.transport.netty package

NettyTransport*Tests were previously in org.elasticsearch.test.transport and ended up being exported with the test jar. org.elasticsearch.transport.netty should be a better place for them together with exising tests.
[TEST] Fix the throttle test.
[TEST] move ClusterDiscoveryConfiguration to org.elasticsearch.test.discovery

ClusterDiscoveryConfiguration is part of the test infra and should get exported as part of the test jar. This is achieved by moving the class to org.elasticsearch.test.discovery

Closes #8337
Update zen.asciidoc

Tidied up the "No master block" asciidoc
Update cluster.asciidoc

Fixed asciidoc on cluster module page
[TEST] only assert consistency before closing
Catch NoSuchDirectoryException on consistency check - the directory might not be there anymore
Update cluster.asciidoc - fix invalid asciidoc