You need to not add the iB if you use multipliers despite it not being a size 
option.

On Monday 13 April 2009 16:15:52 j16sdiz at freenetproject.org wrote:
> Author: j16sdiz
> Date: 2009-04-13 15:15:51 +0000 (Mon, 13 Apr 2009)
> New Revision: 26754
> 
> Modified:
>    trunk/freenet/src/freenet/config/IntOption.java
>    trunk/freenet/src/freenet/config/LongOption.java
>    trunk/freenet/src/freenet/config/ShortOption.java
>    trunk/freenet/src/freenet/config/SubConfig.java
>    trunk/freenet/src/freenet/node/LoggingConfigHandler.java
>    trunk/freenet/src/freenet/node/Node.java
>    trunk/freenet/src/freenet/support/Fields.java
> Log:
> Option.isSize to flag "size" option (fix bug 2614)
> 
> Modified: trunk/freenet/src/freenet/config/IntOption.java
> ===================================================================
> --- trunk/freenet/src/freenet/config/IntOption.java   2009-04-12 21:27:13 UTC 
(rev 26753)
> +++ trunk/freenet/src/freenet/config/IntOption.java   2009-04-13 15:15:51 UTC 
(rev 26754)
> @@ -9,17 +9,20 @@
>  
>  /** Integer config variable */
>  public class IntOption extends Option<Integer> {
> +     protected final boolean isSize;
> +
>       public IntOption(SubConfig conf, String optionName, String 
defaultValueString, int sortOrder, boolean expert,
> -             boolean forceWrite, String shortDesc, String longDesc, 
> IntCallback 
cb) {
> +             boolean forceWrite, String shortDesc, String longDesc, 
> IntCallback 
cb, boolean isSize) {
>               this(conf, optionName, Fields.parseInt(defaultValueString), 
> sortOrder, 
expert, forceWrite, shortDesc, longDesc,
> -                     cb);
> +                     cb, isSize);
>       }
>       
>       public IntOption(SubConfig conf, String optionName, Integer 
> defaultValue, 
int sortOrder, boolean expert,
> -             boolean forceWrite, String shortDesc, String longDesc, 
> IntCallback 
cb) {
> +             boolean forceWrite, String shortDesc, String longDesc, 
> IntCallback 
cb, boolean isSize) {
>               super(conf, optionName, cb, sortOrder, expert, forceWrite, 
> shortDesc, 
longDesc, Option.DataType.NUMBER);
>               this.defaultValue = defaultValue;
>               this.currentValue = defaultValue;
> +             this.isSize = isSize;
>       }
>  
>       @Override
> @@ -39,6 +42,6 @@
>  
>       @Override
>       protected String toString(Integer val) {
> -             return Fields.intToString(val);
> +             return Fields.intToString(val, isSize);
>       }
>  }
> 
> Modified: trunk/freenet/src/freenet/config/LongOption.java
> ===================================================================
> --- trunk/freenet/src/freenet/config/LongOption.java  2009-04-12 21:27:13 UTC 
(rev 26753)
> +++ trunk/freenet/src/freenet/config/LongOption.java  2009-04-13 15:15:51 UTC 
(rev 26754)
> @@ -9,17 +9,20 @@
>  
>  /** Long config variable */
>  public class LongOption extends Option<Long> {
> +     protected final boolean isSize;
> +
>       public LongOption(SubConfig conf, String optionName, String 
defaultValueString, int sortOrder, boolean expert,
> -             boolean forceWrite, String shortDesc, String longDesc, 
LongCallback cb) {
> +             boolean forceWrite, String shortDesc, String longDesc, 
LongCallback cb, boolean isSize) {
>               this(conf, optionName, Fields.parseLong(defaultValueString), 
> sortOrder, 
expert, forceWrite, shortDesc,
> -                     longDesc, cb);
> +                     longDesc, cb, isSize);
>       }
>       
>       public LongOption(SubConfig conf, String optionName, Long defaultValue, 
int sortOrder, boolean expert,
> -             boolean forceWrite, String shortDesc, String longDesc, 
LongCallback cb) {
> +             boolean forceWrite, String shortDesc, String longDesc, 
LongCallback cb, boolean isSize) {
>               super(conf, optionName, cb, sortOrder, expert, forceWrite, 
> shortDesc, 
longDesc, Option.DataType.NUMBER);
>               this.defaultValue = defaultValue;
>               this.currentValue = defaultValue;
> +             this.isSize = isSize;
>       }
>  
>       @Override
> @@ -39,6 +42,6 @@
>       
>       @Override
>       protected String toString(Long val) {
> -             return Fields.longToString(val);
> +             return Fields.longToString(val, isSize);
>       }
>  }
> 
> Modified: trunk/freenet/src/freenet/config/ShortOption.java
> ===================================================================
> --- trunk/freenet/src/freenet/config/ShortOption.java 2009-04-12 21:27:13 
UTC (rev 26753)
> +++ trunk/freenet/src/freenet/config/ShortOption.java 2009-04-13 15:15:51 
UTC (rev 26754)
> @@ -5,11 +5,14 @@
>  import freenet.support.api.ShortCallback;
>  
>  public class ShortOption extends Option<Short> {
> +     protected final boolean isSize;
> +     
>       public ShortOption(SubConfig conf, String optionName, short 
> defaultValue, 
int sortOrder, 
> -                     boolean expert, boolean forceWrite, String shortDesc, 
> String longDesc, 
ShortCallback cb) {
> +                     boolean expert, boolean forceWrite, String shortDesc, 
> String longDesc, 
ShortCallback cb, boolean isSize) {
>               super(conf, optionName, cb, sortOrder, expert, forceWrite, 
> shortDesc, 
longDesc, Option.DataType.NUMBER);
>               this.defaultValue = defaultValue;
>               this.currentValue = defaultValue;
> +             this.isSize = isSize;
>       }
>  
>       private String l10n(String key, String pattern, String value) {
> @@ -29,6 +32,6 @@
>  
>       @Override
>       protected String toString(Short val) {
> -             return Fields.shortToString(val);
> +             return Fields.shortToString(val, isSize);
>       }       
>  }
> 
> Modified: trunk/freenet/src/freenet/config/SubConfig.java
> ===================================================================
> --- trunk/freenet/src/freenet/config/SubConfig.java   2009-04-12 21:27:13 UTC 
(rev 26753)
> +++ trunk/freenet/src/freenet/config/SubConfig.java   2009-04-13 15:15:51 UTC 
(rev 26754)
> @@ -61,27 +61,27 @@
>       }
>       
>       public void register(String optionName, int defaultValue, int sortOrder,
> -                     boolean expert, boolean forceWrite, String shortDesc, 
> String longDesc, 
IntCallback cb) {
> +                     boolean expert, boolean forceWrite, String shortDesc, 
> String longDesc, 
IntCallback cb, boolean isSize) {
>               if(cb == null) cb = new NullIntCallback();
> -             register(new IntOption(this, optionName, defaultValue, 
> sortOrder, expert, 
forceWrite, shortDesc, longDesc, cb));
> +             register(new IntOption(this, optionName, defaultValue, 
> sortOrder, expert, 
forceWrite, shortDesc, longDesc, cb, isSize));
>       }
>       
>       public void register(String optionName, long defaultValue, int 
> sortOrder,
> -                     boolean expert, boolean forceWrite, String shortDesc, 
> String longDesc, 
LongCallback cb) {
> +                     boolean expert, boolean forceWrite, String shortDesc, 
> String longDesc, 
LongCallback cb, boolean isSize) {
>               if(cb == null) cb = new NullLongCallback();
> -             register(new LongOption(this, optionName, defaultValue, 
> sortOrder, 
expert, forceWrite, shortDesc, longDesc, cb));
> +             register(new LongOption(this, optionName, defaultValue, 
> sortOrder, 
expert, forceWrite, shortDesc, longDesc, cb, isSize));
>       }
>       
>       public void register(String optionName, String defaultValueString, int 
sortOrder,
> -                     boolean expert, boolean forceWrite, String shortDesc, 
> String longDesc, 
IntCallback cb) {
> +                     boolean expert, boolean forceWrite, String shortDesc, 
> String longDesc, 
IntCallback cb, boolean isSize) {
>               if(cb == null) cb = new NullIntCallback();
> -             register(new IntOption(this, optionName, defaultValueString, 
> sortOrder, 
expert, forceWrite, shortDesc, longDesc, cb));
> +             register(new IntOption(this, optionName, defaultValueString, 
> sortOrder, 
expert, forceWrite, shortDesc, longDesc, cb, isSize));
>       }
>       
>       public void register(String optionName, String defaultValueString, int 
sortOrder,
> -                     boolean expert, boolean forceWrite, String shortDesc, 
> String longDesc, 
LongCallback cb) {
> +                     boolean expert, boolean forceWrite, String shortDesc, 
> String longDesc, 
LongCallback cb, boolean isSize) {
>               if(cb == null) cb = new NullLongCallback();
> -             register(new LongOption(this, optionName, defaultValueString, 
> sortOrder, 
expert, forceWrite, shortDesc, longDesc, cb));
> +             register(new LongOption(this, optionName, defaultValueString, 
> sortOrder, 
expert, forceWrite, shortDesc, longDesc, cb, isSize));
>       }
>       
>       public void register(String optionName, boolean defaultValue, int 
sortOrder,
> @@ -97,9 +97,9 @@
>       }
>       
>       public void register(String optionName, short defaultValue, int 
> sortOrder,
> -                     boolean expert, boolean forceWrite, String shortDesc, 
> String longDesc, 
ShortCallback cb) {
> +                     boolean expert, boolean forceWrite, String shortDesc, 
> String longDesc, 
ShortCallback cb, boolean isSize) {
>               if(cb == null) cb = new NullShortCallback();
> -             register(new ShortOption(this, optionName, defaultValue, 
> sortOrder, 
expert, forceWrite, shortDesc, longDesc, cb));
> +             register(new ShortOption(this, optionName, defaultValue, 
> sortOrder, 
expert, forceWrite, shortDesc, longDesc, cb, isSize));
>       }
>       
>       public void register(String optionName, String[] defaultValue, int 
sortOrder,
> 
> Modified: trunk/freenet/src/freenet/node/LoggingConfigHandler.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/LoggingConfigHandler.java  2009-04-12 
21:27:13 UTC (rev 26753)
> +++ trunk/freenet/src/freenet/node/LoggingConfigHandler.java  2009-04-13 
15:15:51 UTC (rev 26754)
> @@ -126,7 +126,7 @@
>                                                       
> fileLoggerHook.setMaxOldLogsSize(val);
>                                               }
>                                       }
> -     });
> +     }, true);
>       
>       maxZippedLogsSize = config.getLong("maxZippedLogsSize");
>       
> @@ -202,7 +202,7 @@
>                                               if(fileLoggerHook != null)
>                                                       
> fileLoggerHook.setMaxListBytes(val);
>                                       }
> -     });
> +     }, true);
>       
>       maxCachedLogBytes = config.getLong("maxCachedBytes");
>       
> @@ -221,7 +221,7 @@
>                                               if(fileLoggerHook != null)
>                                                       
> fileLoggerHook.setMaxListLength(val);
>                                       }
> -     });
> +     }, false);
>       
>       maxCachedLogLines = config.getInt("maxCachedLines");
>       
> 
> Modified: trunk/freenet/src/freenet/node/Node.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/Node.java  2009-04-12 21:27:13 UTC (rev 
26753)
> +++ trunk/freenet/src/freenet/node/Node.java  2009-04-13 15:15:51 UTC (rev 
26754)
> @@ -1010,7 +1010,7 @@
>                                               if(maxHTL < 0) throw new 
> InvalidConfigValueException("Impossible max 
HTL");
>                                               maxHTL = val;
>                                       }
> -             });
> +             }, false);
>               
>               maxHTL = nodeConfig.getShort("maxHTL");
>               
> @@ -1257,7 +1257,7 @@
>                                               
> outputThrottle.changeNanosAndBucketSize((1000L * 1000L * 1000L) / 
obwLimit, obwLimit/2);
>                                               
> nodeStats.setOutputLimit(obwLimit);
>                                       }
> -             });
> +             }, false);
>               
>               int obwLimit = nodeConfig.getInt("outputBandwidthLimit");
>               if(obwLimit <= 0)
> @@ -1293,7 +1293,7 @@
>                                               }
>                                               
> nodeStats.setInputLimit(ibwLimit);
>                                       }
> -             });
> +             }, true);
>               
>               int ibwLimit = nodeConfig.getInt("inputBandwidthLimit");
>               if(ibwLimit == -1) {
> @@ -1471,7 +1471,7 @@
>                                               maxOpennetPeers = 
> inputMaxOpennetPeers;
>                                               }
>                                       }
> -             );
> +             , false);
>               
>               maxOpennetPeers = opennetConfig.getInt("maxOpennetPeers");
>               if(maxOpennetPeers > 20) {
> @@ -1665,7 +1665,7 @@
>                                               
> nodeStats.avgStoreLocation.changeMaxReports((int)maxStoreKeys);
>                                               
> nodeStats.avgCacheLocation.changeMaxReports((int)maxCacheKeys);
>                                       }
> -             });
> +             }, true);
>               
>               maxTotalDatastoreSize = nodeConfig.getLong("storeSize");
>               
> @@ -1696,7 +1696,7 @@
>                                       public boolean isReadOnly() {
>                                       return !("salt-hash".equals(storeType));
>                               }
> -                     });
> +                     }, true);
>  
>               storeBloomFilterSize = 
> nodeConfig.getInt("storeBloomFilterSize");
>  
> @@ -1850,7 +1850,7 @@
>                                       databaseMaxMemory = val;
>                               }
>                               
> -                     });
> +                     }, true);
>  
>                       /* There are some JVMs (for example libgcj 4.1.1) whose 
Runtime.maxMemory() does not work. */
>                       long maxHeapMemory = Runtime.getRuntime().maxMemory();
> 
> Modified: trunk/freenet/src/freenet/support/Fields.java
> ===================================================================
> --- trunk/freenet/src/freenet/support/Fields.java     2009-04-12 21:27:13 UTC 
(rev 26753)
> +++ trunk/freenet/src/freenet/support/Fields.java     2009-04-13 15:15:51 UTC 
(rev 26754)
> @@ -687,16 +687,16 @@
>               return res;
>       }
>  
> -     public static String longToString(long val) {
> +     public static String longToString(long val, boolean isSize) {
>               String ret = Long.toString(val);
>  
>               if(val <= 0)
>                       return ret;
>  
>               for(int i = MULTIPLES.length - 1; i >= 0; i--) {
> -                     if(val > MULTIPLES[i] && val % MULTIPLES[i] == 0) {
> +                     if(val > MULTIPLES[i] && val % MULTIPLES[i] == 0 && 
> (isSize || 
MULTIPLES[i] % 1000 == 0)) {
>                               ret = (val / MULTIPLES[i]) + MULTIPLES_2[i];
> -                             
> if(!MULTIPLES_2[i].toLowerCase().equals(MULTIPLES_2[i]))
> +                             
> if(!MULTIPLES_2[i].toLowerCase().equals(MULTIPLES_2[i])) 
>                                       ret += "iB";
>                               break;
>                       }
> @@ -704,14 +704,14 @@
>               return ret;
>       }
>  
> -     public static String intToString(int val) {
> +     public static String intToString(int val, boolean isSize) {
>               String ret = Integer.toString(val);
>  
>               if(val <= 0)
>                       return ret;
>  
>               for(int i = MULTIPLES.length - 1; i >= 0; i--) {
> -                     if(val > MULTIPLES[i] && val % MULTIPLES[i] == 0) {
> +                     if(val > MULTIPLES[i] && val % MULTIPLES[i] == 0 && 
> (isSize || 
MULTIPLES[i] % 1000 == 0)) {
>                               ret = (val / MULTIPLES[i]) + MULTIPLES_2[i];
>                               
> if(!MULTIPLES_2[i].toLowerCase().equals(MULTIPLES_2[i]))
>                                       ret += "iB";
> @@ -721,14 +721,14 @@
>               return ret;
>       }
>  
> -     public static String shortToString(short val) {
> +     public static String shortToString(short val, boolean isSize) {
>               String ret = Short.toString(val);
>  
>               if(val <= 0)
>                       return ret;
>  
>               for(int i = MULTIPLES.length - 1; i >= 0; i--) {
> -                     if(val > MULTIPLES[i] && val % MULTIPLES[i] == 0) {
> +                     if(val > MULTIPLES[i] && val % MULTIPLES[i] == 0 && 
> (isSize || 
MULTIPLES[i] % 1000 == 0)) {
>                               ret = (val / MULTIPLES[i]) + MULTIPLES_2[i];
>                               
> if(!MULTIPLES_2[i].toLowerCase().equals(MULTIPLES_2[i]))
>                                       ret += "iB";
> 
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
> 
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20090414/ec1bca96/attachment.pgp>

Reply via email to