示例#1
0
文件: views.py 项目: bopopescu/hue-2
def kill_job(request, job):
  if request.method != "POST":
    raise Exception(_("kill_job may only be invoked with a POST (got a %(method)s).") % {'method': request.method})

  if not can_kill_job(job, request.user):
    raise PopupException(_("Kill operation is forbidden."))

  try:
    job.kill()
  except Exception, e:
    LOG.exception('Killing job')
    raise PopupException(e)
示例#2
0
文件: views.py 项目: cloudera/hue
def kill_job(request, job):
  if request.method != "POST":
    raise Exception(_("kill_job may only be invoked with a POST (got a %(method)s).") % {'method': request.method})

  if not can_kill_job(job, request.user):
    raise PopupException(_("Kill operation is forbidden."))

  try:
    job.kill()
  except Exception, e:
    LOG.exception('Killing job')
    raise PopupException(e)
示例#3
0
文件: views.py 项目: cloudera/hue
def massage_job_for_json(job, request=None, user=None):
  job = {
    'id': job.jobId,
    'shortId': job.jobId_short,
    'name': hasattr(job, 'jobName') and job.jobName or '',
    'status': job.status,
    'yarnStatus': hasattr(job, 'yarnStatus') and job.yarnStatus or '',
    'url': job.jobId and reverse('jobbrowser.views.single_job', kwargs={'job': job.jobId}) or '',
    'logs': job.jobId and reverse('jobbrowser.views.job_single_logs', kwargs={'job': job.jobId}) or '',
    'queueName': hasattr(job, 'queueName') and job.queueName or _('N/A'),
    'priority': hasattr(job, 'priority') and job.priority or _('N/A'),
    'user': job.user,
    'isRetired': job.is_retired,
    'isMR2': job.is_mr2,
    'progress': hasattr(job, 'progress') and job.progress or 0,
    'mapProgress': hasattr(job, 'mapProgress') and job.mapProgress or '',
    'reduceProgress': hasattr(job, 'reduceProgress') and job.reduceProgress or '',
    'setupProgress': hasattr(job, 'setupProgress') and job.setupProgress or '',
    'cleanupProgress': hasattr(job, 'cleanupProgress') and job.cleanupProgress or '',
    'desiredMaps': job.desiredMaps,
    'desiredReduces': job.desiredReduces,
    'applicationType': hasattr(job, 'applicationType') and job.applicationType or None,
    'type': hasattr(job, 'type') and job.type or None,
    'mapsPercentComplete': int(job.maps_percent_complete) if job.maps_percent_complete else '',
    'finishedMaps': job.finishedMaps,
    'finishedReduces': job.finishedReduces,
    'reducesPercentComplete': int(job.reduces_percent_complete) if job.reduces_percent_complete else '',
    'jobFile': hasattr(job, 'jobFile') and job.jobFile or '',
    'launchTimeMs': hasattr(job, 'launchTimeMs') and job.launchTimeMs or 0,
    'launchTimeFormatted': hasattr(job, 'launchTimeFormatted') and job.launchTimeFormatted or '',
    'startTimeMs': hasattr(job, 'startTimeMs') and job.startTimeMs or 0,
    'startTimeFormatted': hasattr(job, 'startTimeFormatted') and job.startTimeFormatted or '',
    'finishTimeMs': hasattr(job, 'finishTimeMs') and job.finishTimeMs or 0,
    'finishTimeFormatted': hasattr(job, 'finishTimeFormatted') and job.finishTimeFormatted or '',
    'durationFormatted': hasattr(job, 'durationFormatted') and job.durationFormatted or '',
    'durationMs': hasattr(job, 'durationInMillis') and job.durationInMillis or 0,
    'canKill': can_kill_job(job, request.user if request else user),
    'killUrl': job.jobId and reverse('kill_job', kwargs={'job': job.jobId}) or '',
    'diagnostics': hasattr(job, 'diagnostics') and job.diagnostics or '',
  }
  return job
示例#4
0
def massage_job_for_json(job, request=None, user=None):
  job = {
    'id': job.jobId,
    'shortId': job.jobId_short,
    'name': hasattr(job, 'jobName') and job.jobName or '',
    'status': job.status,
    'yarnStatus': hasattr(job, 'yarnStatus') and job.yarnStatus or '',
    'url': job.jobId and reverse('jobbrowser.views.single_job', kwargs={'job': job.jobId}) or '',
    'logs': job.jobId and reverse('jobbrowser.views.job_single_logs', kwargs={'job': job.jobId}) or '',
    'queueName': hasattr(job, 'queueName') and job.queueName or _('N/A'),
    'priority': hasattr(job, 'priority') and job.priority or _('N/A'),
    'user': job.user,
    'isRetired': job.is_retired,
    'isMR2': job.is_mr2,
    'progress': hasattr(job, 'progress') and job.progress or 0,
    'mapProgress': hasattr(job, 'mapProgress') and job.mapProgress or '',
    'reduceProgress': hasattr(job, 'reduceProgress') and job.reduceProgress or '',
    'setupProgress': hasattr(job, 'setupProgress') and job.setupProgress or '',
    'cleanupProgress': hasattr(job, 'cleanupProgress') and job.cleanupProgress or '',
    'desiredMaps': job.desiredMaps,
    'desiredReduces': job.desiredReduces,
    'applicationType': hasattr(job, 'applicationType') and job.applicationType or None,
    'mapsPercentComplete': int(job.maps_percent_complete) if job.maps_percent_complete else '',
    'finishedMaps': job.finishedMaps,
    'finishedReduces': job.finishedReduces,
    'reducesPercentComplete': int(job.reduces_percent_complete) if job.reduces_percent_complete else '',
    'jobFile': hasattr(job, 'jobFile') and job.jobFile or '',
    'launchTimeMs': hasattr(job, 'launchTimeMs') and job.launchTimeMs or 0,
    'launchTimeFormatted': hasattr(job, 'launchTimeFormatted') and job.launchTimeFormatted or '',
    'startTimeMs': hasattr(job, 'startTimeMs') and job.startTimeMs or 0,
    'startTimeFormatted': hasattr(job, 'startTimeFormatted') and job.startTimeFormatted or '',
    'finishTimeMs': hasattr(job, 'finishTimeMs') and job.finishTimeMs or 0,
    'finishTimeFormatted': hasattr(job, 'finishTimeFormatted') and job.finishTimeFormatted or '',
    'durationFormatted': hasattr(job, 'durationFormatted') and job.durationFormatted or '',
    'durationMs': hasattr(job, 'durationInMillis') and job.durationInMillis or 0,
    'canKill': can_kill_job(job, request.user if request else user),
    'killUrl': job.jobId and reverse('jobbrowser.views.kill_job', kwargs={'job': job.jobId}) or '',
    'diagnostics': hasattr(job, 'diagnostics') and job.diagnostics or '',
  }
  return job
示例#5
0
文件: views.py 项目: cquptEthan/hue
def massage_job_for_json(job, request):
    job = {
        "id": job.jobId,
        "shortId": job.jobId_short,
        "name": hasattr(job, "jobName") and job.jobName or "",
        "status": job.status,
        "url": job.jobId and reverse("jobbrowser.views.single_job", kwargs={"job": job.jobId}) or "",
        "logs": job.jobId and reverse("jobbrowser.views.job_single_logs", kwargs={"job": job.jobId}) or "",
        "queueName": hasattr(job, "queueName") and job.queueName or _("N/A"),
        "priority": hasattr(job, "priority") and job.priority.lower() or _("N/A"),
        "user": job.user,
        "isRetired": job.is_retired,
        "isMR2": job.is_mr2,
        "mapProgress": hasattr(job, "mapProgress") and job.mapProgress or "",
        "reduceProgress": hasattr(job, "reduceProgress") and job.reduceProgress or "",
        "setupProgress": hasattr(job, "setupProgress") and job.setupProgress or "",
        "cleanupProgress": hasattr(job, "cleanupProgress") and job.cleanupProgress or "",
        "desiredMaps": job.desiredMaps,
        "desiredReduces": job.desiredReduces,
        "applicationType": hasattr(job, "applicationType") and job.applicationType or None,
        "mapsPercentComplete": int(job.maps_percent_complete) if job.maps_percent_complete else "",
        "finishedMaps": job.finishedMaps,
        "finishedReduces": job.finishedReduces,
        "reducesPercentComplete": int(job.reduces_percent_complete) if job.reduces_percent_complete else "",
        "jobFile": hasattr(job, "jobFile") and job.jobFile or "",
        "launchTimeMs": hasattr(job, "launchTimeMs") and job.launchTimeMs or 0,
        "launchTimeFormatted": hasattr(job, "launchTimeFormatted") and job.launchTimeFormatted or "",
        "startTimeMs": hasattr(job, "startTimeMs") and job.startTimeMs or 0,
        "startTimeFormatted": hasattr(job, "startTimeFormatted") and job.startTimeFormatted or "",
        "finishTimeMs": hasattr(job, "finishTimeMs") and job.finishTimeMs or 0,
        "finishTimeFormatted": hasattr(job, "finishTimeFormatted") and job.finishTimeFormatted or "",
        "durationFormatted": hasattr(job, "durationFormatted") and job.durationFormatted or "",
        "durationMs": hasattr(job, "durationInMillis") and job.durationInMillis or 0,
        "canKill": can_kill_job(job, request.user),
        "killUrl": job.jobId and reverse("jobbrowser.views.kill_job", kwargs={"job": job.jobId}) or "",
    }
    return job