Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
323fd636
Commit
323fd636
authored
Oct 05, 2018
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In logs, dump the partition table in a more compact and readable way
parent
7fff11f6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
31 deletions
+26
-31
neo/lib/pt.py
neo/lib/pt.py
+26
-31
No files found.
neo/lib/pt.py
View file @
323fd636
...
@@ -15,6 +15,8 @@
...
@@ -15,6 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
math
import
math
from
collections
import
defaultdict
from
functools
import
partial
from
.
import
logging
,
protocol
from
.
import
logging
,
protocol
from
.locking
import
Lock
from
.locking
import
Lock
from
.protocol
import
uuid_str
,
CellStates
from
.protocol
import
uuid_str
,
CellStates
...
@@ -256,39 +258,32 @@ class PartitionTable(object):
...
@@ -256,39 +258,32 @@ class PartitionTable(object):
def
_format
(
self
):
def
_format
(
self
):
"""Help debugging partition table management.
"""Help debugging partition table management.
Output sample:
Output sample (np=48, nr=0, just after a 3rd node is added):
pt: node 0: S1, R
pt: 10v 20v 30v 40v
pt: node 1: S2, R
pt: S1 R U.FOF.U.FOF.U.FOF.U.FOF.U.FOF.U.FOF.U.FOF.U.FOF.
pt: node 2: S3, R
pt: S2 R .U.FOF.U.FOF.U.FOF.U.FOF.U.FOF.U.FOF.U.FOF.U.FOF
pt: node 3: S4, R
pt: S3 R ..O..O..O..O..O..O..O..O..O..O..O..O..O..O..O..O
pt: 00: .UU.|U..U|.UU.|U..U|.UU.|U..U|.UU.|U..U|.UU.|U..U|.UU.
pt: 11: U..U|.UU.|U..U|.UU.|U..U|.UU.|U..U|.UU.|U..U|.UU.|U..U
The first line helps to locate a nth partition ('v' is an bottom arrow)
and it is omitted when the table has less than 10 partitions.
Here, there are 4 nodes in RUNNING state.
The first partition has 2 replicas in UP_TO_DATE state, on nodes 1 and
2 (nodes 0 and 3 are displayed as unused for that partition by
displaying a dot).
The first number on the left represents the number of the first
partition on the line (here, line length is 11 to keep the docstring
width under 80 column).
"""
"""
node_list
=
sorted
(
self
.
count_dict
)
node_list
=
sorted
(
self
.
count_dict
)
result
=
[
'pt: node %u: %s, %s'
%
(
i
,
uuid_str
(
node
.
getUUID
()),
if
not
node_list
:
protocol
.
node_state_prefix_dict
[
node
.
getState
()]
)
return
(
)
for
i
,
node
in
enumerate
(
node_list
)]
cell_state_dict
=
protocol
.
cell_state_prefix_dict
append
=
result
.
append
node_dict
=
defaultdict
(
partial
(
bytearray
,
'.'
*
self
.
np
))
line
=
[]
for
offset
,
row
in
enumerate
(
self
.
partition_list
):
max_line_len
=
20
# XXX: hardcoded number of partitions per line
for
cell
in
row
:
prefix
=
0
node_dict
[
cell
.
getNode
()][
offset
]
=
\
prefix_len
=
int
(
math
.
ceil
(
math
.
log10
(
self
.
np
)))
cell_state_dict
[
cell
.
getState
()]
for
offset
,
row
in
enumerate
(
self
.
_formatRows
(
node_list
)):
n
=
len
(
uuid_str
(
node_list
[
-
1
].
getUUID
()))
if
len
(
line
)
==
max_line_len
:
result
=
[
''
.
join
(
'%9sv'
%
x
if
x
else
'pt:'
+
' '
*
(
5
+
n
)
append
(
'pt: %0*u: %s'
%
(
prefix_len
,
prefix
,
'|'
.
join
(
line
)
))
for
x
in
xrange
(
0
,
self
.
np
,
10
))
line
=
[]
]
if
self
.
np
>
10
else
[]
prefix
=
offset
result
.
extend
(
'pt: %-*s %s %s'
%
(
n
,
uuid_str
(
node
.
getUUID
()),
line
.
append
(
row
)
protocol
.
node_state_prefix_dict
[
node
.
getState
()],
if
line
:
node_dict
[
node
])
append
(
'pt: %0*u: %s'
%
(
prefix_len
,
prefix
,
'|'
.
join
(
line
))
)
for
node
in
node_list
)
return
result
return
result
def
_formatRows
(
self
,
node_list
):
def
_formatRows
(
self
,
node_list
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment