Changeset e227464


Ignore:
Timestamp:
Feb 15, 2011 5:23:02 PM (9 years ago)
Author:
hiddenz <hiddenz@…>
Branches:
master
Children:
d468a3a
Parents:
6c61b39 (diff), 4d59570 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge of '2f361aff8dd74139e94c6f92e575638347b28b0a'

and 'c095a7e88a112095206c8abb3db82789c620a5e4'

Files:
13 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    r6c61b39 re227464  
    858858        out.write(statusString + "</td>\n\t");
    859859
     860        // (i) icon column
    860861        out.write("<td class=\"" + rowClass + "\">");
     862        if (isValid && meta.getAnnounce() != null) {
     863            // Link to local details page - note that trailing slash on a single-file torrent
     864            // gets us to the details page instead of the file.
     865            //StringBuilder buf = new StringBuilder(128);
     866            //buf.append("<a href=\"").append(snark.getBaseName())
     867            //   .append("/\" title=\"").append(_("Torrent details"))
     868            //   .append("\"><img alt=\"").append(_("Info")).append("\" border=\"0\" src=\"")
     869            //   .append(_imgPath).append("details.png\"></a>");
     870            //out.write(buf.toString());
     871
     872            // Link to tracker details page
     873            String trackerLink = getTrackerLink(meta.getAnnounce(), snark.getInfoHash());
     874            if (trackerLink != null)
     875                out.write(trackerLink);
     876        }
     877
     878        // File type icon column
     879        out.write("</td>\n<td class=\"" + rowClass + "\">");
    861880        if (isValid) {
     881            // Link to local details page - note that trailing slash on a single-file torrent
     882            // gets us to the details page instead of the file.
    862883            StringBuilder buf = new StringBuilder(128);
    863884            buf.append("<a href=\"").append(snark.getBaseName())
    864885               .append("/\" title=\"").append(_("Torrent details"))
    865                .append("\"><img alt=\"").append(_("Info")).append("\" border=\"0\" src=\"")
    866                .append(_imgPath).append("details.png\"></a>");
    867              out.write(buf.toString());
    868         }
    869 
    870         out.write("</td>\n<td class=\"" + rowClass + "\">");
    871         StringBuilder buf = null;
     886               .append("\">");
     887            out.write(buf.toString());
     888        }
     889        String icon;
     890        if (isMultiFile)
     891            icon = "folder";
     892        else if (isValid)
     893            icon = toIcon(meta.getName());
     894        else
     895            icon = "magnet";
     896        if (isValid) {
     897            out.write(toImg(icon, _("Info")));
     898            out.write("</a>");
     899        } else {
     900            out.write(toImg(icon));
     901        }
     902
     903        // Torrent name column
     904        out.write("</td><td class=\"snarkTorrentName " + rowClass + "\">");
    872905        if (remaining == 0 || isMultiFile) {
    873             buf = new StringBuilder(128);
     906            StringBuilder buf = new StringBuilder(128);
    874907            buf.append("<a href=\"").append(snark.getBaseName());
    875908            if (isMultiFile)
     
    883916            out.write(buf.toString());
    884917        }
    885         String icon;
    886         if (isMultiFile)
    887             icon = "folder";
    888         else if (isValid)
    889             icon = toIcon(meta.getName());
    890         else
    891             icon = "magnet";
    892         if (remaining == 0 || isMultiFile) {
    893             out.write(toImg(icon, _("Open")));
    894             out.write("</a>");
    895         } else {
    896             out.write(toImg(icon));
    897         }
    898         out.write("</td><td class=\"snarkTorrentName " + rowClass + "\">");
    899         if (remaining == 0 || isMultiFile)
    900             out.write(buf.toString());
    901918        out.write(filename);
    902919        if (remaining == 0 || isMultiFile)
     
    11701187        out.write(":<td><input type=\"text\" name=\"newURL\" size=\"85\" value=\"" + newURL + "\"");
    11711188        out.write("title=\"");
    1172         out.write(_("Torrent file must originate from an I2P-based tracker"));
     1189        out.write(_("Enter the torrent file download URL (I2P only), magnet link, or maggot link"));
    11731190        out.write("\"> \n");
    11741191        // not supporting from file at the moment, since the file name passed isn't always absolute (so it may not resolve)
  • core/java/build.xml

    r6c61b39 re227464  
    5050            <fileset dir="./build/obj">
    5151                <include name="**/*.class"/>
     52                <exclude name="**/*Test.class" />
    5253            </fileset>
    5354        </cobertura-instrument>
  • core/java/src/net/i2p/data/DataHelper.java

    r6c61b39 re227464  
    180180     * @return new offset
    181181     */
     182    @Deprecated
    182183    public static int toProperties(byte target[], int offset, Properties props) throws DataFormatException, IOException {
    183184        if (props != null) {
     
    220221     * @return new offset
    221222     */
     223    @Deprecated
    222224    public static int fromProperties(byte source[], int offset, Properties target) throws DataFormatException, IOException {
    223225        int size = (int)fromLong(source, offset, 2);
     
    255257     * @throws RuntimeException if either is too long.
    256258     */
     259    @Deprecated
    257260    public static byte[] toProperties(Properties opts) {
    258261        try {
     
    545548
    546549    /** @deprecated unused */
     550    @Deprecated
    547551    public static byte[] toDate(Date date) throws IllegalArgumentException {
    548552        if (date == null)
     
    679683     * @deprecated unused
    680684     */
     685    @Deprecated
    681686    public static void writeBoolean(OutputStream out, Boolean bool)
    682687        throws DataFormatException, IOException {
     
    690695   
    691696    /** @deprecated unused */
     697    @Deprecated
    692698    public static Boolean fromBoolean(byte data[], int offset) {
    693699        if (data[offset] == BOOLEAN_TRUE)
     
    700706   
    701707    /** @deprecated unused */
     708    @Deprecated
    702709    public static void toBoolean(byte data[], int offset, boolean value) {
    703710        data[offset] = (value ? BOOLEAN_TRUE : BOOLEAN_FALSE);
     
    705712
    706713    /** @deprecated unused */
     714    @Deprecated
    707715    public static void toBoolean(byte data[], int offset, Boolean value) {
    708716        if (value == null)
     
    713721   
    714722    /** deprecated - used only in DatabaseLookupMessage */
     723    @Deprecated
    715724    public static final byte BOOLEAN_TRUE = 0x1;
    716725    /** deprecated - used only in DatabaseLookupMessage */
     726    @Deprecated
    717727    public static final byte BOOLEAN_FALSE = 0x0;
    718728    /** @deprecated unused */
     729    @Deprecated
    719730    public static final byte BOOLEAN_UNKNOWN = 0x2;
    720731    /** @deprecated unused */
     732    @Deprecated
    721733    public static final int BOOLEAN_LENGTH = 1;
    722734
     
    781793     * @deprecated inefficient
    782794     */
     795    @Deprecated
    783796    public final static boolean eq(int lhs, int rhs) {
    784797        return lhs == rhs;
     
    789802     * @deprecated inefficient
    790803     */
     804    @Deprecated
    791805    public final static boolean eq(long lhs, long rhs) {
    792806        return lhs == rhs;
     
    797811     * @deprecated inefficient
    798812     */
     813    @Deprecated
    799814    public final static boolean eq(byte lhs, byte rhs) {
    800815        return lhs == rhs;
     
    975990     *              newline was found
    976991     */
     992    @Deprecated
    977993    public static boolean readLine(InputStream in, StringBuffer buf) throws IOException {
    978994        return readLine(in, buf, null);
     
    9881004     * @deprecated use StringBuilder version
    9891005     */
     1006    @Deprecated
    9901007    public static boolean readLine(InputStream in, StringBuffer buf, Sha256Standalone hash) throws IOException {
    9911008        int c = -1;
  • core/java/src/net/i2p/data/DateAndFlags.java

    r6c61b39 re227464  
    3737     *  @param flags 0 - 65535
    3838     */
    39     public DateAndFlags(int flags, long date) {
     39    public DateAndFlags(long date, int flags) {
    4040        _flags = flags;
    4141        _date = date;
     
    4545     *  @param flags 0 - 65535
    4646     */
    47     public DateAndFlags(int flags, Date date) {
     47    public DateAndFlags(Date date, int flags) {
    4848        _flags = flags;
    4949        _date = date.getTime();
  • core/java/src/net/i2p/util/Executor.java

    r6c61b39 re227464  
    66
    77class Executor implements Runnable {
    8     private I2PAppContext _context;
     8    private final I2PAppContext _context;
    99    private Log _log;
    1010    private final List _readyEvents;
    11     private SimpleStore runn;
     11    private final SimpleStore runn;
    1212
    1313    public Executor(I2PAppContext ctx, Log log, List events, SimpleStore x) {
     
    3232                    evt.timeReached();
    3333                } catch (Throwable t) {
    34                     log("wtf, event borked: " + evt, t);
     34                    log("Executing task " + evt + " exited unexpectedly, please report", t);
    3535                }
    3636                long time = _context.clock().now() - before;
     37                // FIXME _log won't be non-null unless we already had a CRIT
    3738                if ( (time > 1000) && (_log != null) && (_log.shouldLog(Log.WARN)) )
    3839                    _log.warn("wtf, event execution took " + time + ": " + evt);
  • core/java/src/net/i2p/util/SimpleScheduler.java

    r6c61b39 re227464  
    3131    private static final int MIN_THREADS = 2;
    3232    private static final int MAX_THREADS = 4;
    33     private I2PAppContext _context;
    34     private Log _log;
    35     private ScheduledThreadPoolExecutor _executor;
    36     private String _name;
     33    private final I2PAppContext _context;
     34    private final Log _log;
     35    private final ScheduledThreadPoolExecutor _executor;
     36    private final String _name;
    3737    private int _count;
    3838    private final int _threads;
     
    4343        _log = _context.logManager().getLog(SimpleScheduler.class);
    4444        _name = name;
    45         _count = 0;
    4645        long maxMemory = Runtime.getRuntime().maxMemory();
    4746        _threads = (int) Math.max(MIN_THREADS, Math.min(MAX_THREADS, 1 + (maxMemory / (32*1024*1024))));
     
    140139                _timedEvent.timeReached();
    141140            } catch (Throwable t) {
    142                 _log.log(Log.CRIT, _name + " wtf, event borked: " + _timedEvent, t);
     141                _log.log(Log.CRIT, _name + ": Scheduled task " + _timedEvent + " exited unexpectedly, please report", t);
    143142            }
    144143            long time = System.currentTimeMillis() - before;
  • core/java/src/net/i2p/util/SimpleTimer.java

    r6c61b39 re227464  
    1515 * they b0rk the timer).
    1616 *
     17 * WARNING - Deprecated.
     18 * This is an inefficient mess. Use SimpleScheduler or SimpleTimer2 if possible.
    1719 */
    1820public class SimpleTimer {
  • core/java/src/net/i2p/util/SimpleTimer2.java

    r6c61b39 re227464  
    3030    private static final int MIN_THREADS = 2;
    3131    private static final int MAX_THREADS = 4;
    32     private I2PAppContext _context;
     32    private final I2PAppContext _context;
    3333    private static Log _log; // static so TimedEvent can use it
    34     private ScheduledThreadPoolExecutor _executor;
    35     private String _name;
     34    private final ScheduledThreadPoolExecutor _executor;
     35    private final String _name;
    3636    private int _count;
    3737    private final int _threads;
     
    224224                timeReached();
    225225            } catch (Throwable t) {
    226                 _log.log(Log.CRIT, _pool + " wtf, event borked: " + this, t);
     226                _log.log(Log.CRIT, _pool + ": Timed task " + this + " exited unexpectedly, please report", t);
    227227            }
    228228            long time = System.currentTimeMillis() - before;
  • core/java/test/net/i2p/data/LeaseSetTest.java

    r6c61b39 re227464  
    2626    }
    2727    public DataStructure createStructureToRead() { return new LeaseSet(); }
     28   
     29    public void testGetLeaseInvalid() {
     30        // create test subject
     31        LeaseSet subj = new LeaseSet();
     32       
     33        // should contain no leases now..
     34        try {
     35            assertNull(subj.getLease(0));
     36        } catch(RuntimeException exc) {
     37            // all good
     38        }
     39       
     40        // this shouldn't work either
     41        try {
     42            assertNull(subj.getLease(-1));
     43        } catch(RuntimeException exc) {
     44            // all good
     45        }
     46    }
     47   
     48    public void testAddLeaseNull() {
     49        // create test subject
     50        LeaseSet subj = new LeaseSet();
     51       
     52        // now add an null lease
     53        try {
     54            subj.addLease(null);
     55            fail("Failed at failing.");
     56        } catch(IllegalArgumentException exc) {
     57            // all good
     58        }
     59    }
     60   
     61    public void testAddLeaseInvalid() {
     62        // create test subject
     63        LeaseSet subj = new LeaseSet();
     64       
     65        // try to add completely invalid lease(ie. no data)
     66        try {
     67            subj.addLease(new Lease());
     68            fail("Failed at failing.");
     69        } catch(IllegalArgumentException exc) {
     70            // all good
     71        }
     72    }
     73           
    2874}
  • core/java/test/net/i2p/data/RouterAddressTest.java

    r6c61b39 re227464  
    5959        addr.setTransportStyle("Blah");
    6060        assertFalse(addr.equals(null));
     61        assertFalse(addr.equals(""));
    6162    }
    6263   
     
    7475        addr.setTransportStyle("Blah");
    7576        addr.toString();
     77        addr.setOptions(null);
     78        addr.toString();
    7679    }
    7780}
  • history.txt

    r6c61b39 re227464  
     12011-02-15 zzz
     2    * i2psnark: Details link shuffle, mostly restore 0.8.3 behavior
     3    * Profiles: Punish rejections more, in an attempt to spread the
     4                load more through the network
     5    * Timers: Log cleanup
     6
    172011-02-14 Mathiasdm
    28    * Fix headless issue without reboot
     
    4102011-02-13 zzz
    511    * Connect Client: Minor NPE fix cleanup
    6     * JobQueue: Prevet NPE at shutdown (thanks liberty)
     12    * JobQueue: Prevent NPE at shutdown (thanks liberty)
    713    * GeoIP: Prevent startup NPE (ticket #413, thanks RN)
    814    * NetDB: Prevent ExpireLeaseJob NPE (thanks sponge)
     
    2228            when closed by the client, was causing massive memory leak
    2329            for internal clients using lots of sessions (thanks sponge)
     30            (ticket #397)
    2431    * i2psnark:
    2532      - Improved magnet link parsing, use tr parameter if present
  • router/java/src/net/i2p/router/RouterVersion.java

    r6c61b39 re227464  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 11;
     21    public final static long BUILD = 12;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/peermanager/CapacityCalculator.java

    r6c61b39 re227464  
    1212   
    1313    /** used to adjust each period so that we keep trying to expand the peer's capacity */
    14     static long GROWTH_FACTOR = 5;
     14    static final long GROWTH_FACTOR = 5;
    1515   
    1616    /** the calculator estimates over a 1 hour period */
     
    8484     * Let A = accects, R = rejects, F = fails
    8585     * @return estimated and adjusted accepts per hour, for the given period
    86      *         which is, more or less, max(0, 5 + (A * (A / (A + R))) - (4 * F))
     86     *         which is, more or less, max(0, 5 + (A * (A / (A + 2R))) - (4 * F))
    8787     */
    8888    private static double estimateCapacity(RateStat acceptStat, RateStat rejectStat, RateStat failedStat, int period) {
     
    9191        Rate curFailed = failedStat.getRate(period);
    9292
    93         long eventCount = 0;
    94         if (curAccepted != null)
     93        double eventCount = 0;
     94        if (curAccepted != null) {
    9595            eventCount = curAccepted.getCurrentEventCount() + curAccepted.getLastEventCount();
    96         // Punish for rejections.
    97         // We don't want to simply do eventCount -= rejected or we get to zero with 50% rejection,
    98         // and we don't want everybody to be at zero during times of congestion.
    99         if (eventCount > 0) {
    100             long rejected = curRejected.getCurrentEventCount() + curRejected.getLastEventCount();
    101             eventCount = eventCount * eventCount / (eventCount + rejected);
     96            // Punish for rejections.
     97            // We don't want to simply do eventCount -= rejected or we get to zero with 50% rejection,
     98            // and we don't want everybody to be at zero during times of congestion.
     99            if (eventCount > 0 && curRejected != null) {
     100                long rejected = curRejected.getCurrentEventCount() + curRejected.getLastEventCount();
     101                if (rejected > 0)
     102                    eventCount *= eventCount / (eventCount + (2 * rejected));
     103            }
    102104        }
     105
    103106        double stretch = ((double)ESTIMATE_PERIOD) / period;
    104107        double val = eventCount * stretch;
    105         long failed = 0;
     108
    106109        // Let's say a failure is 4 times worse than a rejection.
    107110        // It's actually much worse than that, but with 2-hop tunnels and a 8-peer
    108111        // fast pool, for example, you have a 1/7 chance of being falsely blamed.
    109112        // We also don't want to drive everybody's capacity to zero, that isn't helpful.
    110         if (curFailed != null)
    111             failed = (long) (0.5 + (4.0 * (curFailed.getCurrentTotalValue() + curFailed.getLastTotalValue()) / 100.0));
    112         if (failed > 0) {
    113             //if ( (period <= 10*60*1000) && (curFailed.getCurrentEventCount() > 0) )
    114             //    return 0.0d; // their tunnels have failed in the last 0-10 minutes
    115             //else
    116             val -= failed * stretch;
     113        if (curFailed != null) {
     114            double failed = curFailed.getCurrentTotalValue() + curFailed.getLastTotalValue();
     115            if (failed > 0) {
     116                //if ( (period <= 10*60*1000) && (curFailed.getCurrentEventCount() > 0) )
     117                //    return 0.0d; // their tunnels have failed in the last 0-10 minutes
     118                //else
     119                // .04 = 4.0 / 100.0 adjustment to failed
     120                val -= 0.04 * failed * stretch;
     121            }
    117122        }
    118123       
Note: See TracChangeset for help on using the changeset viewer.