* Netdb Floodfill rework part 4 of N: Search closest-to-the-key
This commit is contained in:
@ -52,6 +52,7 @@ public class RoutingKeyGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private byte _currentModData[];
|
private byte _currentModData[];
|
||||||
|
private long _lastChanged;
|
||||||
|
|
||||||
private final static Calendar _cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"));
|
private final static Calendar _cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||||
private final static SimpleDateFormat _fmt = new SimpleDateFormat("yyyyMMdd");
|
private final static SimpleDateFormat _fmt = new SimpleDateFormat("yyyyMMdd");
|
||||||
@ -60,8 +61,13 @@ public class RoutingKeyGenerator {
|
|||||||
return _currentModData;
|
return _currentModData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getLastChanged() {
|
||||||
|
return _lastChanged;
|
||||||
|
}
|
||||||
|
|
||||||
public void setModData(byte modData[]) {
|
public void setModData(byte modData[]) {
|
||||||
_currentModData = modData;
|
_currentModData = modData;
|
||||||
|
_lastChanged = _context.clock().now();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,4 +137,4 @@ public class RoutingKeyGenerator {
|
|||||||
} catch (Throwable t) { // nop
|
} catch (Throwable t) { // nop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
history.txt
11
history.txt
@ -1,3 +1,14 @@
|
|||||||
|
2009-11-21 zzz
|
||||||
|
* Netdb Floodfill rework part 4 of N:
|
||||||
|
- Search closest-to-the-key
|
||||||
|
- Put closest-to-the-key in explore don't-include-list
|
||||||
|
- Use facade's peer selector for exploration rather than
|
||||||
|
instantiating a new one
|
||||||
|
- Adjust response time limit
|
||||||
|
* netdb.jsp: Add popups on flags
|
||||||
|
* Routerconsole build: rename include files so they aren't
|
||||||
|
compiled and bundled separately (~15KB)
|
||||||
|
|
||||||
2009-11-18 zzz
|
2009-11-18 zzz
|
||||||
* Build: Don't update the po files by default, add new
|
* Build: Don't update the po files by default, add new
|
||||||
target "poupdate" to do that.
|
target "poupdate" to do that.
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 19;
|
public final static long BUILD = 20;
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
|
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
|
||||||
|
@ -68,12 +68,29 @@ class FloodOnlySearchJob extends FloodSearchJob {
|
|||||||
public long getCreated() { return _created; }
|
public long getCreated() { return _created; }
|
||||||
public boolean shouldProcessDSRM() { return _shouldProcessDSRM; }
|
public boolean shouldProcessDSRM() { return _shouldProcessDSRM; }
|
||||||
private static final int CONCURRENT_SEARCHES = 2;
|
private static final int CONCURRENT_SEARCHES = 2;
|
||||||
|
private static final int MIN_FOR_NO_DSRM = 4;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runJob() {
|
public void runJob() {
|
||||||
// pick some floodfill peers and send out the searches
|
// pick some floodfill peers and send out the searches
|
||||||
List floodfillPeers = _facade.getFloodfillPeers();
|
// old
|
||||||
if (floodfillPeers.size() <= 3)
|
//List<Hash> floodfillPeers = _facade.getFloodfillPeers();
|
||||||
_shouldProcessDSRM = true;
|
// new
|
||||||
|
List<Hash> floodfillPeers;
|
||||||
|
KBucketSet ks = _facade.getKBuckets();
|
||||||
|
if (ks != null) {
|
||||||
|
Hash rkey = getContext().routingKeyGenerator().getRoutingKey(_key);
|
||||||
|
floodfillPeers = ((FloodfillPeerSelector)_facade.getPeerSelector()).selectFloodfillParticipants(rkey, MIN_FOR_NO_DSRM, ks);
|
||||||
|
} else {
|
||||||
|
floodfillPeers = Collections.EMPTY_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we dont know enough floodfills,
|
||||||
|
// or the global network routing key just changed (which is set at statrtup,
|
||||||
|
// so this includes the first few minutes of uptime)
|
||||||
|
_shouldProcessDSRM = floodfillPeers.size() < MIN_FOR_NO_DSRM ||
|
||||||
|
getContext().routingKeyGenerator().getLastChanged() > getContext().clock().now() - 30*60*1000;
|
||||||
|
|
||||||
if (floodfillPeers.size() <= 0) {
|
if (floodfillPeers.size() <= 0) {
|
||||||
// ask anybody, they may not return the answer but they will return a few ff peers we can go look up,
|
// ask anybody, they may not return the answer but they will return a few ff peers we can go look up,
|
||||||
// so this situation should be temporary
|
// so this situation should be temporary
|
||||||
@ -86,10 +103,12 @@ class FloodOnlySearchJob extends FloodSearchJob {
|
|||||||
failed();
|
failed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Collections.shuffle(floodfillPeers, getContext().random());
|
||||||
}
|
}
|
||||||
OutNetMessage out = getContext().messageRegistry().registerPending(_replySelector, _onReply, _onTimeout, _timeoutMs);
|
OutNetMessage out = getContext().messageRegistry().registerPending(_replySelector, _onReply, _onTimeout, _timeoutMs);
|
||||||
synchronized (_out) { _out.add(out); }
|
synchronized (_out) { _out.add(out); }
|
||||||
|
|
||||||
|
/********
|
||||||
// We need to randomize our ff selection, else we stay with the same ones since
|
// We need to randomize our ff selection, else we stay with the same ones since
|
||||||
// getFloodfillPeers() is sorted by closest distance. Always using the same
|
// getFloodfillPeers() is sorted by closest distance. Always using the same
|
||||||
// ones didn't help reliability.
|
// ones didn't help reliability.
|
||||||
@ -124,6 +143,7 @@ class FloodOnlySearchJob extends FloodSearchJob {
|
|||||||
} else {
|
} else {
|
||||||
_shouldProcessDSRM = true;
|
_shouldProcessDSRM = true;
|
||||||
}
|
}
|
||||||
|
********/
|
||||||
|
|
||||||
int count = 0; // keep a separate count since _lookupsRemaining could be decremented elsewhere
|
int count = 0; // keep a separate count since _lookupsRemaining could be decremented elsewhere
|
||||||
for (int i = 0; _lookupsRemaining < CONCURRENT_SEARCHES && i < floodfillPeers.size(); i++) {
|
for (int i = 0; _lookupsRemaining < CONCURRENT_SEARCHES && i < floodfillPeers.size(); i++) {
|
||||||
|
Reference in New Issue
Block a user