Changeset 8da1e90


Ignore:
Timestamp:
Jan 19, 2011 4:40:48 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
653abbcc
Parents:
0d52399
Message:
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/I2PAppContext.java

    r0d52399 r8da1e90  
    777777     *
    778778     */
    779     public Clock clock() { // overridden in RouterContext
     779    public Clock clock() {
    780780        if (!_clockInitialized)
    781781            initializeClock();
  • router/java/src/net/i2p/router/RouterContext.java

    r0d52399 r8da1e90  
    1010import net.i2p.router.client.ClientManagerFacadeImpl;
    1111import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
    12 import net.i2p.router.peermanager.Calculator;
    13 import net.i2p.router.peermanager.CapacityCalculator;
    14 import net.i2p.router.peermanager.IntegrationCalculator;
    1512import net.i2p.router.peermanager.PeerManagerFacadeImpl;
    1613import net.i2p.router.peermanager.ProfileManagerImpl;
    1714import net.i2p.router.peermanager.ProfileOrganizer;
    18 import net.i2p.router.peermanager.SpeedCalculator;
    1915import net.i2p.router.transport.CommSystemFacadeImpl;
    2016import net.i2p.router.transport.FIFOBandwidthLimiter;
     
    5854    private MessageStateMonitor _messageStateMonitor;
    5955    private RouterThrottle _throttle;
    60     private RouterClock _clockX;  // LINT field hides another field, hope rename won't break anything.
    61     private Calculator _integrationCalc;
    62     private Calculator _speedCalc;
    63     private Calculator _capacityCalc;
    64 
    6556
    6657    private static List<RouterContext> _contexts = new ArrayList(1);
     
    148139        _throttle = new RouterThrottleImpl(this);
    149140        //_throttle = new RouterDoSThrottle(this);
    150         _integrationCalc = new IntegrationCalculator(this);
    151         _speedCalc = new SpeedCalculator(this);
    152         _capacityCalc = new CapacityCalculator(this);
    153141    }
    154142   
     
    271259     */
    272260    public RouterThrottle throttle() { return _throttle; }
    273    
    274     /** how do we rank the integration of profiles? */
    275     public Calculator integrationCalculator() { return _integrationCalc; }
    276     /** how do we rank the speed of profiles? */
    277     public Calculator speedCalculator() { return _speedCalc; }
    278     /** how do we rank the capacity of profiles? */
    279     public Calculator capacityCalculator() { return _capacityCalc; }
    280261   
    281262    @Override
     
    302283        buf.append(_shitlist).append('\n');
    303284        buf.append(_messageValidator).append('\n');
    304         buf.append(_integrationCalc).append('\n');
    305         buf.append(_speedCalc).append('\n');
    306285        return buf.toString();
    307286    }
     
    364343    }
    365344   
    366     /**
    367      * The context's synchronized clock, which is kept context specific only to
    368      * enable simulators to play with clock skew among different instances.
    369      *
    370      * It wouldn't be necessary to override clock(), except for the reason
    371      * that it triggers initializeClock() of which we definitely
    372      * need the local version to run.
    373      */
    374     @Override
    375     public Clock clock() {
    376         if (!_clockInitialized) initializeClock();
    377         return _clockX;
    378     }
    379345    @Override
    380346    protected void initializeClock() {
    381347        synchronized (this) {
    382             if (_clockX == null)
    383                 _clockX = new RouterClock(this);
     348            if (_clock == null)
     349                _clock = new RouterClock(this);
    384350            _clockInitialized = true;
    385351        }
  • router/java/src/net/i2p/router/peermanager/CapacityCalculator.java

    r0d52399 r8da1e90  
    11package net.i2p.router.peermanager;
    22
    3 import net.i2p.router.RouterContext;
     3import net.i2p.I2PAppContext;
    44import net.i2p.stat.Rate;
    55import net.i2p.stat.RateStat;
    6 import net.i2p.util.Log;
    76
    87/**
    98 * Estimate how many of our tunnels the peer can join per hour.
    109 */
    11 public class CapacityCalculator extends Calculator {
    12     private Log _log;
    13     private RouterContext _context;
    14    
    15     public CapacityCalculator(RouterContext context) {
    16         _context = context;
    17         _log = context.logManager().getLog(CapacityCalculator.class);
    18     }
     10class CapacityCalculator {
     11    private static final I2PAppContext _context = I2PAppContext.getGlobalContext();
    1912   
    2013    /** used to adjust each period so that we keep trying to expand the peer's capacity */
     
    2417    private static long ESTIMATE_PERIOD = 60*60*1000;
    2518   
    26     @Override
    27     public double calc(PeerProfile profile) {
     19    public static double calc(PeerProfile profile) {
    2820        double capacity;
    2921
  • router/java/src/net/i2p/router/peermanager/IntegrationCalculator.java

    r0d52399 r8da1e90  
    11package net.i2p.router.peermanager;
    2 
    3 import net.i2p.router.RouterContext;
    4 import net.i2p.util.Log;
    52
    63/**
     
    96 *
    107 */
    11 public class IntegrationCalculator extends Calculator {
    12     private Log _log;
    13     private RouterContext _context;
     8class IntegrationCalculator {
    149   
    15     public IntegrationCalculator(RouterContext context) {
    16         _context = context;
    17         _log = context.logManager().getLog(IntegrationCalculator.class);
    18     }
    19    
    20     @Override
    21     public double calc(PeerProfile profile) {
     10    public static double calc(PeerProfile profile) {
    2211        long val = 0;
    2312        if (profile.getIsExpandedDB()) {
  • router/java/src/net/i2p/router/peermanager/PeerProfile.java

    r0d52399 r8da1e90  
    2525
    2626public class PeerProfile {
    27     private Log _log;
    28     private RouterContext _context;
     27    private final Log _log;
     28    private final RouterContext _context;
    2929    // whoozaat?
    30     private Hash _peer;
     30    private final Hash _peer;
    3131    // general peer stats
    3232    private long _firstHeardAbout;
     
    6666        _context = context;
    6767        _log = context.logManager().getLog(PeerProfile.class);
    68         _expanded = false;
    69         _speedValue = 0;
    70         _capacityValue = 0;
    71         _integrationValue = 0;
    72         _isFailing = false;
    73         _consecutiveShitlists = 0;
    74         _tunnelTestResponseTimeAvg = 0.0d;
    7568        _peer = peer;
    7669        // this is always true, and there are several places in the router that will NPE
     
    8275    /** what peer is being profiled */
    8376    public Hash getPeer() { return _peer; }
    84     public void setPeer(Hash peer) { _peer = peer; }
    8577   
    8678    /**
     
    475467    }
    476468   
    477     private double calculateSpeed() { return _context.speedCalculator().calc(this); }
    478     private double calculateCapacity() { return _context.capacityCalculator().calc(this); }
    479     private double calculateIntegration() { return _context.integrationCalculator().calc(this); }
     469    private double calculateSpeed() { return SpeedCalculator.calc(this); }
     470    private double calculateCapacity() { return CapacityCalculator.calc(this); }
     471    private double calculateIntegration() { return IntegrationCalculator.calc(this); }
    480472    /** deprecated - unused - always false */
    481473    private boolean calculateIsFailing() { return false; }
  • router/java/src/net/i2p/router/peermanager/SpeedCalculator.java

    r0d52399 r8da1e90  
    11package net.i2p.router.peermanager;
    2 
    3 import net.i2p.router.RouterContext;
    42
    53/**
     
    1412 *
    1513 */
    16 public class SpeedCalculator extends Calculator {
     14class SpeedCalculator {
    1715   
    18     public SpeedCalculator(RouterContext context) {
    19     }
    20    
    21     @Override
    22     public double calc(PeerProfile profile) {
     16    public static double calc(PeerProfile profile) {
    2317        // measures 1 minute throughput of individual tunnels
    2418        double d = (profile.getPeakTunnel1mThroughputKBps()*1024d) + profile.getSpeedBonus();
Note: See TracChangeset for help on using the changeset viewer.