Changeset e028450


Ignore:
Timestamp:
Nov 10, 2009 1:24:39 AM (10 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
ee51f69
Parents:
2dc37981
Message:
  • Netdb StoreJob?, FloodfillVerifyStoreJob?:
    • Fix bug where reply selector wasn't registered for routerinfo stores, so we didn't get stats, and we kept retrying. This also prevented verification and profile updates for routerinfo stores. This bug was introduced 4 years ago by the change to store routerinfos directly.
    • Add dbStoreSuccessful() to profile, and have FVSJ call it or dbStoreFailed() as appropriate to give credit or blame to the floodfill we stored to.
    • Don't let FVSJ verify using the peer we stored to
Location:
router/java/src/net/i2p/router
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/ProfileManager.java

    r2dc37981 re028450  
    138138   
    139139    /**
     140     * Note that we confirmed a successful send of db data to
     141     * the peer.
     142     *
     143     */
     144    void dbStoreSuccessful(Hash peer);
     145
     146    /**
    140147     * Note that we were unable to confirm a successful send of db data to
    141148     * the peer, at least not within our timeout period
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillStoreJob.java

    r2dc37981 re028450  
    99 */
    1010
     11import java.util.Iterator;
     12import java.util.NoSuchElementException;
    1113import java.util.Set;
    1214
     
    5658            // it finds something stamped with that time or newer.
    5759            long published = 0;
    58             boolean isRouterInfo = false;
    5960            DataStructure data = _state.getData();
    60             if (data instanceof RouterInfo) {
     61            boolean isRouterInfo = data instanceof RouterInfo;
     62            if (isRouterInfo) {
    6163                published = ((RouterInfo) data).getPublished();
    62                 isRouterInfo = true;
    6364            } else if (data instanceof LeaseSet) {
    6465                published = ((LeaseSet) data).getEarliestLeaseDate();
    6566            }
     67            // we should always have exactly one successful entry
     68            Hash sentTo = null;
     69            try {
     70                sentTo = _state.getSuccessful().iterator().next();
     71            } catch (NoSuchElementException nsee) {}
    6672            getContext().jobQueue().addJob(new FloodfillVerifyStoreJob(getContext(), _state.getTarget(),
    67                                                                        published, isRouterInfo, _facade));
     73                                                                       published, isRouterInfo, sentTo, _facade));
    6874        }
    6975    }
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillVerifyStoreJob.java

    r2dc37981 re028450  
    2727    private Hash _key;
    2828    private Hash _target;
     29    private Hash _sentTo;
    2930    private FloodfillNetworkDatabaseFacade _facade;
    3031    private long _expiration;
     
    3536    private static final int VERIFY_TIMEOUT = 10*1000;
    3637   
    37     public FloodfillVerifyStoreJob(RouterContext ctx, Hash key, long published, boolean isRouterInfo, FloodfillNetworkDatabaseFacade facade) {
     38    /**
     39     *  @param sentTo who to give the credit or blame to, can be null
     40     */
     41    public FloodfillVerifyStoreJob(RouterContext ctx, Hash key, long published, boolean isRouterInfo, Hash sentTo, FloodfillNetworkDatabaseFacade facade) {
    3842        super(ctx);
    3943        _key = key;
     
    4145        _isRouterInfo = isRouterInfo;
    4246        _log = ctx.logManager().getLog(getClass());
     47        _sentTo = sentTo;
    4348        _facade = facade;
    4449        // wait 10 seconds before trying to verify the store
     
    7176        }
    7277       
     78        if (_log.shouldLog(Log.INFO))
     79            _log.info("Starting verify (stored " + _key + " to " + _sentTo + "), asking " + _target);
    7380        _sendTime = getContext().clock().now();
    7481        _expiration = _sendTime + VERIFY_TIMEOUT;
     
    7784    }
    7885   
     86    /** todo pick one close to the key */
    7987    private Hash pickTarget() {
    8088        FloodfillPeerSelector sel = (FloodfillPeerSelector)_facade.getPeerSelector();
    81         List peers = sel.selectFloodfillParticipants(_facade.getKBuckets());
     89        List<Hash> peers = sel.selectFloodfillParticipants(_facade.getKBuckets());
    8290        Collections.shuffle(peers, getContext().random());
    83         if (peers.size() > 0)
    84             return (Hash)peers.get(0);
     91        for (int i = 0; i < peers.size(); i++) {
     92            Hash rv = peers.get(i);
     93            if (!rv.equals(_sentTo))
     94                return rv;
     95        }
    8596       
    8697        if (_log.shouldLog(Log.WARN))
    87             _log.warn("No peers to verify floodfill with");
    88         return null;
     98            _log.warn("No other peers to verify floodfill with, using the one we sent to");
     99        return _sentTo;
    89100    }
    90101   
     
    141152                    // store ok, w00t!
    142153                    getContext().profileManager().dbLookupSuccessful(_target, delay);
     154                    if (_sentTo != null)
     155                        getContext().profileManager().dbStoreSuccessful(_sentTo);
    143156                    getContext().statManager().addRateData("netDb.floodfillVerifyOK", delay, 0);
     157                    if (_log.shouldLog(Log.INFO))
     158                        _log.info("Verify success");
    144159                    return;
    145160                }
     
    150165                getContext().profileManager().dbLookupReply(_target,  0,
    151166                                ((DatabaseSearchReplyMessage)_message).getNumReplies(), 0, 0, delay);
     167                if (_log.shouldLog(Log.WARN))
     168                    _log.warn("Verify failed - DSRM");
    152169            }
    153170            // store failed, boo, hiss!
     171            if (_sentTo != null)
     172                getContext().profileManager().dbStoreFailed(_sentTo);
    154173            getContext().statManager().addRateData("netDb.floodfillVerifyFail", delay, 0);
    155174            resend();
     
    174193        public String getName() { return "Floodfill verification timeout"; }
    175194        public void runJob() {
     195            // don't know who to blame (we could have gotten a DSRM) so blame both
    176196            getContext().profileManager().dbLookupFailed(_target);
     197            if (_sentTo != null)
     198                getContext().profileManager().dbStoreFailed(_sentTo);
    177199            getContext().statManager().addRateData("netDb.floodfillVerifyTimeout", getContext().clock().now() - _sendTime, 0);
    178200            resend();
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java

    r2dc37981 re028450  
    270270        } else {
    271271            getContext().statManager().addRateData("netDb.storeRouterInfoSent", 1, 0);
     272            // todo - shorter expiration for direct?
    272273            sendDirect(msg, peer, expiration);
    273274        }
     
    299300        m.setReplySelector(selector);
    300301        m.setTarget(peer);
     302        getContext().messageRegistry().registerPending(m);
    301303        getContext().commSystem().processMessage(m);
    302304    }
     
    325327            //    _log.debug(getJobId() + ": Sending tunnel message out " + outTunnelId + " to "
    326328            //               + peer.getIdentity().getHash().toBase64());
    327             TunnelId targetTunnelId = null; // not needed
    328             Job onSend = null; // not wanted
     329            //TunnelId targetTunnelId = null; // not needed
     330            //Job onSend = null; // not wanted
    329331       
    330332            SendSuccessJob onReply = new SendSuccessJob(getContext(), peer, outTunnel, msg.getMessageSize());
     
    427429            sendNext();
    428430        }
    429         public String getName() { return "Kademlia Store Peer Failed"; }
     431        public String getName() { return "Kademlia Store Send Failed"; }
    430432    }
    431433
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreState.java

    r2dc37981 re028450  
    1212import net.i2p.router.RouterContext;
    1313
     14/**
     15 *  Todo: remove exploratory
     16 */
    1417class StoreState {
    1518    private RouterContext _context;
     
    6467        }
    6568    }
     69    /** @deprecated unused */
    6670    public Set<Hash> getSuccessfulExploratory() {
    6771        synchronized (_successfulExploratoryPeers) {
     
    125129    }
    126130
     131    /** @deprecated unused */
    127132    public long confirmedExploratory(Hash peer) {
    128133        long rv = -1;
  • router/java/src/net/i2p/router/peermanager/ProfileManagerImpl.java

    r2dc37981 re028450  
    9090     * Note that a router explicitly rejected joining a tunnel. 
    9191     *
     92     * @param responseTimeMs ignored
    9293     * @param severity how much the peer doesnt want to participate in the
    9394     *                 tunnel (large == more severe)
     
    250251     * necessarily requested it again from them, so they /might/ be lying)
    251252     *
    252      * This will force creation of DB stats
     253     * This is not really interesting, since they could be lying, so we do not
     254     * increment any DB stats at all. On verify, call dbStoreSuccessful().
     255     *
     256     * @param responseTimeMs ignored
    253257     */
    254258    public void dbStoreSent(Hash peer, long responseTimeMs) {
     
    258262        data.setLastHeardFrom(now);
    259263        data.setLastSendSuccessful(now);
     264        //if (!data.getIsExpandedDB())
     265        //    data.expandDBProfile();
     266        //DBHistory hist = data.getDBHistory();
     267        //hist.storeSuccessful();
     268    }
     269   
     270    /**
     271     * Note that we've verified a successful send of db data to the floodfill peer
     272     * by querying another floodfill.
     273     *
     274     * This will force creation of DB stats
     275     */
     276    public void dbStoreSuccessful(Hash peer) {
     277        PeerProfile data = getProfile(peer);
     278        if (data == null) return;
     279        long now = _context.clock().now();
     280        data.setLastHeardFrom(now);
     281        data.setLastSendSuccessful(now);
    260282        if (!data.getIsExpandedDB())
    261283            data.expandDBProfile();
    262284        DBHistory hist = data.getDBHistory();
    263285        hist.storeSuccessful();
    264         // we could do things like update some sort of "how many successful stores we've sent them"...
    265         // naah.. dont really care now
    266286    }
    267287   
     
    278298            data.expandDBProfile();
    279299        DBHistory hist = data.getDBHistory();
    280         hist.storeSuccessful();
     300        hist.storeFailed();
    281301        // we could do things like update some sort of "how many successful stores we've
    282302        // failed to send them"...
Note: See TracChangeset for help on using the changeset viewer.