Changeset e4bb053


Ignore:
Timestamp:
Jan 10, 2011 4:11:33 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
c29d091
Parents:
f15ad23
Message:

findbugs netdb

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

Legend:

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

    rf15ad23 re4bb053  
    8686                if (when + MIN_UPDATE_FREQUENCY > now)
    8787                    continue;
    88                 while (routersByAge.containsKey(new Long(when)))
     88                while (routersByAge.containsKey(Long.valueOf(when)))
    8989                    when++;
    90                routersByAge.put(new Long(when), info.getIdentity().getHash());
     90               routersByAge.put(Long.valueOf(when), info.getIdentity().getHash());
    9191            }
    9292        }
  • router/java/src/net/i2p/router/networkdb/kademlia/KBucketImpl.java

    rf15ad23 re4bb053  
    388388        KBucketImpl bucket = new KBucketImpl(I2PAppContext.getGlobalContext(), local);
    389389        bucket.setRange(low, high);
    390         Hash lowerBoundKey = bucket.getRangeBeginKey();
    391         Hash upperBoundKey = bucket.getRangeEndKey();
     390        //Hash lowerBoundKey = bucket.getRangeBeginKey();
     391        //Hash upperBoundKey = bucket.getRangeEndKey();
    392392        for (int i = 0; i < 100000; i++) {
    393393            Hash rnd = bucket.generateRandomKey();
     
    396396            if (!ok) {
    397397                byte diff[] = bucket.getLocal().cachedXor(rnd);
    398                 BigInteger dv = new BigInteger(1, diff);
     398                //BigInteger dv = new BigInteger(1, diff);
    399399                //log.error("WTF! bucket doesn't want: \n" + toString(rnd.getData())
    400400                //          + "\nDelta: \n" + toString(diff) + "\nDelta val: \n" + dv.toString(2)
     
    404404                           + "\nVal: " + DataHelper.toHexString(rnd.getData())
    405405                           + "\nHigh:" + DataHelper.toHexString(bucket.getRangeEndKey().getData()));
    406                 try { Thread.sleep(1000); } catch (Exception e) {}
     406                try { Thread.sleep(1000); } catch (InterruptedException e) {}
    407407                System.exit(0);
    408408            } else {
     
    416416    private static void testRand2() {
    417417        Log log = I2PAppContext.getGlobalContext().logManager().getLog(KBucketImpl.class);
    418         StringBuilder buf = new StringBuilder(1024*1024*16);
    419418        int low = 1;
    420419        int high = 200;
     
    425424        KBucketImpl bucket = new KBucketImpl(I2PAppContext.getGlobalContext(), local);
    426425        bucket.setRange(low, high);
    427         Hash lowerBoundKey = bucket.getRangeBeginKey();
    428         Hash upperBoundKey = bucket.getRangeEndKey();
     426        //Hash lowerBoundKey = bucket.getRangeBeginKey();
     427        //Hash upperBoundKey = bucket.getRangeEndKey();
    429428        for (int i = 0; i < 100000; i++) {
    430429            Hash rnd = bucket.generateRandomKey();
     
    433432            if (!ok) {
    434433                byte diff[] = bucket.getLocal().cachedXor(rnd);
    435                 BigInteger dv = new BigInteger(1, diff);
     434                //BigInteger dv = new BigInteger(1, diff);
    436435                //log.error("WTF! bucket doesn't want: \n" + toString(rnd.getData())
    437436                //          + "\nDelta: \n" + toString(diff) + "\nDelta val: \n" + dv.toString(2)
     
    441440                           + "\nVal: " + DataHelper.toHexString(rnd.getData())
    442441                           + "\nHigh:" + DataHelper.toHexString(bucket.getRangeEndKey().getData()));
    443                 try { Thread.sleep(1000); } catch (Exception e) {}
     442                try { Thread.sleep(1000); } catch (InterruptedException e) {}
    444443                System.exit(0);
    445444            } else {
     
    447446            }
    448447        }
    449         log.info("Passed 100,000 random key generations against a random hash\n" + buf.toString());
     448        log.info("Passed 100,000 random key generations against a random hash");
    450449    }
    451450   
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    rf15ad23 re4bb053  
    8989        if (_log.shouldLog(Log.DEBUG))
    9090            _log.debug("search Complete: " + key);
    91         SearchJob removed = null;
    9291        synchronized (_activeRequests) {
    93             removed = (SearchJob)_activeRequests.remove(key);
     92            _activeRequests.remove(key);
    9493        }
    9594    }
  • router/java/src/net/i2p/router/networkdb/kademlia/LookupThrottler.java

    rf15ad23 re4bb053  
    5959        @Override
    6060        public boolean equals(Object obj) {
     61            if (obj == null || !(obj instanceof ReplyTunnel))
     62                return false;
    6163            return this.h.equals(((ReplyTunnel)obj).h) &&
    6264                   this.id.equals(((ReplyTunnel)obj).id);
     
    6567        @Override
    6668        public int hashCode() {
    67             return this.h.hashCode() + this.id.hashCode();
     69            return this.h.hashCode() ^ this.id.hashCode();
    6870        }
    6971    }
  • router/java/src/net/i2p/router/networkdb/kademlia/RepublishLeaseSetJob.java

    rf15ad23 re4bb053  
    9090    }
    9191
    92     class OnRepublishSuccess extends JobImpl {
     92    private static class OnRepublishSuccess extends JobImpl {
    9393        public OnRepublishSuccess(RouterContext ctx) { super(ctx); }
    9494        public String getName() { return "Publish leaseSet successful"; }
     
    9999    }
    100100
    101     class OnRepublishFailure extends JobImpl {
     101    private static class OnRepublishFailure extends JobImpl {
    102102        private RepublishLeaseSetJob _job;
    103103        public OnRepublishFailure(RouterContext ctx, RepublishLeaseSetJob job) {
  • router/java/src/net/i2p/router/networkdb/kademlia/SearchState.java

    rf15ad23 re4bb053  
    9999            _pendingPeers.addAll(pending);
    100100            for (Iterator iter = pending.iterator(); iter.hasNext(); )
    101                 _pendingPeerTimes.put(iter.next(), new Long(_context.clock().now()));
     101                _pendingPeerTimes.put(iter.next(), Long.valueOf(_context.clock().now()));
    102102        }
    103103        synchronized (_attemptedPeers) {
     
    108108        synchronized (_pendingPeers) {
    109109            _pendingPeers.add(peer);
    110             _pendingPeerTimes.put(peer, new Long(_context.clock().now()));
     110            _pendingPeerTimes.put(peer, Long.valueOf(_context.clock().now()));
    111111        }
    112112        synchronized (_attemptedPeers) {
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java

    rf15ad23 re4bb053  
    444444                _state.addPending(to, wm);
    445445            } else {
    446                 sent = msg;
    447446                _state.addPending(to);
    448447                // now that almost all floodfills are at 0.7.10,
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreState.java

    rf15ad23 re4bb053  
    115115        synchronized (_pendingPeers) {
    116116            _pendingPeers.add(peer);
    117             _pendingPeerTimes.put(peer, new Long(_context.clock().now()));
     117            _pendingPeerTimes.put(peer, Long.valueOf(_context.clock().now()));
    118118        }
    119119        synchronized (_attemptedPeers) {
     
    125125            _pendingPeers.addAll(pending);
    126126            for (Iterator<Hash> iter = pending.iterator(); iter.hasNext(); )
    127                 _pendingPeerTimes.put(iter.next(), new Long(_context.clock().now()));
     127                _pendingPeerTimes.put(iter.next(), Long.valueOf(_context.clock().now()));
    128128        }
    129129        synchronized (_attemptedPeers) {
  • router/java/src/net/i2p/router/networkdb/kademlia/TransientDataStore.java

    rf15ad23 re4bb053  
    163163   
    164164    @Override
    165     public int hashCode() {
    166         return DataHelper.hashCode(_data);
    167     }
    168     @Override
    169     public boolean equals(Object obj) {
    170         if ( (obj == null) || (obj.getClass() != getClass()) ) return false;
    171         TransientDataStore ds = (TransientDataStore)obj;
    172         return DataHelper.eq(ds._data, _data);
    173     }
    174     @Override
    175165    public String toString() {
    176166        StringBuilder buf = new StringBuilder();
Note: See TracChangeset for help on using the changeset viewer.