Slave goes through 'switchToSlave' process on every 'masterIsElected' event
Fixes an issue which made it impossible to resume a migration

i.e. when the migration had been completed, and the migration aborted...
when it would be picked up again the next time to do the moving of files
from migration directory to store directory there would be an assumption
that the "migrate" method would have been run before it. This led to an
NPE for an uninitialized field.
Updates changelogs for 1.9.9 with last batch of changes
Rewrite of perty to avoid stack build-up and erasure issues

Changes perty such that instead of building Docs for pretty printing
directly, we now build a flat heap representation (DocRecipes).
DocRecipes are abstract, i.e. contain unrendered values.
This is exactly how stack build-up is avoided: Each doc generator
just renders a tiny part of the document, keeping sub-components
abstract in the generated flat representation. An outer
loop continously processes the flat representation and tries
to render any abstract component it finds. Finally,
if all abstract components have been rendered, the flat
representation is turned into a Doc for actual pretty printing,
as before. This is done via simple, heap-based interpreter.

To keep things nice, each generator builds it's slice of
the flat representation using a tiny stack-based DSL.
However this should not be a stack build-up problem as
the nesting level for each individual generator (say
pretty printing of a FunctionInvocation) is just
a few levels deep.

This is the first version of perty with a working
astStructureDocGen (the ability to show both ast
and scala-like representation of ast nodes side by side).

Finally, this also uses scala reflection instead
of using pattern matching to help with some type
erasure problems we say with the old perty.

It is not yet clear wether the overhead is worth the
benefit, we'll have to try it for a while to know.
If it gets in the way, it should be straightforward
to remove using scala reflect.

This version of perty does not yet cover the whole ast
but it is now a in good shape to get started on that.

For reference, here's a condensed list of original
commits. History was squashed since almost all individual
commits where not in a green state.

o Adding scala-reflect dependency
o Add reflective perty (& bling) packages
o Refactor Extractors to be more practical
o Replace use of fix points with a flat reprensentation:
  Add DocSteps, recipes, expand, and eval
o Rebuild pprintToString
o Move Doc helpers to Pretty DSL and fix scalaDocGen
o Fix Pretty DSL so that we can work with different types without calling pretty
o Make scalaDocGenWorkAgain
o Re-enable scalaDocGen using fancy type magic tricks
o Re-enable ast and plan doc gens
o Re-enable AstStructureDocGen
o More ast support for perty
o Update LICENSE files for scala reflect
Fixes tests that left threads behind after run

introduced a simple tracking method that can be used for labelling
threads, only active if assertions are enabled.
Merge pull request #3252 from tinwelint/2.1-resume-migration-fix

[2.1] Fixes an issue which made it impossible to resume a migration
Merge pull request #3258 from boggle/perty-squashed

[2.2] Rewrite of perty to avoid stack build-up and erasure issues
Merge pull request #3217 from lutovich/1.9-slave-epoch-mismatch

[1.9] Slave goes through 'switchToSlave' process on every 'masterIsElected' event
Merge branch '1.9-maint' into 2.0-maint

Conflicts:
	enterprise/backup/CHANGES.txt
	enterprise/ha/src/test/java/org/neo4j/ha/TestSlaveOnlyCluster.java
Merge branch '2.0-maint' into 2.1-maint

Conflicts:
	enterprise/backup/CHANGES.txt
Merge branch '2.1-maint'

Conflicts:
	community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/StoreMigrator.java
	enterprise/ha/src/test/java/org/neo4j/ha/TestSlaveOnlyCluster.java
	enterprise/ha/src/test/java/org/neo4j/kernel/ha/ClusterTopologyChangesIT.java
	enterprise/ha/src/test/java/org/neo4j/test/AbstractClusterTest.java
Merge pull request #3259 from tinwelint/2.2-clean-test-litter

[2.2] Fixes tests that left threads behind after run
Merge remote-tracking branch 'upstream/master'
Adds index id to init/start logging of IndexingService