Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autoradio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ale
autoradio
Commits
6c2a3abf
Commit
6c2a3abf
authored
11 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
fix some comments where the code has been updated
parent
7ee361e9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
masterelection/masterelection.go
+9
-6
9 additions, 6 deletions
masterelection/masterelection.go
node/node.go
+1
-0
1 addition, 0 deletions
node/node.go
with
10 additions
and
6 deletions
masterelection/masterelection.go
+
9
−
6
View file @
6c2a3abf
...
...
@@ -106,7 +106,7 @@ func (m *MasterElection) runMaster(index uint64) {
case
t
:=
<-
tick
.
C
:
// To verify that we actually are still the
// master (not just we believe we are), try
//
yet another
compare-and-swap to check that
//
a
compare-and-swap
operation
to check that
// the stored master address is still our own,
// and no-one stole our lock. If not, the TTL
// will be updated (and the lock renewed).
...
...
@@ -136,7 +136,9 @@ func (m *MasterElection) runSlave(index uint64) {
// Start a watch on the lock, waiting for its removal.
response
,
err
:=
m
.
client
.
Watch
(
m
.
Path
,
index
+
1
,
nil
,
m
.
stop
)
if
err
!=
nil
{
log
.
Printf
(
"slave Watch() error: %+v"
,
err
)
if
err
!=
etcd
.
ErrWatchStoppedByUser
{
log
.
Printf
(
"slave Watch() error: %+v"
,
err
)
}
return
}
...
...
@@ -162,15 +164,16 @@ func (m *MasterElection) Run() {
// Since a failed Create does not return the
// RAFT index, let's optimistically query the lock
// before starting just to set a baseline for the
//
index
.
//
following Watch()
.
if
iresponse
,
err
:=
m
.
client
.
Get
(
m
.
Path
,
false
);
err
==
nil
{
log
.
Printf
(
"lock already exists: %+v"
,
iresponse
)
watchIndex
=
iresponse
.
ModifiedIndex
}
// Try to acquire the lock. If we are currently the
// master, the previous value should be our own
// address, otherwise it should be unset.
// Try to acquire the lock. This call will only succeed
// if the lockfile does not exist (either because it
// expired, or the previous master exited gracefully and
// deleted it).
response
,
err
:=
m
.
client
.
Create
(
m
.
Path
,
m
.
Addr
,
m
.
TTL
)
if
err
==
nil
{
...
...
This diff is collapsed.
Click to expand it.
node/node.go
+
1
−
0
View file @
6c2a3abf
...
...
@@ -175,6 +175,7 @@ func (w *ConfigSyncer) Run() {
if
err
==
etcd
.
ErrWatchStoppedByUser
{
return
}
else
if
err
!=
nil
{
// Log the error, but keep watching.
log
.
Printf
(
"Watch(): %s"
,
err
)
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment