Ejemplo n.º 1
0
    def get_log(self, notebook, snippet, startFrom=0, size=None):
        job_id = snippet['result']['handle']['id']

        oozie_workflow = check_job_access_permission(self.request, job_id)
        logs, workflow_actions, is_really_done = self._get_log_output(
            oozie_workflow)
        return logs
Ejemplo n.º 2
0
    def get_log(self, notebook, snippet, startFrom=0, size=None):
        job_id = snippet['result']['handle']['id']

        oozie_job = check_job_access_permission(self.request, job_id)
        logs = self._get_log_output(oozie_job)

        return logs if logs else oozie_job.log
Ejemplo n.º 3
0
  def get_log(self, notebook, snippet, startFrom=0, size=None):
    job_id = snippet['result']['handle']['id']

    oozie_workflow = check_job_access_permission(self.request, job_id)
    logs, workflow_actions, is_really_done = self._get_output(oozie_workflow)

    return logs.get('pig', _('No result'))
Ejemplo n.º 4
0
  def get_log(self, notebook, snippet, startFrom=0, size=None):
    job_id = snippet['result']['handle']['id']

    oozie_job = check_job_access_permission(self.request, job_id)
    status_resp = oozie_job.log

    return status_resp
Ejemplo n.º 5
0
  def get_log(self, notebook, snippet, startFrom=0, size=None):
    job_id = snippet['result']['handle']['id']
    request = MockRequest(self.user, self.fs, self.jt)

    oozie_workflow = check_job_access_permission(MockRequest(self.user, self.fs, self.jt), job_id)
    logs, workflow_actions, is_really_done = api.get(self.jt, self.jt, self.user).get_log(request, oozie_workflow)

    return logs
Ejemplo n.º 6
0
    def cancel(self, notebook, snippet):
        job_id = snippet['result']['handle']['id']

        job = check_job_access_permission(self, job_id)
        check_job_edition_permission(job, self.user)

        api.get(self.fs, self.jt, self.user).stop(job_id)

        return {'status': 0}
Ejemplo n.º 7
0
    def cancel(self, notebook, snippet):
        job_id = snippet['result']['handle']['id']

        job = check_job_access_permission(self, job_id)
        oozie_job = check_job_edition_permission(job, self.user)

        oozie_job.kill()

        return {'status': 0}
Ejemplo n.º 8
0
  def cancel(self, notebook, snippet):
    job_id = snippet['result']['handle']['id']

    job = check_job_access_permission(self, job_id)
    oozie_job = check_job_edition_permission(job, self.user)

    oozie_job.kill()

    return {'status': 0}
Ejemplo n.º 9
0
  def cancel(self, notebook, snippet):
    job_id = snippet['result']['handle']['id']

    job = check_job_access_permission(self, job_id)
    check_job_edition_permission(job, self.user)

    api.get(self.fs, self.jt, self.user).stop(job_id)

    return {'status': 0}
Ejemplo n.º 10
0
  def fetch_result(self, notebook, snippet, rows, start_over):
    job_id = snippet['result']['handle']['id']

    oozie_workflow = check_job_access_permission(MockRequest(self.user, self.fs, self.jt), job_id)
    output = get_workflow_output(oozie_workflow, self.fs)

    return {
        'data':  [hdfs_link(output)],
        'meta': [{'name': 'Header', 'type': 'STRING_TYPE', 'comment': ''}],
        'type': 'text'
    }
Ejemplo n.º 11
0
  def check_status(self, notebook, snippet):
    response = {}
    job_id = snippet['result']['handle']['id']
    oozie_job = check_job_access_permission(self.request, job_id)

    if oozie_job.status in ('KILLED', 'FAILED'):
      raise QueryError(_('Job was %s') % oozie_job.status)

    response['status'] = 'running' if oozie_job.is_running() else 'available'

    return response
Ejemplo n.º 12
0
    def check_status(self, notebook, snippet):
        response = {}
        job_id = snippet['result']['handle']['id']
        oozie_job = check_job_access_permission(self.request, job_id)

        if oozie_job.status in ('KILLED', 'FAILED'):
            raise QueryError(_('Job was %s') % oozie_job.status)

        response['status'] = 'running' if oozie_job.is_running(
        ) else 'available'

        return response
Ejemplo n.º 13
0
  def fetch_result(self, notebook, snippet, rows, start_over):
    job_id = snippet['result']['handle']['id']

    oozie_workflow = check_job_access_permission(self.request, job_id)
    logs, workflow_actions, is_really_done = self._get_output(oozie_workflow)

    output = logs.get('pig', _('No result'))

    return {
        'data':  [[line] for line in output.split('\n')], # hdfs_link()
        'meta': [{'name': 'Header', 'type': 'STRING_TYPE', 'comment': ''}],
        'type': 'table',
        'has_more': False,
    }
Ejemplo n.º 14
0
def stop(request):
  if request.method != 'POST':
    raise PopupException(_('POST request required.'))

  pig_script = PigScript.objects.get(id=request.POST.get('id'))
  job_id = pig_script.dict['job_id']

  job = check_job_access_permission(request, job_id)
  check_job_edition_permission(job, request.user)

  try:
    api.get(request.fs, request.jt, request.user).stop(job_id)
  except RestException, e:
    raise PopupException(_("Error stopping Pig script.") % e.message)
Ejemplo n.º 15
0
Archivo: views.py Proyecto: ronglei/hue
def stop(request):
    if request.method != "POST":
        raise PopupException(_("POST request required."))

    spark_script = SparkScript.objects.get(id=request.POST.get("id"))
    job_id = spark_script.dict["job_id"]

    job = check_job_access_permission(request, job_id)
    check_job_edition_permission(job, request.user)

    try:
        api.get(request.fs, request.jt, request.user).stop(job_id)
    except RestException, e:
        raise PopupException(_("Error stopping Pig script.") % e.message)
Ejemplo n.º 16
0
def stop(request):
    if request.method != 'POST':
        raise PopupException(_('POST request required.'))

    pig_script = PigScript.objects.get(id=request.POST.get('id'))
    job_id = pig_script.dict['job_id']

    job = check_job_access_permission(request, job_id)
    check_job_edition_permission(job, request.user)

    try:
        api.get(request.fs, request.jt, request.user).stop(job_id)
    except RestException, e:
        raise PopupException(_("Error stopping Pig script.") % e.message)
Ejemplo n.º 17
0
  def get_jobs(self, notebook, snippet, logs):
    jobs = []
    job_id = snippet['result']['handle']['id']

    oozie_job = check_job_access_permission(self.request, job_id)
    actions = oozie_job.get_working_actions()
    for action in actions:
      if action.externalId is not None:
        jobs.append({
          'name': action.externalId,
          'url': reverse('jobbrowser.views.single_job', kwargs={'job': action.externalId}),
          'started': action.startTime is not None,
          'finished': action.endTime is not None
        })
    return jobs
Ejemplo n.º 18
0
  def get_jobs(self, notebook, snippet, logs):
    jobs = []
    job_id = snippet['result']['handle']['id']

    oozie_job = check_job_access_permission(self.request, job_id)
    actions = oozie_job.get_working_actions()
    for action in actions:
      if action.externalId is not None:
        jobs.append({
          'name': action.externalId,
          'url': reverse('jobbrowser.views.single_job', kwargs={'job': action.externalId}),
          'started': action.startTime is not None,
          'finished': action.endTime is not None
        })
    return jobs
Ejemplo n.º 19
0
    def fetch_result(self, notebook, snippet, rows, start_over):
        job_id = snippet['result']['handle']['id']

        oozie_workflow = check_job_access_permission(self.request, job_id)
        logs, workflow_actions, is_really_done = self._get_output(
            oozie_workflow)

        output = logs.get('pig', _('No result'))

        return {
            'data': [[line] for line in output.split('\n')],  # hdfs_link()
            'meta': [{
                'name': 'Header',
                'type': 'STRING_TYPE',
                'comment': ''
            }],
            'type': 'table',
            'has_more': False,
        }
Ejemplo n.º 20
0
  def check_status(self, notebook, snippet):
    job_id = snippet['result']['handle']['id']
    request = MockRequest(self.user, self.fs, self.jt)

    oozie_workflow = check_job_access_permission(request, job_id)
    logs, workflow_actions, is_really_done = api.get(self.jt, self.jt, self.user).get_log(request, oozie_workflow)

    if is_really_done and not oozie_workflow.is_running():
      if oozie_workflow.status in ('KILLED', 'FAILED'):
        raise QueryError(_('The script failed to run and was stopped'))
      status = 'available'
    elif oozie_workflow.is_running():
      status = 'running'
    else:
      status = 'failed'

    return {
        'status': status
    }
Ejemplo n.º 21
0
def watch(request, job_id):
    oozie_workflow = check_job_access_permission(request, job_id)
    logs, workflow_actions, is_really_done = api.get(
        request.fs, request.jt, request.user).get_log(request, oozie_workflow)
    output = get_workflow_output(oozie_workflow, request.fs)

    workflow = {
        'job_id':
        oozie_workflow.id,
        'status':
        oozie_workflow.status,
        'progress':
        oozie_workflow.get_progress(),
        'isRunning':
        oozie_workflow.is_running(),
        'killUrl':
        reverse('oozie:manage_oozie_jobs',
                kwargs={
                    'job_id': oozie_workflow.id,
                    'action': 'kill'
                }),
        'rerunUrl':
        reverse('oozie:rerun_oozie_job',
                kwargs={
                    'job_id':
                    oozie_workflow.id,
                    'app_path':
                    urllib.parse.quote(oozie_workflow.appPath.encode('utf-8'),
                                       safe=SAFE_CHARACTERS_URI_COMPONENTS)
                }),
        'actions':
        workflow_actions
    }

    response = {
        'workflow': workflow,
        'logs': logs,
        'isReallyDone': is_really_done,
        'output': hdfs_link(output)
    }

    return JsonResponse(response, content_type="text/plain")
Ejemplo n.º 22
0
Archivo: views.py Proyecto: ronglei/hue
def watch(request, job_id):
    oozie_workflow = check_job_access_permission(request, job_id)
    logs, workflow_actions = api.get(request.jt, request.jt, request.user).get_log(request, oozie_workflow)
    output = get_workflow_output(oozie_workflow, request.fs)

    workflow = {
        "job_id": oozie_workflow.id,
        "status": oozie_workflow.status,
        "progress": oozie_workflow.get_progress(),
        "isRunning": oozie_workflow.is_running(),
        "killUrl": reverse("oozie:manage_oozie_jobs", kwargs={"job_id": oozie_workflow.id, "action": "kill"}),
        "rerunUrl": reverse(
            "oozie:rerun_oozie_job", kwargs={"job_id": oozie_workflow.id, "app_path": oozie_workflow.appPath}
        ),
        "actions": workflow_actions,
    }

    response = {"workflow": workflow, "logs": logs, "output": hdfs_link(output)}

    return HttpResponse(json.dumps(response), content_type="text/plain")
Ejemplo n.º 23
0
    def check_status(self, notebook, snippet):
        job_id = snippet['result']['handle']['id']

        oozie_workflow = check_job_access_permission(self.request, job_id)
        logs, workflow_actions, is_really_done = self._get_output(
            oozie_workflow)

        if is_really_done and not oozie_workflow.is_running():
            if oozie_workflow.status in ('KILLED', 'FAILED'):
                raise QueryError(_('The script failed to run and was stopped'))
            if logs:
                status = 'available'
            else:
                status = 'running'  # Tricky case when the logs are being moved by YARN at job completion
        elif oozie_workflow.is_running():
            status = 'running'
        else:
            status = 'failed'

        return {'status': status}
Ejemplo n.º 24
0
  def check_status(self, notebook, snippet):
    response = {'status': 'running'}

    job_id = snippet['result']['handle']['id']
    oozie_job = check_job_access_permission(self.request, job_id)

    if oozie_job.is_running():
      return response
    elif oozie_job.status in ('KILLED', 'FAILED'):
      raise QueryError(_('Job was %s') % oozie_job.status)
    else:
      # Check if job results are actually available, since YARN takes a while to move logs to JHS,
      log_output = self.get_log(notebook, snippet)
      if log_output:
        results = self._get_results(log_output, snippet['type'])
        if results:
          response['status'] = 'available'
      else:
        response['status'] = 'failed'

    return response
Ejemplo n.º 25
0
  def check_status(self, notebook, snippet):
    job_id = snippet['result']['handle']['id']

    oozie_workflow = check_job_access_permission(self.request, job_id)
    logs, workflow_actions, is_really_done = self._get_output(oozie_workflow)

    if is_really_done and not oozie_workflow.is_running():
      if oozie_workflow.status in ('KILLED', 'FAILED'):
        raise QueryError(_('The script failed to run and was stopped'))
      if logs:
        status = 'available'
      else:
        status = 'running' # Tricky case when the logs are being moved by YARN at job completion
    elif oozie_workflow.is_running():
      status = 'running'
    else:
      status = 'failed'

    return {
        'status': status
    }
Ejemplo n.º 26
0
    def check_status(self, notebook, snippet):
        response = {'status': 'running'}

        job_id = snippet['result']['handle']['id']
        oozie_job = check_job_access_permission(self.request, job_id)

        if oozie_job.is_running():
            return response
        elif oozie_job.status in ('KILLED', 'FAILED'):
            raise QueryError(_('Job was %s') % oozie_job.status)
        else:
            # Check if job results are actually available, since YARN takes a while to move logs to JHS,
            log_output = self.get_log(notebook, snippet)
            if log_output:
                results = self._get_results(log_output, snippet['type'])
                if results:
                    response['status'] = 'available'
            else:
                response['status'] = 'failed'

        return response
Ejemplo n.º 27
0
def watch(request, job_id):
    oozie_workflow = check_job_access_permission(request, job_id)
    logs, workflow_actions, is_really_done = api.get(
        request.jt, request.jt, request.user).get_log(request, oozie_workflow)
    output = get_workflow_output(oozie_workflow, request.fs)

    workflow = {
        'job_id':
        oozie_workflow.id,
        'status':
        oozie_workflow.status,
        'progress':
        oozie_workflow.get_progress(),
        'isRunning':
        oozie_workflow.is_running(),
        'killUrl':
        reverse('oozie:manage_oozie_jobs',
                kwargs={
                    'job_id': oozie_workflow.id,
                    'action': 'kill'
                }),
        'rerunUrl':
        reverse('oozie:rerun_oozie_job',
                kwargs={
                    'job_id': oozie_workflow.id,
                    'app_path': oozie_workflow.appPath
                }),
        'actions':
        workflow_actions
    }

    response = {
        'workflow': workflow,
        'logs': logs,
        'isReallyDone': is_really_done,
        'output': hdfs_link(output)
    }

    return HttpResponse(json.dumps(response), content_type="text/plain")
Ejemplo n.º 28
0
def watch(request, job_id):
  oozie_workflow = check_job_access_permission(request, job_id)
  logs, workflow_actions = api.get(request.jt, request.jt, request.user).get_log(request, oozie_workflow)
  output = get_workflow_output(oozie_workflow, request.fs)

  workflow = {
    'job_id': oozie_workflow.id,
    'status': oozie_workflow.status,
    'progress': oozie_workflow.get_progress(),
    'isRunning': oozie_workflow.is_running(),
    'killUrl': reverse('oozie:manage_oozie_jobs', kwargs={'job_id': oozie_workflow.id, 'action': 'kill'}),
    'rerunUrl': reverse('oozie:rerun_oozie_job', kwargs={'job_id': oozie_workflow.id, 'app_path': oozie_workflow.appPath}),
    'actions': workflow_actions
  }

  response = {
    'workflow': workflow,
    'logs': logs,
    'output': hdfs_link(output)
  }

  return HttpResponse(json.dumps(response), content_type="text/plain")
Ejemplo n.º 29
0
    def progress(self, snippet, logs):
        job_id = snippet['result']['handle']['id']

        oozie_job = check_job_access_permission(self.request, job_id)
        return oozie_job.get_progress(),
Ejemplo n.º 30
0
  def progress(self, snippet, logs):
    job_id = snippet['result']['handle']['id']

    oozie_job = check_job_access_permission(self.request, job_id)
    return oozie_job.get_progress(),
Ejemplo n.º 31
0
  def get_log(self, notebook, snippet, startFrom=0, size=None):
    job_id = snippet['result']['handle']['id']

    oozie_job = check_job_access_permission(self.request, job_id)
    return self._get_log_output(oozie_job)
Ejemplo n.º 32
0
  def progress(self, snippet, logs):
    job_id = snippet['result']['handle']['id']

    oozie_workflow = check_job_access_permission(MockRequest(self.user, self.fs, self.jt), job_id)
    return oozie_workflow.get_progress(),