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