Author: toad
Date: 2008-09-25 23:03:35 +0000 (Thu, 25 Sep 2008)
New Revision: 22841
Modified:
trunk/freenet/src/freenet/node/Node.java
Log:
On unix other than OS/X, set preallocate to false on physical threat level low,
to true on physical threat level normal.
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2008-09-25 22:55:43 UTC (rev
22840)
+++ trunk/freenet/src/freenet/node/Node.java 2008-09-25 23:03:35 UTC (rev
22841)
@@ -78,6 +78,7 @@
import freenet.node.NodeDispatcher.NodeDispatcherCallback;
import freenet.node.SecurityLevels.FRIENDS_THREAT_LEVEL;
import freenet.node.SecurityLevels.NETWORK_THREAT_LEVEL;
+import freenet.node.SecurityLevels.PHYSICAL_THREAT_LEVEL;
import freenet.node.updater.NodeUpdateManager;
import freenet.node.useralerts.AbstractUserAlert;
import freenet.node.useralerts.BuildOldAgeUserAlert;
@@ -651,7 +652,7 @@
startupTime = System.currentTimeMillis();
SimpleFieldSet oldConfig = config.getSimpleFieldSet();
// Setup node-specific configuration
- SubConfig nodeConfig = new SubConfig("node", config);
+ final SubConfig nodeConfig = new SubConfig("node", config);
int sortOrder = 0;
@@ -1600,6 +1601,25 @@
maxStoreKeys = maxTotalKeys / 2;
maxCacheKeys = maxTotalKeys - maxStoreKeys;
+ if(File.separatorChar == '/' &&
System.getProperty("os.name").toLowerCase().indexOf("mac os") < 0) {
+ securityLevels.addPhysicalThreatLevelListener(new
SecurityLevelListener<SecurityLevels.PHYSICAL_THREAT_LEVEL>() {
+
+ public void onChange(PHYSICAL_THREAT_LEVEL
oldLevel, PHYSICAL_THREAT_LEVEL newLevel) {
+ try {
+ if(newLevel ==
PHYSICAL_THREAT_LEVEL.LOW)
+
nodeConfig.set("storePreallocate", false);
+ else
+
nodeConfig.set("storePreallocate", true);
+ } catch (NodeNeedRestartException e) {
+ // Ignore
+ } catch (InvalidConfigValueException e)
{
+ // Ignore
+ }
+ }
+
+ });
+ }
+
/*
* On Windows, setting the file length normally involves
writing lots of zeros.
* So it's an uninterruptible system call that takes a loooong
time. On OS/X,