SPY-167: Avoid deadlock on notify listeners.

Motivation
----------
Because of how the addListener and notifyListener works, it could be that
one deadlocks each other because they are waiting on the same locks from
different threads.

Modifications
-------------
The listeners are copied before notified, moving it out of the synch block.

Result
------
Since notify is not synched anymore, the lock should be not happening anymore.

Note that also the listeners array is set to empty which avoid notifying listeners
more than once potentially.

Thanks to @adamhonen for pointing out the fix.

Change-Id: I7ebda58c2eadd62d8885e3eeac79d5a971e07979
Reviewed-on: http://review.couchbase.org/36219
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
SPY-166: Only readd a WRITE_QUEUED operation, not clone it in addition.

Motivation
----------
When a WRITE_QUEUED operation is redistributed, it needs to be readded
but not cloned (since its still in a sendable state).

Modification
------------
Return after adding the operation again.

Result
------
The operation is readded and not cloned afterwards too.

Change-Id: I79fec436aa538a8a4074e82f69b3ed186c5126b7
Reviewed-on: http://review.couchbase.org/36258
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
SPY-165: Do not cache the selectedKeys.

Motivation
----------
Caching the selected keys may cause issues if the selector is accessed by different
threads, also the loop for the keys is not using the iterator correct.

Modifications
-------------
Make it not cache the keys and also correctly make use of an iterator to loop through
the keys.

Result
------
No stale/cached selected keys and correctly using the iterator should lead to better
stability during failure cases.

Thanks to Brad Svee (@sveesible) for suggesting the fix

Change-Id: If82cdfc810c758a4196415cb709a03ebd72c3d15
Reviewed-on: http://review.couchbase.org/36222
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>