" />
+
diff --git a/core/java/src/net/i2p/crypto/AESInputStream.java b/core/java/test/net/i2p/crypto/AESInputStream.java
similarity index 100%
rename from core/java/src/net/i2p/crypto/AESInputStream.java
rename to core/java/test/net/i2p/crypto/AESInputStream.java
diff --git a/core/java/src/net/i2p/crypto/AESOutputStream.java b/core/java/test/net/i2p/crypto/AESOutputStream.java
similarity index 100%
rename from core/java/src/net/i2p/crypto/AESOutputStream.java
rename to core/java/test/net/i2p/crypto/AESOutputStream.java
diff --git a/history.txt b/history.txt
index ba49a9f94..edf31ea7f 100644
--- a/history.txt
+++ b/history.txt
@@ -1,3 +1,17 @@
+2009-10-16 zzz
+ * Crypto: Two more test classes out of the lib
+ * FloodfillMonitor: Slow down the volunteers again
+ * oldconsole.jsp: Remove almost all of it, add lines for tino
+ * MessageHistory: Cleanups
+ * NetDb: Rework part 1 of N:
+ - Flood only to those closest to the key
+ - Java 5 fixups
+ * ProfileOrganizerRenderer:
+ - Move to routerconsole
+ - Write directly to Writer for speed
+ * Router: Add router.hideFloodfillParticipant option for testing
+ * StatisticsManager: Cleanup after release
+
* 2009-10-12 0.7.7 released
2009-10-11 zzz
diff --git a/hosts.txt b/hosts.txt
index 4b0427a17..475a26cce 100644
--- a/hosts.txt
+++ b/hosts.txt
@@ -319,3 +319,5 @@ bob.i2p=5uAI6ENnNP8acDkAtYqBjLa-gFqM~uERNZdJBKtRwUvDkuXvIM66pYfYL3-ugTmoR-SIveDl
sponge.i2p=VG4Bd~q1RA3BdoF3z5fSR7p0xe1CTVgDMWVGyFchA9Wm2iXUkIR35G45XE31Uc9~IOt-ktNLL2~TYQZ13Vl8udosngDn8RJG1NtVASH4khsbgkkoFLWd6UuvuOjQKBFKjaEPJgxOzh0kxolRPPNHhFuuAGzNLKvz~LI2MTf0P6nwmRg1lBoRIUpSVocEHY4X306nT2VtY07FixbJcPCU~EeRin24yNoiZop-C3Wi1SGwJJK-NS7mnkNzd8ngDJXDJtR-wLP1vNyyBY6NySgqPiIhENHoVeX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B8HC9CbnsMJjPEFT6gvvtSpxULvSQGSJyD6OIzebXvQIYANAapEk1VP1OSIJlteOIwGDXkGj9ZyLpT7~RpUpk92v9L53Zjof~WjJmGqqWWsL~yypl0~nMUw5MLaKv5AJywDnFIJDR-GlkQQj5fECeefge30Y92CHwxgImwj3v7~DwXuU9d5u6KyzJSuByOGRvwVAAAA
diff --git a/news.xml b/news.xml
index 24fe7efbb..7f0fd04f3 100644
--- a/news.xml
+++ b/news.xml
@@ -23,7 +23,7 @@ number of session keys transferred, by improving the
methods of dropping messages during overload, and by reducing
drops by high-bandwidth routers.
There is a new unsigned update option
-for those of you that would like automatic udpates to bleeding-edge development versions.
+for those of you that would like automatic updates to bleeding-edge development versions.
The release also contains several changes to reduce memory and CPU usage,
and a large assortment of bug fixes.
diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java
index 6e52f2bc5..3e9a6cc66 100644
--- a/router/java/src/net/i2p/router/Router.java
+++ b/router/java/src/net/i2p/router/Router.java
@@ -463,14 +463,15 @@ public class Router {
ri.addCapability(CAPABILITY_BW256);
}
- if (FloodfillNetworkDatabaseFacade.floodfillEnabled(_context))
+ // if prop set to true, don't tell people we are ff even if we are
+ if (FloodfillNetworkDatabaseFacade.floodfillEnabled(_context) &&
+ !Boolean.valueOf(_context.getProperty("router.hideFloodfillParticipant")).booleanValue())
ri.addCapability(FloodfillNetworkDatabaseFacade.CAPACITY_FLOODFILL);
- if("true".equalsIgnoreCase(_context.getProperty(Router.PROP_HIDDEN, "false")))
+ if(Boolean.valueOf(_context.getProperty(PROP_HIDDEN)).booleanValue())
ri.addCapability(RouterInfo.CAPABILITY_HIDDEN);
- String forceUnreachable = _context.getProperty(PROP_FORCE_UNREACHABLE);
- if ( (forceUnreachable != null) && ("true".equalsIgnoreCase(forceUnreachable)) ) {
+ if (Boolean.valueOf(_context.getProperty(PROP_FORCE_UNREACHABLE)).booleanValue()) {
ri.addCapability(CAPABILITY_UNREACHABLE);
return;
}
@@ -582,7 +583,13 @@ public class Router {
//_context.inNetMessagePool().registerHandlerJobBuilder(TunnelMessage.MESSAGE_TYPE, new TunnelMessageHandler(_context));
}
+ /**
+ * this is for oldconsole.jsp, pretty much unused except as a way to get memory info,
+ * so let's comment out the rest, it is available elsewhere, and we don't really
+ * want to spend a minute rendering a multi-megabyte page in memory.
+ */
public void renderStatusHTML(Writer out) throws IOException {
+/****************
out.write("
Router console
\n" +
"console | stats
\n" +
"" +
"
\n");
+**************/
- StringBuilder buf = new StringBuilder(32*1024);
+ StringBuilder buf = new StringBuilder(4*1024);
+ // Please don't change the text or formatting, tino matches it in his scripts
if ( (_routerInfo != null) && (_routerInfo.getIdentity() != null) )
buf.append("Router: ").append(_routerInfo.getIdentity().getHash().toBase64()).append("
\n");
- buf.append("As of: ").append(new Date(_context.clock().now())).append(" (uptime: ").append(DataHelper.formatDuration(getUptime())).append(")
\n");
+ buf.append("As of: ").append(new Date(_context.clock().now())).append("
\n");
+ buf.append("RouterUptime: " ).append(DataHelper.formatDuration(getUptime())).append("
\n");
buf.append("Started on: ").append(new Date(getWhenStarted())).append("
\n");
buf.append("Clock offset: ").append(_context.clock().getOffset()).append("ms (OS time: ").append(new Date(_context.clock().now() - _context.clock().getOffset())).append(")
\n");
+ buf.append("RouterVersion: ").append(RouterVersion.FULL_VERSION).append(" / SDK: ").append(CoreVersion.VERSION).append("
\n");
long tot = Runtime.getRuntime().totalMemory()/1024;
long free = Runtime.getRuntime().freeMemory()/1024;
buf.append("Memory: In use: ").append((tot-free)).append("KB Free: ").append(free).append("KB
\n");
- buf.append("Version: Router: ").append(RouterVersion.VERSION).append(" / SDK: ").append(CoreVersion.VERSION).append("
\n");
if (_higherVersionSeen)
buf.append("HIGHER VERSION SEEN - please check to see if there is a new release out
\n");
+/*********
buf.append("
Bandwidth
\n");
long sent = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes();
long received = _context.bandwidthLimiter().getTotalAllocatedInboundBytes();
@@ -768,6 +779,7 @@ public class Router {
buf.append("\n");
}
buf.append("\n");
+***********/
out.write(buf.toString());
out.flush();
}
diff --git a/router/java/src/net/i2p/router/StatisticsManager.java b/router/java/src/net/i2p/router/StatisticsManager.java
index 86b0ee113..03afd73b0 100644
--- a/router/java/src/net/i2p/router/StatisticsManager.java
+++ b/router/java/src/net/i2p/router/StatisticsManager.java
@@ -122,8 +122,7 @@ public class StatisticsManager implements Service {
//includeRate("jobQueue.jobRunSlow", stats, new long[] { 10*60*1000l, 60*60*1000l });
//includeRate("crypto.elGamal.encrypt", stats, new long[] { 60*60*1000 });
// total event count can be used to track uptime
- boolean hideTotals = ! RouterVersion.VERSION.equals("0.7.6");
- includeRate("tunnel.participatingTunnels", stats, new long[] { 60*60*1000 }, hideTotals);
+ includeRate("tunnel.participatingTunnels", stats, new long[] { 60*60*1000 }, true);
//includeRate("tunnel.testSuccessTime", stats, new long[] { 10*60*1000l });
//includeRate("client.sendAckTime", stats, new long[] { 60*60*1000 }, true);
//includeRate("udp.sendConfirmTime", stats, new long[] { 10*60*1000 });
diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillMonitorJob.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillMonitorJob.java
index a1a74fc86..24d27c27a 100644
--- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillMonitorJob.java
+++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillMonitorJob.java
@@ -50,7 +50,7 @@ class FloodfillMonitorJob extends JobImpl {
// there's a lot of eligible non-floodfills, keep them from all jumping in at once
// To do: somehow assess the size of the network to make this adaptive?
if (!ff)
- delay *= 3;
+ delay *= 7;
requeue(delay);
}
diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java
index 2b8659c69..bb34f8dc6 100644
--- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java
+++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java
@@ -94,9 +94,22 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
}
}
+ private static final int MAX_TO_FLOOD = 9;
+
+ /**
+ * Send to a subset of all floodfill peers.
+ * We do this to implement Kademlia within the floodfills, i.e.
+ * we flood to those closest to the key.
+ */
public void flood(DataStructure ds) {
+ Hash key;
+ if (ds instanceof LeaseSet)
+ key = ((LeaseSet)ds).getDestination().calculateHash();
+ else
+ key = ((RouterInfo)ds).getIdentity().calculateHash();
+ Hash rkey = _context.routingKeyGenerator().getRoutingKey(key);
FloodfillPeerSelector sel = (FloodfillPeerSelector)getPeerSelector();
- List peers = sel.selectFloodfillParticipants(getKBuckets());
+ List peers = sel.selectFloodfillParticipants(rkey, MAX_TO_FLOOD, getKBuckets());
int flooded = 0;
for (int i = 0; i < peers.size(); i++) {
Hash peer = (Hash)peers.get(i);
@@ -107,12 +120,11 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
continue;
DatabaseStoreMessage msg = new DatabaseStoreMessage(_context);
if (ds instanceof LeaseSet) {
- msg.setKey(((LeaseSet)ds).getDestination().calculateHash());
msg.setLeaseSet((LeaseSet)ds);
} else {
- msg.setKey(((RouterInfo)ds).getIdentity().calculateHash());
msg.setRouterInfo((RouterInfo)ds);
}
+ msg.setKey(key);
msg.setReplyGateway(null);
msg.setReplyToken(0);
msg.setReplyTunnel(null);
@@ -125,11 +137,11 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
_context.commSystem().processMessage(m);
flooded++;
if (_log.shouldLog(Log.INFO))
- _log.info("Flooding the entry for " + msg.getKey().toBase64() + " to " + peer.toBase64());
+ _log.info("Flooding the entry for " + key.toBase64() + " to " + peer.toBase64());
}
if (_log.shouldLog(Log.INFO))
- _log.info("Flooded the to " + flooded + " peers");
+ _log.info("Flooded the data to " + flooded + " of " + peers.size() + " peers");
}
private static final int FLOOD_PRIORITY = 200;
diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillPeerSelector.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillPeerSelector.java
index d051460a2..0aa672587 100644
--- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillPeerSelector.java
+++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillPeerSelector.java
@@ -32,16 +32,16 @@ class FloodfillPeerSelector extends PeerSelector {
* @return List of Hash for the peers selected
*/
@Override
- public List selectMostReliablePeers(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets) {
+ public List selectMostReliablePeers(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets) {
return selectNearestExplicitThin(key, maxNumRouters, peersToIgnore, kbuckets, true);
}
@Override
- public List selectNearestExplicitThin(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets) {
+ public List selectNearestExplicitThin(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets) {
return selectNearestExplicitThin(key, maxNumRouters, peersToIgnore, kbuckets, false);
}
- public List selectNearestExplicitThin(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets, boolean preferConnected) {
+ public List selectNearestExplicitThin(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets, boolean preferConnected) {
if (peersToIgnore == null)
peersToIgnore = new HashSet(1);
peersToIgnore.add(_context.routerHash());
@@ -56,30 +56,55 @@ class FloodfillPeerSelector extends PeerSelector {
return rv;
}
- /** Returned list will not include our own hash */
- public List selectFloodfillParticipants(KBucketSet kbuckets) {
+ /**
+ * @return all floodfills not shitlisted forever. list will not include our own hash
+ *
+ */
+ public List selectFloodfillParticipants(KBucketSet kbuckets) {
if (kbuckets == null) return new ArrayList();
FloodfillSelectionCollector matches = new FloodfillSelectionCollector(null, null, 0);
kbuckets.getAll(matches);
return matches.getFloodfillParticipants();
}
+ /**
+ * @return all floodfills not shitlisted foreverx
+ * @param maxNumRouters max to return
+ * Sorted by closest to the key if > maxNumRouters, otherwise not
+ */
+ public List selectFloodfillParticipants(Hash key, int maxNumRouters, KBucketSet kbuckets) {
+ List ffs = selectFloodfillParticipants(kbuckets);
+ if (ffs.size() <= maxNumRouters)
+ return ffs; // unsorted
+ TreeMap sorted = new TreeMap();
+ for (int i = 0; i < ffs.size(); i++) {
+ Hash h = ffs.get(i);
+ BigInteger diff = getDistance(key, h);
+ sorted.put(diff, h);
+ }
+ List rv = new ArrayList(maxNumRouters);
+ for (int i = 0; i < maxNumRouters; i++) {
+ rv.add(sorted.remove(sorted.firstKey()));
+ }
+ return rv;
+ }
+
private class FloodfillSelectionCollector implements SelectionCollector {
- private TreeMap _sorted;
- private List _floodfillMatches;
+ private TreeMap _sorted;
+ private List _floodfillMatches;
private Hash _key;
- private Set _toIgnore;
+ private Set _toIgnore;
private int _matches;
private int _wanted;
- public FloodfillSelectionCollector(Hash key, Set toIgnore, int wanted) {
+ public FloodfillSelectionCollector(Hash key, Set toIgnore, int wanted) {
_key = key;
_sorted = new TreeMap();
- _floodfillMatches = new ArrayList(1);
+ _floodfillMatches = new ArrayList(8);
_toIgnore = toIgnore;
_matches = 0;
_wanted = wanted;
}
- public List getFloodfillParticipants() { return _floodfillMatches; }
+ public List getFloodfillParticipants() { return _floodfillMatches; }
private static final int EXTRA_MATCHES = 100;
public void add(Hash entry) {
//if (_context.profileOrganizer().isFailing(entry))
@@ -115,15 +140,15 @@ class FloodfillPeerSelector extends PeerSelector {
_matches++;
}
/** get the first $howMany entries matching */
- public List get(int howMany) {
+ public List get(int howMany) {
return get(howMany, false);
}
- public List get(int howMany, boolean preferConnected) {
+ public List get(int howMany, boolean preferConnected) {
Collections.shuffle(_floodfillMatches, _context.random());
- List rv = new ArrayList(howMany);
- List badff = new ArrayList(howMany);
- List unconnectedff = new ArrayList(howMany);
+ List rv = new ArrayList(howMany);
+ List badff = new ArrayList(howMany);
+ List unconnectedff = new ArrayList(howMany);
int found = 0;
long now = _context.clock().now();
// Only add in "good" floodfills here...
diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillStoreJob.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillStoreJob.java
index 3279f437c..2c9eeb5b6 100644
--- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillStoreJob.java
+++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillStoreJob.java
@@ -17,10 +17,14 @@ import net.i2p.data.RouterInfo;
import net.i2p.router.Job;
import net.i2p.router.RouterContext;
+/**
+ * This extends StoreJob to fire off a FloodfillVerifyStoreJob after success.
+ *
+ */
class FloodfillStoreJob extends StoreJob {
private FloodfillNetworkDatabaseFacade _facade;
/**
- * Create a new search for the routingKey specified
+ * Send a data structure to the floodfills
*
*/
public FloodfillStoreJob(RouterContext context, FloodfillNetworkDatabaseFacade facade, Hash key, DataStructure data, Job onSuccess, Job onFailure, long timeoutMs) {
@@ -31,7 +35,7 @@ class FloodfillStoreJob extends StoreJob {
* @param toSkip set of peer hashes of people we dont want to send the data to (e.g. we
* already know they have it). This can be null.
*/
- public FloodfillStoreJob(RouterContext context, FloodfillNetworkDatabaseFacade facade, Hash key, DataStructure data, Job onSuccess, Job onFailure, long timeoutMs, Set toSkip) {
+ public FloodfillStoreJob(RouterContext context, FloodfillNetworkDatabaseFacade facade, Hash key, DataStructure data, Job onSuccess, Job onFailure, long timeoutMs, Set toSkip) {
super(context, facade, key, data, onSuccess, onFailure, timeoutMs, toSkip);
_facade = facade;
}
diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/PeerSelector.java b/router/java/src/net/i2p/router/networkdb/kademlia/PeerSelector.java
index 328691b99..918465391 100644
--- a/router/java/src/net/i2p/router/networkdb/kademlia/PeerSelector.java
+++ b/router/java/src/net/i2p/router/networkdb/kademlia/PeerSelector.java
@@ -43,10 +43,9 @@ public class PeerSelector {
* @return ordered list of Hash objects
*/
/* FIXME Exporting non-public type through public API FIXME */
- public List selectMostReliablePeers(Hash key, int numClosest, Set alreadyChecked, KBucketSet kbuckets) {// LINT -- Exporting non-public type through public API
+ public List selectMostReliablePeers(Hash key, int numClosest, Set alreadyChecked, KBucketSet kbuckets) {// LINT -- Exporting non-public type through public API
// get the peers closest to the key
- List nearest = selectNearestExplicit(key, numClosest, alreadyChecked, kbuckets);
- return nearest;
+ return selectNearestExplicit(key, numClosest, alreadyChecked, kbuckets);
}
/**
@@ -57,10 +56,11 @@ public class PeerSelector {
* @return List of Hash for the peers selected, ordered by bucket (but intra bucket order is not defined)
*/
/* FIXME Exporting non-public type through public API FIXME */
- public List selectNearestExplicit(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets) {// LINT -- Exporting non-public type through public API
- if (true)
+ public List selectNearestExplicit(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets) {// LINT -- Exporting non-public type through public API
+ //if (true)
return selectNearestExplicitThin(key, maxNumRouters, peersToIgnore, kbuckets);
+/******
if (peersToIgnore == null)
peersToIgnore = new HashSet(1);
peersToIgnore.add(_context.routerHash());
@@ -84,6 +84,7 @@ public class PeerSelector {
+ peerHashes + " (not including " + peersToIgnore + ") [allHashes.size = "
+ allHashes.size() + "]");
return peerHashes;
+******/
}
/**
@@ -94,7 +95,7 @@ public class PeerSelector {
* @return List of Hash for the peers selected, ordered by bucket (but intra bucket order is not defined)
*/
/* FIXME Exporting non-public type through public API FIXME */
- public List selectNearestExplicitThin(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets) { // LINT -- Exporting non-public type through public API
+ public List selectNearestExplicitThin(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets) { // LINT -- Exporting non-public type through public API
if (peersToIgnore == null)
peersToIgnore = new HashSet(1);
peersToIgnore.add(_context.routerHash());
@@ -109,11 +110,11 @@ public class PeerSelector {
}
private class MatchSelectionCollector implements SelectionCollector {
- private TreeMap _sorted;
+ private TreeMap _sorted;
private Hash _key;
- private Set _toIgnore;
+ private Set _toIgnore;
private int _matches;
- public MatchSelectionCollector(Hash key, Set toIgnore) {
+ public MatchSelectionCollector(Hash key, Set toIgnore) {
_key = key;
_sorted = new TreeMap();
_toIgnore = toIgnore;
@@ -135,8 +136,8 @@ public class PeerSelector {
_matches++;
}
/** get the first $howMany entries matching */
- public List get(int howMany) {
- List rv = new ArrayList(howMany);
+ public List get(int howMany) {
+ List rv = new ArrayList(howMany);
for (int i = 0; i < howMany; i++) {
if (_sorted.size() <= 0)
break;
@@ -151,6 +152,7 @@ public class PeerSelector {
* strip out all of the peers that are failing
*
*/
+/********
private void removeFailingPeers(Set peerHashes) {
List failing = null;
for (Iterator iter = peerHashes.iterator(); iter.hasNext(); ) {
@@ -184,6 +186,7 @@ public class PeerSelector {
if (failing != null)
peerHashes.removeAll(failing);
}
+**********/
public static BigInteger getDistance(Hash targetKey, Hash routerInQuestion) {
// plain XOR of the key and router
@@ -199,7 +202,7 @@ public class PeerSelector {
* @return List of Hash for the peers selected, ordered by bucket (but intra bucket order is not defined)
*/
/* FIXME Exporting non-public type through public API FIXME */
- public List selectNearest(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets) { // LINT -- Exporting non-public type through public API
+ public List selectNearest(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets) { // LINT -- Exporting non-public type through public API
// sure, this may not be exactly correct per kademlia (peers on the border of a kbucket in strict kademlia
// would behave differently) but I can see no reason to keep around an /additional/ more complicated algorithm.
// later if/when selectNearestExplicit gets costly, we may revisit this (since kbuckets let us cache the distance()
diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java b/router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java
index cc4c51329..af3ba2b27 100644
--- a/router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java
+++ b/router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java
@@ -56,7 +56,7 @@ class StoreJob extends JobImpl {
private final static int STORE_PRIORITY = 100;
/**
- * Create a new search for the routingKey specified
+ * Send a data structure to the floodfills
*
*/
public StoreJob(RouterContext context, KademliaNetworkDatabaseFacade facade, Hash key,
@@ -69,7 +69,7 @@ class StoreJob extends JobImpl {
* already know they have it). This can be null.
*/
public StoreJob(RouterContext context, KademliaNetworkDatabaseFacade facade, Hash key,
- DataStructure data, Job onSuccess, Job onFailure, long timeoutMs, Set toSkip) {
+ DataStructure data, Job onSuccess, Job onFailure, long timeoutMs, Set toSkip) {
super(context);
_log = context.logManager().getLog(StoreJob.class);
getContext().statManager().createRateStat("netDb.storeRouterInfoSent", "How many routerInfo store messages have we sent?", "NetworkDatabase", new long[] { 5*60*1000l, 60*60*1000l, 24*60*60*1000l });
@@ -146,7 +146,7 @@ class StoreJob extends JobImpl {
// This will help minimize active connections for floodfill peers and allow
// the network to scale.
// Perhaps the ultimate solution is to send RouterInfos through a lease also.
- List closestHashes;
+ List closestHashes;
if (_state.getData() instanceof RouterInfo)
closestHashes = getMostReliableRouters(_state.getTarget(), toCheck, _state.getAttempted());
else
@@ -165,8 +165,8 @@ class StoreJob extends JobImpl {
//_state.addPending(closestHashes);
if (_log.shouldLog(Log.INFO))
_log.info(getJobId() + ": Continue sending key " + _state.getTarget() + " after " + _state.getAttempted().size() + " tries to " + closestHashes);
- for (Iterator iter = closestHashes.iterator(); iter.hasNext(); ) {
- Hash peer = (Hash)iter.next();
+ for (Iterator iter = closestHashes.iterator(); iter.hasNext(); ) {
+ Hash peer = iter.next();
DataStructure ds = _facade.getDataStore().get(peer);
if ( (ds == null) || !(ds instanceof RouterInfo) ) {
if (_log.shouldLog(Log.INFO))
@@ -215,7 +215,7 @@ class StoreJob extends JobImpl {
*
* @return ordered list of Hash objects
*/
- private List getClosestRouters(Hash key, int numClosest, Set alreadyChecked) {
+ private List getClosestRouters(Hash key, int numClosest, Set alreadyChecked) {
Hash rkey = getContext().routingKeyGenerator().getRoutingKey(key);
//if (_log.shouldLog(Log.DEBUG))
// _log.debug(getJobId() + ": Current routing key for " + key + ": " + rkey);
@@ -225,7 +225,7 @@ class StoreJob extends JobImpl {
return _peerSelector.selectNearestExplicit(rkey, numClosest, alreadyChecked, ks);
}
- private List getMostReliableRouters(Hash key, int numClosest, Set alreadyChecked) {
+ private List getMostReliableRouters(Hash key, int numClosest, Set alreadyChecked) {
Hash rkey = getContext().routingKeyGenerator().getRoutingKey(key);
KBucketSet ks = _facade.getKBuckets();
if (ks == null) return new ArrayList();
diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/StoreState.java b/router/java/src/net/i2p/router/networkdb/kademlia/StoreState.java
index 91e7687ba..eaa51edb0 100644
--- a/router/java/src/net/i2p/router/networkdb/kademlia/StoreState.java
+++ b/router/java/src/net/i2p/router/networkdb/kademlia/StoreState.java
@@ -15,12 +15,12 @@ class StoreState {
private RouterContext _context;
private Hash _key;
private DataStructure _data;
- private final HashSet _pendingPeers;
- private HashMap _pendingPeerTimes;
- private final HashSet _successfulPeers;
- private final HashSet _successfulExploratoryPeers;
- private final HashSet _failedPeers;
- private final HashSet _attemptedPeers;
+ private final HashSet _pendingPeers;
+ private HashMap _pendingPeerTimes;
+ private final HashSet _successfulPeers;
+ private final HashSet _successfulExploratoryPeers;
+ private final HashSet _failedPeers;
+ private final HashSet _attemptedPeers;
private int _completeCount;
private volatile long _completed;
private volatile long _started;
@@ -28,7 +28,7 @@ class StoreState {
public StoreState(RouterContext ctx, Hash key, DataStructure data) {
this(ctx, key, data, null);
}
- public StoreState(RouterContext ctx, Hash key, DataStructure data, Set toSkip) {
+ public StoreState(RouterContext ctx, Hash key, DataStructure data, Set toSkip) {
_context = ctx;
_key = key;
_data = data;
@@ -48,29 +48,29 @@ class StoreState {
public Hash getTarget() { return _key; }
public DataStructure getData() { return _data; }
- public Set getPending() {
+ public Set getPending() {
synchronized (_pendingPeers) {
- return (Set)_pendingPeers.clone();
+ return (Set)_pendingPeers.clone();
}
}
- public Set getAttempted() {
+ public Set getAttempted() {
synchronized (_attemptedPeers) {
- return (Set)_attemptedPeers.clone();
+ return (Set)_attemptedPeers.clone();
}
}
- public Set getSuccessful() {
+ public Set getSuccessful() {
synchronized (_successfulPeers) {
- return (Set)_successfulPeers.clone();
+ return (Set)_successfulPeers.clone();
}
}
- public Set getSuccessfulExploratory() {
+ public Set getSuccessfulExploratory() {
synchronized (_successfulExploratoryPeers) {
- return (Set)_successfulExploratoryPeers.clone();
+ return (Set)_successfulExploratoryPeers.clone();
}
}
- public Set getFailed() {
+ public Set getFailed() {
synchronized (_failedPeers) {
- return (Set)_failedPeers.clone();
+ return (Set)_failedPeers.clone();
}
}
public boolean completed() { return _completed != -1; }
@@ -92,10 +92,10 @@ class StoreState {
_attemptedPeers.add(peer);
}
}
- public void addPending(Collection pending) {
+ public void addPending(Collection pending) {
synchronized (_pendingPeers) {
_pendingPeers.addAll(pending);
- for (Iterator iter = pending.iterator(); iter.hasNext(); )
+ for (Iterator iter = pending.iterator(); iter.hasNext(); )
_pendingPeerTimes.put(iter.next(), new Long(_context.clock().now()));
}
synchronized (_attemptedPeers) {
@@ -113,7 +113,7 @@ class StoreState {
long rv = -1;
synchronized (_pendingPeers) {
_pendingPeers.remove(peer);
- Long when = (Long)_pendingPeerTimes.remove(peer);
+ Long when = _pendingPeerTimes.remove(peer);
if (when != null)
rv = _context.clock().now() - when.longValue();
}
@@ -128,7 +128,7 @@ class StoreState {
long rv = -1;
synchronized (_pendingPeers) {
_pendingPeers.remove(peer);
- Long when = (Long)_pendingPeerTimes.remove(peer);
+ Long when = _pendingPeerTimes.remove(peer);
if (when != null)
rv = _context.clock().now() - when.longValue();
}
@@ -159,43 +159,43 @@ class StoreState {
buf.append(" Attempted: ");
synchronized (_attemptedPeers) {
buf.append(_attemptedPeers.size()).append(' ');
- for (Iterator iter = _attemptedPeers.iterator(); iter.hasNext(); ) {
- Hash peer = (Hash)iter.next();
+ for (Iterator iter = _attemptedPeers.iterator(); iter.hasNext(); ) {
+ Hash peer = iter.next();
buf.append(peer.toBase64()).append(" ");
}
}
buf.append(" Pending: ");
synchronized (_pendingPeers) {
buf.append(_pendingPeers.size()).append(' ');
- for (Iterator iter = _pendingPeers.iterator(); iter.hasNext(); ) {
- Hash peer = (Hash)iter.next();
+ for (Iterator iter = _pendingPeers.iterator(); iter.hasNext(); ) {
+ Hash peer = iter.next();
buf.append(peer.toBase64()).append(" ");
}
}
buf.append(" Failed: ");
synchronized (_failedPeers) {
buf.append(_failedPeers.size()).append(' ');
- for (Iterator iter = _failedPeers.iterator(); iter.hasNext(); ) {
- Hash peer = (Hash)iter.next();
+ for (Iterator iter = _failedPeers.iterator(); iter.hasNext(); ) {
+ Hash peer = iter.next();
buf.append(peer.toBase64()).append(" ");
}
}
buf.append(" Successful: ");
synchronized (_successfulPeers) {
buf.append(_successfulPeers.size()).append(' ');
- for (Iterator iter = _successfulPeers.iterator(); iter.hasNext(); ) {
- Hash peer = (Hash)iter.next();
+ for (Iterator iter = _successfulPeers.iterator(); iter.hasNext(); ) {
+ Hash peer = iter.next();
buf.append(peer.toBase64()).append(" ");
}
}
buf.append(" Successful Exploratory: ");
synchronized (_successfulExploratoryPeers) {
buf.append(_successfulExploratoryPeers.size()).append(' ');
- for (Iterator iter = _successfulExploratoryPeers.iterator(); iter.hasNext(); ) {
- Hash peer = (Hash)iter.next();
+ for (Iterator iter = _successfulExploratoryPeers.iterator(); iter.hasNext(); ) {
+ Hash peer = iter.next();
buf.append(peer.toBase64()).append(" ");
}
}
return buf.toString();
}
-}
\ No newline at end of file
+}
diff --git a/router/java/src/net/i2p/router/peermanager/PeerManager.java b/router/java/src/net/i2p/router/peermanager/PeerManager.java
index 41110c306..009a6ed50 100644
--- a/router/java/src/net/i2p/router/peermanager/PeerManager.java
+++ b/router/java/src/net/i2p/router/peermanager/PeerManager.java
@@ -250,8 +250,4 @@ class PeerManager {
return rv;
}
}
-
- public void renderStatusHTML(Writer out) throws IOException {
- _organizer.renderStatusHTML(out);
- }
}
diff --git a/router/java/src/net/i2p/router/peermanager/PeerManagerFacadeImpl.java b/router/java/src/net/i2p/router/peermanager/PeerManagerFacadeImpl.java
index 3483873a5..14ee5317e 100644
--- a/router/java/src/net/i2p/router/peermanager/PeerManagerFacadeImpl.java
+++ b/router/java/src/net/i2p/router/peermanager/PeerManagerFacadeImpl.java
@@ -78,8 +78,8 @@ public class PeerManagerFacadeImpl implements PeerManagerFacade {
return _manager.getPeersByCapability(capability);
}
+ /** @deprecated, moved to routerconsole */
public void renderStatusHTML(Writer out) throws IOException {
- _manager.renderStatusHTML(out);
}
}
diff --git a/router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java b/router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java
index 07d25fce8..4fd812efa 100644
--- a/router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java
+++ b/router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java
@@ -139,7 +139,7 @@ public class ProfileOrganizer {
}
public void setUs(Hash us) { _us = us; }
- Hash getUs() { return _us; }
+ public Hash getUs() { return _us; }
public double getSpeedThreshold() { return _thresholdSpeedValue; }
public double getCapacityThreshold() { return _thresholdCapacityValue; }
@@ -258,11 +258,6 @@ public class ProfileOrganizer {
_persistenceHelper.writeProfile(prof, out);
}
- public void renderStatusHTML(Writer out) throws IOException {
- ProfileOrganizerRenderer rend = new ProfileOrganizerRenderer(this, _context);
- rend.renderStatusHTML(out);
- }
-
/**
* Return a set of Hashes for peers that are both fast and reliable. If an insufficient
* number of peers are both fast and reliable, fall back onto high capacity peers, and if that