Commit d75b081a authored by Thomas Phil's avatar Thomas Phil

RM-55 scheduler optimizations

parent dbfc2d4e
# from sqlalchemy import func, and_, or_
#
# from strongr.schedulerdomain.model import Job, JobState, VmState, Vm
from strongr.schedulerdomain.model.scalingdrivers.surfhpccloudscaler import SurfHpcScaler
from .wrapper import Command
#
# import strongr.core.gateways
......@@ -14,28 +15,5 @@ class TestCommand(Command):
test:run
"""
def handle(self):
#command_bus = strongr.core.domain.schedulerdomain.SchedulerDomain.schedulerService().getCommandBus()
#command_factory = strongr.core.domain.schedulerdomain.SchedulerDomain.commandFactory()
#command_bus.handle(command_factory.newScaleIn())
# check for VM's marked for death without jobs
#from pprint import pprint
#session = strongr.core.gateways.Gateways.sqlalchemy_session()
# check for VM's marked for death without jobs
#subquery = session.query(Job.vm_id,
# func.count(Job.job_id).label('jobs')) \
# .filter(
# Job.state.in_([JobState.ASSIGNED, JobState.RUNNING])
# ).group_by(Job.vm_id).subquery('j')
# marked_for_death_vms = session.query(Vm) \
# .outerjoin(subquery, subquery.c.vm_id == Vm.vm_id) \
# .filter(and_(Vm.state == VmState.MARKED_FOR_DEATH, or_(subquery.c.jobs == None, subquery.c.jobs == 0))) \
# .all()
#
# pprint(marked_for_death_vms)
command_factory = strongr.core.domain.schedulerdomain.SchedulerDomain.commandFactory()
command_bus = strongr.core.domain.schedulerdomain.SchedulerDomain.schedulerService().getCommandBus()
command_bus.handle(command_factory.newCheckJobsRunning())
s = SurfHpcScaler(config=dict(strongr.core.Core.config().schedulerdomain.as_dict()[strongr.core.Core.config().schedulerdomain.scalingdriver]))
s.scaleout(None)
......@@ -26,7 +26,7 @@ class SurfHpcScaler(AbstractScaleIn, AbstractScaleOut, AbstractVmTemplateRetriev
return deadline
def get_templates(self):
return self._config.templates.as_dict()
return self._config.templates
def scalein(self, command):
if strongr.core.gateways.Gateways.lock('scaleout-lock').exists():
......@@ -89,7 +89,7 @@ class SurfHpcScaler(AbstractScaleIn, AbstractScaleOut, AbstractVmTemplateRetriev
query_factory = strongr.core.domain.schedulerdomain.SchedulerDomain.queryFactory()
query_bus = strongr.core.domain.schedulerdomain.SchedulerDomain.schedulerService().getQueryBus()
templates = dict(config.templates.as_dict()) # make a copy because we want to manipulate the list
templates = dict(config.templates) # make a copy because we want to manipulate the list
active_vms = query_bus.handle(query_factory.newRequestVms([VmState.NEW, VmState.PROVISION, VmState.READY]))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment