Author: toad
Date: 2008-02-07 14:58:09 +0000 (Thu, 07 Feb 2008)
New Revision: 17661

Modified:
   trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/NodeStarter.java
   trunk/freenet/src/freenet/node/simulator/RealNodePingTest.java
   trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
   trunk/freenet/src/freenet/node/simulator/RealNodeRoutingTest.java
   trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java
Log:
Node.storeType - can be "bdb-index" (BDB index, as now), or "ram". The latter 
stores everything including the data in RAM, and disables any size limits.
Use it in one-VM-many-nodes tests.

Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-02-07 
14:37:39 UTC (rev 17660)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-02-07 
14:58:09 UTC (rev 17661)
@@ -636,6 +636,8 @@
 Node.storeMaxMemTooHigh=Giving more than 80% of your ram to BDB is probably 
not what you want to do!
 Node.storeSize=Store size in bytes
 Node.storeSizeLong=Store size in bytes
+Node.storeType=Store type (LEAVE THIS ALONE)
+Node.storeTypeLong=Datastore type. Currently this can be bdb-index (use a 
BerkeleyDBFreenetStore to store the index, and keep the data in files on disk), 
or ram (keep the index and the data in RAM). Only use ram if you know what you 
are doing and have enough RAM to store all your data!
 Node.swapRInterval=Swap request send interval (ms)
 Node.swapRIntervalLong=Interval between swap attempting to send swap requests 
in milliseconds. Leave this alone!
 NodeClientCore.couldNotFindOrCreateDir=Could not find or create directory

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2008-02-07 14:37:39 UTC (rev 
17660)
+++ trunk/freenet/src/freenet/node/Node.java    2008-02-07 14:58:09 UTC (rev 
17661)
@@ -89,6 +89,7 @@
 import freenet.store.FreenetStore;
 import freenet.store.KeyCollisionException;
 import freenet.store.PubkeyStore;
+import freenet.store.RAMFreenetStore;
 import freenet.store.SSKStore;
 import freenet.support.DoubleTokenBucket;
 import freenet.support.Executor;
@@ -164,6 +165,29 @@
                }
        }

+       private class StoreTypeCallback implements StringCallback, 
EnumerableOptionCallback {
+
+               public String get() {
+                       return storeType;
+               }
+
+               public void set(String val) throws InvalidConfigValueException {
+                       throw new InvalidConfigValueException("Store type 
cannot be changed on the fly");
+               }
+
+               public String[] getPossibleValues() {
+                       return new String[] {
+                                       "bdb-index",
+                                       "ram"
+                       };
+               }
+
+               public void setPossibleValues(String[] val) {
+                       throw new UnsupportedOperationException();
+               }
+               
+       }
+       
        private static class L10nCallback implements StringCallback, 
EnumerableOptionCallback {

                public String get() {
@@ -254,6 +278,8 @@

        /** Datastore directory */
        private final File storeDir;
+       
+       private final String storeType;

        /** The number of bytes per key total in all the different datastores. 
All the datastores
         * are always the same size in number of keys. */
@@ -1059,6 +1085,10 @@

                });

+               nodeConfig.register("storeType", "bdb-index", sortOrder++, 
true, false, "Node.storeType", "Node.storeTypeLong", new StoreTypeCallback());
+               
+               storeType = nodeConfig.getString("storeType");
+               
                nodeConfig.register("storeSize", "1G", sortOrder++, false, 
true, "Node.storeSize", "Node.storeSizeLong", 
                                new LongCallback() {

@@ -1103,7 +1133,7 @@

                maxTotalDatastoreSize = nodeConfig.getLong("storeSize");

-               if(maxTotalDatastoreSize < 0 || maxTotalDatastoreSize < (32 * 
1024 * 1024)) { // totally arbitrary minimum!
+               if(maxTotalDatastoreSize < 0 || maxTotalDatastoreSize < (32 * 
1024 * 1024) && !storeType.equals("ram")) { // totally arbitrary minimum!
                        throw new 
NodeInitException(NodeInitException.EXIT_INVALID_STORE_SIZE, "Invalid store 
size");
                }

@@ -1120,7 +1150,7 @@
                                                throw new 
InvalidConfigValueException("Moving datastore on the fly not supported at 
present");
                                        }
                });
-               
+
                final String suffix = "-" + getDarknetPortNumber();
                String datastoreDir = nodeConfig.getString("storeDir");
                // FIXME: temporary cludge for backward compat.
@@ -1189,6 +1219,8 @@
                maxStoreKeys = maxTotalKeys / 2;
                maxCacheKeys = maxTotalKeys - maxStoreKeys;

+               if(storeType.equals("bdb-index")) {
+               
                // Setup datastores

                // First, global settings
@@ -1455,6 +1487,24 @@
                        throw new 
NodeInitException(NodeInitException.EXIT_STORE_RECONSTRUCT, msg);
                }

+               } else {
+                       chkDatastore = new CHKStore();
+                       new RAMFreenetStore(chkDatastore, (int) 
Math.min(Integer.MAX_VALUE, maxStoreKeys));
+                       chkDatacache = new CHKStore();
+                       new RAMFreenetStore(chkDatacache, (int) 
Math.min(Integer.MAX_VALUE, maxCacheKeys));
+                       pubKeyDatastore = new PubkeyStore();
+                       new RAMFreenetStore(pubKeyDatastore, (int) 
Math.min(Integer.MAX_VALUE, maxStoreKeys));
+                       pubKeyDatacache = new PubkeyStore();
+                       new RAMFreenetStore(pubKeyDatacache, (int) 
Math.min(Integer.MAX_VALUE, maxCacheKeys));
+                       sskDatastore = new SSKStore(this);
+                       new RAMFreenetStore(sskDatastore, (int) 
Math.min(Integer.MAX_VALUE, maxStoreKeys));
+                       sskDatacache = new SSKStore(this);
+                       new RAMFreenetStore(sskDatacache, (int) 
Math.min(Integer.MAX_VALUE, maxCacheKeys));
+                       storeShutdownHook = null;
+                       envMutableConfig = null;
+                       this.storeEnvironment = null;
+               }
+               
                // FIXME back compatibility
                SimpleFieldSet oldThrottleFS = null;
                File oldThrottle = new File("throttle.dat");

Modified: trunk/freenet/src/freenet/node/NodeStarter.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeStarter.java     2008-02-07 14:37:39 UTC 
(rev 17660)
+++ trunk/freenet/src/freenet/node/NodeStarter.java     2008-02-07 14:58:09 UTC 
(rev 17661)
@@ -335,7 +335,8 @@
         */
        public static Node createTestNode(int port, String testName, boolean 
doClient, 
                        boolean doSwapping, boolean disableProbabilisticHTLs, 
short maxHTL,
-                       int dropProb, RandomSource random, Executor executor, 
int threadLimit) throws NodeInitException {
+                       int dropProb, RandomSource random, Executor executor, 
int threadLimit, 
+                       long storeSize, boolean ramStore) throws 
NodeInitException {

                File baseDir = new File(testName);
                File portDir = new File(baseDir, Integer.toString(port));
@@ -364,6 +365,9 @@
                configFS.put("node.includeLocalAddressesInNoderefs", true);
                configFS.put("node.enableARKs", false);
                configFS.put("node.threadLimit", threadLimit);
+               if(ramStore) 
+                       configFS.putSingle("node.storeType", "ram");
+               configFS.put("storeSize", storeSize);

                PersistentConfig config = new PersistentConfig(configFS);


Modified: trunk/freenet/src/freenet/node/simulator/RealNodePingTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodePingTest.java      
2008-02-07 14:37:39 UTC (rev 17660)
+++ trunk/freenet/src/freenet/node/simulator/RealNodePingTest.java      
2008-02-07 14:58:09 UTC (rev 17661)
@@ -33,8 +33,8 @@
         RandomSource random = NodeStarter.globalTestInit("pingtest");
         // Create 2 nodes
         Executor executor = new PooledExecutor();
-        Node node1 = NodeStarter.createTestNode(5001, "pingtest", false, 
false, true, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000);
-        Node node2 = NodeStarter.createTestNode(5002, "pingtest", false, 
false, true, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000);
+        Node node1 = NodeStarter.createTestNode(5001, "pingtest", false, 
false, true, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000, 65536, true);
+        Node node2 = NodeStarter.createTestNode(5002, "pingtest", false, 
false, true, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000, 65536, true);
         // Connect
         node1.connect(node2);
         node2.connect(node1);

Modified: 
trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java     
2008-02-07 14:37:39 UTC (rev 17660)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java     
2008-02-07 14:58:09 UTC (rev 17661)
@@ -56,7 +56,7 @@
         Executor executor = new PooledExecutor();
         for(int i=0;i<NUMBER_OF_NODES;i++) {
             nodes[i] = 
-               NodeStarter.createTestNode(5001+i, wd, false, true, true, 
MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES);
+               NodeStarter.createTestNode(5001+i, wd, false, true, true, 
MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES, 256*1024, true);
             Logger.normal(RealNodeRoutingTest.class, "Created node "+i);
             // Make the network immediately routable.
             // Comment out if we want to include a routing/swapping test as 
well.

Modified: trunk/freenet/src/freenet/node/simulator/RealNodeRoutingTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeRoutingTest.java   
2008-02-07 14:37:39 UTC (rev 17660)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeRoutingTest.java   
2008-02-07 14:58:09 UTC (rev 17661)
@@ -48,7 +48,7 @@
         Executor executor = new PooledExecutor();
         for(int i=0;i<NUMBER_OF_NODES;i++) {
             nodes[i] = 
-               NodeStarter.createTestNode(5001+i, wd, false, true, true, 
MAX_HTL, 0 /* no dropped packets */, random, executor, 500*NUMBER_OF_NODES);
+               NodeStarter.createTestNode(5001+i, wd, false, true, true, 
MAX_HTL, 0 /* no dropped packets */, random, executor, 500*NUMBER_OF_NODES, 
65536, true);
             Logger.normal(RealNodeRoutingTest.class, "Created node "+i);
         }
         Logger.normal(RealNodeRoutingTest.class, "Created "+NUMBER_OF_NODES+" 
nodes");

Modified: trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java      
2008-02-07 14:37:39 UTC (rev 17660)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java      
2008-02-07 14:58:09 UTC (rev 17661)
@@ -79,7 +79,7 @@
         Executor executor = new PooledExecutor();
         for(int i=0;i<NUMBER_OF_NODES;i++) {
             nodes[i] = 
-               NodeStarter.createTestNode(5000+i, testName, false, true, true, 
MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES);
+               NodeStarter.createTestNode(5000+i, testName, false, true, true, 
MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES, 1024*1024, true);
             Logger.normal(RealNodeRoutingTest.class, "Created node "+i);
         }
         SimpleFieldSet refs[] = new SimpleFieldSet[NUMBER_OF_NODES];


Reply via email to