Changeset df4143f


Ignore:
Timestamp:
Aug 25, 2009 1:12:24 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
95aba0c
Parents:
51fd4d7
Message:
  • NetDb?:
    • oops, store leaseset locally even when shutting down (fix -16)
    • Java 5 cleanups
  • PRNG:
    • Rename config option to prng.buffers (was router.prng.buffers)
    • Change the default from 16 to 2 for I2PAppContext (saves 3.5MB)
  • TunnelPool?:
    • Don't test tunnels when shutting down
    • Less rates
    • Java 5 cleanups
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • android/res/raw/router_config

    r51fd4d7 rdf4143f  
    44i2p.dir.pid=/data/data/net.i2p.router/files/tmp
    55# save memory
    6 router.prng.buffers=2
     6prng.buffers=2
    77router.decayingBloomFilterM=20
    88stat.full=false
  • core/java/src/gnu/crypto/prng/AsyncFortunaStandalone.java

    r51fd4d7 rdf4143f  
    1313 */
    1414public class AsyncFortunaStandalone extends FortunaStandalone implements Runnable {
    15     private static final int DEFAULT_BUFFERS = 16;
     15    /**
     16     * This is set to 2 to minimize memory usage for standalone apps.
     17     * The router must override this via the prng.buffers property in the router context.
     18     */
     19    private static final int DEFAULT_BUFFERS = 2;
    1620    private static final int BUFSIZE = 256*1024;
    1721    private int _bufferCount;
     
    2933    public AsyncFortunaStandalone(I2PAppContext context) {
    3034        super();
    31         _bufferCount = context.getProperty("router.prng.buffers", DEFAULT_BUFFERS);
     35        _bufferCount = Math.max(context.getProperty("prng.buffers", DEFAULT_BUFFERS), 2);
    3236        asyncBuffers = new byte[_bufferCount][BUFSIZE];
    3337        status = new int[_bufferCount];
  • core/java/src/net/i2p/client/I2PSessionImpl2.java

    r51fd4d7 rdf4143f  
    9292     *  and P2P apps (with generally uncompressible data) should
    9393     *  set to false.
     94     *
     95     *  Todo: don't compress if destination is local?
    9496     */
    9597    private static final int DONT_COMPRESS_SIZE = 66;
  • router/java/src/net/i2p/router/Router.java

    r51fd4d7 rdf4143f  
    331331       
    332332        // let the timestamper get us sync'ed
     333        // this will block for quite a while on a disconnected machine
    333334        long before = System.currentTimeMillis();
    334335        _context.clock().getTimestamper().waitForInitialization();
  • router/java/src/net/i2p/router/RouterContext.java

    r51fd4d7 rdf4143f  
    7676        _contexts.add(this);
    7777    }
    78     /**
     78
     79    /**
     80     * Set properties where the defaults must be different from those
     81     * in I2PAppContext.
     82     *
    7983     * Unless we are explicitly disabling the timestamper, we want to use it.
    8084     * We need this now as the new timestamper default is disabled (so we don't
    8185     * have each I2PAppContext creating their own SNTP queries all the time)
    8286     *
    83      */
    84     static final Properties filterProps(Properties envProps) {
     87     * Set more PRNG buffers, as the default is now small for the I2PAppContext.
     88     *
     89     */
     90    private static final Properties filterProps(Properties envProps) {
    8591        if (envProps == null)
    8692            envProps = new Properties();
    8793        if (envProps.getProperty("time.disabled") == null)
    8894            envProps.setProperty("time.disabled", "false");
     95        if (envProps.getProperty("prng.buffers") == null)
     96            envProps.setProperty("prng.buffers", "16");
    8997        return envProps;
    9098    }
     99
    91100    public void initAll() {
    92101        if ("false".equals(getProperty("i2p.dummyClientFacade", "false")))
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    r51fd4d7 rdf4143f  
    5757    /** where the data store is pushing the data */
    5858    private String _dbDir;
    59     private final Set _exploreKeys = new HashSet(64); // set of Hash objects that we should search on (to fill up a bucket, not to get data)
     59    private final Set<Hash> _exploreKeys = new HashSet(64); // set of Hash objects that we should search on (to fill up a bucket, not to get data)
    6060    private boolean _initialized;
    6161    /** Clock independent time of when we started up */
     
    7373     *
    7474     */
    75     private final Map _publishingLeaseSets;
     75    private final Map<Hash, RepublishLeaseSetJob> _publishingLeaseSets;
    7676   
    7777    /**
     
    8181     *
    8282     */
    83     private final Map _activeRequests;
     83    private final Map<Hash, SearchJob> _activeRequests;
    8484   
    8585    /**
     
    161161    }
    162162   
    163     public Set getExploreKeys() {
     163    public Set<Hash> getExploreKeys() {
    164164        if (!_initialized) return null;
    165165        synchronized (_exploreKeys) {
     
    303303     * Get the routers closest to that key in response to a remote lookup
    304304     */
    305     public Set findNearestRouters(Hash key, int maxNumRouters, Set peersToIgnore) {
     305    public Set<RouterInfo> findNearestRouters(Hash key, int maxNumRouters, Set peersToIgnore) {
    306306        if (!_initialized) return null;
    307307        return getRouters(_peerSelector.selectNearest(key, maxNumRouters, peersToIgnore, _kb));
    308308    }
    309309   
    310     private Set getRouters(Collection hashes) {
     310    private Set<RouterInfo> getRouters(Collection hashes) {
    311311        if (!_initialized) return null;
    312312        Set rv = new HashSet(hashes.size());
     
    482482    public void publish(LeaseSet localLeaseSet) {
    483483        if (!_initialized) return;
    484         if (_context.router().gracefulShutdownInProgress())
    485             return;
    486484        Hash h = localLeaseSet.getDestination().calculateHash();
    487485        try {
     
    492490        }
    493491        if (!_context.clientManager().shouldPublishLeaseSet(h))
     492            return;
     493        if (_context.router().gracefulShutdownInProgress())
    494494            return;
    495495       
     
    856856        return leases;
    857857    }
    858     private Set getRouters() {
     858    private Set<RouterInfo> getRouters() {
    859859        if (!_initialized) return null;
    860860        Set routers = new HashSet();
  • router/java/src/net/i2p/router/tunnel/pool/TestJob.java

    r51fd4d7 rdf4143f  
    3232    /** base to randomize the test delay on */
    3333    private static final int TEST_DELAY = 30*1000;
     34    private static final long[] RATES = { 60*1000, 10*60*1000l, 60*60*1000l };
    3435   
    3536    public TestJob(RouterContext ctx, PooledTunnelCreatorConfig cfg, TunnelPool pool) {
     
    4445        getTiming().setStartAfter(getDelay() + ctx.clock().now());
    4546        ctx.statManager().createRateStat("tunnel.testFailedTime", "How long did the failure take (max of 60s for full timeout)?", "Tunnels",
    46                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     47                                         RATES);
    4748        ctx.statManager().createRateStat("tunnel.testExploratoryFailedTime", "How long did the failure of an exploratory tunnel take (max of 60s for full timeout)?", "Tunnels",
    48                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     49                                         RATES);
    4950        ctx.statManager().createRateStat("tunnel.testFailedCompletelyTime", "How long did the complete failure take (max of 60s for full timeout)?", "Tunnels",
    50                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     51                                         RATES);
    5152        ctx.statManager().createRateStat("tunnel.testExploratoryFailedCompletelyTime", "How long did the complete failure of an exploratory tunnel take (max of 60s for full timeout)?", "Tunnels",
    52                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     53                                         RATES);
    5354        ctx.statManager().createRateStat("tunnel.testSuccessLength", "How long were the tunnels that passed the test?", "Tunnels",
    54                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     55                                         RATES);
    5556        ctx.statManager().createRateStat("tunnel.testSuccessTime", "How long did tunnel testing take?", "Tunnels",
    56                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     57                                         RATES);
    5758        ctx.statManager().createRateStat("tunnel.testAborted", "Tunnel test could not occur, since there weren't any tunnels to test with", "Tunnels",
    58                                          new long[] { 60*1000, 10*60*1000l, 60*60*1000l, 3*60*60*1000l, 24*60*60*1000l });
     59                                         RATES);
    5960    }
    6061    public String getName() { return "Test tunnel"; }
     
    7071            return;
    7172        }
     73        if (getContext().router().gracefulShutdownInProgress())
     74            return;   // don't reschedule
    7275        _found = false;
    7376        // note: testing with exploratory tunnels always, even if the tested tunnel
  • router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java

    r51fd4d7 rdf4143f  
    3838    private Log _log;
    3939    /** Hash (destination) to TunnelPool */
    40     private final Map _clientInboundPools;
     40    private final Map<Hash, TunnelPool> _clientInboundPools;
    4141    /** Hash (destination) to TunnelPool */
    42     private final Map _clientOutboundPools;
     42    private final Map<Hash, TunnelPool> _clientOutboundPools;
    4343    private TunnelPool _inboundExploratory;
    4444    private TunnelPool _outboundExploratory;
     
    9191        TunnelPool pool = null;
    9292        synchronized (_clientInboundPools) {
    93             pool = (TunnelPool)_clientInboundPools.get(destination);
     93            pool = _clientInboundPools.get(destination);
    9494        }
    9595        if (pool != null) {
     
    120120        TunnelPool pool = null;
    121121        synchronized (_clientOutboundPools) {
    122             pool = (TunnelPool)_clientOutboundPools.get(destination);
     122            pool = _clientOutboundPools.get(destination);
    123123        }
    124124        if (pool != null) {
     
    131131        TunnelInfo info = null;
    132132        synchronized (_clientInboundPools) {
    133             for (Iterator iter = _clientInboundPools.values().iterator(); iter.hasNext(); ) {
    134                 TunnelPool pool = (TunnelPool)iter.next();
     133            for (Iterator<TunnelPool> iter = _clientInboundPools.values().iterator(); iter.hasNext(); ) {
     134                TunnelPool pool = iter.next();
    135135                info = pool.getTunnel(id);
    136136                if (info != null)
     
    167167            TunnelPool pool = null;
    168168            synchronized (_clientInboundPools) {
    169                 pool = (TunnelPool)_clientInboundPools.get(client);
     169                pool = _clientInboundPools.get(client);
    170170            }
    171171            count += pool.listTunnels().size();
     
    183183            TunnelPool pool = null;
    184184            synchronized (_clientOutboundPools) {
    185                 pool = (TunnelPool)_clientOutboundPools.get(client);
     185                pool = _clientOutboundPools.get(client);
    186186            }
    187187            count += pool.listTunnels().size();
     
    197197        TunnelPool pool;
    198198        if (tunnel.isInbound())
    199             pool = (TunnelPool)_clientInboundPools.get(client);
     199            pool = _clientInboundPools.get(client);
    200200        else
    201             pool = (TunnelPool)_clientOutboundPools.get(client);
     201            pool = _clientOutboundPools.get(client);
    202202        if (pool == null)
    203203            return false;
     
    212212        TunnelPool pool = null;
    213213        synchronized (_clientInboundPools) {
    214             pool = (TunnelPool)_clientInboundPools.get(client);
     214            pool = _clientInboundPools.get(client);
    215215        }
    216216        if (pool != null)
     
    222222        TunnelPool pool = null;
    223223        synchronized (_clientOutboundPools) {
    224             pool = (TunnelPool)_clientOutboundPools.get(client);
     224            pool = _clientOutboundPools.get(client);
    225225        }
    226226        if (pool != null)
     
    235235        setSettings(_clientOutboundPools, client, settings);
    236236    }
    237     private void setSettings(Map pools, Hash client, TunnelPoolSettings settings) {
     237    private void setSettings(Map<Hash, TunnelPool> pools, Hash client, TunnelPoolSettings settings) {
    238238        TunnelPool pool = null;
    239239        synchronized (pools) {
    240             pool = (TunnelPool)pools.get(client);
     240            pool = pools.get(client);
    241241        }
    242242        if (pool != null) {
     
    261261        // should we share the clientPeerSelector across both inbound and outbound?
    262262        synchronized (_clientInboundPools) {
    263             inbound = (TunnelPool)_clientInboundPools.get(dest);
     263            inbound = _clientInboundPools.get(dest);
    264264            if (inbound == null) {
    265265                inbound = new TunnelPool(_context, this, settings.getInboundSettings(),
     
    271271        }
    272272        synchronized (_clientOutboundPools) {
    273             outbound = (TunnelPool)_clientOutboundPools.get(dest);
     273            outbound = _clientOutboundPools.get(dest);
    274274            if (outbound == null) {
    275275                outbound = new TunnelPool(_context, this, settings.getOutboundSettings(),
     
    295295        TunnelPool outbound = null;
    296296        synchronized (_clientInboundPools) {
    297             inbound = (TunnelPool)_clientInboundPools.remove(destination);
     297            inbound = _clientInboundPools.remove(destination);
    298298        }
    299299        synchronized (_clientOutboundPools) {
    300             outbound = (TunnelPool)_clientOutboundPools.remove(destination);
     300            outbound = _clientOutboundPools.remove(destination);
    301301        }
    302302        if (inbound != null)
     
    306306    }
    307307   
     308    /** queue a recurring test job if appropriate */
    308309    void buildComplete(PooledTunnelCreatorConfig cfg) {
    309         buildComplete();
    310         if (cfg.getLength() > 1) {
     310        //buildComplete();
     311        if (cfg.getLength() > 1 &&
     312            !_context.router().gracefulShutdownInProgress()) {
    311313            TunnelPool pool = cfg.getTunnelPool();
    312314            if (pool == null) {
     315                // never seen this before, do we reallly need to bother
     316                // trying so hard to find his pool?
    313317                _log.error("How does this not have a pool?  " + cfg, new Exception("baf"));
    314318                if (cfg.getDestination() != null) {
    315319                    if (cfg.isInbound()) {
    316320                        synchronized (_clientInboundPools) {
    317                             pool = (TunnelPool)_clientInboundPools.get(cfg.getDestination());
     321                            pool = _clientInboundPools.get(cfg.getDestination());
    318322                        }
    319323                    } else {
    320324                        synchronized (_clientOutboundPools) {
    321                             pool = (TunnelPool)_clientOutboundPools.get(cfg.getDestination());
     325                            pool = _clientOutboundPools.get(cfg.getDestination());
    322326                        }
    323327                    }
     
    334338        }
    335339    }
     340
     341    /** ?? */
    336342    void buildComplete() {}
    337343   
     
    385391   
    386392    /** list of TunnelPool instances currently in play */
    387     void listPools(List out) {
     393    void listPools(List<TunnelPool> out) {
    388394        synchronized (_clientInboundPools) {
    389395            out.addAll(_clientInboundPools.values());
     
    408414        renderPool(out, _inboundExploratory, _outboundExploratory);
    409415       
    410         List destinations = null;
     416        List<Hash> destinations = null;
    411417        synchronized (_clientInboundPools) {
    412418            destinations = new ArrayList(_clientInboundPools.keySet());
    413419        }
    414420        for (int i = 0; i < destinations.size(); i++) {
    415             Hash client = (Hash)destinations.get(i);
     421            Hash client = destinations.get(i);
    416422            TunnelPool in = null;
    417423            TunnelPool outPool = null;
    418424            synchronized (_clientInboundPools) {
    419                 in = (TunnelPool)_clientInboundPools.get(client);
     425                in = _clientInboundPools.get(client);
    420426            }
    421427            synchronized (_clientOutboundPools) {
    422                 outPool = (TunnelPool)_clientOutboundPools.get(client);
     428                outPool = _clientOutboundPools.get(client);
    423429            }
    424430            String name = (in != null ? in.getSettings().getDestinationNickname() : null);
     
    506512
    507513    private void renderPool(Writer out, TunnelPool in, TunnelPool outPool) throws IOException {
    508         List tunnels = null;
     514        List<TunnelInfo> tunnels = null;
    509515        if (in == null)
    510516            tunnels = new ArrayList();
     
    520526        int maxLength = 1;
    521527        for (int i = 0; i < tunnels.size(); i++) {
    522             TunnelInfo info = (TunnelInfo)tunnels.get(i);
     528            TunnelInfo info = tunnels.get(i);
    523529            if (info.getLength() > maxLength)
    524530                maxLength = info.getLength();
     
    537543        out.write("</tr>\n");
    538544        for (int i = 0; i < tunnels.size(); i++) {
    539             TunnelInfo info = (TunnelInfo)tunnels.get(i);
     545            TunnelInfo info = tunnels.get(i);
    540546            long timeLeft = info.getExpiration()-_context.clock().now();
    541547            if (timeLeft <= 0)
Note: See TracChangeset for help on using the changeset viewer.