Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
21b6b4f9
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
21b6b4f9
编写于
9月 04, 2018
作者:
B
Brian Johnson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix to bridge shape code in launch method. GH #4973
上级
ed314d8b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
52 addition
and
26 deletion
+52
-26
tests/Cluster.py
tests/Cluster.py
+52
-26
未找到文件。
tests/Cluster.py
浏览文件 @
21b6b4f9
...
...
@@ -166,17 +166,11 @@ class Cluster(object):
cmdArr
.
append
(
"--specific-nodeos"
)
cmdArr
.
append
(
arg
)
shapeFilePrefix
=
"shape_bridge"
shapeFile
=
shapeFilePrefix
+
".json"
shapeHostsFile
=
shapeFilePrefix
+
"_hosts.json"
# must be last cmdArr.append before subprocess.call, so that everything is on the command line
# before constructing the shape.json file for "bridge"
if
topo
==
"bridge"
:
numProducers
=
totalProducers
if
totalProducers
is
not
None
else
totalNodes
maxProducers
=
ord
(
'z'
)
-
ord
(
'a'
)
+
1
assert
numProducers
<
maxProducers
,
\
"ERROR: topo of %s assumes names of
\"
defproducera
\"
to
\"
defproducerz
\"
, so must have at most %d producers"
%
\
(
topo
,
maxProducers
)
shapeFilePrefix
=
"shape_bridge"
shapeFile
=
shapeFilePrefix
+
".json"
cmdArrForOutput
=
copy
.
deepcopy
(
cmdArr
)
cmdArrForOutput
.
append
(
"--output"
)
cmdArrForOutput
.
append
(
shapeFile
)
...
...
@@ -195,16 +189,21 @@ class Cluster(object):
# an array of array, the first level of arrays is the pair entries of the map, the second is an array
# of two entries - [ <first>, <second> ] with first being the name and second being the node definition
shapeFileNodes
=
shapeFileObject
[
"nodes"
]
numProducers
=
totalProducers
if
totalProducers
is
not
None
else
totalNodes
maxProducers
=
ord
(
'z'
)
-
ord
(
'a'
)
+
1
assert
numProducers
<
maxProducers
,
\
"ERROR: topo of %s assumes names of
\"
defproducera
\"
to
\"
defproducerz
\"
, so must have at most %d producers"
%
\
(
topo
,
maxProducers
)
# will make a map to node object to make identification easier
biosNodeObject
=
None
bridgeNodes
=
{}
producerNodes
=
{}
producers
=
{}
index
=
0
producers
=
[]
for
append
in
range
(
ord
(
'a'
),
ord
(
'a'
)
+
numProducers
):
name
=
"defproducer"
+
chr
(
append
)
producers
[
name
]
=
index
index
+=
1
producers
.
append
(
name
)
# first group starts at 0
secondGroupStart
=
int
((
numProducers
+
1
)
/
2
)
...
...
@@ -217,7 +216,7 @@ class Cluster(object):
p
=
re
.
compile
(
r
'^testnet_(\d+)$'
)
m
=
p
.
match
(
nodeName
)
return
int
(
m
.
group
(
1
))
for
shapeFileNodePair
in
shapeFileNodes
:
assert
(
len
(
shapeFileNodePair
)
==
2
)
nodeName
=
shapeFileNodePair
[
0
]
...
...
@@ -230,26 +229,53 @@ class Cluster(object):
nodeNum
=
getNodeNum
(
nodeName
)
Utils
.
Print
(
"nodeNum=%d, shapeFileNode=%s"
%
(
nodeNum
,
shapeFileNode
))
assert
(
"producers"
in
shapeFileNode
)
numNodeProducers
=
len
(
shapeFileNode
[
"producers"
])
shapeFileNodeProds
=
shapeFileNode
[
"producers"
]
numNodeProducers
=
len
(
shapeFileNodeProds
)
if
(
numNodeProducers
==
0
):
bridgeNodes
[
nodeName
]
=
shapeFileNode
else
:
producerNodes
[
nodeName
]
=
shapeFileNode
if
nodeNum
<
secondGroupStart
:
producerGroup1
.
append
(
nodeName
)
else
:
producerGroup2
.
append
(
nodeName
)
#Utils.Print("shapeFileNodeMap=%s" % (shapeFileNodeMap))
group
=
None
# go through all the producers for this node and determine which group on the bridged network they are in
for
shapeFileNodeProd
in
shapeFileNodeProds
:
producerIndex
=
0
for
prod
in
producers
:
if
prod
==
shapeFileNodeProd
:
break
producerIndex
+=
1
prodGroup
=
None
if
producerIndex
<
secondGroupStart
:
prodGroup
=
1
if
group
is
None
:
group
=
prodGroup
producerGroup1
.
append
(
nodeName
)
Utils
.
Print
(
"Group1 grouping producerIndex=%s, secondGroupStart=%s"
%
(
producerIndex
,
secondGroupStart
))
else
:
prodGroup
=
2
if
group
is
None
:
group
=
prodGroup
producerGroup2
.
append
(
nodeName
)
Utils
.
Print
(
"Group2 grouping producerIndex=%s, secondGroupStart=%s"
%
(
producerIndex
,
secondGroupStart
))
if
group
!=
prodGroup
:
errorExit
(
"Node configuration not consistent with
\"
bridge
\"
topology. Node %s has producers that fall into both halves of the bridged network"
%
(
nodeName
))
for
_
,
bridgeNode
in
bridgeNodes
.
items
():
bridgeNode
[
"peers"
]
=
[]
for
prodName
,
prodNode
in
producerNodes
.
items
():
nodeNum
=
getNodeNum
(
prodName
)
group
=
producerGroup1
if
nodeNum
<
secondGroupStart
else
producerGroup2
prodNode
[
"peers"
]
=
[
i
for
i
in
group
if
i
!=
prodNode
]
for
bridgeName
in
bridgeNodes
:
prodNode
[
"peers"
].
append
(
bridgeName
)
for
prodName
in
producerNodes
:
bridgeNode
[
"peers"
].
append
(
prodName
)
def
connectGroup
(
group
,
producerNodes
,
bridgeNodes
)
:
groupStr
=
""
for
nodeName
in
group
:
groupStr
+=
nodeName
+
", "
prodNode
=
producerNodes
[
nodeName
]
prodNode
[
"peers"
]
=
[
i
for
i
in
group
if
i
!=
nodeName
]
for
bridgeName
in
bridgeNodes
:
prodNode
[
"peers"
].
append
(
bridgeName
)
connectGroup
(
producerGroup1
,
producerNodes
,
bridgeNodes
)
connectGroup
(
producerGroup2
,
producerNodes
,
bridgeNodes
)
f
=
open
(
shapeFile
,
"w"
)
f
.
write
(
json
.
dumps
(
shapeFileObject
,
indent
=
4
,
sort_keys
=
True
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录