Ejemplo n.º 1
0
 def _write_process_update(self, **kw):
     """Write a process update to the coordinator's checkpoint stream."""
     process_status = ProcessStatus(**kw)
     process_status.seq = self._seq
     process_status.process = self.name()
     self._ckpt_write(RunnerCkpt(process_status=process_status))
     self._seq += 1
Ejemplo n.º 2
0
 def _initialize_ckpt_header(self):
   """
     Initializes the RunnerHeader for this checkpoint stream if it has not already
     been constructed.
   """
   if self._state.header is None:
     header = RunnerHeader(
       task_id=self._task_id,
       launch_time_ms=int(self._launch_time*1000),
       sandbox=self._sandbox,
       log_dir=self._log_dir,
       hostname=socket.gethostname(),
       user=self._user,
       ports=self._portmap)
     runner_ckpt = RunnerCkpt(runner_header=header)
     self._dispatcher.dispatch(self._state, runner_ckpt)
Ejemplo n.º 3
0
 def _set_process_status(self, process_name, process_state, **kw):
   if 'sequence_number' in kw:
     sequence_number = kw.pop('sequence_number')
     log.debug('_set_process_status(%s <= %s, seq=%s[force])' % (process_name,
       ProcessState._VALUES_TO_NAMES.get(process_state), sequence_number))
   else:
     current_run = self._current_process_run(process_name)
     if not current_run:
       assert process_state == ProcessState.WAITING
       sequence_number = 0
     else:
       sequence_number = current_run.seq + 1
     log.debug('_set_process_status(%s <= %s, seq=%s[auto])' % (process_name,
       ProcessState._VALUES_TO_NAMES.get(process_state), sequence_number))
   runner_ckpt = RunnerCkpt(process_status=ProcessStatus(
     process=process_name, state=process_state, seq=sequence_number, **kw))
   self._dispatcher.dispatch(self._state, runner_ckpt, self._recovery)
Ejemplo n.º 4
0
 def write_process_status(status):
     ckpt.write(RunnerCkpt(process_status=status))
Ejemplo n.º 5
0
 def write_task_state(state):
     update = TaskStatus(state=state,
                         timestamp_ms=int(clock.time() * 1000),
                         runner_pid=os.getpid(),
                         runner_uid=os.getuid())
     ckpt.write(RunnerCkpt(task_status=update))
Ejemplo n.º 6
0
 def _set_task_status(self, state):
   update = TaskStatus(state=state, timestamp_ms=int(self._clock.time() * 1000),
                       runner_pid=os.getpid(), runner_uid=os.getuid())
   runner_ckpt = RunnerCkpt(task_status=update)
   self._dispatcher.dispatch(self._state, runner_ckpt, self._recovery)
Ejemplo n.º 7
0
 def on_initialization(self, header):
   log.debug('_on_initialization: %s' % header)
   ThermosTaskValidator.assert_valid_task(self._runner.task)
   ThermosTaskValidator.assert_valid_ports(self._runner.task, header.ports)
   self._checkpoint(RunnerCkpt(runner_header=header))
Ejemplo n.º 8
0
 def on_task_transition(self, state, task_update):
   log.debug('_on_task_transition: %s' % task_update)
   self._checkpoint(RunnerCkpt(task_status=task_update))
Ejemplo n.º 9
0
 def on_process_transition(self, state, process_update):
   log.debug('_on_process_transition: %s' % process_update)
   self._checkpoint(RunnerCkpt(process_status=process_update))