Changeset 2f09389


Ignore:
Timestamp:
Dec 23, 2015 10:59:53 AM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
2698076
Parents:
8da3257
Message:

netdb minor cleanups

Location:
router/java/src/net/i2p/router/networkdb/kademlia
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodOnlySearchJob.java

    r8da3257 r2f09389  
    221221        }
    222222        _facade.complete(_key);
    223         getContext().statManager().addRateData("netDb.failedTime", time, 0);
     223        getContext().statManager().addRateData("netDb.failedTime", time);
    224224        for (Job j : _onFailed) {
    225225            getContext().jobQueue().addJob(j);
     
    252252        }
    253253        _facade.complete(_key);
    254         getContext().statManager().addRateData("netDb.successTime", time, 0);
     254        getContext().statManager().addRateData("netDb.successTime", time);
    255255        for (Job j : _onFind) {
    256256            getContext().jobQueue().addJob(j);
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillDatabaseLookupMessageHandler.java

    r8da3257 r2f09389  
    4444
    4545    public Job createJob(I2NPMessage receivedMessage, RouterIdentity from, Hash fromHash) {
    46         _context.statManager().addRateData("netDb.lookupsReceived", 1, 0);
     46        _context.statManager().addRateData("netDb.lookupsReceived", 1);
    4747
    4848        DatabaseLookupMessage dlm = (DatabaseLookupMessage)receivedMessage;
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillVerifyStoreJob.java

    r8da3257 r2f09389  
    258258                    if (_sentTo != null)
    259259                        getContext().profileManager().dbStoreSuccessful(_sentTo);
    260                     getContext().statManager().addRateData("netDb.floodfillVerifyOK", delay, 0);
     260                    getContext().statManager().addRateData("netDb.floodfillVerifyOK", delay);
    261261                    if (_log.shouldLog(Log.INFO))
    262262                        _log.info("Verify success for " + _key);
     
    291291            if (_target != null && !_target.equals(_sentTo))
    292292                getContext().profileManager().dbLookupFailed(_target);
    293             getContext().statManager().addRateData("netDb.floodfillVerifyFail", delay, 0);
     293            getContext().statManager().addRateData("netDb.floodfillVerifyFail", delay);
    294294            resend();
    295295        }       
     
    329329            //if (_sentTo != null)
    330330            //    getContext().profileManager().dbStoreFailed(_sentTo);
    331             getContext().statManager().addRateData("netDb.floodfillVerifyTimeout", getContext().clock().now() - _sendTime, 0);
     331            getContext().statManager().addRateData("netDb.floodfillVerifyTimeout", getContext().clock().now() - _sendTime);
    332332            if (_log.shouldLog(Log.WARN))
    333333                _log.warn("Verify timed out for: " + _key);
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    r8da3257 r2f09389  
    213213        if (!_initialized) return;
    214214        _exploreKeys.removeAll(toRemove);
    215         _context.statManager().addRateData("netDb.exploreKeySet", _exploreKeys.size(), 0);
     215        _context.statManager().addRateData("netDb.exploreKeySet", _exploreKeys.size());
    216216    }
    217217
     
    221221            _exploreKeys.add(iter.next());
    222222        }
    223         _context.statManager().addRateData("netDb.exploreKeySet", _exploreKeys.size(), 0);
     223        _context.statManager().addRateData("netDb.exploreKeySet", _exploreKeys.size());
    224224    }
    225225   
  • router/java/src/net/i2p/router/networkdb/kademlia/LookupThrottler.java

    r8da3257 r2f09389  
    4646    /** yes, we could have a two-level lookup, or just do h.tostring() + id.tostring() */
    4747    private static class ReplyTunnel {
    48         public Hash h;
    49         public TunnelId id;
     48        public final Hash h;
     49        public final TunnelId id;
    5050
    5151        ReplyTunnel(Hash h, TunnelId id) {
  • router/java/src/net/i2p/router/networkdb/kademlia/PeerSelector.java

    r8da3257 r2f09389  
    113113    /** UNUSED */
    114114    private class MatchSelectionCollector implements SelectionCollector<Hash> {
    115         private TreeMap<BigInteger, Hash> _sorted;
    116         private Hash _key;
    117         private Set<Hash> _toIgnore;
     115        private final TreeMap<BigInteger, Hash> _sorted;
     116        private final Hash _key;
     117        private final Set<Hash> _toIgnore;
    118118        private int _matches;
    119119        public MatchSelectionCollector(Hash key, Set<Hash> toIgnore) {
     
    121121            _sorted = new TreeMap<BigInteger, Hash>();
    122122            _toIgnore = toIgnore;
    123             _matches = 0;
    124123        }
    125124        public void add(Hash entry) {
  • router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java

    r8da3257 r2f09389  
    166166   
    167167    private class RemoveJob extends JobImpl {
    168         private Hash _key;
     168        private final Hash _key;
    169169        public RemoveJob(Hash key) {
    170170            super(PersistentDataStore.this._context);
  • router/java/src/net/i2p/router/networkdb/kademlia/RepublishLeaseSetJob.java

    r8da3257 r2f09389  
    5454                        if (_log.shouldLog(Log.INFO))
    5555                            _log.info("Publishing " + ls);
    56                         getContext().statManager().addRateData("netDb.republishLeaseSetCount", 1, 0);
     56                        getContext().statManager().addRateData("netDb.republishLeaseSetCount", 1);
    5757                        _facade.sendStore(_dest, ls, null, new OnRepublishFailure(getContext(), this), REPUBLISH_LEASESET_TIMEOUT, null);
    5858                        _lastPublished = getContext().clock().now();
     
    106106    /** requeue */
    107107    private static class OnRepublishFailure extends JobImpl {
    108         private RepublishLeaseSetJob _job;
     108        private final RepublishLeaseSetJob _job;
    109109        public OnRepublishFailure(RouterContext ctx, RepublishLeaseSetJob job) {
    110110            super(ctx);
  • router/java/src/net/i2p/router/networkdb/kademlia/SearchJob.java

    r8da3257 r2f09389  
    782782   
    783783    private static class Search {
    784         private Job _onFind;
    785         private Job _onFail;
    786         private long _expiration;
    787         private boolean _isLease;
     784        private final Job _onFind;
     785        private final Job _onFail;
     786        private final long _expiration;
     787        private final boolean _isLease;
    788788       
    789789        public Search(Job onFind, Job onFail, long expiration, boolean isLease) {
  • router/java/src/net/i2p/router/networkdb/kademlia/SearchReplyJob.java

    r8da3257 r2f09389  
    101101                    if (_log.shouldLog(Log.INFO))
    102102                        _log.info("Peer " + _peer.toBase64() + " sends us bad replies, so not verifying " + peer.toBase64());
    103                     getContext().statManager().addRateData("netDb.searchReplyValidationSkipped", 1, 0);
     103                    getContext().statManager().addRateData("netDb.searchReplyValidationSkipped", 1);
    104104                }
    105105            }
     
    126126            _log.info("Peer reply from " + _peer.toBase64());
    127127        _repliesPendingVerification--;
    128         getContext().statManager().addRateData("netDb.searchReplyValidated", 1, 0);
     128        getContext().statManager().addRateData("netDb.searchReplyValidated", 1);
    129129    }
    130130    void replyNotVerified() {
     
    133133        _repliesPendingVerification--;
    134134        _invalidPeers++;
    135         getContext().statManager().addRateData("netDb.searchReplyNotValidated", 1, 0);
     135        getContext().statManager().addRateData("netDb.searchReplyNotValidated", 1);
    136136    }
    137137}
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java

    r8da3257 r2f09389  
    294294        }
    295295        msg.setEntry(_state.getData());
    296         msg.setMessageExpiration(getContext().clock().now() + _timeoutMs);
     296        long now = getContext().clock().now();
     297        msg.setMessageExpiration(now + _timeoutMs);
    297298
    298299        if (router.getIdentity().equals(getContext().router().getRouterInfo().getIdentity())) {
     
    306307            _log.debug(getJobId() + ": Send store timeout is " + responseTime);
    307308
    308         sendStore(msg, router, getContext().clock().now() + responseTime);
     309        sendStore(msg, router, now + responseTime);
    309310    }
    310311   
     
    316317    private void sendStore(DatabaseStoreMessage msg, RouterInfo peer, long expiration) {
    317318        if (msg.getEntry().getType() == DatabaseEntry.KEY_TYPE_LEASESET) {
    318             getContext().statManager().addRateData("netDb.storeLeaseSetSent", 1, 0);
     319            getContext().statManager().addRateData("netDb.storeLeaseSetSent", 1);
    319320            // if it is an encrypted leaseset...
    320321            if (getContext().keyRing().get(msg.getKey()) != null)
     
    323324                sendStoreThroughClient(msg, peer, expiration);
    324325        } else {
    325             getContext().statManager().addRateData("netDb.storeRouterInfoSent", 1, 0);
     326            getContext().statManager().addRateData("netDb.storeRouterInfoSent", 1);
    326327            sendDirect(msg, peer, expiration);
    327328        }
     
    558559     */
    559560    private class SendSuccessJob extends JobImpl implements ReplyJob {
    560         private RouterInfo _peer;
    561         private TunnelInfo _sendThrough;
    562         private int _msgSize;
     561        private final RouterInfo _peer;
     562        private final TunnelInfo _sendThrough;
     563        private final int _msgSize;
    563564       
    564565        public SendSuccessJob(RouterContext enclosingContext, RouterInfo peer) {
     
    616617     */
    617618    private class FailedJob extends JobImpl {
    618         private RouterInfo _peer;
    619         private long _sendOn;
     619        private final RouterInfo _peer;
     620        private final long _sendOn;
    620621
    621622        public FailedJob(RouterContext enclosingContext, RouterInfo peer, long sendOn) {
     
    636637
    637638            getContext().profileManager().dbStoreFailed(hash);
    638             getContext().statManager().addRateData("netDb.replyTimeout", getContext().clock().now() - _sendOn, 0);
     639            getContext().statManager().addRateData("netDb.replyTimeout", getContext().clock().now() - _sendOn);
    639640           
    640641            sendNext();
Note: See TracChangeset for help on using the changeset viewer.