Exemplo n.º 1
0
 def stop_job(self):
     request = task.StopRequest(jobId=peloton.JobID(value=self.job_id))
     self.client.task_svc.Stop(
         request,
         metadata=self.client.jobmgr_metadata,
         timeout=default_timeout,
     )
Exemplo n.º 2
0
    def stop_task(self, job_id, instance_id):
        """
        param job_id: id of the job
        param instance_id: instance id of the task to stop

        type job_id: str
        type instance_id: int

        rtype: task.StopResponse
        """
        rng = task.InstanceRange(to=instance_id + 1)
        setattr(rng, "from", instance_id)
        request = task.StopRequest(
            jobId=peloton.JobID(value=job_id), ranges=[rng]
        )
        try:
            print_okblue("Stopping task %d of Job %s" % (instance_id, job_id))
            resp = self.client.task_svc.Stop(
                request,
                metadata=self.client.jobmgr_metadata,
                timeout=default_timeout,
            )
            return resp
        except Exception as e:
            print_fail("Exception calling Stop Tasks :%s" % str(e))
            raise
Exemplo n.º 3
0
 def stop(self, ranges=None):
     """
     Stops a job or certain tasks based on the ranges
     :param ranges: the instance ranges to stop
     :return: task stop response from the API
     """
     request = task.StopRequest(jobId=peloton.JobID(value=self.job_id),
                                ranges=ranges)
     response = self.client.task_svc.Stop(
         request,
         metadata=self.client.jobmgr_metadata,
         timeout=self.config.rpc_timeout_sec,
     )
     log.info("stopping tasks in job {0} with ranges {1}".format(
         self.job_id, ranges))
     return response
Exemplo n.º 4
0
    def stop_job(self, job_id):
        """
        param job_id: id of the job
        type job_id: str

        rtype: job.StopResponse
        """
        request = task.StopRequest(jobId=peloton.JobID(value=job_id))
        try:
            print_okblue("Killing all tasks of Job %s" % job_id)
            resp = self.client.task_svc.Stop(
                request,
                metadata=self.client.jobmgr_metadata,
                timeout=default_timeout,
            )
            return resp
        except Exception as e:
            print_fail("Exception calling List Tasks :%s" % str(e))
            raise