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
Xavier Thompson
neoppod
Commits
79ea07c8
Commit
79ea07c8
authored
Nov 19, 2015
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small optimizations & cleanups
parent
0d36de7b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
20 deletions
+14
-20
neo/master/handlers/__init__.py
neo/master/handlers/__init__.py
+2
-3
neo/master/handlers/identification.py
neo/master/handlers/identification.py
+2
-5
neo/master/transactions.py
neo/master/transactions.py
+9
-11
neo/storage/database/manager.py
neo/storage/database/manager.py
+1
-1
No files found.
neo/master/handlers/__init__.py
View file @
79ea07c8
...
@@ -83,9 +83,8 @@ class MasterHandler(EventHandler):
...
@@ -83,9 +83,8 @@ class MasterHandler(EventHandler):
conn
.
answer
(
Packets
.
AnswerNodeInformation
())
conn
.
answer
(
Packets
.
AnswerNodeInformation
())
def
askPartitionTable
(
self
,
conn
):
def
askPartitionTable
(
self
,
conn
):
ptid
=
self
.
app
.
pt
.
getID
()
pt
=
self
.
app
.
pt
row_list
=
self
.
app
.
pt
.
getRowList
()
conn
.
answer
(
Packets
.
AnswerPartitionTable
(
pt
.
getID
(),
pt
.
getRowList
()))
conn
.
answer
(
Packets
.
AnswerPartitionTable
(
ptid
,
row_list
))
DISCONNECTED_STATE_DICT
=
{
DISCONNECTED_STATE_DICT
=
{
...
...
neo/master/handlers/identification.py
View file @
79ea07c8
...
@@ -43,13 +43,11 @@ class IdentificationHandler(MasterHandler):
...
@@ -43,13 +43,11 @@ class IdentificationHandler(MasterHandler):
if
node_type
==
NodeTypes
.
CLIENT
:
if
node_type
==
NodeTypes
.
CLIENT
:
if
app
.
cluster_state
!=
ClusterStates
.
RUNNING
:
if
app
.
cluster_state
!=
ClusterStates
.
RUNNING
:
raise
NotReadyError
raise
NotReadyError
node_ctor
=
app
.
nm
.
createClient
handler
=
app
.
client_service_handler
handler
=
app
.
client_service_handler
human_readable_node_type
=
' client '
human_readable_node_type
=
' client '
elif
node_type
==
NodeTypes
.
STORAGE
:
elif
node_type
==
NodeTypes
.
STORAGE
:
if
app
.
cluster_state
==
ClusterStates
.
STOPPING_BACKUP
:
if
app
.
cluster_state
==
ClusterStates
.
STOPPING_BACKUP
:
raise
NotReadyError
raise
NotReadyError
node_ctor
=
app
.
nm
.
createStorage
manager
=
app
.
_current_manager
manager
=
app
.
_current_manager
if
manager
is
None
:
if
manager
is
None
:
manager
=
app
manager
=
app
...
@@ -57,11 +55,9 @@ class IdentificationHandler(MasterHandler):
...
@@ -57,11 +55,9 @@ class IdentificationHandler(MasterHandler):
uuid
is
not
None
and
node
is
not
None
)
uuid
is
not
None
and
node
is
not
None
)
human_readable_node_type
=
' storage (%s) '
%
(
state
,
)
human_readable_node_type
=
' storage (%s) '
%
(
state
,
)
elif
node_type
==
NodeTypes
.
MASTER
:
elif
node_type
==
NodeTypes
.
MASTER
:
node_ctor
=
app
.
nm
.
createMaster
handler
=
app
.
secondary_master_handler
handler
=
app
.
secondary_master_handler
human_readable_node_type
=
' master '
human_readable_node_type
=
' master '
elif
node_type
==
NodeTypes
.
ADMIN
:
elif
node_type
==
NodeTypes
.
ADMIN
:
node_ctor
=
app
.
nm
.
createAdmin
handler
=
app
.
administration_handler
handler
=
app
.
administration_handler
human_readable_node_type
=
'n admin '
human_readable_node_type
=
'n admin '
else
:
else
:
...
@@ -70,7 +66,8 @@ class IdentificationHandler(MasterHandler):
...
@@ -70,7 +66,8 @@ class IdentificationHandler(MasterHandler):
uuid
=
app
.
getNewUUID
(
uuid
,
address
,
node_type
)
uuid
=
app
.
getNewUUID
(
uuid
,
address
,
node_type
)
logging
.
info
(
'Accept a'
+
human_readable_node_type
+
uuid_str
(
uuid
))
logging
.
info
(
'Accept a'
+
human_readable_node_type
+
uuid_str
(
uuid
))
if
node
is
None
:
if
node
is
None
:
node
=
node_ctor
(
uuid
=
uuid
,
address
=
address
)
node
=
app
.
nm
.
createFromNodeType
(
node_type
,
uuid
=
uuid
,
address
=
address
)
node
.
setUUID
(
uuid
)
node
.
setUUID
(
uuid
)
node
.
setState
(
state
)
node
.
setState
(
state
)
node
.
setConnection
(
conn
)
node
.
setConnection
(
conn
)
...
...
neo/master/transactions.py
View file @
79ea07c8
...
@@ -190,7 +190,8 @@ class TransactionManager(object):
...
@@ -190,7 +190,8 @@ class TransactionManager(object):
return
oid_list
return
oid_list
def
setLastOID
(
self
,
oid
):
def
setLastOID
(
self
,
oid
):
self
.
_last_oid
=
max
(
oid
,
self
.
_last_oid
)
if
self
.
_last_oid
<
oid
:
self
.
_last_oid
=
oid
def
getLastOID
(
self
):
def
getLastOID
(
self
):
return
self
.
_last_oid
return
self
.
_last_oid
...
@@ -245,7 +246,8 @@ class TransactionManager(object):
...
@@ -245,7 +246,8 @@ class TransactionManager(object):
"""
"""
Set the last TID, keep the previous if lower
Set the last TID, keep the previous if lower
"""
"""
self
.
_last_tid
=
max
(
self
.
_last_tid
,
tid
)
if
self
.
_last_tid
<
tid
:
self
.
_last_tid
=
tid
def
reset
(
self
):
def
reset
(
self
):
"""
"""
...
@@ -340,9 +342,7 @@ class TransactionManager(object):
...
@@ -340,9 +342,7 @@ class TransactionManager(object):
instanciation time.
instanciation time.
"""
"""
logging
.
debug
(
'Lock TXN %s for %s'
,
dump
(
ttid
),
uuid_str
(
uuid
))
logging
.
debug
(
'Lock TXN %s for %s'
,
dump
(
ttid
),
uuid_str
(
uuid
))
assert
ttid
in
self
.
_ttid_dict
,
"Transaction not started"
if
self
.
_ttid_dict
[
ttid
].
lock
(
uuid
)
and
self
.
_queue
[
0
][
1
]
==
ttid
:
txn
=
self
.
_ttid_dict
[
ttid
]
if
txn
.
lock
(
uuid
)
and
self
.
_queue
[
0
][
1
]
==
ttid
:
# all storage are locked and we unlock the commit queue
# all storage are locked and we unlock the commit queue
self
.
_unlockPending
()
self
.
_unlockPending
()
...
@@ -352,8 +352,7 @@ class TransactionManager(object):
...
@@ -352,8 +352,7 @@ class TransactionManager(object):
current transactions
current transactions
"""
"""
unlock
=
False
unlock
=
False
# iterate over a copy because _unlockPending may alter the dict
for
ttid
,
txn
in
self
.
_ttid_dict
.
iteritems
():
for
ttid
,
txn
in
self
.
_ttid_dict
.
items
():
if
txn
.
forget
(
uuid
)
and
self
.
_queue
[
0
][
1
]
==
ttid
:
if
txn
.
forget
(
uuid
)
and
self
.
_queue
[
0
][
1
]
==
ttid
:
unlock
=
True
unlock
=
True
if
unlock
:
if
unlock
:
...
@@ -365,12 +364,11 @@ class TransactionManager(object):
...
@@ -365,12 +364,11 @@ class TransactionManager(object):
pop
=
queue
.
pop
pop
=
queue
.
pop
insert
=
queue
.
insert
insert
=
queue
.
insert
on_commit
=
self
.
_on_commit
on_commit
=
self
.
_on_commit
get
=
self
.
_ttid_dict
.
ge
t
ttid_dict
=
self
.
_ttid_dic
t
while
queue
:
while
queue
:
uuid
,
ttid
=
pop
(
0
)
uuid
,
ttid
=
pop
(
0
)
txn
=
get
(
ttid
,
None
)
txn
=
ttid_dict
[
ttid
]
# _queue can contain un-prepared transactions
if
txn
.
locked
():
if
txn
is
not
None
and
txn
.
locked
():
on_commit
(
txn
)
on_commit
(
txn
)
else
:
else
:
insert
(
0
,
(
uuid
,
ttid
))
insert
(
0
,
(
uuid
,
ttid
))
...
...
neo/storage/database/manager.py
View file @
79ea07c8
...
@@ -180,7 +180,7 @@ class DatabaseManager(object):
...
@@ -180,7 +180,7 @@ class DatabaseManager(object):
"""
"""
ptid
=
self
.
getConfiguration
(
'ptid'
)
ptid
=
self
.
getConfiguration
(
'ptid'
)
if
ptid
is
not
None
:
if
ptid
is
not
None
:
return
long
(
ptid
)
return
int
(
ptid
)
def
setPTID
(
self
,
ptid
):
def
setPTID
(
self
,
ptid
):
"""
"""
...
...
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