SPY-178: KetamaNodeLocator#getReadonlyCopy uses unsafe operations.

Motivation
----------
Users reported java.lang.UnsupportedOperationException when using the
KetamaNodeLocator#getReadonlyCopy() method. It turns out the error
only shows up when the JVM is run with the -XX:+AggressiveOpts flag.

Modifications
-------------
Changing the iterator to properly update the TreeMap while iterating
fixes the problem.

Result
------
Correct behavior for KetamaNodeLocator#getReadonlyCopy(), even when
the -XX:+AggressiveOpts flag is enabled.

Change-Id: I6e7f09892687b8896c9b295a94fb473857ec212f
Reviewed-on: http://review.couchbase.org/43040
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
SPY-179: Reconnect has wrong ceiling, leading to very long reconnect delays.

Motivation
----------
This is a regression which was introduced through the change in SPY-158
(https://github.com/couchbase/spymemcached/commit/bfaec2b4f1385f20f32fd0ed0736b52ef572e340).

Because the time is now converted to millis right away, but the comparison checks with the 2^n
still converted to seconds. That way, even with a very high N it is smaller than the default of
30k.

Modifications
-------------
The code now correctly converts the 2^n to milliseconds before comparing it, making it a comparison
on the same unit of time again.

Result
------
The ceiling is now properly respected and as a result, reconnect delays are properly capped at
their defined maximum.

Change-Id: I0c976344d0f8e09bc041d94f3544620ef4fb3117
Reviewed-on: http://review.couchbase.org/42925
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Update Spring FactoryBean to properly support isSingleton property

Motivation
----------
The current MemcachedClientFactoryBean is marked as a singleton to Spring but
does not respect the flag. It is creating a new instance with every call to
getObject(). According to the Spring Javadoc a FactoryBean marked with
isSingleton true should always return the same reference. By doing this it
will also expose an ability to safely shutdown a client instance.

Modifications
-------------
The class was updated to implement the Spring InitializingBean and
DesposableBean interfaces. These interfaces provide the two key lifecycle
methods to create and shutdown the client object. The afterPropertiesSet is
called after the FactoryBean is constructed and all of the properties have
been set. This will create the client object and store it in a field so the
same reference can be returned. The destroy method is called when closing the
Spring context. It will call the client's shutdown method. I have also added a
new property that allows a caller to specify the number of seconds to wait
before shutting down the client. This is a well established Spring pattern
that is used in many of their own FactoryBean implementations.

Result
------
A more accurate Factory bean that respects the Spring lifecycle and provides
a safe shutdown mechanism.

Change-Id: I9ae2d71ae7d3fe899bce8ec8200e215aa987400d
Reviewed-on: http://review.couchbase.org/44144
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Merge branch 'master' of https://github.com/couchbase/spymemcached