[freenet-cvs] r11996 - in trunk/freenet/src/freenet: config node

nextgens at freenetproject.org nextgens at freenetproject.org
Tue Mar 6 16:53:38 UTC 2007


Author: nextgens
Date: 2007-03-06 16:53:37 +0000 (Tue, 06 Mar 2007)
New Revision: 11996

Modified:
   trunk/freenet/src/freenet/config/BooleanOption.java
   trunk/freenet/src/freenet/config/IntOption.java
   trunk/freenet/src/freenet/config/LongOption.java
   trunk/freenet/src/freenet/config/Option.java
   trunk/freenet/src/freenet/config/ShortOption.java
   trunk/freenet/src/freenet/config/StringArrOption.java
   trunk/freenet/src/freenet/config/StringOption.java
   trunk/freenet/src/freenet/node/Node.java
Log:
Fix #1202: add a new method to Options in the config. framework : getDefault()

Modified: trunk/freenet/src/freenet/config/BooleanOption.java
===================================================================
--- trunk/freenet/src/freenet/config/BooleanOption.java	2007-03-06 16:16:57 UTC (rev 11995)
+++ trunk/freenet/src/freenet/config/BooleanOption.java	2007-03-06 16:53:37 UTC (rev 11996)
@@ -58,6 +58,10 @@
 		getValue();
 		return currentValue == defaultValue;
 	}
+	
+	public boolean getDefault() {
+		return defaultValue;
+	}
 
 	public void setDefault() {
 		currentValue = defaultValue;

Modified: trunk/freenet/src/freenet/config/IntOption.java
===================================================================
--- trunk/freenet/src/freenet/config/IntOption.java	2007-03-06 16:16:57 UTC (rev 11995)
+++ trunk/freenet/src/freenet/config/IntOption.java	2007-03-06 16:53:37 UTC (rev 11996)
@@ -74,6 +74,10 @@
 		if(cachedStringValue != null) return cachedStringValue;
 		return Integer.toString(val);
 	}
+	
+	public int getDefault(){
+		return defaultValue;
+	}
 
 	public boolean isDefault() {
 		getValue();

Modified: trunk/freenet/src/freenet/config/LongOption.java
===================================================================
--- trunk/freenet/src/freenet/config/LongOption.java	2007-03-06 16:16:57 UTC (rev 11995)
+++ trunk/freenet/src/freenet/config/LongOption.java	2007-03-06 16:53:37 UTC (rev 11996)
@@ -81,6 +81,10 @@
 		getValue();
 		return currentValue == defaultValue;
 	}
+	
+	public long getDefault() {
+		return defaultValue;
+	}
 
 	public void setDefault() {
 		currentValue = defaultValue;

Modified: trunk/freenet/src/freenet/config/Option.java
===================================================================
--- trunk/freenet/src/freenet/config/Option.java	2007-03-06 16:16:57 UTC (rev 11995)
+++ trunk/freenet/src/freenet/config/Option.java	2007-03-06 16:53:37 UTC (rev 11996)
@@ -78,7 +78,7 @@
 	 * Is this option set to the default?
 	 */
 	public abstract boolean isDefault();
-
+	
 	/** Set to the default. Don't use after completed initialization, as this does not call the callback. FIXME fix this? */
 	public abstract void setDefault();
 }

Modified: trunk/freenet/src/freenet/config/ShortOption.java
===================================================================
--- trunk/freenet/src/freenet/config/ShortOption.java	2007-03-06 16:16:57 UTC (rev 11995)
+++ trunk/freenet/src/freenet/config/ShortOption.java	2007-03-06 16:53:37 UTC (rev 11996)
@@ -55,6 +55,10 @@
 		return currentValue == defaultValue;
 	}
 	
+	public short getDefault() {
+		return defaultValue;
+	}
+	
 	public void setDefault() {
 		currentValue = defaultValue;
 	}

Modified: trunk/freenet/src/freenet/config/StringArrOption.java
===================================================================
--- trunk/freenet/src/freenet/config/StringArrOption.java	2007-03-06 16:16:57 UTC (rev 11995)
+++ trunk/freenet/src/freenet/config/StringArrOption.java	2007-03-06 16:53:37 UTC (rev 11996)
@@ -96,7 +96,7 @@
 		}
 	}
 
-	public String[] getDefaultValue() {
+	public String[] getDefault() {
 		return defaultValue;
 	}
 

Modified: trunk/freenet/src/freenet/config/StringOption.java
===================================================================
--- trunk/freenet/src/freenet/config/StringOption.java	2007-03-06 16:16:57 UTC (rev 11995)
+++ trunk/freenet/src/freenet/config/StringOption.java	2007-03-06 16:53:37 UTC (rev 11996)
@@ -49,4 +49,8 @@
 		currentValue = defaultValue;
 	}
 	
+	public String getDefault(){
+		return defaultValue;
+	}
+	
 }

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java	2007-03-06 16:16:57 UTC (rev 11995)
+++ trunk/freenet/src/freenet/node/Node.java	2007-03-06 16:53:37 UTC (rev 11996)
@@ -41,6 +41,7 @@
 import freenet.client.FetchContext;
 import freenet.config.FreenetFilePersistentConfig;
 import freenet.config.InvalidConfigValueException;
+import freenet.config.LongOption;
 import freenet.config.PersistentConfig;
 import freenet.config.SubConfig;
 import freenet.crypt.DSA;
@@ -1313,8 +1314,14 @@
 			}
 			
 		});
-		
+
 		databaseMaxMemory = nodeConfig.getLong("databaseMaxMemory");
+		// see #1202
+		if(databaseMaxMemory > (80 * Runtime.getRuntime().maxMemory() / 100)){
+			Logger.error(this, "The databaseMemory setting is set too high " + databaseMaxMemory +
+					" ... let's assume it's not what the user wants to do and restore the default.");
+			databaseMaxMemory = ((LongOption) nodeConfig.getOption("databaseMaxMemory")).getDefault();
+		}
 		envMutableConfig.setCacheSize(databaseMaxMemory);
 		// http://www.oracle.com/technology/products/berkeley-db/faq/je_faq.html#35
 		// FIXME is this the correct place to set these parameters?




More information about the cvs mailing list