* PeerSelector:
- Limit exploratory tunnels to connected peers when over half the connection limit (was 80%) - Have the high capacity tier fall back to a new connected tier before moving on to the not failing tier so that tunnel build success doesn't collapse * PeerTestJob: - Limit to connected peers
This commit is contained in:
11
history.txt
11
history.txt
@ -1,3 +1,14 @@
|
||||
2009-06-17 zzz
|
||||
* PeerSelector:
|
||||
- Limit exploratory tunnels to connected peers when over
|
||||
half the connection limit (was 80%)
|
||||
- Have the high capacity tier fall back to a new connected tier
|
||||
before moving on to the not failing tier
|
||||
so that tunnel build success doesn't collapse and drive
|
||||
connections to the limit
|
||||
* PeerTestJob:
|
||||
- Limit to connected peers
|
||||
|
||||
2009-06-12 zzz
|
||||
* Console:
|
||||
- Move the console css from default.css in the .war to docs/themes/console/console.css,
|
||||
|
@ -36,6 +36,7 @@ public abstract class CommSystemFacade implements Service {
|
||||
public int countActiveSendPeers() { return 0; }
|
||||
public boolean haveInboundCapacity() { return true; }
|
||||
public boolean haveOutboundCapacity() { return true; }
|
||||
public boolean haveHighOutboundCapacity() { return true; }
|
||||
public List getMostRecentErrorMessages() { return Collections.EMPTY_LIST; }
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
||||
/** deprecated */
|
||||
public final static String ID = "Monotone";
|
||||
public final static String VERSION = CoreVersion.VERSION;
|
||||
public final static long BUILD = 1;
|
||||
public final static long BUILD = 2;
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
|
||||
|
@ -116,7 +116,14 @@ class PeerManager {
|
||||
case PeerSelectionCriteria.PURPOSE_TEST:
|
||||
// for now, the peers we test will be the reliable ones
|
||||
//_organizer.selectWellIntegratedPeers(criteria.getMinimumRequired(), exclude, curVals);
|
||||
_organizer.selectNotFailingPeers(criteria.getMinimumRequired(), exclude, peers);
|
||||
|
||||
// The PeerTestJob does only run every 5 minutes, but
|
||||
// this was helping drive us to connection limits, let's leave the exploration
|
||||
// to the ExploratoryPeerSelector, which will restrict to connected peers
|
||||
// when we get close to the limit. So let's stick with connected peers here.
|
||||
// Todo: what's the point of the PeerTestJob anyway?
|
||||
//_organizer.selectNotFailingPeers(criteria.getMinimumRequired(), exclude, peers);
|
||||
_organizer.selectActiveNotFailingPeers(criteria.getMinimumRequired(), exclude, peers);
|
||||
break;
|
||||
case PeerSelectionCriteria.PURPOSE_TUNNEL:
|
||||
// pull all of the fast ones, regardless of how many we
|
||||
|
@ -316,8 +316,8 @@ public class ProfileOrganizer {
|
||||
} finally { releaseReadLock(); }
|
||||
if (matches.size() < howMany) {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("selectHighCap("+howMany+"), not enough fast (" + matches.size() + ") going on to notFailing");
|
||||
selectNotFailingPeers(howMany, exclude, matches, mask);
|
||||
_log.info("selectHighCap("+howMany+"), not enough highcap (" + matches.size() + ") going on to ANFP2");
|
||||
selectActiveNotFailingPeers2(howMany, exclude, matches, mask);
|
||||
} else {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("selectHighCap("+howMany+"), found enough highCap (" + matches.size() + ")");
|
||||
@ -375,6 +375,7 @@ public class ProfileOrganizer {
|
||||
selectAllNotFailingPeers(howMany, exclude, matches, onlyNotFailing, mask);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a set of Hashes for peers that are both not failing and we're actively
|
||||
* talking with.
|
||||
@ -403,6 +404,39 @@ public class ProfileOrganizer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a set of Hashes for peers that are both not failing and we're actively
|
||||
* talking with.
|
||||
*
|
||||
* We use commSystem().isEstablished(), not profile.getIsActive(), as the
|
||||
* NTCP idle time is now shorter than the 5 minute getIsActive() threshold,
|
||||
* and we're using this to try and limit connections.
|
||||
*
|
||||
* This DOES cascade further to non-connected peers.
|
||||
*/
|
||||
private void selectActiveNotFailingPeers2(int howMany, Set exclude, Set matches, int mask) {
|
||||
if (matches.size() < howMany) {
|
||||
Map<Hash, PeerProfile> activePeers = new HashMap();
|
||||
getReadLock();
|
||||
try {
|
||||
for (Iterator<Map.Entry<Hash, PeerProfile>> iter = _notFailingPeers.entrySet().iterator(); iter.hasNext(); ) {
|
||||
Map.Entry<Hash, PeerProfile> e = iter.next();
|
||||
if (_context.commSystem().isEstablished(e.getKey()))
|
||||
activePeers.put(e.getKey(), e.getValue());
|
||||
}
|
||||
locked_selectPeers(activePeers, howMany, exclude, matches, mask);
|
||||
} finally { releaseReadLock(); }
|
||||
}
|
||||
if (matches.size() < howMany) {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("selectANFP2("+howMany+"), not enough ANFP (" + matches.size() + ") going on to notFailing");
|
||||
selectNotFailingPeers(howMany, exclude, matches, mask);
|
||||
} else {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("selectANFP2("+howMany+"), found enough ANFP (" + matches.size() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a set of Hashes for peers that are not failing.
|
||||
*
|
||||
@ -520,8 +554,8 @@ public class ProfileOrganizer {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Unreachable: " + l);
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Unreachable: " + l);
|
||||
return l;
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,8 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
||||
public boolean haveInboundCapacity() { return (_manager == null ? false : _manager.haveInboundCapacity()); }
|
||||
@Override
|
||||
public boolean haveOutboundCapacity() { return (_manager == null ? false : _manager.haveOutboundCapacity()); }
|
||||
@Override
|
||||
public boolean haveHighOutboundCapacity() { return (_manager == null ? false : _manager.haveHighOutboundCapacity()); }
|
||||
|
||||
/**
|
||||
* Framed average clock skew of connected peers in seconds, or null if we cannot answer.
|
||||
|
@ -47,6 +47,7 @@ public interface Transport {
|
||||
public int countActivePeers();
|
||||
public int countActiveSendPeers();
|
||||
public boolean haveCapacity();
|
||||
public boolean haveHighCapacity();
|
||||
public Vector getClockSkews();
|
||||
public List getMostRecentErrorMessages();
|
||||
|
||||
|
@ -215,6 +215,20 @@ public class TransportManager implements TransportEventListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Are all transports well below their outbound connection limit
|
||||
* Use for throttling in the router.
|
||||
*/
|
||||
public boolean haveHighOutboundCapacity() {
|
||||
if (_transports.size() <= 0)
|
||||
return false;
|
||||
for (int i = 0; i < _transports.size(); i++) {
|
||||
if (!((Transport)_transports.get(i)).haveHighCapacity())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is at least one transport below its inbound connection limit + some margin
|
||||
* Use for throttling in the router.
|
||||
|
@ -326,6 +326,10 @@ public class NTCPTransport extends TransportImpl {
|
||||
return countActivePeers() < getMaxConnections() * 4 / 5;
|
||||
}
|
||||
|
||||
public boolean haveHighCapacity() {
|
||||
return countActivePeers() < getMaxConnections() / 2;
|
||||
}
|
||||
|
||||
/** queue up afterSend call, which can take some time w/ jobs, etc */
|
||||
void sendComplete(OutNetMessage msg) { _finisher.add(msg); }
|
||||
|
||||
|
@ -1382,6 +1382,12 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
}
|
||||
}
|
||||
|
||||
public boolean haveHighCapacity() {
|
||||
synchronized (_peersByIdent) {
|
||||
return _peersByIdent.size() < getMaxConnections() / 2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return our peer clock skews on this transport.
|
||||
* Vector composed of Long, each element representing a peer skew in seconds.
|
||||
|
@ -47,7 +47,7 @@ class ExploratoryPeerSelector extends TunnelPeerSelector {
|
||||
//
|
||||
if (exploreHighCap)
|
||||
ctx.profileOrganizer().selectHighCapacityPeers(length, exclude, matches);
|
||||
else if (ctx.commSystem().haveOutboundCapacity())
|
||||
else if (ctx.commSystem().haveHighOutboundCapacity())
|
||||
ctx.profileOrganizer().selectNotFailingPeers(length, exclude, matches, false);
|
||||
else // use only connected peers so we don't make more connections
|
||||
ctx.profileOrganizer().selectActiveNotFailingPeers(length, exclude, matches);
|
||||
|
Reference in New Issue
Block a user