Mercurial > hg > FederatedLinda
comparison tools/python-PE/CompactRouting/ant_mesh10.py @ 8:6c40056777be
Initial revision
author | fuchita |
---|---|
date | Sat, 16 Feb 2008 13:18:02 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
7:1809e2b05824 | 8:6c40056777be |
---|---|
1 import re | |
2 import sys | |
3 import string | |
4 import time | |
5 | |
6 sys.path.append('../modules') | |
7 | |
8 import FederatedLinda | |
9 | |
10 ROUTING_HEADER_FORMAT = "!I" | |
11 TUPLE_ID_LINKCONFIG = 1 | |
12 TUPLE_ID_ROUTING = 2 | |
13 | |
14 ROUTING_COMMAND_CONNECT = 1 | |
15 ROUTING_COMMAND_DISCONNECT = 2 | |
16 ROUTING_COMMAND_TRANSFER = 3 | |
17 ROUTING_COMMAND_UPDATE_TABLE = 4 | |
18 | |
19 testxml = \ | |
20 """<graph name = "Graf"> | |
21 <node label = "Node000" tsid = "ant001.cs.ie.u-ryukyu.ac.jp:10000"> | |
22 <destination label = "Node002"/> | |
23 </node> | |
24 <node label = "Node009" tsid = "ant015.cs.ie.u-ryukyu.ac.jp:10009"> | |
25 <destination label = "Node005"/> | |
26 <destination label = "Node008"/> | |
27 </node> | |
28 <node label = "Node008" tsid = "ant014.cs.ie.u-ryukyu.ac.jp:10008"> | |
29 <destination label = "Node007"/> | |
30 <destination label = "Node009"/> | |
31 <destination label = "Node004"/> | |
32 </node> | |
33 <node label = "Node007" tsid = "ant013.cs.ie.u-ryukyu.ac.jp:10007"> | |
34 <destination label = "Node006"/> | |
35 <destination label = "Node008"/> | |
36 <destination label = "Node003"/> | |
37 </node> | |
38 <node label = "Node006" tsid = "ant012.cs.ie.u-ryukyu.ac.jp:10006"> | |
39 <destination label = "Node007"/> | |
40 </node> | |
41 <node label = "Node005" tsid = "ant011.cs.ie.u-ryukyu.ac.jp:10005"> | |
42 <destination label = "Node002"/> | |
43 <destination label = "Node009"/> | |
44 <destination label = "Node004"/> | |
45 </node> | |
46 <node label = "Node004" tsid = "ant005.cs.ie.u-ryukyu.ac.jp:10004"> | |
47 <destination label = "Node001"/> | |
48 <destination label = "Node003"/> | |
49 <destination label = "Node005"/> | |
50 <destination label = "Node008"/> | |
51 </node> | |
52 <node label = "Node003" tsid = "ant004.cs.ie.u-ryukyu.ac.jp:10003"> | |
53 <destination label = "Node004"/> | |
54 <destination label = "Node007"/> | |
55 </node> | |
56 <node label = "Node002" tsid = "ant003.cs.ie.u-ryukyu.ac.jp:10002"> | |
57 <destination label = "Node005"/> | |
58 <destination label = "Node000"/> | |
59 <destination label = "Node001"/> | |
60 </node> | |
61 <node label = "Node001" tsid = "ant002.cs.ie.u-ryukyu.ac.jp:10001"> | |
62 <destination label = "Node004"/> | |
63 <destination label = "Node002"/> | |
64 </node> | |
65 </graph> | |
66 """ | |
67 def getFirstTsid(xmltext): | |
68 p = re.compile('(?<=tsid = \").*(?=\")') | |
69 m = p.findall(xmltext) | |
70 return m[0] | |
71 | |
72 | |
73 | |
74 if __name__ == "__main__": | |
75 | |
76 if (len(sys.argv) == 2): | |
77 print " : %s <xmlfilename>" % sys.argv[0] | |
78 xmltext = open(sys.argv[1]).read() | |
79 if xmltext is None: | |
80 sys.exit(1) | |
81 else: | |
82 xmltext = testxml | |
83 | |
84 start = time.time() | |
85 print "start time ",start | |
86 | |
87 firsttsid = getFirstTsid(xmltext) | |
88 | |
89 flinda = FederatedLinda.FederatedLinda() | |
90 | |
91 host, portnum = string.split(firsttsid,':') | |
92 | |
93 linda1 = flinda.open(host, int(portnum)) | |
94 linda1.Out(TUPLE_ID_LINKCONFIG, testxml) | |
95 flinda.sync() | |
96 | |
97 | |
98 |