You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2016/04/22 23:55:23 UTC
[2/7] qpid-dispatch git commit: DISPATCH-10 - Use the inter_router
cost in the route computation.
DISPATCH-10 - Use the inter_router cost in the route computation.
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/607e942b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/607e942b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/607e942b
Branch: refs/heads/master
Commit: 607e942b44500e051dafaa7fc505844469b0b9f1
Parents: 9f23292
Author: Ted Ross <tr...@redhat.com>
Authored: Wed Apr 20 16:51:00 2016 -0400
Committer: Ted Ross <tr...@redhat.com>
Committed: Fri Apr 22 17:50:20 2016 -0400
----------------------------------------------------------------------
python/qpid_dispatch_internal/router/node.py | 3 ++-
python/qpid_dispatch_internal/router/path.py | 21 +++++++++++----------
2 files changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/607e942b/python/qpid_dispatch_internal/router/node.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/router/node.py b/python/qpid_dispatch_internal/router/node.py
index 7ae08fd..2dfcbcf 100644
--- a/python/qpid_dispatch_internal/router/node.py
+++ b/python/qpid_dispatch_internal/router/node.py
@@ -146,8 +146,9 @@ class NodeTracker(object):
collection = {self.my_id : self.link_state}
for node_id, node in self.nodes.items():
collection[node_id] = node.link_state
- next_hops, valid_origins = self.container.path_engine.calculate_routes(collection)
+ next_hops, cost, valid_origins = self.container.path_engine.calculate_routes(collection)
self.container.log_ls(LOG_TRACE, "Computed next hops: %r" % next_hops)
+ self.container.log_ls(LOG_TRACE, "Computed costs: %r" % cost)
self.container.log_ls(LOG_TRACE, "Computed valid origins: %r" % valid_origins)
##
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/607e942b/python/qpid_dispatch_internal/router/path.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/router/path.py b/python/qpid_dispatch_internal/router/path.py
index f47ae13..2e15257 100644
--- a/python/qpid_dispatch_internal/router/path.py
+++ b/python/qpid_dispatch_internal/router/path.py
@@ -40,7 +40,7 @@ class PathEngine(object):
link_states[_id] = ls.peers
for p in ls.peers:
if p not in link_states:
- link_states[p] = [_id]
+ link_states[p] = {_id:1L}
##
## Setup Dijkstra's Algorithm
@@ -61,27 +61,28 @@ class PathEngine(object):
if cost[u] == None:
# There are no more reachable nodes in unresolved
break
- for v in link_states[u]:
+ for v, v_cost in link_states[u].items():
if unresolved.contains(v):
- alt = cost[u] + 1 # TODO - Use link cost instead of 1
+ alt = cost[u] + v_cost
if cost[v] == None or alt < cost[v]:
cost[v] = alt
prev[v] = u
unresolved.set_cost(v, alt)
##
- ## Remove unreachable nodes from the map. Note that this will also remove the
+ ## Remove unreachable nodes from the maps. Note that this will also remove the
## root node (has no previous node) from the map.
##
for u, val in prev.items():
if not val:
prev.pop(u)
+ cost.pop(u)
##
- ## Return previous-node map. This is a map of all reachable, remote nodes to
- ## their predecessor node.
+ ## Return previous-node and cost maps. Prev is a map of all reachable, remote nodes to
+ ## their predecessor node. Cost is a map of all reachable nodes and their costs.
##
- return prev
+ return prev, cost
def _calculate_valid_origins(self, nodeset, collection):
@@ -96,7 +97,7 @@ class PathEngine(object):
valid_origin[node] = []
for root in valid_origin.keys():
- prev = self._calculate_tree_from_root(root, collection)
+ prev, cost = self._calculate_tree_from_root(root, collection)
nodes = prev.keys()
while len(nodes) > 0:
u = nodes[0]
@@ -119,7 +120,7 @@ class PathEngine(object):
##
## Generate the shortest-path tree with the local node as root
##
- prev = self._calculate_tree_from_root(self.id, collection)
+ prev, cost = self._calculate_tree_from_root(self.id, collection)
nodes = prev.keys()
##
@@ -145,7 +146,7 @@ class PathEngine(object):
##
valid_origins = self._calculate_valid_origins(prev.keys(), collection)
- return (next_hops, valid_origins)
+ return (next_hops, cost, valid_origins)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org