def onGotItem(self, item): """ Process the given item and broadcast outcome Note that item can either be a stop command or a start command not both errors get sent to the logger node and no further processing is done """ d = defer.Deferred() logs = sim.Logger() el = item.firstChildElement() params = sim.getParameters(el, logs) if not params: # not an item for this component d = defer.succeed(None) elif params.cmd == 'stop': d = self.broadcastStop(params) elif params.cmd == 'start': # if they have requested a portfolio run # they should have provided an ID and output location params.run_id = getRunId(item, logs) portfolio = port.getPortfolio(el, logs) if logs.hasSeverity(collab.ERROR_EL): d = self.broadcastLogs(logs, params) else: # broadcast this one log.msg('Portfolio is valid, send on to be processed') d = self.broadcastStart(params, portfolio) return d
def onGotItem(self, item): """ Process the given item and broadcast outcome Needs to respond to stop messages by collecting the answer together and then passing them on API calls need to be distinguished from subsystem messages """ d = defer.Deferred() logs = sim.Logger() node = item.nodeIdentifier el = item.firstChildElement() params = sim.getParameters(el, logs) if not params: # not an item for this component d = defer.succeed(None) # API calls if params.cmd == 'stop': d = self.api_onGotStop(params) elif params.cmd == 'start': portfolio = port.getPortfolio(el, logs) d = self.api_onGotStart(params, portfolio, node) elif params.cmd == 'results': dists = sim.getDistributions(el, logs) d = self.api_broadcastResults(params, dists) elif params.cmd == 'info': progress = sim.getProgress(el, logs) if progress: d = self.api_broadcastProgress(params, progress) return d
def onGotItem(self, item): logger = sim.Logger() params = sim.getParameters(item, logger) if not params: log.msg('cannot find run id') return defer.succeed(None) elif params.cmd == 'results': return self.onGotDistribution(params, item, logger) elif params.cmd == 'stop': return self.onGotStoppedSimulation(params)
def onGotItem(self, item): logger = sim.Logger() params = sim.getParameters(item, logger) d = defer.succeed(None) if not params: log.msg('cannot find run id') elif params.cmd == 'start': if params.run_id not in self.tasks: self.tasks[params.run_id] = self.coop.cooperate(self.onGotStartSimulation(params, item, logger)) elif params.cmd == 'stop': d = self.onGotStoppedSimulation(params) return d