Changeset f32d3aae


Ignore:
Timestamp:
Jan 6, 2018 4:15:15 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
25d16b13
Parents:
b8f17c7
Message:

Console: Show and set burst bandwidth on /config (ticket #2123)
Better error handling
Comment out some unused things, misc. cleanups

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigNetHandler.java

    rb8f17c7 rf32d3aae  
    4444    private boolean _laptop;
    4545    private String _inboundRate;
    46     private String _inboundBurstRate;
    47     private String _inboundBurst;
     46    //private String _inboundBurstRate;
     47    //private String _inboundBurst;
    4848    private String _outboundRate;
    49     private String _outboundBurstRate;
    50     private String _outboundBurst;
     49    //private String _outboundBurstRate;
     50    //private String _outboundBurst;
    5151    private String _sharePct;
    5252    private boolean _ratesOnly;
     
    115115        _inboundRate = (rate != null ? rate.trim() : null);
    116116    }
     117
     118/*
    117119    public void setInboundburstrate(String rate) {
    118120        _inboundBurstRate = (rate != null ? rate.trim() : null);
     
    121123        _inboundBurst = (factor != null ? factor.trim() : null);
    122124    }
     125****/
     126
    123127    public void setOutboundrate(String rate) {
    124128        _outboundRate = (rate != null ? rate.trim() : null);
    125129    }
     130
     131/*
    126132    public void setOutboundburstrate(String rate) {
    127133        _outboundBurstRate = (rate != null ? rate.trim() : null);
     
    130136        _outboundBurst = (factor != null ? factor.trim() : null);
    131137    }
     138****/
     139
    132140    public void setSharePercentage(String pct) {
    133141        _sharePct = (pct != null ? pct.trim() : null);
     
    488496        }
    489497
    490         // Since burst is now hidden in the gui, set burst to +10% for 20 seconds
     498        // Since burst is now hidden in the gui, set burst to +10% for 20 seconds (prior to 0.9.33)
     499        // As of 0.9.33, we set strict bandwidth limits. Specified rate is the burst rate,
     500        // and we set the standard rate to 50KB or 10% lower (whichever is less).
    491501        if ( (_inboundRate != null) && (_inboundRate.length() > 0) &&
    492             !_inboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, "" + FIFOBandwidthRefiller.DEFAULT_INBOUND_BANDWIDTH))) {
    493             changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, _inboundRate);
     502            !_inboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH,
     503                                                      Integer.toString(FIFOBandwidthRefiller.DEFAULT_INBOUND_BURST_BANDWIDTH)))) {
    494504            try {
    495                 int rate = Integer.parseInt(_inboundRate) * (100 + DEF_BURST_PCT) / 100;
     505                int rate = Integer.parseInt(_inboundRate);
    496506                int kb = DEF_BURST_TIME * rate;
    497                 changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, "" + rate);
    498                 changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH_PEAK, "" + kb);
    499             } catch (NumberFormatException nfe) {}
    500             bwUpdated = true;
     507                changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, Integer.toString(rate));
     508                changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH_PEAK, Integer.toString(kb));
     509                rate -= Math.min(rate * DEF_BURST_PCT / 100, 50);
     510                changes.put(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, Integer.toString(rate));
     511                bwUpdated = true;
     512            } catch (NumberFormatException nfe) {
     513                addFormError(_t("Invalid bandwidth"));
     514            }
    501515        }
    502516        if ( (_outboundRate != null) && (_outboundRate.length() > 0) &&
    503             !_outboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, "" + FIFOBandwidthRefiller.DEFAULT_OUTBOUND_BANDWIDTH))) {
    504             changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, _outboundRate);
     517            !_outboundRate.equals(_context.getProperty(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH,
     518                                                       Integer.toString(FIFOBandwidthRefiller.DEFAULT_OUTBOUND_BURST_BANDWIDTH)))) {
    505519            try {
    506                 int rate = Integer.parseInt(_outboundRate) * (100 + DEF_BURST_PCT) / 100;
     520                int rate = Integer.parseInt(_outboundRate);
    507521                int kb = DEF_BURST_TIME * rate;
    508                 changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, "" + rate);
    509                 changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH_PEAK, "" + kb);
    510             } catch (NumberFormatException nfe) {}
    511             bwUpdated = true;
     522                changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, Integer.toString(rate));
     523                changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH_PEAK, Integer.toString(kb));
     524                rate -= Math.min(rate * DEF_BURST_PCT / 100, 50);
     525                changes.put(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, Integer.toString(rate));
     526                bwUpdated = true;
     527            } catch (NumberFormatException nfe) {
     528                addFormError(_t("Invalid bandwidth"));
     529            }
    512530        }
    513531
  • apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigNetHelper.java

    rb8f17c7 rf32d3aae  
    236236
    237237    public String getInboundRate() {
    238         return "" + _context.bandwidthLimiter().getInboundKBytesPerSecond();
    239     }
     238        return Integer.toString(_context.bandwidthLimiter().getInboundKBytesPerSecond());
     239    }
     240
    240241    public String getOutboundRate() {
    241         return "" + _context.bandwidthLimiter().getOutboundKBytesPerSecond();
    242     }
    243     public String getInboundRateBits() {
    244         return kbytesToBits(_context.bandwidthLimiter().getInboundKBytesPerSecond());
    245     }
    246     public String getOutboundRateBits() {
    247         return kbytesToBits(_context.bandwidthLimiter().getOutboundKBytesPerSecond());
    248     }
     242        return Integer.toString(_context.bandwidthLimiter().getOutboundKBytesPerSecond());
     243    }
     244
     245    public String getInboundBurstRateBits() {
     246        return kbytesToBits(_context.bandwidthLimiter().getInboundBurstKBytesPerSecond());
     247    }
     248
     249    public String getOutboundBurstRateBits() {
     250        return kbytesToBits(_context.bandwidthLimiter().getOutboundBurstKBytesPerSecond());
     251    }
     252
    249253    public String getShareRateBits() {
    250254        return kbytesToBits(getShareBandwidth());
     
    254258               ' ' + _t("or {0} bytes per month maximum", DataHelper.formatSize(kbytes * (1024L * 60 * 60 * 24 * 31)));
    255259    }
     260
    256261    public String getInboundBurstRate() {
    257         return "" + _context.bandwidthLimiter().getInboundBurstKBytesPerSecond();
    258     }
     262        return Integer.toString(_context.bandwidthLimiter().getInboundBurstKBytesPerSecond());
     263    }
     264
    259265    public String getOutboundBurstRate() {
    260         return "" + _context.bandwidthLimiter().getOutboundBurstKBytesPerSecond();
    261     }
     266        return Integer.toString(_context.bandwidthLimiter().getOutboundBurstKBytesPerSecond());
     267    }
     268
     269/*
    262270    public String getInboundBurstFactorBox() {
    263271        int numSeconds = 1;
     
    302310    }
    303311   
    304     /** removed */
    305312    public String getEnableLoadTesting() {
    306313        return "";
    307314    }
     315****/
    308316   
    309317    public String getSharePercentageBox() {
  • apps/routerconsole/jsp/config.jsp

    rb8f17c7 rf32d3aae  
    3131 <b><%=intl._t("I2P will work best if you configure your rates to match the speed of your internet connection.")%></b>
    3232 </td></tr>
    33    <tr><td><input style="text-align: right; width: 5em;" name="inboundrate" type="text" size="5" maxlength="5" value="<jsp:getProperty name="nethelper" property="inboundRate" />" >
     33<%-- display burst, set standard, handler will fix up --%>
     34   <tr><td><input style="text-align: right; width: 5em;" name="inboundrate" type="text" size="5" maxlength="5" value="<jsp:getProperty name="nethelper" property="inboundBurstRate" />" >
    3435          <%=intl._t("KBps In")%>
    35         </td><td>(<jsp:getProperty name="nethelper" property="inboundRateBits" />)</td>
    36 <% /********
     36        </td><td>(<jsp:getProperty name="nethelper" property="inboundBurstRateBits" />)</td>
     37<%--
    3738<!-- let's keep this simple...
    3839 bursting up to
     
    4041    <jsp:getProperty name="nethelper" property="inboundBurstFactorBox" /><br>
    4142-->
    42 *********/ %>
     43--%>
    4344    </tr><tr>
    44         <td><input style="text-align: right; width: 5em;" name="outboundrate" type="text" size="5" maxlength="5" value="<jsp:getProperty name="nethelper" property="outboundRate" />" >
     45<%-- display burst, set standard, handler will fix up --%>
     46        <td><input style="text-align: right; width: 5em;" name="outboundrate" type="text" size="5" maxlength="5" value="<jsp:getProperty name="nethelper" property="outboundBurstRate" />" >
    4547         <%=intl._t("KBps Out")%>
    46         </td><td>(<jsp:getProperty name="nethelper" property="outboundRateBits" />)</td>
    47 <% /********
     48        </td><td>(<jsp:getProperty name="nethelper" property="outboundBurstRateBits" />)</td>
     49<%--
    4850<!-- let's keep this simple...
    4951 bursting up to
     
    5355    A negative rate sets the default.</i><br>
    5456-->
    55 *********/ %>
     57--%>
    5658    </tr><tr>
    5759        <td><jsp:getProperty name="nethelper" property="sharePercentageBox" /> <%=intl._t("Share")%></td>
  • router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java

    rb8f17c7 rf32d3aae  
    234234        if (_inboundBurstKBytesPerSecond <= 0)
    235235            _inboundBurstKBytesPerSecond = DEFAULT_INBOUND_BURST_BANDWIDTH;
     236        if (_inboundBurstKBytesPerSecond < _inboundKBytesPerSecond)
     237            _inboundBurstKBytesPerSecond = _inboundKBytesPerSecond;
    236238        _limiter.setInboundBurstKBps(_inboundBurstKBytesPerSecond);
    237239    }
     
    251253        if (_outboundBurstKBytesPerSecond <= 0)
    252254            _outboundBurstKBytesPerSecond = DEFAULT_OUTBOUND_BURST_BANDWIDTH;
     255        if (_outboundBurstKBytesPerSecond < _outboundKBytesPerSecond)
     256            _outboundBurstKBytesPerSecond = _outboundKBytesPerSecond;
    253257        _limiter.setOutboundBurstKBps(_outboundBurstKBytesPerSecond);
    254258    }
Note: See TracChangeset for help on using the changeset viewer.