Add IPeerSelector interface from #1382

Adds the IPeerSelector interface established by kevan in ticket #1382
Implements PeerSelector class to track peerids

Implements the IPeerSelector class as PeerSelector and integrates the
class into Tahoe2ServerSelector in order to track peerids and existing
share allocations among the peers
Add _get_next_allocation method; remove duplicated logic from _loop

Implements Kevan's refactoring of _loop:

"This is essentially a copy-and-paste of tracker and share selection
logic from within _loop to _get_next_allocation. Now,
_get_next_allocation is responsible for telling _loop what to do (i.e.,
which server to use, and which shares to store on that server), and
_loop is responsible for doing what _get_next_allocation says to do.
This isn't a big change right now, but allows us to move to an external
peer selector object more easily (and obviously) in the future.

This also unifies the log messages for success and failure, and the
exception messages printed on a failure. Before, users would see two
slightly different messages depending on where in _loop the allocation
was noted as successful (or unsuccessful). This commit chooses the more
verbose form of these messages to be used on all successes and failures."
Fix spelling error in comments for _get_next_allocation
Implements Happiness_Upload class

Implements the Happiness_Upload class to generate a maximum
matching of peerids to shareids based on Kevan Carstensen's
master thesis. Existing share allocations are reused if possible
and their leases should be renewed by the uploader. If a shareid
does not have a match in the maximum matching graph, its
respective peerid is set to 'None'.
Happiness_Upload now calculates happiness

Happiness_Upload now calculates happiness with _calculate_happiness
whenever a set of mappings is generated. The client accesses
the happiness value by happiness().
Happiness_Upload calculates happiness when servermap is not supplied or empty
Adds _distribute_homeless_shares

If homeless shares exist, _distribute_homeless_shares is called
in order to find homes for the shares. If possible a homeless share
is placed on a server it is already on, signifying that the share
should be renewed instead of being uploaded to a new server.
Otherwise the function attempts to distribute the shares as evenly
as possible over the available peers.

_calculate_happiness has been refactored to keep track of homeless
shares to minimize iteration over the new mappings.
Removes redundant if statement in generate_mappings
PeerSelector uses sets for existing_shares instead of lists
PeerSelector uses Happiness_Upload

PeerSelector uses Happiness_Upload to implement get_tasks
and is_healthy. In order to do this PeerSelector now requires
the parameters num_segments, total_shares, needed_shares, and
servers_of_happiness from Tahoe2ServerSelector when initialized.
generate_mappings returns a dictionary of shareid -> set([peerid])
Implements _reindex_shares

Since shares are ints, a bidirectional directionary of ints to ints
creates conflicts. Therefore when shares are reindexed, two dicts
must be created, one with shares -> indexes and one with indexes
-> shares.

Also fixes a small issue when a set was incorrectly being added
to existing_peers.
Implements PeerSelector into Tahoe2ServerSelector

Initial attempt to refactor Tahoe2ServerSelector in terms of
the PeerSelector. This does not pass all of the existing
tests in test_upload.py
Happiness_Upload now takes in full_peers

The PeerSelector now passes the set of full peers to Happiness_Upload.
Also removes the case in which no servermap is supplied from
generate_mappings because the case is redundant.
Fixes construction of peer priorities

Fixes an error in _distribute_homeless_shares where the loop
was trying to assign a priority to full_peers when full_peers
are not present in the priority dictionary. If the loop encounters
a peer that is full, it just skips over that peer.
Adds edge situation where servermap is empty
Removes unnecessary comment about version dependency
Removes todo from tests

Removes todo from tests in test_upload.py because these tests
should pass once this patch is finished.
Adds edge case to _distribute_homeless_shares

Adds exception to _distribute_homeless_shares that caused
tests to hang indefinitely.