fix occasional failure in BookieWriteLedgerTest.
- do strict ledger metadata confliction checking only when it needs to do ledger metadata updates, otherwise multiple bookies replaces happens in an ensemble change would fail with MetadataVersionException
- move assertion out-side of callbacks in BookieWriteLedgerTest.

RB_ID=138495
Hedwig Client Logging - Part II
Trace out exceptions where they weren't already being correctly logged

RB_ID=139553
make logger as a static variable
not all logger in bookkeeper & hedwig are static. some class like PendnigReadOp and LedgerEntry would have lots of objects, it might be bad. so this task is to make logger as a static variable if it didn't.

with benefit, cleaning up the imports when touching that file.

RB_ID=141138
- fix metadata overwritten issue when resolve metadata conflicts in changing ensemble.

    - change LedgerMetadata#resolveConflicts to LedgerMetadata#isConflictWith, to make the function clearer
    - when changing ensemble, we should use the local in-memory copy for metadata when resolving conflicts
    - when resolve metadata version issue during closing a ledger, we use the metadata in zookeeper to ensure
      that we don't overwrite the ensemble that already replaced by re-replication (re-replication only works
      on a closed ledger).

RB_ID=141877
stop resubscribe if it is already subscribed

RB_ID=140342
BookKeeper: Publish an internal version of the bookkeeper binaries so as to not conflict with open source versions.
Publish an internal version of the bookkeeper binaries so as to not conflict with open source versions. Starting with the snapshot version, but we will use the same convention for the non snapshot version as well.

Working to get mvn publish working

RB_ID=151374
BookKeeper: Removing Journal Pages from the File system Cache
Incorporate Ivan's comments in preparation to submit the patch for removing journal pages from the file system cache.

RB_ID=151055
Bookkeeper: Use Jetty Version compatible with twitter commons
Use Jetty Version compatible with twitter commons

RB_ID=147643
BookKeeper: Reduce the noise in the trace output during restart of the bookkeeper client
When the ingester job restarted the write iterators of the distributed log application which effectively tears down the BK client - during this tear down, outstanding operations fails causing a lot of noise in the trace output. Many of these exceptions are expected - but this message storm causes the log to lose useful information. Making these messages selective.

We also saw a lot of messages when we tested restarting a bookie - will go through that code path and also try to reduce noise there.

RB_ID=151335
Allow LedgerHandle.close to be called on a closed ledger
Don't throw exception in synchronous version LedgerHandle.close if the ledger is already closed so clients can call it multiple times.

RB_ID=145348
BookKeeper: Local Bookie Journal and ledger paths
Use the journal directory and ledger paths specified in the configuration file passed in to local bookie. Before this change local bookie was always creating directories in the temp folder

RB_ID=152584
BookKeeper: PerChannelBookieClient race during channel disconnect
The channel should be closed in the synchronized block to avoid the race where the disconnect marks the channel as disconnected - another thread attempts to reconnect, marks the channel as connected and then the disconnect thread closes the newly established channel.

RB_ID=153820
BookKeeper: Fix the logging to correctly log exceptions other than ChannelClosedException
Fix the logging to correctly log exceptions other than ChannelClosedException (this was a typo in a previous change). Also changed the trace to be WARN as we are only turning on WARN level for bookkeeper client in distributed log.

RB_ID=153816
BookKeeper: Netty channel lifetime in PerChannelBookieClient
This change fixes two issues
1. If the channelDisconnectedEvent is processed out of order, it can send the bookkeeper client in an endless loop of reconnection attempts. We should process the channelDisconnectEvent and error out pending operations, but close and change the channel state only if the closed channel is still the current Channel
2. If writing to the channel encounters a channel closed exception, we do the same processing and force the next operation to open a new connection

RB_ID=155039
BookKeeper: Fix the disconnect race in PerChannelBookieClient
- Fix the race that causes a clean channel to be disconnected when two requests simultaneously try to connect
- Add instrumentation to log disconnects received from netty
- Add a test similar to what Ivan added in open source for a related issue

RB_ID=156117
BookKeeper: Fix an incorrect trace message
The channel was being logged before it was set, fixing that.

RB_ID=156744
BookKeeper: Bookie should allow binding to ephemeral ports
For automated unit tests its necessary to be able to use ephemeral ports. I refactored the restart process as follows to enable use of ephemeral ports

Restart sequence
1. First instantiate the server factory and bind to the port
   --- if using ephemeral ports this is where a port will be picked and
       used for rest of the startup
2. Initialise the bookie - using the port that the connection bound to
3. Set the packet processor in the server (this is only used after the server starts running
4. Start the bookie - read the journal, replay, recover
5. Start the server and accept connections

RB_ID=160633
bookkeeper: should not use System.nanoTime as journal file id. otherwise, it would cause journal file garbage collected by mistake
- should not use System.nanoTime as journal file id. otherwise, it would cause journal file garbage collected by mistake. (similar issue we encountered before in Distributed Log)

http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/System.html#nanoTime%28%29

RB_ID=160047
BookKeeper: Local Bookkeeper enhancements for testability
1. Allow creating local bookies without always starting a zookeeper server - This is required as tests may want to create and use their own instance of a test zookeeper
2. Allow using non default zookeeper host and more importantly non default ZK port
3. Allowing the caller to specify the initial port for the bookies
4. Optionally shutdown bookies when the bookie thread exits

RB_ID=161055
BookKeeper: Ephemeral ports in local bookkeeper
Allow specifying ephemeral ports in local bookkeeper

RB_ID=161056