Esempio 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
Esempio 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
Esempio 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'))
Esempio 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
Esempio 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
Esempio 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}
Esempio 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}
Esempio 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}
Esempio 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}
Esempio 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'
    }
Esempio 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
Esempio 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
Esempio 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,
    }
Esempio 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)
Esempio n. 15
0
File: views.py Progetto: 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)
Esempio 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)
Esempio 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
Esempio 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
Esempio 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,
        }
Esempio 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
    }
Esempio 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")
Esempio n. 22
0
File: views.py Progetto: 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")
Esempio 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}
Esempio 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
Esempio 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
    }
Esempio 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
Esempio 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")
Esempio 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")
Esempio 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(),
Esempio 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(),
Esempio 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)
Esempio 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(),