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
Iliya Manolov
neoppod
Commits
96827f57
Commit
96827f57
authored
Jan 03, 2012
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge called-once methods into their caller.
parent
caeac356
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
70 deletions
+53
-70
neo/master/app.py
neo/master/app.py
+53
-70
No files found.
neo/master/app.py
View file @
96827f57
...
...
@@ -150,6 +150,7 @@ class Application(object):
to self as well as master nodes."""
neo
.
lib
.
logging
.
info
(
'begin the election of a primary master'
)
client_handler
=
election
.
ClientElectionHandler
(
self
)
self
.
unconnected_master_node_set
.
clear
()
self
.
negotiating_master_node_set
.
clear
()
self
.
listening_conn
.
setHandler
(
election
.
ServerElectionHandler
(
self
))
...
...
@@ -165,25 +166,6 @@ class Application(object):
self
.
primary
=
None
self
.
primary_master_node
=
None
try
:
self
.
_doElection
(
bootstrap
)
except
ElectionFailure
,
m
:
# something goes wrong, clean then restart
self
.
_electionFailed
(
m
)
bootstrap
=
False
else
:
# election succeed, stop the process
self
.
primary
=
self
.
primary
is
None
break
def
_doElection
(
self
,
bootstrap
):
"""
Start the election process:
- Try to connect to any known master node
- Wait at most for the timeout defined by bootstrap parameter
When done, the current process is defined either as primary or
secondary master node
"""
# Wait at most 20 seconds at bootstrap. Otherwise, wait at most
# 10 seconds to avoid stopping the whole cluster for a long time.
# Note that even if not all master are up in the first 20 seconds
...
...
@@ -193,7 +175,6 @@ class Application(object):
expiration
=
20
else
:
expiration
=
10
client_handler
=
election
.
ClientElectionHandler
(
self
)
t
=
0
while
True
:
current_time
=
time
()
...
...
@@ -217,29 +198,8 @@ class Application(object):
if
not
(
self
.
unconnected_master_node_set
or
self
.
negotiating_master_node_set
):
break
def
_announcePrimary
(
self
):
"""
Broadcast the announce that I'm the primary
"""
# I am the primary.
neo
.
lib
.
logging
.
debug
(
'I am the primary, sending an announcement'
)
for
conn
in
self
.
em
.
getClientList
():
conn
.
notify
(
Packets
.
AnnouncePrimary
())
conn
.
abort
()
t
=
time
()
while
self
.
em
.
getClientList
():
self
.
em
.
poll
(
1
)
if
t
+
10
<
time
():
for
conn
in
self
.
em
.
getClientList
():
conn
.
close
()
break
def
_electionFailed
(
self
,
m
):
"""
Ask other masters to reelect a primary after an election failure.
"""
except
ElectionFailure
,
m
:
# something goes wrong, clean then restart
neo
.
lib
.
logging
.
error
(
'election failed: %s'
,
(
m
,
))
# Ask all connected nodes to reelect a single primary master.
...
...
@@ -260,6 +220,29 @@ class Application(object):
# Close all connections.
for
conn
in
self
.
em
.
getClientList
()
+
self
.
em
.
getServerList
():
conn
.
close
()
bootstrap
=
False
else
:
# election succeed, stop the process
self
.
primary
=
self
.
primary
is
None
break
def
_announcePrimary
(
self
):
"""
Broadcast the announce that I'm the primary
"""
# I am the primary.
neo
.
lib
.
logging
.
debug
(
'I am the primary, sending an announcement'
)
for
conn
in
self
.
em
.
getClientList
():
conn
.
notify
(
Packets
.
AnnouncePrimary
())
conn
.
abort
()
t
=
time
()
while
self
.
em
.
getClientList
():
self
.
em
.
poll
(
1
)
if
t
+
10
<
time
():
for
conn
in
self
.
em
.
getClientList
():
conn
.
close
()
break
def
broadcastNodesInformation
(
self
,
node_list
):
...
...
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