Introduces a tiny sleep in the loop that checks HA availability

to avoid heavy CPU busy-wait
Removes the need for HA snapshots on cluster join

Slaves now will respond to masterIsAvailable events with slaveIsAvailable
 always. That means that when an instance joins, it will see all the
 availability events that make up the cluster, bringing it up to date.
 This removes the need for snapshot to be received on cluster join.

Conflicts:
	enterprise/ha/src/main/java/org/neo4j/kernel/ha/HighlyAvailableGraphDatabase.java
	enterprise/ha/src/main/java/org/neo4j/kernel/ha/cluster/HighAvailabilityModeSwitcher.java
Ignores TransactionNotPresentOnMasterExceptions

This was done already but not for all cases. Puts that catching in one
place so that all code paths benefit.

Conflicts:
	enterprise/com/src/main/java/org/neo4j/com/Server.java
Fixes issue where more HA availability messages than necessary were broadcast

Previous attempt in this area left open a bug where for example the master receiving
 a SlaveIsAvailable event would make it broadcast a MasterIsAvailable event again,
 refuelling a loop of such exchanges. This makes sure that the instance's state and
 the incoming transition are examined to decide on what to broadcast.
Introduces tests for the above.

Conflicts:
	enterprise/ha/src/test/java/org/neo4j/kernel/ha/cluster/HighAvailabilityModeSwitcherTest.java
Improved data provided by AvailabilityGuard to help debugging.

Conflicts:
	community/kernel/src/main/java/org/neo4j/helpers/collection/Iterables.java
	community/kernel/src/main/java/org/neo4j/kernel/AvailabilityGuard.java
	community/kernel/src/main/java/org/neo4j/kernel/InternalAbstractGraphDatabase.java
	community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/TxManagerTest.java
	enterprise/ha/src/main/java/org/neo4j/kernel/ha/HighlyAvailableGraphDatabase.java
Improved logging for failure on rollback.

Conflicts:
	community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/TxManager.java
Improved error reporting for file lock failures.
Fixed message reordering issue by using two stacks

Conflicts:
	community/server/src/main/java/org/neo4j/server/rest/batch/BatchOperations.java
Fixes message reordering issue in Atomic Broadcast

Messages that created new messages caused a message reordering
 issue that can really screw things up. This deals with that by
 replacing the single queue with two stacks that are cleverly
 bounced back and forth to get the correct ordering.
Adds a test for this condition

Authored by Rickard Oberg

Conflicts:
	enterprise/cluster/src/main/java/org/neo4j/cluster/StateMachines.java
Remove duplicate shutdown
Merge fixes
Refactors state machine contexts into interfaces

This commit is a needed refactoring to make state machines more testable.
 It removes all dependencies from all state machine contexts that before
 had them interconnected and all tangled up, requiring multiple levels
 of mocking. Instead, now they are all implemented by MultiPaxosContext
 which takes care to factor out common needed functionality. While the
 diff is large, it does not represent too big of a change.

Conflicts:
	enterprise/cluster/src/main/java/org/neo4j/cluster/MultiPaxosServerFactory.java
	enterprise/cluster/src/main/java/org/neo4j/cluster/protocol/ConfigurationContext.java
	enterprise/cluster/src/main/java/org/neo4j/cluster/protocol/TimeoutsContext.java
	enterprise/cluster/src/main/java/org/neo4j/cluster/protocol/atomicbroadcast/multipaxos/AcceptorContext.java
	enterprise/cluster/src/main/java/org/neo4j/cluster/protocol/atomicbroadcast/multipaxos/AtomicBroadcastState.java
	enterprise/cluster/src/main/java/org/neo4j/cluster/protocol/atomicbroadcast/multipaxos/MultiPaxosContext.java
	enterprise/cluster/src/main/java/org/neo4j/cluster/protocol/cluster/ClusterContext.java
	enterprise/cluster/src/main/java/org/neo4j/cluster/protocol/cluster/ClusterState.java
	enterprise/cluster/src/main/java/org/neo4j/cluster/protocol/election/ElectionState.java
	enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/election/ElectionStateTest.java
	enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/heartbeat/HeartbeatContextTest.java
	enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/heartbeat/HeartbeatStateTest.java
Merge fixes
Fixes Paxos instance reuse issue

It is possible for a Paxos instance to be started before a previous
 instance has been closed, and to use the same instance Id. A potential
 bug around this is that on receiving phase1Timeout for the second
 instance, the message will be dropped altogether and not retried, as
 the proposer state machine considers the instance closed.
 This commit fixes this issue and introduces a test case for it.

Conflicts:
	enterprise/cluster/src/main/java/org/neo4j/cluster/protocol/atomicbroadcast/multipaxos/ProposerState.java
	enterprise/cluster/src/test/java/org/neo4j/cluster/protocol/atomicbroadcast/multipaxos/ProposerStateTest.java
Fixes issue with instances properly changing to PENDING on losing quorum

Instances in TO_SLAVE or TO_MASTER state will remain forever in that state
 if quorum is lost and regained. This commit adds tests for this condition
 and removes an if statement that caused it.
Ensures that ProposerState unbooks retried instances