Changeset 3ba921ec


Ignore:
Timestamp:
Aug 30, 2005 1:59:11 AM (15 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
5f18cec
Parents:
e313da25
git-author:
jrandom <jrandom> (08/30/05 01:59:11)
git-committer:
zzz <zzz@…> (08/30/05 01:59:11)
Message:

2005-08-29 jrandom

  • Added the new test Floodfill netDb
Files:
8 added
24 edited

Legend:

Unmodified
Added
Removed
  • apps/syndie/java/src/net/i2p/syndie/sml/HTMLPreviewRenderer.java

    re313da25 r3ba921ec  
    104104        }
    105105
     106        if (_archives.size() > 0) {
     107            _postBodyBuffer.append("<b>Archives:</b>");
     108            for (int i = 0; i < _archives.size(); i++) {
     109                ArchiveRef a = (ArchiveRef)_archives.get(i);
     110                _postBodyBuffer.append(" <a href=\"").append(getArchiveURL(null, new SafeURL(a.locationSchema + "://" + a.location)));
     111                _postBodyBuffer.append("\">").append(sanitizeString(a.name)).append("</a>");
     112                if (a.description != null)
     113                    _postBodyBuffer.append(": ").append(sanitizeString(a.description));
     114            }
     115            _postBodyBuffer.append("<br />\n");
     116        }
     117
    106118        _postBodyBuffer.append("</td>\n</form>\n</tr>\n");
    107119        _postBodyBuffer.append("</table>\n");
  • apps/syndie/java/src/net/i2p/syndie/sml/HTMLRenderer.java

    re313da25 r3ba921ec  
    2727    protected List _links;
    2828    protected List _blogs;
     29    protected List _archives;
    2930    protected StringBuffer _preBodyBuffer;
    3031    protected StringBuffer _bodyBuffer;
     
    9495        _links = new ArrayList();
    9596        _blogs = new ArrayList();
     97        _archives = new ArrayList();
    9698        _cutBody = cutBody;
    9799        _showImages = showImages;
     
    262264     */
    263265    public void receiveBlog(String name, String hash, String tag, long entryId, List locations, String description) {
    264         if (!continueBody()) { return; }
    265         if (hash == null) return;
    266        
    267266        System.out.println("Receiving the blog: " + name + "/" + hash + "/" + tag + "/" + entryId +"/" + locations + ": "+ description);
    268267        byte blogData[] = Base64.decode(hash);
     
    279278            _blogs.add(b);
    280279   
     280        if (!continueBody()) { return; }
     281        if (hash == null) return;
     282       
    281283        Hash blog = new Hash(blogData);
    282284        if (entryId > 0) {
     
    320322    }
    321323   
     324    protected static class ArchiveRef {
     325        public String name;
     326        public String description;
     327        public String locationSchema;
     328        public String location;
     329        public int hashCode() { return -1; }
     330        public boolean equals(Object o) {
     331            ArchiveRef a = (ArchiveRef)o;
     332            return DataHelper.eq(name, a.name) && DataHelper.eq(description, a.description)
     333                   && DataHelper.eq(locationSchema, a.locationSchema)
     334                   && DataHelper.eq(location, a.location);
     335        }
     336    }
     337    public void receiveArchive(String name, String description, String locationSchema, String location,
     338                               String postingKey, String anchorText) {       
     339        ArchiveRef a = new ArchiveRef();
     340        a.name = name;
     341        a.description = description;
     342        a.locationSchema = locationSchema;
     343        a.location = location;
     344        if (!_archives.contains(a))
     345            _archives.add(a);
     346   
     347        if (!continueBody()) { return; }
     348       
     349        _bodyBuffer.append(sanitizeString(anchorText)).append(" [Archive ");
     350        if (name != null)
     351            _bodyBuffer.append(sanitizeString(name));
     352        if (location != null) {
     353            _bodyBuffer.append(" at ");
     354            SafeURL surl = new SafeURL(locationSchema + "://" + location);
     355            _bodyBuffer.append("<a href=\"").append(getArchiveURL(null, surl));
     356            _bodyBuffer.append("\">").append(sanitizeString(surl.toString())).append("</a>");
     357        }
     358        if (description != null)
     359            _bodyBuffer.append(": ").append(sanitizeString(description));
     360        _bodyBuffer.append("]");
     361    }
     362   
    322363    protected static class Link {
    323364        public String schema;
     
    414455            else if (addrs > 1)
    415456                _postBodyBuffer.append(addrs).append(" addresses ");
     457           
     458            int archives = _archives.size();
     459            if (archives == 1)
     460                _postBodyBuffer.append("1 archive ");
     461            else if (archives > 1)
     462                _postBodyBuffer.append(archives).append(" archives ");
    416463           
    417464            if (_entry != null) {
     
    491538
    492539            if (_addresses.size() > 0) {
    493                 _postBodyBuffer.append("<b>Addresses:</b> ");
     540                _postBodyBuffer.append("<b>Addresses:</b>");
    494541                for (int i = 0; i < _addresses.size(); i++) {
    495542                    Address a = (Address)_addresses.get(i);
    496                     _postBodyBuffer.append("<a href=\"addaddress.jsp?schema=");
     543                    _postBodyBuffer.append(" <a href=\"addaddress.jsp?schema=");
    497544                    _postBodyBuffer.append(sanitizeURL(a.schema)).append("&location=");
    498545                    _postBodyBuffer.append(sanitizeURL(a.location)).append("&name=");
     
    503550            }
    504551
    505            
     552            if (_archives.size() > 0) {
     553                _postBodyBuffer.append("<b>Archives:</b>");
     554                for (int i = 0; i < _archives.size(); i++) {
     555                    ArchiveRef a = (ArchiveRef)_archives.get(i);
     556                    _postBodyBuffer.append(" <a href=\"").append(getArchiveURL(null, new SafeURL(a.locationSchema + "://" + a.location)));
     557                    _postBodyBuffer.append("\">").append(sanitizeString(a.name)).append("</a>");
     558                    if (a.description != null)
     559                        _postBodyBuffer.append(": ").append(sanitizeString(a.description));
     560                }
     561                _postBodyBuffer.append("<br />\n");
     562            }
     563
    506564            if (_entry != null) {
    507565                List replies = _archive.getIndex().getReplies(_entry.getURI());
  • apps/syndie/java/src/net/i2p/syndie/sml/SMLParser.java

    re313da25 r3ba921ec  
    197197    private static final String T_PRE = "pre";
    198198    private static final String T_ATTACHMENT = "attachment";
     199    private static final String T_ARCHIVE = "archive";
    199200   
    200201    private static final String P_ATTACHMENT = "attachment";
     
    212213    private static final String P_ADDRESS_SCHEMA = "schema";
    213214    private static final String P_ATTACHMENT_ID = "id";
     215    private static final String P_ARCHIVE_NAME = "name";
     216    private static final String P_ARCHIVE_DESCRIPTION = "description";
     217    private static final String P_ARCHIVE_LOCATION_SCHEMA = "schema";
     218    private static final String P_ARCHIVE_LOCATION = "location";
     219    private static final String P_ARCHIVE_POSTING_KEY = "postingkey";
    214220   
    215221    private void parseTag(String tagName, Map attr, String body, EventReceiver receiver) {
     
    242248            receiver.receiveBlog(getString(P_BLOG_NAME, attr), getString(P_BLOG_HASH, attr), getString(P_BLOG_TAG, attr),
    243249                                 getLong(P_BLOG_ENTRY, attr), locations, body);
     250        } else if (T_ARCHIVE.equals(tagName)) {
     251            receiver.receiveArchive(getString(P_ARCHIVE_NAME, attr), getString(P_ARCHIVE_DESCRIPTION, attr),
     252                                    getString(P_ARCHIVE_LOCATION_SCHEMA, attr), getString(P_ARCHIVE_LOCATION, attr),
     253                                    getString(P_ARCHIVE_POSTING_KEY, attr), body);
    244254        } else if (T_LINK.equals(tagName)) {
    245255            receiver.receiveLink(getString(P_LINK_SCHEMA, attr), getString(P_LINK_LOCATION, attr), body);
  • apps/syndie/jsp/post.jsp

    re313da25 r3ba921ec  
    9898* [blog name="name" blogtag="tag"]description[/blog] = link to all posts in all blogs with the specified tag
    9999* [link schema="eep" location="http://forum.i2p"]text[/link] = offer a link to an external resource (accessible with the given schema)
     100* [archive name="name" description="they have good stuff" schema="eep" location="http://syndiemedia.i2p/archive/archive.txt"]foo![/archive] = offer an easy way to sync up with a new Syndie archive
    100101
    101102SML headers are newline delimited key=value pairs.  Example keys are:
  • core/java/src/net/i2p/data/RouterInfo.java

    re313da25 r3ba921ec  
    316316            return "";
    317317    }
     318   
     319    public void addCapability(char cap) {
     320        if (_options == null) _options = new OrderedProperties();
     321        synchronized (_options) {
     322            String caps = _options.getProperty(PROP_CAPABILITIES);
     323            if (caps == null)
     324                _options.setProperty(PROP_CAPABILITIES, ""+cap);
     325            else if (caps.indexOf(cap) == -1)
     326                _options.setProperty(PROP_CAPABILITIES, caps + cap);
     327        }
     328    }
    318329       
    319330    /**
  • history.txt

    re313da25 r3ba921ec  
    1 $Id: history.txt,v 1.230 2005/08/24 17:55:27 jrandom Exp $
     1$Id: history.txt,v 1.231 2005/08/27 17:15:38 jrandom Exp $
     2
     32005-08-29  jrandom
     4    * Added the new test Floodfill netDb
    25
    362005-08-27  jrandom
  • router/java/src/net/i2p/router/NetworkDatabaseFacade.java

    re313da25 r3ba921ec  
    6060   
    6161    public int getKnownRouters() { return 0; }
     62    public int getKnownLeaseSets() { return 0; }
    6263}
    6364
  • router/java/src/net/i2p/router/Router.java

    re313da25 r3ba921ec  
    3636import net.i2p.router.message.GarlicMessageHandler;
    3737//import net.i2p.router.message.TunnelMessageHandler;
     38import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
    3839import net.i2p.router.startup.StartupJob;
    3940import net.i2p.stat.Rate;
     
    292293            ri.setOptions(stats);
    293294            ri.setAddresses(_context.commSystem().createAddresses());
     295            if (FloodfillNetworkDatabaseFacade.floodfillEnabled(_context))
     296                ri.addCapability(FloodfillNetworkDatabaseFacade.CAPACITY_FLOODFILL);
    294297            SigningPrivateKey key = _context.keyManager().getSigningPrivateKey();
    295298            if (key == null) {
  • router/java/src/net/i2p/router/RouterContext.java

    re313da25 r3ba921ec  
    1010import net.i2p.router.client.ClientManagerFacadeImpl;
    1111import net.i2p.router.networkdb.kademlia.KademliaNetworkDatabaseFacade;
     12import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
    1213import net.i2p.router.peermanager.Calculator;
    1314import net.i2p.router.peermanager.CapacityCalculator;
     
    9899        _messageRegistry = new OutboundMessageRegistry(this);
    99100        _messageStateMonitor = new MessageStateMonitor(this);
    100         _netDb = new KademliaNetworkDatabaseFacade(this);
     101        _netDb = new FloodfillNetworkDatabaseFacade(this); // new KademliaNetworkDatabaseFacade(this);
    101102        _keyManager = new KeyManager(this);
    102103        if ("false".equals(getProperty("i2p.vmCommSystem", "false")))
  • router/java/src/net/i2p/router/RouterVersion.java

    re313da25 r3ba921ec  
    1616 */
    1717public class RouterVersion {
    18     public final static String ID = "$Revision: 1.219 $ $Date: 2005/08/24 17:55:26 $";
     18    public final static String ID = "$Revision: 1.220 $ $Date: 2005/08/27 17:15:38 $";
    1919    public final static String VERSION = "0.6.0.3";
    20     public final static long BUILD = 3;
     20    public final static long BUILD = 4;
    2121    public static void main(String args[]) {
    2222        System.out.println("I2P Router version: " + VERSION);
  • router/java/src/net/i2p/router/StatisticsManager.java

    re313da25 r3ba921ec  
    2020import net.i2p.stat.RateStat;
    2121import net.i2p.util.Log;
     22import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
    2223
    2324/**
     
    148149            stats.setProperty("stat_uptime", DataHelper.formatDuration(_context.router().getUptime()));
    149150            stats.setProperty("stat__rateKey", "avg;maxAvg;pctLifetime;[sat;satLim;maxSat;maxSatLim;][num;lifetimeFreq;maxFreq]");
     151           
     152            if (FloodfillNetworkDatabaseFacade.isFloodfill(_context.router().getRouterInfo())) {
     153                stats.setProperty("netdb.knownRouters", ""+_context.netDb().getKnownRouters());
     154                stats.setProperty("netdb.knownLeaseSets", ""+_context.netDb().getKnownLeaseSets());
     155            }
     156           
    150157            _log.debug("Publishing peer rankings");
    151158        } else {
  • router/java/src/net/i2p/router/networkdb/HandleDatabaseLookupMessageJob.java

    re313da25 r3ba921ec  
    6060    }
    6161   
     62    protected boolean answerAllQueries() { return false; }
     63   
    6264    public void runJob() {
    6365        if (_log.shouldLog(Log.DEBUG))
     
    7678            // only answer a request for a LeaseSet if it has been published
    7779            // to us, or, if its local, if we would have published to ourselves
    78             if (ls.getReceivedAsPublished()) {
     80            if (answerAllQueries() || ls.getReceivedAsPublished()) {
    7981                getContext().statManager().addRateData("netDb.lookupsMatchedReceivedPublished", 1, 0);
    8082                sendData(_message.getSearchKey(), ls, fromKey, _message.getReplyTunnel());
  • router/java/src/net/i2p/router/networkdb/PublishLocalRouterInfoJob.java

    re313da25 r3ba921ec  
    1818import net.i2p.router.RouterContext;
    1919import net.i2p.router.Router;
     20import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
    2021import net.i2p.util.Log;
    2122
     
    4546            ri.setOptions(stats);
    4647            ri.setAddresses(getContext().commSystem().createAddresses());
     48            if (FloodfillNetworkDatabaseFacade.floodfillEnabled(getContext()))
     49                ri.addCapability(FloodfillNetworkDatabaseFacade.CAPACITY_FLOODFILL);
    4750            SigningPrivateKey key = getContext().keyManager().getSigningPrivateKey();
    4851            if (key == null) {
  • router/java/src/net/i2p/router/networkdb/kademlia/DataPublisherJob.java

    re313da25 r3ba921ec  
    5656                }
    5757            }
    58             StoreJob store = new StoreJob(getContext(), _facade, key, data, null, null, STORE_TIMEOUT);
    59             getContext().jobQueue().addJob(store);
     58            _facade.sendStore(key, data, null, null, STORE_TIMEOUT, null);
     59            //StoreJob store = new StoreJob(getContext(), _facade, key, data, null, null, STORE_TIMEOUT);
     60            //getContext().jobQueue().addJob(store);
    6061        }
    6162        requeue(RERUN_DELAY_MS);
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    re313da25 r3ba921ec  
    4747 */
    4848public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
    49     private Log _log;
     49    protected Log _log;
    5050    private KBucketSet _kb; // peer hashes sorted into kbuckets, but within kbuckets, unsorted
    5151    private DataStore _ds; // hash to DataStructure mapping, persisted when necessary
     
    6363    /** when was the last time an exploration found something new? */
    6464    private long _lastExploreNew;
    65     private PeerSelector _peerSelector;
    66     private RouterContext _context;
     65    protected PeerSelector _peerSelector;
     66    protected RouterContext _context;
    6767    /**
    6868     * Map of Hash to RepublishLeaseSetJob for leases we'realready managing.
     
    9494    }
    9595   
    96 
    97    
    9896    /**
    9997     * for the 10 minutes after startup, don't fail db entries so that if we were
     
    124122    public KademliaNetworkDatabaseFacade(RouterContext context) {
    125123        _context = context;
    126         _log = _context.logManager().getLog(KademliaNetworkDatabaseFacade.class);
     124        _log = _context.logManager().getLog(getClass());
    127125        _initialized = false;
    128         _peerSelector = new PeerSelector(_context);
     126        _peerSelector = createPeerSelector();
    129127        _publishingLeaseSets = new HashMap(8);
    130128        _lastExploreNew = 0;
     
    132130        _enforceNetId = DEFAULT_ENFORCE_NETID;
    133131    }
     132   
     133    protected PeerSelector createPeerSelector() { return new PeerSelector(_context); }
     134    public PeerSelector getPeerSelector() { return _peerSelector; }
    134135   
    135136    KBucketSet getKBuckets() { return _kb; }
     
    267268        _dbDir = dbDir;
    268269       
    269         _context.inNetMessagePool().registerHandlerJobBuilder(DatabaseLookupMessage.MESSAGE_TYPE, new DatabaseLookupMessageHandler(_context));
    270         _context.inNetMessagePool().registerHandlerJobBuilder(DatabaseStoreMessage.MESSAGE_TYPE, new DatabaseStoreMessageHandler(_context));
     270        createHandlers();
    271271       
    272272        _initialized = true;
     
    308308    }
    309309   
     310    protected void createHandlers() {
     311        _context.inNetMessagePool().registerHandlerJobBuilder(DatabaseLookupMessage.MESSAGE_TYPE, new DatabaseLookupMessageHandler(_context));
     312        _context.inNetMessagePool().registerHandlerJobBuilder(DatabaseStoreMessage.MESSAGE_TYPE, new DatabaseStoreMessageHandler(_context));
     313    }
     314   
    310315    /**
    311316     * Get the routers closest to that key in response to a remote lookup
     
    360365   
    361366    public int getKnownRouters() {
     367        if (_kb == null) return 0;
    362368        CountRouters count = new CountRouters();
    363369        _kb.getAll(count);
     
    369375        public int size() { return _count; }
    370376        public void add(Hash entry) {
     377            if (_ds == null) return;
    371378            Object o = _ds.get(entry);
    372379            if (o instanceof RouterInfo)
     380                _count++;
     381        }
     382    }
     383   
     384    public int getKnownLeaseSets() { 
     385        if (_kb == null) return 0;
     386        CountLeaseSets count = new CountLeaseSets();
     387        _kb.getAll(count);
     388        return count.size();
     389    }
     390   
     391    private class CountLeaseSets implements SelectionCollector {
     392        private int _count;
     393        public int size() { return _count; }
     394        public void add(Hash entry) {
     395            if (_ds == null) return;
     396            Object o = _ds.get(entry);
     397            if (o instanceof LeaseSet)
    373398                _count++;
    374399        }
     
    820845        return 4 * (int)responseTime;  // give it up to 4x the average response time
    821846    }
     847
     848    public void sendStore(Hash key, DataStructure ds, Job onSuccess, Job onFailure, long sendTimeout, Set toIgnore) {
     849        _context.jobQueue().addJob(new StoreJob(_context, this, key, ds, onSuccess, onFailure, sendTimeout, toIgnore));
     850    }
    822851   
    823852    public void renderStatusHTML(Writer out) throws IOException {
  • router/java/src/net/i2p/router/networkdb/kademlia/PeerSelector.java

    re313da25 r3ba921ec  
    2828
    2929class PeerSelector {
    30     private Log _log;
    31     private RouterContext _context;
     30    protected Log _log;
     31    protected RouterContext _context;
    3232   
    3333    public PeerSelector(RouterContext ctx) {
    3434        _context = ctx;
    35         _log = _context.logManager().getLog(PeerSelector.class);
     35        _log = _context.logManager().getLog(getClass());
    3636    }
    3737   
  • router/java/src/net/i2p/router/networkdb/kademlia/RepublishLeaseSetJob.java

    re313da25 r3ba921ec  
    2323public class RepublishLeaseSetJob extends JobImpl {
    2424    private Log _log;
    25     private final static long REPUBLISH_LEASESET_DELAY = 3*60*1000; // 3 mins
     25    private final static long REPUBLISH_LEASESET_DELAY = 5*60*1000;
    2626    private final static long REPUBLISH_LEASESET_TIMEOUT = 60*1000;
    2727    private Hash _dest;
     
    4949                    } else {
    5050                        getContext().statManager().addRateData("netDb.republishLeaseSetCount", 1, 0);
    51                         getContext().jobQueue().addJob(new StoreJob(getContext(), _facade, _dest, ls, new OnSuccess(getContext()), new OnFailure(getContext()), REPUBLISH_LEASESET_TIMEOUT));
     51                        _facade.sendStore(_dest, ls, new OnSuccess(getContext()), new OnFailure(getContext()), REPUBLISH_LEASESET_TIMEOUT, null);
     52                        //getContext().jobQueue().addJob(new StoreJob(getContext(), _facade, _dest, ls, new OnSuccess(getContext()), new OnFailure(getContext()), REPUBLISH_LEASESET_TIMEOUT));
    5253                    }
    5354                } else {
     
    5556                        _log.warn("Client " + _dest + " is local, but we can't find a valid LeaseSet?  perhaps its being rebuilt?");
    5657                }
    57                 long republishDelay = getContext().random().nextLong(2*REPUBLISH_LEASESET_DELAY);
    58                 requeue(republishDelay);
     58                if (false) { // floodfill doesnt require republishing
     59                    long republishDelay = getContext().random().nextLong(2*REPUBLISH_LEASESET_DELAY);
     60                    requeue(republishDelay);
     61                }
    5962                return;
    6063            } else {
  • router/java/src/net/i2p/router/networkdb/kademlia/SearchJob.java

    re313da25 r3ba921ec  
    6262     *
    6363     */
    64     private static final int PER_PEER_TIMEOUT = 2*1000;
     64    private static final int PER_PEER_TIMEOUT = 5*1000;
    6565   
    6666    /**
     
    9797        _deferredSearches = new ArrayList(0);
    9898        _deferredCleared = false;
    99         _peerSelector = new PeerSelector(getContext());
     99        _peerSelector = facade.getPeerSelector();
    100100        _startedOn = -1;
    101101        _expiration = getContext().clock().now() + timeoutMs;
     
    134134     */
    135135    protected int getPerPeerTimeoutMs() {
     136        if (true)
     137            return PER_PEER_TIMEOUT;
    136138        int rv = -1;
    137139        RateStat rs = getContext().statManager().getRate("netDb.successTime");
     
    577579        private Hash _peer;
    578580        private boolean _penalizePeer;
     581        private long _sentOn;
    579582        public FailedJob(RouterContext enclosingContext, RouterInfo peer) {
    580583            this(enclosingContext, peer, true);
     
    589592            _penalizePeer = penalizePeer;
    590593            _peer = peer.getIdentity().getHash();
     594            _sentOn = enclosingContext.clock().now();
    591595        }
    592596        public void runJob() {
     597            if (_state.completed()) return;
    593598            _state.replyTimeout(_peer);
    594599            if (_penalizePeer) {
    595600                if (_log.shouldLog(Log.WARN))
    596                     _log.warn("Penalizing peer for timeout on search: " + _peer.toBase64());
     601                    _log.warn("Penalizing peer for timeout on search: " + _peer.toBase64() + " after " + (getContext().clock().now() - _sentOn));
    597602                getContext().profileManager().dbLookupFailed(_peer);
    598603            } else {
     
    658663                ds = _facade.lookupRouterInfoLocally(_state.getTarget());
    659664                if (ds != null)
    660                     getContext().jobQueue().addJob(new StoreJob(getContext(), _facade, _state.getTarget(),
    661                                                                 ds, null, null, RESEND_TIMEOUT,
    662                                                                 _state.getSuccessful()));
     665                    _facade.sendStore(_state.getTarget(), ds, null, null, RESEND_TIMEOUT, _state.getSuccessful());
    663666            }
    664667        } else {
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java

    re313da25 r3ba921ec  
    3333    private Log _log;
    3434    private KademliaNetworkDatabaseFacade _facade;
    35     private StoreState _state;
     35    protected StoreState _state;
    3636    private Job _onSuccess;
    3737    private Job _onFailure;
     
    8383        _timeoutMs = timeoutMs;
    8484        _expiration = context.clock().now() + timeoutMs;
    85         _peerSelector = new PeerSelector(context);
     85        _peerSelector = facade.getPeerSelector();
    8686    }
    8787
     
    113113        }
    114114    }
     115   
     116    protected int getParallelization() { return PARALLELIZATION; }
     117    protected int getRedundancy() { return REDUNDANCY; }
    115118
    116119    /**
     
    122125    private void continueSending() {
    123126        if (_state.completed()) return;
    124         int toCheck = PARALLELIZATION - _state.getPending().size();
     127        int toCheck = getParallelization() - _state.getPending().size();
    125128        if (toCheck <= 0) {
    126129            // too many already pending
     
    129132            return;
    130133        }
    131         if (toCheck > PARALLELIZATION)
    132             toCheck = PARALLELIZATION;
     134        if (toCheck > getParallelization())
     135            toCheck = getParallelization();
    133136
    134137        List closestHashes = getClosestRouters(_state.getTarget(), toCheck, _state.getAttempted());
     
    311314            getContext().statManager().addRateData("netDb.ackTime", howLong, howLong);
    312315
    313             if (_state.getCompleteCount() >= REDUNDANCY) {
     316            if (_state.getCompleteCount() >= getRedundancy()) {
    314317                succeed();
    315318            } else {
     
    353356     * Send was totally successful
    354357     */
    355     private void succeed() {
     358    protected void succeed() {
    356359        if (_log.shouldLog(Log.INFO))
    357360            _log.info(getJobId() + ": Succeeded sending key " + _state.getTarget());
     
    368371     * Send totally failed
    369372     */
    370     private void fail() {
     373    protected void fail() {
    371374        if (_log.shouldLog(Log.WARN))
    372375            _log.warn(getJobId() + ": Failed sending key " + _state.getTarget());
  • router/java/src/net/i2p/router/startup/CreateRouterInfoJob.java

    re313da25 r3ba921ec  
    2626import net.i2p.router.Router;
    2727import net.i2p.router.RouterContext;
     28import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
    2829import net.i2p.util.Log;
    2930
     
    5455            Properties stats = getContext().statPublisher().publishStatistics();
    5556            stats.setProperty(RouterInfo.PROP_NETWORK_ID, Router.NETWORK_ID+"");
     57            if (FloodfillNetworkDatabaseFacade.floodfillEnabled(getContext()))
     58                info.addCapability(FloodfillNetworkDatabaseFacade.CAPACITY_FLOODFILL);
    5659            info.setOptions(stats);
    5760            info.setPeers(new HashSet());
  • router/java/src/net/i2p/router/startup/RebuildRouterInfoJob.java

    re313da25 r3ba921ec  
    2626import net.i2p.router.Router;
    2727import net.i2p.router.RouterContext;
     28import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
    2829import net.i2p.util.Log;
    2930
     
    127128                stats.setProperty(RouterInfo.PROP_NETWORK_ID, ""+Router.NETWORK_ID);
    128129                info.setOptions(stats);
     130                if (FloodfillNetworkDatabaseFacade.floodfillEnabled(getContext()))
     131                    info.addCapability(FloodfillNetworkDatabaseFacade.CAPACITY_FLOODFILL);
    129132                // info.setPeers(new HashSet()); // this would have the trusted peers
    130133                info.setPublished(CreateRouterInfoJob.getCurrentPublishDate(getContext()));
  • router/java/src/net/i2p/router/tunnel/InboundMessageDistributor.java

    re313da25 r3ba921ec  
    55import net.i2p.data.Payload;
    66import net.i2p.data.i2np.DataMessage;
     7import net.i2p.data.i2np.DatabaseStoreMessage;
    78import net.i2p.data.i2np.DeliveryInstructions;
    89import net.i2p.data.i2np.I2NPMessage;
     
    110111                    return;
    111112                } else {
    112                     _context.inNetMessagePool().add(data, null, null);
     113                    if (data instanceof DatabaseStoreMessage) {
     114                        // treat db store explicitly, since we don't want to republish (or flood)
     115                        // unnecessarily
     116                        DatabaseStoreMessage dsm = (DatabaseStoreMessage)data;
     117                        if (dsm.getValueType() == DatabaseStoreMessage.KEY_TYPE_LEASESET)
     118                            _context.netDb().store(dsm.getKey(), dsm.getLeaseSet());
     119                        else
     120                            _context.netDb().store(dsm.getKey(), dsm.getRouterInfo());
     121                    } else {
     122                        _context.inNetMessagePool().add(data, null, null);
     123                    }
    113124                    return;
    114125                }
  • router/java/src/net/i2p/router/tunnel/TunnelCreatorConfig.java

    re313da25 r3ba921ec  
    8989        StringBuffer buf = new StringBuffer(128);
    9090        if (_isInbound)
    91             buf.append("inbound: ");
     91            buf.append("inbound");
    9292        else
    93             buf.append("outbound: ");
     93            buf.append("outbound");
     94        if (_destination == null)
     95            buf.append(" exploratory");
     96        buf.append(": ");
    9497        for (int i = 0; i < _peers.length; i++) {
    9598            buf.append(_peers[i].toBase64().substring(0,4));
  • router/java/src/net/i2p/router/tunnel/pool/ExploratoryPeerSelector.java

    re313da25 r3ba921ec  
    77import net.i2p.router.RouterContext;
    88import net.i2p.router.TunnelPoolSettings;
     9import net.i2p.util.Log;
    910
    1011/**
     
    1516class ExploratoryPeerSelector extends TunnelPeerSelector {
    1617    public List selectPeers(RouterContext ctx, TunnelPoolSettings settings) {
     18        Log l = ctx.logManager().getLog(getClass());
    1719        int length = getLength(ctx, settings);
    18         if (length < 0)
     20        if (length < 0) {
     21            if (l.shouldLog(Log.DEBUG))
     22                l.debug("Length requested is zero: " + settings);
    1923            return null;
     24        }
    2025       
    21         if (shouldSelectExplicit(settings))
    22             return selectExplicit(ctx, settings, length);
     26        if (shouldSelectExplicit(settings)) {
     27            List rv = selectExplicit(ctx, settings, length);
     28            if (l.shouldLog(Log.DEBUG))
     29                l.debug("Explicit peers selected: " + rv);
     30            return rv;
     31        }
    2332       
     33        HashSet exclude = new HashSet(1);
     34        exclude.add(ctx.routerHash());
    2435        HashSet matches = new HashSet(length);
    25         ctx.profileOrganizer().selectNotFailingPeers(length, null, matches, true);
     36        ctx.profileOrganizer().selectNotFailingPeers(length, exclude, matches, false);
     37       
     38        if (l.shouldLog(Log.DEBUG))
     39            l.debug("profileOrganizer.selectNotFailing(" + length + ") found " + matches);
    2640       
    2741        matches.remove(ctx.routerHash());
Note: See TracChangeset for help on using the changeset viewer.