Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
neoppod
Commits
ab082d7e
Commit
ab082d7e
authored
Apr 04, 2019
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
neoctl: better display of full partition tables
parent
c6453626
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
12 deletions
+30
-12
neo/lib/pt.py
neo/lib/pt.py
+9
-0
neo/master/pt.py
neo/master/pt.py
+0
-9
neo/neoctl/app.py
neo/neoctl/app.py
+21
-3
No files found.
neo/lib/pt.py
View file @
ab082d7e
...
@@ -109,6 +109,15 @@ class PartitionTable(object):
...
@@ -109,6 +109,15 @@ class PartitionTable(object):
self
.
partition_list
=
[[]
for
_
in
xrange
(
self
.
np
)]
self
.
partition_list
=
[[]
for
_
in
xrange
(
self
.
np
)]
self
.
count_dict
=
{}
self
.
count_dict
=
{}
def
addNodeList
(
self
,
node_list
):
"""Add nodes"""
added_list
=
[]
for
node
in
node_list
:
if
node
not
in
self
.
count_dict
:
self
.
count_dict
[
node
]
=
0
added_list
.
append
(
node
)
return
added_list
def
getAssignedPartitionList
(
self
,
uuid
):
def
getAssignedPartitionList
(
self
,
uuid
):
""" Return the partition assigned to the specified UUID """
""" Return the partition assigned to the specified UUID """
assigned_partitions
=
[]
assigned_partitions
=
[]
...
...
neo/master/pt.py
View file @
ab082d7e
...
@@ -163,15 +163,6 @@ class PartitionTable(neo.lib.pt.PartitionTable):
...
@@ -163,15 +163,6 @@ class PartitionTable(neo.lib.pt.PartitionTable):
return
cell_list
return
cell_list
def
addNodeList
(
self
,
node_list
):
"""Add nodes"""
added_list
=
[]
for
node
in
node_list
:
if
node
not
in
self
.
count_dict
:
self
.
count_dict
[
node
]
=
0
added_list
.
append
(
node
)
return
added_list
def
tweak
(
self
,
drop_list
=
()):
def
tweak
(
self
,
drop_list
=
()):
"""Optimize partition table
"""Optimize partition table
...
...
neo/neoctl/app.py
View file @
ab082d7e
...
@@ -16,9 +16,11 @@
...
@@ -16,9 +16,11 @@
import
sys
import
sys
from
.neoctl
import
NeoCTL
,
NotReadyException
from
.neoctl
import
NeoCTL
,
NotReadyException
from
neo.lib.node
import
NodeManager
from
neo.lib.pt
import
PartitionTable
from
neo.lib.util
import
p64
,
u64
,
tidFromTime
,
timeStringFromTID
from
neo.lib.util
import
p64
,
u64
,
tidFromTime
,
timeStringFromTID
from
neo.lib.protocol
import
uuid_str
,
formatNodeList
,
\
from
neo.lib.protocol
import
uuid_str
,
formatNodeList
,
\
ClusterStates
,
NodeTypes
,
UUID_NAMESPACES
,
ZERO_TID
ClusterStates
,
Node
States
,
Node
Types
,
UUID_NAMESPACES
,
ZERO_TID
action_dict
=
{
action_dict
=
{
'print'
:
{
'print'
:
{
...
@@ -47,6 +49,11 @@ uuid_int = (lambda ns: lambda uuid:
...
@@ -47,6 +49,11 @@ uuid_int = (lambda ns: lambda uuid:
(
ns
[
uuid
[
0
]]
<<
24
)
+
int
(
uuid
[
1
:])
(
ns
[
uuid
[
0
]]
<<
24
)
+
int
(
uuid
[
1
:])
)({
str
(
k
)[
0
]:
v
for
k
,
v
in
UUID_NAMESPACES
.
iteritems
()})
)({
str
(
k
)[
0
]:
v
for
k
,
v
in
UUID_NAMESPACES
.
iteritems
()})
class
dummy_app
:
id_timestamp
=
uuid
=
0
class
TerminalNeoCTL
(
object
):
class
TerminalNeoCTL
(
object
):
def
__init__
(
self
,
*
args
,
**
kw
):
def
__init__
(
self
,
*
args
,
**
kw
):
self
.
neoctl
=
NeoCTL
(
*
args
,
**
kw
)
self
.
neoctl
=
NeoCTL
(
*
args
,
**
kw
)
...
@@ -68,6 +75,15 @@ class TerminalNeoCTL(object):
...
@@ -68,6 +75,15 @@ class TerminalNeoCTL(object):
asNode
=
staticmethod
(
uuid_int
)
asNode
=
staticmethod
(
uuid_int
)
def
formatPartitionTable
(
self
,
row_list
):
nm
=
NodeManager
()
nm
.
update
(
dummy_app
,
1
,
self
.
neoctl
.
getNodeList
(
node_type
=
NodeTypes
.
STORAGE
))
pt
=
object
.
__new__
(
PartitionTable
)
pt
.
_load
(
None
,
None
,
row_list
,
nm
.
getByUUID
)
pt
.
addNodeList
(
nm
.
getByStateList
(
NodeStates
.
RUNNING
))
return
'
\
n
'
.
join
(
line
[
4
:]
for
line
in
pt
.
_format
())
def
formatRowList
(
self
,
row_list
):
def
formatRowList
(
self
,
row_list
):
return
'
\
n
'
.
join
(
'%03d |%s'
%
(
offset
,
return
'
\
n
'
.
join
(
'%03d |%s'
%
(
offset
,
''
.
join
(
' %s - %s |'
%
(
uuid_str
(
uuid
),
state
)
''
.
join
(
' %s - %s |'
%
(
uuid_str
(
uuid
),
state
)
...
@@ -109,7 +125,9 @@ class TerminalNeoCTL(object):
...
@@ -109,7 +125,9 @@ class TerminalNeoCTL(object):
ptid
,
num_replicas
,
row_list
=
self
.
neoctl
.
getPartitionRowList
(
ptid
,
num_replicas
,
row_list
=
self
.
neoctl
.
getPartitionRowList
(
min_offset
=
min_offset
,
max_offset
=
max_offset
,
node
=
node
)
min_offset
=
min_offset
,
max_offset
=
max_offset
,
node
=
node
)
return
'# ptid: %s, replicas: %s
\
n
%s'
%
(
ptid
,
num_replicas
,
return
'# ptid: %s, replicas: %s
\
n
%s'
%
(
ptid
,
num_replicas
,
self
.
formatRowList
(
enumerate
(
row_list
,
min_offset
)))
self
.
formatRowList
(
enumerate
(
row_list
,
min_offset
))
if
min_offset
or
max_offset
else
self
.
formatPartitionTable
(
row_list
))
def
getNodeList
(
self
,
params
):
def
getNodeList
(
self
,
params
):
"""
"""
...
@@ -190,7 +208,7 @@ class TerminalNeoCTL(object):
...
@@ -190,7 +208,7 @@ class TerminalNeoCTL(object):
changed
,
row_list
=
self
.
neoctl
.
tweakPartitionTable
(
changed
,
row_list
=
self
.
neoctl
.
tweakPartitionTable
(
map
(
self
.
asNode
,
params
[
dry_run
:]),
dry_run
)
map
(
self
.
asNode
,
params
[
dry_run
:]),
dry_run
)
if
changed
:
if
changed
:
return
self
.
format
RowList
(
enumerate
(
row_list
)
)
return
self
.
format
PartitionTable
(
row_list
)
return
'No change done.'
return
'No change done.'
def
killNode
(
self
,
params
):
def
killNode
(
self
,
params
):
...
...
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