Merge pull request #2130 from tinwelint/2.0-merge-1.9

Merge 1.9 --> 2.0
Reuse existing parser rules
Remove the OSGi example.

It was removed last year from 2.0 because it was flaky and it now fails
incomprehensibly on TeamCity. There doesn't seem to be any point
spending lots of time working out what is wrong with it just for this
one unimportant example.

Conflicts:
	community/embedded-examples/src/test/java/org/neo4j/examples/osgi/Neo4jActivator.java
	community/embedded-examples/src/test/java/org/neo4j/examples/osgi/OSGiDocIT.java
Introduce the StoreChannel abstraction, and the AdversarialFSA.

The StoreChannel interface is very similar to the API of the FileChannel class.
I had to introduce it because of the many final methods of the FileChannel.
The AdversarialFileSystemAbstraction needed to be able to throw exceptions from those methods
that were marked as final in the FileChannel, so I had to abstract away the FileChannel itself, and
introduce this new indirection. The StoreFileChannel wraps a FileChannel while exposing the
StoreChannel API.

The AdversarialFileSystemAbstraction is a file system that can be configured to throw exceptions and
failures as we please. This is useful for testing partial failure scenarios that our current robustness
suite does not cover, since it currently only works by killing entire processes - not individual
transactions.
Additional cleanup after the introduction of StoreChannel
Add mischief to the adversarial file system.
Merge pull request #2132 from chrisvest/1.9-adversarial-fs

Introduce the StoreChannel abstraction, and the AdversarialFSA.
Fix building 1.9 on Java 6
Merge pull request #2144 from chrisvest/1.9-fix-java6-build

Fix building 1.9 on Java 6
Also fix the test compilation on Java 6
Raise an exception if Server shutdown fails.

Rather than just log exceptions that happen during shutdown, we
carefullly catch and record them. Then after shutdown is complete, if
there was an exception during the process we re-raise it.

This change uncovered a couple of problems that were previously being
ignored. They are cases where tests call #stop() even though #start()
did not succeed. Those #stop() methods are now more defensive to cope
with that.
Merge branch '1.9-maint' into 2.0-merge-1.9

Conflicts:
	community/kernel/src/main/java/org/neo4j/kernel/DefaultFileSystemAbstraction.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/nioneo/store/AbstractStore.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/nioneo/store/FileSystemAbstraction.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/nioneo/store/IdGeneratorImpl.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/nioneo/store/RelationshipTypeStore.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/legacystore/LegacyDynamicStoreReader.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/legacystore/LegacyNeoStoreReader.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/legacystore/LegacyNodeStoreReader.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/legacystore/LegacyPropertyIndexStoreReader.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/legacystore/LegacyPropertyStoreReader.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/legacystore/LegacyRelationshipStoreReader.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/legacystore/LegacyRelationshipTypeStoreReader.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/TxLog.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/xaframework/DirectLogBuffer.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/xaframework/LogBuffer.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/xaframework/LogIoUtils.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/xaframework/XaLogicalLog.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/xaframework/XaLogicalLogFiles.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/util/DumpLogicalLog.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/util/FileUtils.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/util/IoPrimitiveUtils.java
	community/kernel/src/test/java/org/neo4j/kernel/CannedFileSystemAbstraction.java
	community/kernel/src/test/java/org/neo4j/kernel/impl/core/TestChangingOfLogFormat.java
	community/kernel/src/test/java/org/neo4j/kernel/impl/index/TestIndexCommand.java
	community/kernel/src/test/java/org/neo4j/kernel/impl/nioneo/store/TestDynamicStore.java
	community/kernel/src/test/java/org/neo4j/kernel/impl/nioneo/store/TestGraphProperties.java
	community/kernel/src/test/java/org/neo4j/kernel/impl/nioneo/store/TestIdGenerator.java
	community/kernel/src/test/java/org/neo4j/kernel/impl/nioneo/store/TestPersistenceWindowPoolContention.java
	community/kernel/src/test/java/org/neo4j/kernel/impl/nioneo/store/TestXa.java
	community/kernel/src/test/java/org/neo4j/kernel/impl/storemigration/MigrationTestUtils.java
	community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/TestXaFramework.java
	community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/xaframework/LogMatchers.java
	community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/xaframework/TestPartialTransactionCopier.java
	community/kernel/src/test/java/org/neo4j/test/IdJumpingFileSystemAbstraction.java
	community/kernel/src/test/java/org/neo4j/test/LogTestUtils.java
Fixes byte count monitoring and adds some debugging output

ByteCounterMonitor implementations were being updated wrongly by many
 of the components that used them. This is now fixed.
Introduced MonitoredReadableByteChannel as a wrapper around a
 ReadableByteChannel that updates on reads a given monitor. This solves
 most issues with monitoring.
BufferedFileChannel now wraps a ByteCounterMonitor to monitor
 actual writes.
BlockLogBuffer also now updates bytes written on done().
Merge branch '2.0-maint' into 2.0-merge-1.9

Conflicts:
	community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/xaframework/XaLogicalLog.java
	community/kernel/src/main/java/org/neo4j/kernel/impl/util/BufferedFileChannel.java
	community/kernel/src/test/java/org/neo4j/kernel/impl/util/TestBufferedFileChannel.java
Merge pull request #2152 from chrisvest/2.0-merge-1.9

2.0 merge 1.9
Merge pull request #2153 from benbc/1.9-dont-swallow-server-shutdown-exceptions

Raise an exception if Server shutdown fails.
Merge branch '1.9-maint' into 2.0-maint

Conflicts:
	community/server/src/main/java/org/neo4j/server/AbstractNeoServer.java
	community/server/src/main/java/org/neo4j/server/web/Jetty6WebServer.java
	community/server/src/test/java/org/neo4j/server/web/TestJetty6WebServer.java
Fix exception merging to be compatible with Java 1.6.
Don't access resources during shutdown.

The XaDataSourceManager was creating new resources in
unregisterDataSource(). When this method is called during shutdown,
other components may already have been shut down so the resource
creation may fail.

The particular case we saw was a race condition shutting down during a
master switch, which caused a NullPointerException in
XaConnectionHelperImpl when LuceneDataSource tried to create a
LuceneXaResource with a null XaResourceManager (which had been nulled
out during the master switch).
Remove a catch block that was suppressing failures in a test and make the test more robust.

The catch block in HTTPLoggingDocIT was suppressing all failures. Once
it had been removed it became apparent that the test was
flaky. Specifically it almost always failed in my IDE when run
alone (although it passed when run with the other tests in the file). I
believe the flakiness was because the log file wasn't always flushed to
disk before the assertion was reached.