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
Levin Zimmermann
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):
conn
.
answer
(
Packets
.
AnswerNodeInformation
())
def
askPartitionTable
(
self
,
conn
):
ptid
=
self
.
app
.
pt
.
getID
()
row_list
=
self
.
app
.
pt
.
getRowList
()
conn
.
answer
(
Packets
.
AnswerPartitionTable
(
ptid
,
row_list
))
pt
=
self
.
app
.
pt
conn
.
answer
(
Packets
.
AnswerPartitionTable
(
pt
.
getID
(),
pt
.
getRowList
()))
DISCONNECTED_STATE_DICT
=
{
...
...
neo/master/handlers/identification.py
View file @
79ea07c8
...
...
@@ -43,13 +43,11 @@ class IdentificationHandler(MasterHandler):
if
node_type
==
NodeTypes
.
CLIENT
:
if
app
.
cluster_state
!=
ClusterStates
.
RUNNING
:
raise
NotReadyError
node_ctor
=
app
.
nm
.
createClient
handler
=
app
.
client_service_handler
human_readable_node_type
=
' client '
elif
node_type
==
NodeTypes
.
STORAGE
:
if
app
.
cluster_state
==
ClusterStates
.
STOPPING_BACKUP
:
raise
NotReadyError
node_ctor
=
app
.
nm
.
createStorage
manager
=
app
.
_current_manager
if
manager
is
None
:
manager
=
app
...
...
@@ -57,11 +55,9 @@ class IdentificationHandler(MasterHandler):
uuid
is
not
None
and
node
is
not
None
)
human_readable_node_type
=
' storage (%s) '
%
(
state
,
)
elif
node_type
==
NodeTypes
.
MASTER
:
node_ctor
=
app
.
nm
.
createMaster
handler
=
app
.
secondary_master_handler
human_readable_node_type
=
' master '
elif
node_type
==
NodeTypes
.
ADMIN
:
node_ctor
=
app
.
nm
.
createAdmin
handler
=
app
.
administration_handler
human_readable_node_type
=
'n admin '
else
:
...
...
@@ -70,7 +66,8 @@ class IdentificationHandler(MasterHandler):
uuid
=
app
.
getNewUUID
(
uuid
,
address
,
node_type
)
logging
.
info
(
'Accept a'
+
human_readable_node_type
+
uuid_str
(
uuid
))
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
.
setState
(
state
)
node
.
setConnection
(
conn
)
...
...
neo/master/transactions.py
View file @
79ea07c8
...
...
@@ -190,7 +190,8 @@ class TransactionManager(object):
return
oid_list
def
setLastOID
(
self
,
oid
):
self
.
_last_oid
=
max
(
oid
,
self
.
_last_oid
)
if
self
.
_last_oid
<
oid
:
self
.
_last_oid
=
oid
def
getLastOID
(
self
):
return
self
.
_last_oid
...
...
@@ -245,7 +246,8 @@ class TransactionManager(object):
"""
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
):
"""
...
...
@@ -340,9 +342,7 @@ class TransactionManager(object):
instanciation time.
"""
logging
.
debug
(
'Lock TXN %s for %s'
,
dump
(
ttid
),
uuid_str
(
uuid
))
assert
ttid
in
self
.
_ttid_dict
,
"Transaction not started"
txn
=
self
.
_ttid_dict
[
ttid
]
if
txn
.
lock
(
uuid
)
and
self
.
_queue
[
0
][
1
]
==
ttid
:
if
self
.
_ttid_dict
[
ttid
].
lock
(
uuid
)
and
self
.
_queue
[
0
][
1
]
==
ttid
:
# all storage are locked and we unlock the commit queue
self
.
_unlockPending
()
...
...
@@ -352,8 +352,7 @@ class TransactionManager(object):
current transactions
"""
unlock
=
False
# iterate over a copy because _unlockPending may alter the dict
for
ttid
,
txn
in
self
.
_ttid_dict
.
items
():
for
ttid
,
txn
in
self
.
_ttid_dict
.
iteritems
():
if
txn
.
forget
(
uuid
)
and
self
.
_queue
[
0
][
1
]
==
ttid
:
unlock
=
True
if
unlock
:
...
...
@@ -365,12 +364,11 @@ class TransactionManager(object):
pop
=
queue
.
pop
insert
=
queue
.
insert
on_commit
=
self
.
_on_commit
get
=
self
.
_ttid_dict
.
ge
t
ttid_dict
=
self
.
_ttid_dic
t
while
queue
:
uuid
,
ttid
=
pop
(
0
)
txn
=
get
(
ttid
,
None
)
# _queue can contain un-prepared transactions
if
txn
is
not
None
and
txn
.
locked
():
txn
=
ttid_dict
[
ttid
]
if
txn
.
locked
():
on_commit
(
txn
)
else
:
insert
(
0
,
(
uuid
,
ttid
))
...
...
neo/storage/database/manager.py
View file @
79ea07c8
...
...
@@ -180,7 +180,7 @@ class DatabaseManager(object):
"""
ptid
=
self
.
getConfiguration
(
'ptid'
)
if
ptid
is
not
None
:
return
long
(
ptid
)
return
int
(
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