Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
py12306
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
python
py12306
Commits
91e68f68
Unverified
Commit
91e68f68
authored
Jan 22, 2019
by
pjialin
Committed by
GitHub
Jan 22, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #93 from imhy123/master
使用expire判断节点下线
parents
5c8a1327
864c239a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
.gitignore
.gitignore
+1
-0
cluster.py
py12306/cluster/cluster.py
+3
-4
No files found.
.gitignore
View file @
91e68f68
.idea
.idea
.vscode
.DS_Store
.DS_Store
venv
venv
__pycache__
__pycache__
...
...
py12306/cluster/cluster.py
View file @
91e68f68
...
@@ -25,7 +25,7 @@ class Cluster():
...
@@ -25,7 +25,7 @@ class Cluster():
KEY_USER_COOKIES
=
KEY_PREFIX
+
'user_cookies'
KEY_USER_COOKIES
=
KEY_PREFIX
+
'user_cookies'
KEY_USER_INFOS
=
KEY_PREFIX
+
'user_infos'
KEY_USER_INFOS
=
KEY_PREFIX
+
'user_infos'
KEY_USER_LAST_HEARTBEAT
=
KEY_PREFIX
+
'user_last_heartbeat'
KEY_USER_LAST_HEARTBEAT
=
KEY_PREFIX
+
'user_last_heartbeat'
KEY_NODES_ALIVE
=
KEY_PREFIX
+
'nodes_alive
'
KEY_NODES_ALIVE
_PREFIX
=
KEY_PREFIX
+
'nodes_alive_
'
KEY_CDN_AVAILABLE_ITEMS
=
KEY_PREFIX
+
'cdn_available_items'
KEY_CDN_AVAILABLE_ITEMS
=
KEY_PREFIX
+
'cdn_available_items'
KEY_CDN_LAST_CHECK_AT
=
KEY_PREFIX
+
'cdn_last_check_at'
KEY_CDN_LAST_CHECK_AT
=
KEY_PREFIX
+
'cdn_last_check_at'
...
@@ -185,9 +185,8 @@ class Cluster():
...
@@ -185,9 +185,8 @@ class Cluster():
检查节点是否存活
检查节点是否存活
:return:
:return:
"""
"""
alive
=
self
.
session
.
hgetall
(
self
.
KEY_NODES_ALIVE
)
for
node
in
self
.
nodes
:
for
node
in
self
.
nodes
:
if
no
de
not
in
alive
or
(
time_int
()
-
int
(
alive
[
node
]))
>
self
.
lost_alive_time
:
if
no
t
self
.
session
.
exists
(
self
.
KEY_NODES_ALIVE_PREFIX
+
node
)
:
self
.
left_cluster
(
node
)
self
.
left_cluster
(
node
)
# def kick_out_from_nodes(self, node_name):
# def kick_out_from_nodes(self, node_name):
...
@@ -197,7 +196,7 @@ class Cluster():
...
@@ -197,7 +196,7 @@ class Cluster():
while
True
:
while
True
:
if
self
.
node_name
not
in
self
.
get_nodes
():
# 已经被 kict out 重新加下
if
self
.
node_name
not
in
self
.
get_nodes
():
# 已经被 kict out 重新加下
self
.
join_cluster
()
self
.
join_cluster
()
self
.
session
.
hset
(
self
.
KEY_NODES_ALIVE
,
self
.
node_name
,
str
(
time_int
())
)
self
.
session
.
set
(
self
.
KEY_NODES_ALIVE_PREFIX
+
self
.
node_name
,
Config
()
.
NODE_IS_MASTER
,
ex
=
self
.
lost_alive_time
)
stay_second
(
self
.
keep_alive_time
)
stay_second
(
self
.
keep_alive_time
)
def
subscribe
(
self
):
def
subscribe
(
self
):
...
...
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