Skip to content

Commit

Permalink
rebalance actually rebalances
Browse files Browse the repository at this point in the history
  • Loading branch information
witlox committed Aug 28, 2019
1 parent 0e77a2c commit 458a2b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion dcron/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import json
import logging
import pathlib
import time
from datetime import datetime

import jinja2

Expand All @@ -35,7 +37,7 @@

from dcron.cron.cronitem import CronItem
from dcron.datagram.client import broadcast
from dcron.protocols.messages import Kill, Run, Toggle
from dcron.protocols.messages import Kill, Run, Toggle, ReBalance
from dcron.protocols.udpserializer import UdpSerializer
from dcron.storage import CronEncoder
from dcron.utils import get_ip
Expand Down Expand Up @@ -134,6 +136,14 @@ async def re_balance(self, request):

self.scheduler.re_balance()

jobs = self.storage.cluster_jobs.copy()

broadcast(self.udp_port, UdpSerializer.dump(ReBalance(timestamp=datetime.now()), self.hash_key))

time.sleep(5)
for job in jobs:
broadcast(self.udp_port, UdpSerializer.dump(job, self.hash_key))

raise web.HTTPAccepted()

async def kill_job(self, request):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.9.17
current_version = 0.9.18
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from setuptools import setup

version = "0.9.17"
version = "0.9.18"

requirements = ['aiohttp',
'aiofiles',
Expand Down

0 comments on commit 458a2b4

Please sign in to comment.