REST: Renamed indexed_script and indexed_template specs

The file name of the REST specs should be the same as
the endpoint which it documents.
REST: Fixed indexed script/template tests

The clients don't have access to the error message
for matching purposes.  Rewritten tests to work
with the clients
Serialization: Fix bwc issue by falling back to old threadpool serialization

This fixes an issue introduced by the serialization changes in #6486
which are not needed at all. Node that the serialization itself is not broken
but the TransportClient uses its own version on initial connect and getting
the NodeInfos.
[BUILD] Randomization script refactoring

1) Refactored randomization logic to the top
2) Add logics to support window platforms
Search: Added support for named filters/queries inside nested filters and queries.

Closes #6293
Query: When parent doc is found stop iterating over segments and continue with the next top matching child doc.

The parent doc has been found and there is no need to check subsequent segments.

Closes #6895
Closes #1843
Scripting: Remove setNextScore in SearchScript.

While it would be nice to do this all the way up the chain (into
score functions), this at least removes the weird dual
setNextScore/setScorer for SearchScripts.

closes #6864
Scripts: Make ScoreAccessor utility available for other script engines.

With the removal of setNextScore in #6864, script engines must use
the Scorer to find the score of a document.  The DocLookup is updated
appropriately to do this, but most script engines require a Number to be
bound for numeric variables.  Groovy already had an encapsulation for
this funtionality, and this moves it out to be shared with other script
engines.

closes #6898
[Scripts] GroovyScriptEngineService don't create ScoreAccess if lookup is null
Netty: Refactoring to make MessageChannelHandler extensible

Small refactorings to make the MessageChannelHandler more extensible.
Also allowed access to the different netty pipelines

Closes #6889
bin/plugin removes itself

If you call `bin/plugin --remove es-plugin` the plugin got removed but the file `bin/plugin` itself was also deleted.

We now don't allow the following plugin names:

* elasticsearch
* plugin
* elasticsearch.bat
* plugin.bat
* elasticsearch.in.sh
* service.bat

Closes #6745
[TEST] Use array* helper assert methods instead of verifying the array directly
[TEST] Fixed intermittent failure due to lack of mapping
Refactoring: Rename FieldMapper.termsFilter to fieldDataTermsFilter.

FieldMapper has two methods
`Filter termsFilter(List values, @Nullable QueryParseContext)` which is supposed
to work on the inverted index and
`Filter termsFilter(QueryParseContext, List, QueryParseContext)` which is
supposed to work on field data. Let's rename the second one to
`fieldDataTermsFilter` and remove the unused `QueryParseContext`.

Close #6888
[Infra] remove indicesLifecycle.Listener from IndexingMemoryController

The IndexingMemoryController determines the amount of indexing buffer size and translog buffer size each shard should have. It takes memory from inactive shards (indexing wise) and assigns it to other shards. To do so it needs to know about the addition and closing of shards. The current implementation hooks into the indicesService.indicesLifecycle() mechanism to receive call backs, such shard entered the POST_RECOVERY state. Those call backs are typically run on the thread that actually made the change. A mutex was used to synchronize those callbacks with IndexingMemoryController's background thread, which updates the internal engines memory usage on a regular interval. This introduced a dependency between those threads and the locks of the internal engines hosted on the node. In a *very* rare situation (two tests runs locally) this can cause recovery time outs where two nodes are recovering replicas from each other.

 This commit introduces a a lock free approach that updates the internal data structures during iterations in the background thread.

Closes #6892
Revert "Netty: Refactoring to make MessageChannelHandler extensible"

This results in unstable tests, most likely due to Channels being mixed
up by wrongly creating the pipelines. Needs investigation and a test.

This reverts commit db7f0d36af6692b1648cbea6e1e7147e7cfa70dc.
[Store] delete unallocated shards under a cluster state task

This is to prevent a rare racing condition where the very same shard gets allocated to the node after our sanity check that the cluster state didn't check and the actual deletion of the files.

Closes #6902
Added three frequency levels for resource watching

 It's now possible to register watchers along with a specified check frequency. There are three frequencies: low, medium, high. Each one is associated with a check interval that determines how frequent the watchers will check for changes and notify listeners if needed. By default, the intervals are 5s, 30s and 60s respectively, but they can also be customized in the settings. also:

  - Added the WatcherHandle construct by which one can stop it (remove it) and resume it (re add it). Also provices access to the watchers itself and the frequency by which it's checked
  - Change the default frequency to 30 seconds interval (used to be 60 seconds). The only watcher that is currently effected by this is the script watcher (now auto-loading scripts will auto-load every 30 seconds if changed)
[Bulk] Add blocking close method to BulkProcessor

Blocks until all bulk requests have completed.

Closes #4158
Closes #6314
[Bulk] Release semaphore again after close

The bulk processor tries to acquire all leases for the semaphore to wait
for all pending requests. Yet, we should release them afterwards again to
ensure we don't ever deadlock if there is a bug in the processor.
This commit also adds a testcase for this method