Esempio n. 1
0
 def handle_agent_death(self, state, recp):
     recp = IRecipient(recp)
     task = state.handler_tasks.get(recp.key, None)
     if task:
         return task.notify_finish()
     else:
         task = self.initiate_protocol(HandleDeath, recp,
                                       state.notification_sender)
         self._register_task(recp.key, task)
         return task.notify_finish()
Esempio n. 2
0
 def _start_global(self, state, blackbox):
     kwargs = dict()
     if blackbox:
         kwargs['blackbox'] = blackbox
     task = state.agent.initiate_protocol(start_agent.GloballyStartAgent,
                                          state.descriptor, **kwargs)
     return task.notify_finish()
Esempio n. 3
0
 def testTask(self):
     agent = self.get_local('agent')
     yield agent.run_tasks()
     self.assertEqual(agent.get_result("task_result1"), 18 + 18*2)
     self.assertEqual(agent.get_result("task_result2"), 42 + 42*2)
     task = yield agent.start_task(66)
     result = yield task.notify_finish()
     self.assertEqual(result, 66 + 66*2)
Esempio n. 4
0
 def apply_migration(self, state, migration, export=None):
     '''
     apply_migration(migration) -> Apply the migration object.
     '''
     tunel = state.exports.get_by_name(export)
     task = self.initiate_protocol(ApplyMigration, tunel.recipient,
                                   migration)
     return task.notify_finish()
Esempio n. 5
0
 def testRetryingProtocol(self):
     d = self.cb_after(None, self.agent, 'initiate_protocol')
     task = self.agent.retrying_protocol(ErrorTask, max_retries=3)
     self.finished = task.notify_finish()
     yield d
     self.assertEqual(task.attempt, 1)
     yield self.cb_after(None, self.agent, 'initiate_protocol')
     yield self.cb_after(None, self.agent, 'initiate_protocol')
     yield self.cb_after(None, self.agent, 'initiate_protocol')
     self.assertEqual(task.attempt, task.max_retries+1)
     self.assertFailure(self.finished, DummyException)
Esempio n. 6
0
    def apply_migration_step(self, state, migration_or_id, step):
        migration = self._get_migration(migration_or_id)

        if isinstance(step, int):
            step = migration.get_steps()[step]
        if not isinstance(step, MigrationStep):
            raise AttributeError("Second parameter expected to be a "
                                 "MigrationStep or an index in step of"
                                 "migration, got %r instead." % step)
        task = self.initiate_protocol(ApplyMigrationStep, migration, step,
                                      state.notification_sender)
        return task.notify_finish()
Esempio n. 7
0
 def start_agent(self, state, doc_id, allocation_id=None,
                 static_name=None, **kwargs):
     task = self.initiate_protocol(StartAgent, doc_id, allocation_id,
                                   kwargs=kwargs, static_name=static_name)
     return task.notify_finish()
Esempio n. 8
0
 def resolve_missing_shard_agent_problem(self, state, host_recipients):
     task = state.medium.initiate_protocol(
         problem.CollectiveSolver, MissingShard(self), host_recipients)
     return task.notify_finish()