Update of /cvsroot/freenet/freenet/src/freenet/node/rt
In directory sc8-pr-cvs1:/tmp/cvs-serv8069/src/freenet/node/rt
Modified Files:
ResponseTimeEstimator.java
HistoryKeepingRoutingPointStore.java
Log Message:
Initial/testing version of Routing flux lines. Can be seen at most-detailed OCM
PeerHandlerMode page.
Index: ResponseTimeEstimator.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/ResponseTimeEstimator.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -w -r1.30 -r1.31
--- ResponseTimeEstimator.java 3 Nov 2003 16:32:24 -0000 1.30
+++ ResponseTimeEstimator.java 3 Nov 2003 21:36:30 -0000 1.31
@@ -36,14 +36,11 @@
// }
public class ResponseTimeEstimator implements TimeEstimator {
- //BigInteger key[];
- //int time[];
- //double sensitivity[];
protected static final double SENSITIVITY_MAX = 10.0;
protected RecentReports recent;
protected RoutingPointStore store;
- protected final boolean keepHistory = false;
+ protected final boolean keepHistory = true;
static final int TIMEBYTES = 4,
BYTES = Key.KEYBYTES + TIMEBYTES;
@@ -114,7 +111,6 @@
store = new
HistoryKeepingRoutingPointStore(accuracy,initTime,keyspace);
else
store = new RoutingPointStore(accuracy,initTime,keyspace);
- if(initTime < 0) throw new IllegalArgumentException("negative initTime");
recent = new RecentReports();
}
@@ -720,13 +716,12 @@
throw new IllegalArgumentException("unknown type");
}
public void drapGraphOnImage(boolean dontClipPoints, Bitmap
bmp,boolean drawHistoryIfPossible, Color lineCol, Color crossCol) {
- int lowest = Integer.MAX_VALUE;
- int highest = 0;
BigInteger a = keyspace.subtract(BigInteger.ONE);
BigInteger b = a.divide(BigInteger.valueOf(bmp.getWidth()));
- BigInteger at = BigInteger.ZERO;
LinkedList l = new LinkedList();
+ int lowest=Integer.MAX_VALUE;
+ int highest=0;
if(drawHistoryIfPossible && store instanceof
HistoryKeepingRoutingPointStore &&
((HistoryKeepingRoutingPointStore)store).historySize()>0)
{
@@ -734,19 +729,21 @@
HistoryKeepingRoutingPointStore hstore =
(HistoryKeepingRoutingPointStore)store;
synchronized (hstore) {
for (int i2 = 1; i2 < hstore.historySize();
i2++) {
-
+ BigInteger at = BigInteger.ZERO;
GraphDataSet g = new GraphDataSet();
g.val = new int[bmp.getWidth()];
g.lineCol = nextColor;
g.crossCol = null;
for (int i = 0; i < bmp.getWidth();
i++) {
g.val[i] = guess(at, i2);
- lowest = Math.min(lowest,
g.val[i]);
- highest = Math.max(highest,
g.val[i]);
+ g.lowest = Math.min(g.lowest,
g.val[i]);
+ lowest = Math.min(g.lowest,
lowest);
+ g.highest =
Math.max(g.highest, g.val[i]);
+ highest = Math.max(g.highest,
highest);
at = at.add(b);
}
l.add(g);
- nextColor = Color.add(nextColor,new
Color(10,10,10));
+ nextColor = Color.add(nextColor,new
Color(10,10,10)); //The older, the lighter
}
}
}
@@ -754,39 +751,54 @@
g.val = new int[bmp.getWidth()];
g.lineCol = lineCol;
g.crossCol = crossCol;
+ BigInteger at = BigInteger.ZERO;
for (int i = 0; i < bmp.getWidth(); i++) {
g.val[i] = guess(at);
- lowest = Math.min(lowest, g.val[i]);
- highest = Math.max(highest, g.val[i]);
+ g.lowest = Math.min(g.lowest, g.val[i]);
+ lowest = Math.min(g.lowest, lowest);
+ g.highest = Math.max(g.highest, g.val[i]);
+ highest = Math.max(g.highest, highest);
at = at.add(b);
}
l.add(g);
Iterator it = l.iterator();
- while(it.hasNext())
- drapGraphOnImage(dontClipPoints, bmp,
(GraphDataSet)it.next(),b,lowest,highest);
+ while(it.hasNext()){
+ GraphDataSet n = (GraphDataSet)it.next();
+ //n.lowest = g.lowest;
+ //n.highest = g.highest;
+ n.lowest = lowest;
+ n.highest = highest;
+ drapGraphOnImage(dontClipPoints, bmp, n,b);
+ }
}
private class GraphDataSet{
int[] val;
Color lineCol,crossCol;
+ int lowest=Integer.MAX_VALUE;
+ int highest=0;
}
- private void drapGraphOnImage(boolean dontClipPoints, Bitmap bmp,
GraphDataSet g,BigInteger b,int lowest, int highest) {
+ private void drapGraphOnImage(boolean dontClipPoints, Bitmap bmp,
GraphDataSet g,BigInteger b) {
if(g.crossCol != null){ //Only consider recent max/min if we
are actually going to draw the crosses
RecentReports.LowestHighestPair lowestAndHighestRecent
= recent.getLowestAndHighest(dontClipPoints);
- lowest = Math.min(lowestAndHighestRecent.lowest,
lowest);
- highest = Math.max(lowestAndHighestRecent.highest,
highest);
+ g.lowest = Math.min(lowestAndHighestRecent.lowest,
g.lowest);
+ g.highest = Math.max(lowestAndHighestRecent.highest,
g.highest);
}
// lowest ... highest
// lowest mapped to 0
// highest mapped to height
- double multiplier = ((double) bmp.getHeight() - 1) / ((double)
(highest - lowest));
+ double multiplier = ((double) bmp.getHeight() - 1) / ((double)
(g.highest - g.lowest));
if (g.lineCol != null) {
bmp.setPenColor(g.lineCol);
+ //int initposition = (int) ((g.val[0] - g.lowest) *
multiplier);
+ //initposition = bmp.getHeight() - (initposition + 1);
+ //bmp.moveTo(0,initposition);
for (int i = 0; i < bmp.getWidth(); i++) {
- int position = (int) ((g.val[i] - lowest) *
multiplier);
+ int position = (int) ((g.val[i] - g.lowest) *
multiplier);
position = bmp.getHeight() - (position + 1);
bmp.setPixel(i, position);
+ //bmp.drawTo(i,position);
}
}
@@ -799,7 +811,7 @@
while (e.hasMoreElements()) {
RecentReports.KeyTimePair kt =
(RecentReports.KeyTimePair) e.nextElement();
int w = kt.key.divide(b).intValue();
- int h = (int) ((kt.time - lowest) *
multiplier);
+ int h = (int) ((kt.time - g.lowest) *
multiplier);
h = Math.max(h, 0);
h = Math.min(bmp.getHeight() - 1, h);
h = bmp.getHeight() - (h + 1);
Index: HistoryKeepingRoutingPointStore.java
===================================================================
RCS file:
/cvsroot/freenet/freenet/src/freenet/node/rt/HistoryKeepingRoutingPointStore.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- HistoryKeepingRoutingPointStore.java 3 Nov 2003 16:32:25 -0000 1.1
+++ HistoryKeepingRoutingPointStore.java 3 Nov 2003 21:36:31 -0000 1.2
@@ -45,20 +45,18 @@
*/
protected void notifyPrePointModified(int index) {
if(initialized)
- {
- RoutingPoint[] p = snapshot();
- //Since one of the points is about to be modified we'll have to
- //clone it off from its original to keep a proper history
- p[index] = (RoutingPoint)p[index].clone();
- }
+ snapshot();
super.notifyPrePointModified(index);
}
//Takes a snapshot of the current 'points' and returns the actual resulting
historic data
private synchronized RoutingPoint[] snapshot(){
if(history.size() > MAX_HISTORY_LENGTH)
history.removeFirst();
- RoutingPoint[] c = (RoutingPoint[])points.clone();
+ RoutingPoint[] c = new RoutingPoint[points.length];
history.addLast(c);
+ for(int i =0;i<c.length;i++){ //Detach from original
+ c[i] = (RoutingPoint)points[i].clone();
+ }
return c;
}
_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs