def launchTask(self, driver, task):
    """
      Invoked when a task has been launched on this executor (initiated via Scheduler::launchTasks).
      Note that this task can be realized with a thread, a process, or some simple computation,
      however, no other callbacks will be invoked on this executor until this callback has returned.
    """
    self.launched.set()
    self.log('launchTask got task: %s:%s' % (task.name, task.task_id.value))

    # TODO(wickman)  Update the tests to call registered(), then remove this line and issue
    # an assert if self._driver is not populated.
    self._driver = driver

    if self._runner:
      log.error('Already running a task! %s' % self._task_id)
      self.send_update(driver, task.task_id.value, mesos_pb.TASK_LOST,
          "Task already running on this executor: %s" % self._task_id)
      return

    self._slave_id = task.slave_id.value
    self._task_id = task.task_id.value

    try:
      assigned_task = assigned_task_from_mesos_task(task)
      mesos_task = mesos_task_instance_from_assigned_task(assigned_task)
    except Exception as e:
      log.fatal('Could not deserialize AssignedTask')
      log.fatal(traceback.format_exc())
      self.send_update(
          driver, self._task_id, mesos_pb.TASK_FAILED, "Could not deserialize task: %s" % e)
      defer(driver.stop, delay=self.STOP_WAIT)
      return

    defer(lambda: self._run(driver, assigned_task, mesos_task))
  def launchTask(self, driver, task):
    """
      Invoked when a task has been launched on this executor (initiated via Scheduler::launchTasks).
      Note that this task can be realized with a thread, a process, or some simple computation,
      however, no other callbacks will be invoked on this executor until this callback has returned.
    """
    self.launched.set()
    self.log('launchTask got task: %s:%s' % (task.name, task.task_id.value))

    # TODO(wickman)  Update the tests to call registered(), then remove this line and issue
    # an assert if self._driver is not populated.
    self._driver = driver

    if self._runner:
      log.error('Already running a task! %s' % self._task_id)
      self.send_update(driver, task.task_id.value, mesos_pb.TASK_LOST,
          "Task already running on this executor: %s" % self._task_id)
      return

    self._slave_id = task.slave_id.value
    self._task_id = task.task_id.value

    try:
      assigned_task = assigned_task_from_mesos_task(task)
      mesos_task = mesos_task_instance_from_assigned_task(assigned_task)
    except Exception as e:
      log.fatal('Could not deserialize AssignedTask')
      log.fatal(traceback.format_exc())
      self.send_update(
          driver, self._task_id, mesos_pb.TASK_FAILED, "Could not deserialize task: %s" % e)
      defer(driver.stop, delay=self.STOP_WAIT)
      return

    defer(lambda: self._run(driver, assigned_task, mesos_task))
 def validate_task(cls, task):
   try:
     assigned_task = assigned_task_from_mesos_task(task)
     return assigned_task
   except Exception:
     log.fatal('Could not deserialize AssignedTask')
     log.fatal(traceback.format_exc())
     return None
Example #4
0
 def validate_task(cls, task):
     try:
         assigned_task = assigned_task_from_mesos_task(task)
         return assigned_task
     except Exception:
         log.fatal('Could not deserialize AssignedTask')
         log.fatal(traceback.format_exc())
         return None
 def _die(self, driver, status, msg):
   log.fatal(msg)
   self.send_update(driver, self._task_id, status, msg)
   defer(driver.stop, delay=self.STOP_WAIT)
Example #6
0
def die(msg):
    log.fatal(msg)
    sys.exit(1)
Example #7
0
 def _die(self, driver, status, msg):
     log.fatal(msg)
     self.send_update(driver, self._task_id, status, msg)
     defer(driver.stop, delay=self.STOP_WAIT)
Example #8
0
def die(msg):
  log.fatal(msg)
  sys.exit(1)
Example #9
0
import twitter.common.log

# By default seperate files are created for each log level
# To have logs in a single file:
twitter.common.log.options.LogOptions.set_simple(True) 
# By default logs are saved /var/tmp/
# To change where logs are saved:
twitter.common.log.options.LogOptions.set_log_dir(os.getcwd())

log = twitter.common.log.init('testapp')

log.debug("debug message %s" % TEXT)
log.info("info message %s" % TEXT)
log.warn("warn message %s" % TEXT)
log.error("error message %s" % TEXT)
log.fatal("fatal message %s" % TEXT)