[or-cvs] r20539: {torctl} Add support for storing descriptor bandwidth values in addit (torctl/branches/stable/python/TorCtl)
mikeperry at seul.org
mikeperry at seul.org
Sun Sep 13 05:06:46 UTC 2009
Author: mikeperry
Date: 2009-09-13 01:06:46 -0400 (Sun, 13 Sep 2009)
New Revision: 20539
Modified:
torctl/branches/stable/python/TorCtl/SQLSupport.py
torctl/branches/stable/python/TorCtl/TorCtl.py
Log:
Add support for storing descriptor bandwidth values in
addition to consensus values.
Modified: torctl/branches/stable/python/TorCtl/SQLSupport.py
===================================================================
--- torctl/branches/stable/python/TorCtl/SQLSupport.py 2009-09-12 17:16:35 UTC (rev 20538)
+++ torctl/branches/stable/python/TorCtl/SQLSupport.py 2009-09-13 05:06:46 UTC (rev 20539)
@@ -107,6 +107,7 @@
using_mapper_options(save_on_init=False)
router = ManyToOne('Router')
bw = Field(Integer)
+ desc_bw = Field(Integer)
rank = Field(Integer)
pub_time = Field(Time)
@@ -211,6 +212,7 @@
avg_rank = Field(Float)
max_rank = Field(Integer)
avg_bw = Field(Float)
+ avg_desc_bw = Field(Float)
percentile = Field(Float)
@@ -365,24 +367,28 @@
def _compute_ranks():
tc_session.clear()
- min_r = select([func.min(BwHistory.rank)],
+ min_r = select([func.min(BwHistory.rank)],
BwHistory.table.c.router_idhex
== RouterStats.table.c.router_idhex).as_scalar()
- avg_r = select([func.avg(BwHistory.rank)],
+ avg_r = select([func.avg(BwHistory.rank)],
BwHistory.table.c.router_idhex
== RouterStats.table.c.router_idhex).as_scalar()
- max_r = select([func.max(BwHistory.rank)],
+ max_r = select([func.max(BwHistory.rank)],
BwHistory.table.c.router_idhex
== RouterStats.table.c.router_idhex).as_scalar()
- avg_bw = select([func.avg(BwHistory.bw)],
+ avg_bw = select([func.avg(BwHistory.bw)],
BwHistory.table.c.router_idhex
== RouterStats.table.c.router_idhex).as_scalar()
+ avg_desc_bw = select([func.avg(BwHistory.desc_bw)],
+ BwHistory.table.c.router_idhex
+ == RouterStats.table.c.router_idhex).as_scalar()
RouterStats.table.update(values=
{RouterStats.table.c.min_rank:min_r,
RouterStats.table.c.avg_rank:avg_r,
RouterStats.table.c.max_rank:max_r,
- RouterStats.table.c.avg_bw:avg_bw}).execute()
+ RouterStats.table.c.avg_bw:avg_bw,
+ RouterStats.table.c.avg_desc_bw:avg_desc_bw}).execute()
#min_avg_rank = select([func.min(RouterStats.avg_rank)]).as_scalar()
max_avg_rank = select([func.max(RouterStats.avg_rank)]).as_scalar()
@@ -604,6 +610,7 @@
f.write("node_id=$"+s.router.idhex+" nick="+s.router.nickname)
f.write(" strm_bw="+str(cvt(s.sbw,0)))
f.write(" filt_bw="+str(cvt(s.filt_sbw,0)))
+ f.write(" desc_bw="+str(int(cvt(s.avg_desc_bw,0))))
f.write(" ns_bw="+str(int(cvt(s.avg_bw,0)))+"\n")
f.flush()
@@ -669,7 +676,7 @@
r = Router.query.options(eagerload('bw_history')).filter_by(
idhex=idhex).with_labels().one()
bwh = BwHistory(router=r, rank=rc.list_rank, bw=rc.bw,
- pub_time=r.published)
+ desc_bw=rc.desc_bw, pub_time=r.published)
r.bw_history.append(bwh)
#tc_session.add(bwh)
tc_session.add(r)
Modified: torctl/branches/stable/python/TorCtl/TorCtl.py
===================================================================
--- torctl/branches/stable/python/TorCtl/TorCtl.py 2009-09-12 17:16:35 UTC (rev 20538)
+++ torctl/branches/stable/python/TorCtl/TorCtl.py 2009-09-13 05:06:46 UTC (rev 20539)
@@ -288,6 +288,7 @@
self.bw = ns_bandwidth
else:
self.bw = bw
+ self.desc_bw = bw
self.exitpolicy = exitpolicy
self.flags = flags # Technicaly from NS doc
self.down = down
More information about the tor-commits
mailing list