Throttle writers if mem-table reach 3/4 of size limit while snapshot is being flushed, and block writers if mem-table reach size limit until snapshot cleared.

RB_ID=120513
Expire readahead cache entry after 5 minutes

RB_ID=120535
Enabling logging (execution trace) in the Bookkeeper Tests (again!)

- One of the merges from the external repo disabled logging so enabling it again
- Enable at the INFO level to not slow down the tests too much

RB_ID=120982
Additional Journal Stats/Tracing
1. Track the reasons for flushing the buffers to the journal file (helps diagnose efficiency of group commit and various config parameters)
2. Track the number of Journal Force writes 3. I also added debug tracing that I use to ensure that writes are acknowledged only after the journal force write has been issued on them.

RB_ID=121182
Add thread pool to process callback to offload Journal forcewrite thread, which is shown impacting group-commit throughput. The number of threads is 1 + number of writers, with one of the thread as dispatcher thread from time to time and also serving callbacks.

RB_ID=121505
provide compression in hedwig request/response stream

RB_ID=120472
Journal Flush: Avoid flushing for empty queue in high throughput mode
In the high throughput mode, it doesn't make sense to flush just because the queue was empty momentarily, instead we should let the max wait or max outstanding bytes logic do the appropriate grouping of flushes. I am therefore adding a mechanism to skip flushing on queue empty.

RB_ID=121724
merge 4.2.0 release changes which fixed logic issues, race conditions

- BOOKKEEPER-503: The test case of TestThrottlingDelivery#testServerSideThrottle failed sometimes (jiannan & sijie via ivank)
- BOOKKEEPER-539: ClientNotSubscribedException & doesn't receive enough messages in TestThrottlingDelivery#testServerSideThrottle (sijie)
- BOOKKEEPER-538: Race condition in BookKeeper#close (ivank via fpj)
- BOOKKEEPER-540: #stopServingSubscriber when channel is disconnected. (Fangmin via sijie)
- BOOKKEEPER-543: Read zk host list in a wrong way in hedwig server (Fangmin via sijie)
- BOOKKEEPER-529: stopServingSubscriber in delivery manager should remove stub callbacks in ReadAheadCache (sijie via ivank)
- BOOKKEEPER-533: TestSubAfterCloseSub fails strangely in tests (ivank via fpj)
- BOOKKEEPER-532: AbstractSubscriptionManager#AcquireOp read subscriptions every time even it already owned the topic. (sijie via fpj)
- BOOKKEEPER-355: Ledger recovery will mark ledger as closed with -1, in case of slow bookie is added to ensemble during recovery add (ivank)
- BOOKKEEPER-507: Race condition happens if closeSubscription and subscribe happened at the same time (in multiplexed client). (sijie via ivank)
- BOOKKEEPER-514: TestDeadLock hanging sometimes (ivank, sijie via fpj)
- BOOKKEEPER-500: Fencing doesn't work when restarting bookies. (sijie via ivank)
- BOOKKEEPER-509: TestBookKeeperPersistenceManager failed on latest trunk (sijie via ivank)
- BOOKKEEPER-504: Fix findbugs warning in PendingReadOp (fpj via ivank)
- BOOKKEEPER-336: bookie readEntries is taking more time if the ensemble has failed bookie(s) (ivank)
- BOOKKEEPER-458:  Annoy BKReadException error when changing ledger. (jiannan via fpj)
- BOOKKEEPER-365: Ledger will never recover if one of the quorum bookie is down forever and others dont have entry (sijie via ivank)

RB_ID=119332
Optimize SkipList flush by Sync thread to check if mem-table entry after sync-logMarker, which indicates the target checkpoint position. SkipList is augmented to capture last rolled-logMarker before inserting any entry, to indicate all entries are added after rolled log Marker (aka checkpoint). The sync thread simply move sync-logMarker on timeout or shutdown for checkpoint position, which allows SkipList size limit and sync-interval settings factored in the tuning.

RB_ID=122088
fix hedwig test failures due to bad readahead settings after changed to guava cache

RB_ID=122714
Remove journal pages from the file system page cache after force write
1. JNA based native I/O library
- On-demand initialization so that the initialization happens only when one of the native methods is used.
- Extract file system descriptor from java.io.FileDescriptor using Reflection
- Use posix_fadvise on linux based systems to hint to the filesystem that a range of the file will not be needed again (can be removed from the cache)
2. Journal Force Write Changes
- Track the last force write position
- Issue fadvise on the range between the last force write position and recent force write position
3. Added a configuration option to enable this selectively.

RB_ID=123695
optimize checkpoint to avoid I/O contention

- preallocate entry log files in seperated thread
- separated checkpoint logic from writing data to filesystem, which avoid contention on same entry log file.
1. checkpoint only happened in rotating entry log file.
2. when entry logger rotated a log file, it schedule a checkpoint request. SyncThread use the checkpoint to checkpoint LedgerStorage. after LedgerStorage finished checkpoint, SyncThread called CheckPoint#checkpointComplete to roll a marker and gc journal if necessary.

RB_ID=123624
Missing change for uploading the HubLoad contents before and after rebalance
Commit e9d6834b6 was missing the uploading of the HubLoad contents after the rebalance cycle

RB_ID=124086
separate index directories from ledger directories.

RB_ID=123967
BOOKKEEPER-447: Bookie can fail to recover if index pages flushed before ledger flush acknowledged

2 places fixed when merging this patch.

1) uses <= to check pageCount. since we increase the page count first.
2) change BufferedReadChannel to return -1 when reading data past eof. since entrylogger needs this information to throw NoEntryException when short reads.

RB_ID=124500
 Hedwig loadtest framework
 The previous load test had a lot of custom code for tracking stats which was of no use because we have shifted to using twitter-stats. This is a time based benchmark. It supports the following:
 1) Publishing at a configurable rate or with a configurable number of outstanding requests.
 2) Configurable concurrency for publishes.
 3) Configurable number of receivers per topic.
 4) Being able to publish and subscribe to a configurable range of topics.
 5) Configurable topic and subscriber names.

RB_ID=104273
Track last entry position of LedgerEntryPage. Introduce ZeroBuffer class to clean up buffer-zero usage.

RB_ID=123153
Skip entry log flushing if ledger garbage collected already.

RB_ID=126726
Touch dirty flag first when adding entry to storage

RB_ID=126833
Checkpoint upon shutdown and address race condition of logChannelsToFlush.

RB_ID=127018