Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
0ca3475
Adding job moving feature
DasFranck Jul 5, 2017
346e0ef
Checking destination_queue is not null or empty before moving a job (…
DasFranck Jul 5, 2017
2c73b9b
Prompt message modified for move action (dashboard/static/js/views/jo…
DasFranck Jul 5, 2017
a3fc2ec
Factoring move with requeue (basetasks/utils.py)
DasFranck Jul 5, 2017
d1ea418
Remove move member function in Job (mrq/job.py)
DasFranck Jul 5, 2017
d5086ad
Retry count is now shown in the dashboard (dashboard/static/js/views/…
DasFranck Jul 5, 2017
fff76c6
Remove move exception import in Job (mrq/job.py)
DasFranck Jul 5, 2017
efbfffe
Adding group job moving feature
DasFranck Jul 5, 2017
62cd693
Adding a supplementary for move action in groupactions (dashboard/sta…
DasFranck Jul 6, 2017
99e88b6
Adding a UI for worker groups configuration (not working for now)
DasFranck Jul 7, 2017
2ea541f
Adding buttons to delete/add workers groups (dashboard/static/js/view…
DasFranck Jul 7, 2017
2d1b322
Updating POST on /api/workergroups (dashboard/app.py)
DasFranck Jul 10, 2017
9bdea97
Updating UI for worker groups configuration, working and nearly finis…
DasFranck Jul 10, 2017
026592e
Don't send profiles with an empty name (Worker group configuration UI)
DasFranck Jul 10, 2017
d51866a
Don't send workergroups with an empty name (Dashboard - Worker group …
DasFranck Jul 11, 2017
7255838
Adding serial checking to avoid configuration conflict writing (Dashb…
DasFranck Jul 11, 2017
f806295
Adding a test for job killing and sleep test task (tests/{test_kill.p…
DasFranck Jul 12, 2017
4e77a07
Adding a killing feature for jobs (mrq/{job.py,worker.py})
DasFranck Jul 12, 2017
0d0b506
Replacing iteritems (non-existant in Python3) (mrq/dashboard/app.py)
DasFranck Jul 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions mrq/basetasks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,29 @@ def perform_action(self, action, query, destination_queue):
if list(query.keys()) == ["queue"]:
Queue(query["queue"]).empty()

elif action == "move":
cursor = self.collection.find(query, projection=["_id", "queue"])
fetched_jobs = list(cursor)
for jobs in group_iter(fetched_jobs, n=1000):
jobs_by_queue = defaultdict(list)
for job in jobs:
jobs_by_queue[job["queue"]].append(job["_id"])
stats["requeued"] += 1

for queue in jobs_by_queue:

updates = {
"status": "queued",
"datequeued": datetime.datetime.utcnow(),
"dateupdated": datetime.datetime.utcnow(),
"queue": destination_queue,
"retry_count": 0
}

self.collection.update({
"_id": {"$in": jobs_by_queue[queue]}
}, {"$set": updates}, multi=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utiliser le code de "requeue" plutôt que tout dupliquer

elif action in ("requeue", "requeue_retry"):

# Requeue task by groups of maximum 1k items (if all in the same
Expand Down
13 changes: 13 additions & 0 deletions mrq/dashboard/static/js/views/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@ define(["jquery", "underscore", "views/generic/datatablepage", "models"],functio
});
self.refreshCallStack(job_id);

} else if (action == "move") {

var queue = prompt("Test");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test

if (queue != null && queue != "")
{
self.jobaction(evt, {
"id": job_id,
"action": action,
"destination_queue": queue
});
}

} else {

self.jobaction(evt, {
Expand Down Expand Up @@ -392,6 +404,7 @@ define(["jquery", "underscore", "views/generic/datatablepage", "models"],functio
"<br/><br/>"+
"<button class='btn btn-xs btn-danger pull-right' data-action='cancel'><span class='glyphicon glyphicon-remove-circle'></span> Cancel</button>"+
"<button class='btn btn-xs btn-warning' data-action='requeue'><span class='glyphicon glyphicon-refresh'></span> Requeue</button>"+
"<button class='btn btn-xs btn-warning' data-action='move'><span class='glyphicon glyphicon-refresh'></span> Move to...</button>"+
"</div>";
}
return "";
Expand Down
4 changes: 4 additions & 0 deletions mrq/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class AbortInterrupt(_MrqInterrupt):
pass


class MovedInterrupt(_MrqInterrupt):
pass


class RetryInterrupt(_MrqInterrupt):
delay = None
queue = None
Expand Down
9 changes: 8 additions & 1 deletion mrq/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from bson import ObjectId
from redis.exceptions import LockError
import time
from .exceptions import RetryInterrupt, MaxRetriesInterrupt, AbortInterrupt, MaxConcurrencyInterrupt
from .exceptions import RetryInterrupt, MaxRetriesInterrupt, AbortInterrupt, MaxConcurrencyInterrupt, MovedInterrupt
from .utils import load_class_by_path, group_iter
import gevent
import objgraph
Expand Down Expand Up @@ -270,6 +270,13 @@ def requeue(self, queue=None, retry_count=0):
"retry_count": retry_count
})

def move(self, queue=None, retry_count=0):
""" Cancel and requeues the current job in an other queue."""
exc = MovedInterrupt()
self._attach_original_exception(exc)
self.requeue(queue, retry_count)
raise exc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

def perform(self):
""" Loads and starts the main task for this job, the saves the result. """

Expand Down