Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
437844f1
authored
Feb 18, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: added queue checkig mechanism
parent
dc4d0b54
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
circle/storage/models.py
+7
-2
circle/storage/tasks/local_tasks.py
+19
-0
No files found.
circle/storage/models.py
View file @
437844f1
...
@@ -13,7 +13,7 @@ from sizefield.models import FileSizeField
...
@@ -13,7 +13,7 @@ from sizefield.models import FileSizeField
from
acl.models
import
AclBase
from
acl.models
import
AclBase
from
.tasks
import
local_tasks
,
remote_tasks
from
.tasks
import
local_tasks
,
remote_tasks
from
common.models
import
ActivityModel
,
activitycontextimpl
from
common.models
import
ActivityModel
,
activitycontextimpl
,
WorkerNotFound
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -36,7 +36,12 @@ class DataStore(Model):
...
@@ -36,7 +36,12 @@ class DataStore(Model):
return
u'
%
s (
%
s)'
%
(
self
.
name
,
self
.
path
)
return
u'
%
s (
%
s)'
%
(
self
.
name
,
self
.
path
)
def
get_remote_queue_name
(
self
,
queue_id
):
def
get_remote_queue_name
(
self
,
queue_id
):
return
self
.
hostname
+
'.'
+
queue_id
logger
.
debug
(
"Checking for storage queue
%
s.
%
s"
,
self
.
hostname
,
queue_id
)
if
local_tasks
.
check_queue
(
self
.
hostname
,
queue_id
):
return
self
.
hostname
+
'.'
+
queue_id
else
:
raise
WorkerNotFound
()
class
Disk
(
AclBase
,
TimeStampedModel
):
class
Disk
(
AclBase
,
TimeStampedModel
):
...
...
circle/storage/tasks/local_tasks.py
View file @
437844f1
...
@@ -2,6 +2,25 @@ from manager.mancelery import celery
...
@@ -2,6 +2,25 @@ from manager.mancelery import celery
@celery.task
@celery.task
def
check_queue
(
storage
,
queue_id
):
''' Celery inspect job to check for active workers at queue_id
return True/False
'''
drivers
=
[
'storage'
,
'download'
]
worker_list
=
[
storage
+
"."
+
d
for
d
in
drivers
]
queue_name
=
storage
+
"."
+
queue_id
# v is List of List of queues dict
active_queues
=
celery
.
control
.
inspect
(
worker_list
)
.
active_queues
()
if
active_queues
is
not
None
:
node_workers
=
[
v
for
k
,
v
in
active_queues
.
iteritems
()]
for
worker
in
node_workers
:
for
queue
in
worker
:
if
queue
[
'name'
]
==
queue_name
:
return
True
return
False
@celery.task
def
deploy
(
disk
,
user
):
def
deploy
(
disk
,
user
):
disk
.
deploy
(
task_uuid
=
deploy
.
request
.
id
,
user
=
user
)
disk
.
deploy
(
task_uuid
=
deploy
.
request
.
id
,
user
=
user
)
...
...
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