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
3b3b254a
Commit
3b3b254a
authored
Mar 23, 2012
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Packets.AcceptIdentification "primary_uuid" field.
Prepares for type change so it is easily reversible.
parent
f35b298b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
34 deletions
+37
-34
neo/client/handlers/master.py
neo/client/handlers/master.py
+5
-5
neo/client/handlers/storage.py
neo/client/handlers/storage.py
+3
-3
neo/lib/bootstrap.py
neo/lib/bootstrap.py
+2
-2
neo/lib/protocol.py
neo/lib/protocol.py
+1
-1
neo/master/handlers/election.py
neo/master/handlers/election.py
+6
-6
neo/master/handlers/secondary.py
neo/master/handlers/secondary.py
+2
-2
neo/tests/master/testElectionHandler.py
neo/tests/master/testElectionHandler.py
+14
-11
neo/tests/storage/testIdentificationHandler.py
neo/tests/storage/testIdentificationHandler.py
+4
-4
No files found.
neo/client/handlers/master.py
View file @
3b3b254a
...
...
@@ -29,7 +29,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
app
.
trying_master_node
=
None
def
_acceptIdentification
(
self
,
node
,
uuid
,
num_partitions
,
num_replicas
,
your_uuid
,
primary
_uuid
,
known_master_list
):
num_replicas
,
your_uuid
,
primary
,
known_master_list
):
app
=
self
.
app
# Register new master nodes.
...
...
@@ -47,13 +47,13 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
assert
found
,
(
node
,
dump
(
uuid
),
known_master_list
)
conn
=
node
.
getConnection
()
if
primary
_uuid
is
not
None
:
primary_node
=
app
.
nm
.
getByUUID
(
primary
_uuid
)
if
primary
is
not
None
:
primary_node
=
app
.
nm
.
getByUUID
(
primary
)
if
primary_node
is
None
:
# I don't know such a node. Probably this information
# is old. So ignore it.
logging
.
warning
(
'Unknown primary master
UUID
: %s. Ignoring.'
,
dump
(
primary
_uuid
))
logging
.
warning
(
'Unknown primary master: %s. Ignoring.'
,
dump
(
primary
))
return
else
:
if
app
.
trying_master_node
is
not
primary_node
:
...
...
neo/client/handlers/storage.py
View file @
3b3b254a
...
...
@@ -48,10 +48,10 @@ class StorageBootstrapHandler(AnswerBaseHandler):
raise
NodeNotReady
(
message
)
def
_acceptIdentification
(
self
,
node
,
uuid
,
num_partitions
,
num_replicas
,
your_uuid
,
primary
_uuid
,
uuid
,
num_partitions
,
num_replicas
,
your_uuid
,
primary
,
master_list
):
assert
primary
_uuid
==
self
.
app
.
primary_master_node
.
getUUID
(),
(
dump
(
primary
_uuid
),
dump
(
self
.
app
.
primary_master_node
.
getUUID
()))
assert
primary
==
self
.
app
.
primary_master_node
.
getUUID
(),
(
dump
(
primary
),
dump
(
self
.
app
.
primary_master_node
.
getUUID
()))
node
.
setUUID
(
uuid
)
class
StorageAnswersHandler
(
AnswerBaseHandler
):
...
...
neo/lib/bootstrap.py
View file @
3b3b254a
...
...
@@ -90,7 +90,7 @@ class BootstrapManager(EventHandler):
conn
.
close
()
def
_acceptIdentification
(
self
,
node
,
uuid
,
num_partitions
,
num_replicas
,
your_uuid
,
primary
_uuid
,
known_master_list
):
num_replicas
,
your_uuid
,
primary
,
known_master_list
):
nm
=
self
.
app
.
nm
# Register new master nodes.
...
...
@@ -100,7 +100,7 @@ class BootstrapManager(EventHandler):
master_node
=
nm
.
createMaster
(
address
=
address
)
master_node
.
setUUID
(
uuid
)
self
.
primary
=
nm
.
getByUUID
(
primary
_uuid
)
self
.
primary
=
nm
.
getByUUID
(
primary
)
if
self
.
primary
is
None
or
self
.
current
is
not
self
.
primary
:
# three cases here:
# - something goes wrong (unknown UUID)
...
...
neo/lib/protocol.py
View file @
3b3b254a
...
...
@@ -722,7 +722,7 @@ class RequestIdentification(Packet):
PNumber
(
'num_partitions'
),
PNumber
(
'num_replicas'
),
PUUID
(
'your_uuid'
),
PUUID
(
'primary
_uuid
'
),
PUUID
(
'primary'
),
PList
(
'known_master_list'
,
PStruct
(
'master'
,
PAddress
(
'address'
),
...
...
neo/master/handlers/election.py
View file @
3b3b254a
...
...
@@ -79,7 +79,7 @@ class ClientElectionHandler(BaseElectionHandler):
self
.
app
.
negotiating_master_node_set
.
discard
(
addr
)
def
_acceptIdentification
(
self
,
node
,
peer_uuid
,
num_partitions
,
num_replicas
,
your_uuid
,
primary
_uuid
,
known_master_list
):
num_replicas
,
your_uuid
,
primary
,
known_master_list
):
app
=
self
.
app
if
your_uuid
!=
app
.
uuid
:
...
...
@@ -94,7 +94,7 @@ class ClientElectionHandler(BaseElectionHandler):
for
address
,
uuid
in
known_master_list
:
if
app
.
server
==
address
:
# This is self.
assert
peer_uuid
!=
primary
_uuid
or
uuid
==
your_uuid
,
(
assert
peer_uuid
!=
primary
or
uuid
==
your_uuid
,
(
dump
(
uuid
),
dump
(
your_uuid
))
continue
n
=
app
.
nm
.
getByAddress
(
address
)
...
...
@@ -106,18 +106,18 @@ class ClientElectionHandler(BaseElectionHandler):
if
n
.
getUUID
()
is
None
or
n
.
getUUID
()
!=
uuid
:
n
.
setUUID
(
uuid
)
if
primary
_uuid
is
not
None
:
if
primary
is
not
None
:
# The primary master is defined.
if
app
.
primary_master_node
is
not
None
\
and
app
.
primary_master_node
.
getUUID
()
!=
primary
_uuid
:
and
app
.
primary_master_node
.
getUUID
()
!=
primary
:
# There are multiple primary master nodes. This is
# dangerous.
raise
ElectionFailure
,
'multiple primary master nodes'
primary_node
=
app
.
nm
.
getByUUID
(
primary
_uuid
)
primary_node
=
app
.
nm
.
getByUUID
(
primary
)
if
primary_node
is
None
:
# I don't know such a node. Probably this information
# is old. So ignore it.
logging
.
warning
(
'received an unknown primary node
UUID
'
)
logging
.
warning
(
'received an unknown primary node'
)
else
:
# Whatever the situation is, I trust this master.
app
.
primary
=
False
...
...
neo/master/handlers/secondary.py
View file @
3b3b254a
...
...
@@ -87,9 +87,9 @@ class PrimaryHandler(EventHandler):
n
.
setUUID
(
uuid
)
def
_acceptIdentification
(
self
,
node
,
uuid
,
num_partitions
,
num_replicas
,
your_uuid
,
primary
_uuid
,
known_master_list
):
num_replicas
,
your_uuid
,
primary
,
known_master_list
):
app
=
self
.
app
if
primary
_uuid
!=
app
.
primary_master_node
.
getUUID
():
if
primary
!=
app
.
primary_master_node
.
getUUID
():
raise
PrimaryFailure
(
'unexpected primary uuid'
)
if
your_uuid
!=
app
.
uuid
:
...
...
neo/tests/master/testElectionHandler.py
View file @
3b3b254a
...
...
@@ -136,6 +136,7 @@ class MasterClientElectionTests(MasterClientElectionTestBase):
def
test_acceptIdentificationKnowsPrimary
(
self
):
master1
,
master1_conn
=
self
.
identifyToMasterNode
()
master1_uuid
=
master1
.
getUUID
()
primary1
=
master1_uuid
self
.
election
.
acceptIdentification
(
master1_conn
,
NodeTypes
.
MASTER
,
...
...
@@ -143,7 +144,7 @@ class MasterClientElectionTests(MasterClientElectionTestBase):
1
,
0
,
self
.
app
.
uuid
,
master1_uuid
,
primary1
,
[(
master1
.
getAddress
(),
master1_uuid
)],
)
self
.
assertNotEqual
(
self
.
app
.
primary_master_node
,
None
)
...
...
@@ -155,6 +156,8 @@ class MasterClientElectionTests(MasterClientElectionTestBase):
master1_uuid
=
master1
.
getUUID
()
master2_uuid
=
master2
.
getUUID
()
master3_uuid
=
master3
.
getUUID
()
primary1
=
master1_uuid
primary3
=
master3_uuid
master1_address
=
master1
.
getAddress
()
master2_address
=
master2
.
getAddress
()
master3_address
=
master3
.
getAddress
()
...
...
@@ -165,7 +168,7 @@ class MasterClientElectionTests(MasterClientElectionTestBase):
1
,
0
,
self
.
app
.
uuid
,
master1_uuid
,
primary1
,
[(
master1_address
,
master1_uuid
)],
)
self
.
assertRaises
(
ElectionFailure
,
self
.
election
.
acceptIdentification
,
...
...
@@ -175,7 +178,7 @@ class MasterClientElectionTests(MasterClientElectionTestBase):
1
,
0
,
self
.
app
.
uuid
,
master3_uuid
,
primary3
,
[
(
master1_address
,
master1_uuid
),
(
master2_address
,
master2_uuid
),
...
...
@@ -320,7 +323,7 @@ class MasterServerElectionTests(MasterClientElectionTestBase):
address
,
self
.
app
.
name
,
)
node_type
,
uuid
,
partitions
,
replicas
,
_peer_uuid
,
primary
_uuid
,
\
node_type
,
uuid
,
partitions
,
replicas
,
_peer_uuid
,
primary
,
\
master_list
=
self
.
checkAcceptIdentification
(
conn
,
decode
=
True
)
self
.
assertEqual
(
node_type
,
NodeTypes
.
MASTER
)
self
.
assertEqual
(
uuid
,
self
.
app
.
uuid
)
...
...
@@ -329,7 +332,7 @@ class MasterServerElectionTests(MasterClientElectionTestBase):
self
.
assertTrue
((
address
,
peer_uuid
)
in
master_list
)
self
.
assertTrue
(
self
.
app
.
server
in
[
x
[
0
]
for
x
in
master_list
])
self
.
assertEqual
(
peer_uuid
,
_peer_uuid
)
return
primary
_uuid
return
primary
def
testRequestIdentificationDoesNotKnowPrimary
(
self
):
self
.
app
.
primary
=
False
...
...
@@ -338,19 +341,19 @@ class MasterServerElectionTests(MasterClientElectionTestBase):
def
testRequestIdentificationKnowsPrimary
(
self
):
self
.
app
.
primary
=
False
primary
_uuid
=
self
.
getNewUUID
()
primary
=
self
.
getNewUUID
()
self
.
app
.
primary_master_node
=
Mock
({
'getUUID'
:
primary
_uuid
,
'getUUID'
:
primary
,
})
self
.
assertEqual
(
self
.
_requestIdentification
(),
primary
_uuid
)
self
.
assertEqual
(
self
.
_requestIdentification
(),
primary
)
def
testRequestIdentificationIsPrimary
(
self
):
self
.
app
.
primary
=
True
primary
_uuid
=
self
.
app
.
uuid
primary
=
self
.
app
.
uuid
self
.
app
.
primary_master_node
=
Mock
({
'getUUID'
:
primary
_uuid
,
'getUUID'
:
primary
,
})
self
.
assertEqual
(
self
.
_requestIdentification
(),
primary
_uuid
)
self
.
assertEqual
(
self
.
_requestIdentification
(),
primary
)
def
testAnnouncePrimary1
(
self
):
""" check the wrong cases """
...
...
neo/tests/storage/testIdentificationHandler.py
View file @
3b3b254a
...
...
@@ -82,9 +82,9 @@ class StorageIdentificationHandlerTests(NeoUnitTestBase):
uuid
=
self
.
getNewUUID
()
conn
=
self
.
getFakeConnection
(
uuid
=
uuid
)
node
=
self
.
app
.
nm
.
createClient
(
uuid
=
uuid
)
master
_uuid
=
self
.
getNewUUID
()
master
=
self
.
getNewUUID
()
self
.
app
.
master_node
=
Mock
({
'getUUID'
:
master
_uuid
,
'getUUID'
:
master
,
})
self
.
identification
.
requestIdentification
(
conn
,
NodeTypes
.
CLIENT
,
uuid
,
None
,
self
.
app
.
name
)
...
...
@@ -93,11 +93,11 @@ class StorageIdentificationHandlerTests(NeoUnitTestBase):
self
.
assertEqual
(
node
.
getUUID
(),
uuid
)
self
.
assertTrue
(
node
.
getConnection
()
is
conn
)
args
=
self
.
checkAcceptIdentification
(
conn
,
decode
=
True
)
node_type
,
address
,
_np
,
_nr
,
_uuid
,
_master
_uuid
,
_master_list
=
args
node_type
,
address
,
_np
,
_nr
,
_uuid
,
_master
,
_master_list
=
args
self
.
assertEqual
(
node_type
,
NodeTypes
.
STORAGE
)
self
.
assertEqual
(
address
,
None
)
self
.
assertEqual
(
_uuid
,
uuid
)
self
.
assertEqual
(
_master
_uuid
,
master_uuid
)
self
.
assertEqual
(
_master
,
master
)
# TODO: check _master_list ?
if
__name__
==
"__main__"
:
...
...
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