Package org.apache.hive.hcatalog.templeton.tool

Examples of org.apache.hive.hcatalog.templeton.tool.JobState


  public CompleteBean run(String id)
    throws CallbackFailedException, IOException {
    if (id == null)
      acceptWithError("No jobid given");

    JobState state = null;
    try {
      state = new JobState(id, Main.getAppConfigInstance());
      if (state.getCompleteStatus() == null)
        failed("Job not yet complete. jobId=" + id, null);

      Long notified = state.getNotifiedTime();
      if (notified != null)
        return acceptWithError("Callback already run for jobId=" + id +
                " at " + new Date(notified));

      String callback = state.getCallback();
      if (callback == null)
        return new CompleteBean("No callback registered");

      try {
        doCallback(state.getId(), callback);
      } catch (Exception e) {
        failed("Callback failed " + callback + " for " + id, e);
      }

      state.setNotifiedTime(System.currentTimeMillis());
      return new CompleteBean("Callback sent");
    } finally {
      if (state != null)
        state.close();
    }
  }
View Full Code Here


  }

  public void registerJob(String id, String user, String callback,
      Map<String, Object> userArgs)
    throws IOException {
    JobState state = null;
    try {
      state = new JobState(id, Main.getAppConfigInstance());
      state.setUser(user);
      state.setCallback(callback);
      state.setUserArgs(userArgs);
    } finally {
      if (state != null)
        state.close();
    }
  }
View Full Code Here

      JobStatus[] jobs = tracker.getAllJobs();

      if (jobs != null) {
        for (JobStatus job : jobs) {
          JobState state = null;
          try {
            String id = job.getJobID().toString();
            state = new JobState(id, Main.getAppConfigInstance());
            if (showall || user.equals(state.getUser()))
              ids.add(id);
          } finally {
            if (state != null) {
              state.close();
            }
          }
        }
      }
View Full Code Here

  public QueueStatusBean run(String user, String id)
    throws NotAuthorizedException, BadParam, IOException, InterruptedException
  {
    WebHCatJTShim tracker = null;
    JobState state = null;
    try {
      UserGroupInformation ugi = UgiFactory.getUgi(user);
      tracker = ShimLoader.getHadoopShims().getWebHCatShim(appConf, ugi);
      JobID jobid = StatusDelegator.StringToJobID(id);
      if (jobid == null)
        throw new BadParam("Invalid jobid: " + id);
      state = new JobState(id, Main.getAppConfigInstance());
      return StatusDelegator.makeStatus(tracker, jobid, state);
    } catch (IllegalStateException e) {
      throw new BadParam(e.getMessage());
    } finally {
      if (tracker != null)
        tracker.close();
      if (state != null)
        state.close();
    }
  }
View Full Code Here

  public QueueStatusBean run(String user, String id)
    throws NotAuthorizedException, BadParam, IOException, InterruptedException
  {
    UserGroupInformation ugi = UgiFactory.getUgi(user);
    WebHCatJTShim tracker = null;
    JobState state = null;
    try {
      tracker = ShimLoader.getHadoopShims().getWebHCatShim(appConf, ugi);
      JobID jobid = StatusDelegator.StringToJobID(id);
      if (jobid == null)
        throw new BadParam("Invalid jobid: " + id);
      tracker.killJob(jobid);
      state = new JobState(id, Main.getAppConfigInstance());
      String childid = state.getChildId();
      if (childid != null)
        tracker.killJob(StatusDelegator.StringToJobID(childid));
      return StatusDelegator.makeStatus(tracker, jobid, state);
    } catch (IllegalStateException e) {
      throw new BadParam(e.getMessage());
    } finally {
      if (tracker != null)
        tracker.close();
      if (state != null)
        state.close();
    }
  }
View Full Code Here

  public QueueStatusBean run(String user, String id)
    throws NotAuthorizedException, BadParam, IOException, InterruptedException
  {
    WebHCatJTShim tracker = null;
    JobState state = null;
    try {
      UserGroupInformation ugi = UgiFactory.getUgi(user);
      tracker = ShimLoader.getHadoopShims().getWebHCatShim(appConf, ugi);
      JobID jobid = StatusDelegator.StringToJobID(id);
      if (jobid == null)
        throw new BadParam("Invalid jobid: " + id);
      state = new JobState(id, Main.getAppConfigInstance());
      return StatusDelegator.makeStatus(tracker, jobid, state);
    } catch (IllegalStateException e) {
      throw new BadParam(e.getMessage());
    } finally {
      if (tracker != null)
        tracker.close();
      if (state != null)
        state.close();
    }
  }
View Full Code Here

  public QueueStatusBean run(String user, String id)
    throws NotAuthorizedException, BadParam, IOException, InterruptedException
  {
    UserGroupInformation ugi = UgiFactory.getUgi(user);
    WebHCatJTShim tracker = null;
    JobState state = null;
    try {
      tracker = ShimLoader.getHadoopShims().getWebHCatShim(appConf, ugi);
      JobID jobid = StatusDelegator.StringToJobID(id);
      if (jobid == null)
        throw new BadParam("Invalid jobid: " + id);
      tracker.killJob(jobid);
      state = new JobState(id, Main.getAppConfigInstance());
      List<JobState> children = state.getChildren();
      if (children != null) {
        for (JobState child : children) {
          try {
            tracker.killJob(StatusDelegator.StringToJobID(child.getId()));
          } catch (IOException e) {
            LOG.warn("templeton: fail to kill job " + child.getId());
          }
        }
      }
      return StatusDelegator.makeStatus(tracker, jobid, state);
    } catch (IllegalStateException e) {
      throw new BadParam(e.getMessage());
    } finally {
      if (tracker != null)
        tracker.close();
      if (state != null)
        state.close();
    }
  }
View Full Code Here

  }

  public void registerJob(String id, String user, String callback,
      Map<String, Object> userArgs)
    throws IOException {
    JobState state = null;
    try {
      state = new JobState(id, Main.getAppConfigInstance());
      state.setUser(user);
      state.setCallback(callback);
      state.setUserArgs(userArgs);
    } finally {
      if (state != null)
        state.close();
    }
  }
View Full Code Here

  public CompleteBean run(String id, String jobStatus)
    throws CallbackFailedException, IOException {
    if (id == null)
      acceptWithError("No jobid given");

    JobState state = null;
    /* we don't want to cancel the delegation token if we think the callback is going to
     to be retried, for example, because the job is not complete yet */
    boolean cancelMetastoreToken = false;
    try {
      state = new JobState(id, Main.getAppConfigInstance());
      if (state.getCompleteStatus() == null)
        failed("Job not yet complete. jobId=" + id + " Status from JobTracker=" + jobStatus, null);

      Long notified = state.getNotifiedTime();
      if (notified != null) {
        cancelMetastoreToken = true;
        return acceptWithError("Callback already run for jobId=" + id +
                " at " + new Date(notified));
      }

      String callback = state.getCallback();
      if (callback == null) {
        cancelMetastoreToken = true;
        return new CompleteBean("No callback registered");
      }
     
      try {
        doCallback(state.getId(), callback);
        cancelMetastoreToken = true;
      } catch (Exception e) {
        failed("Callback failed " + callback + " for " + id, e);
      }

      state.setNotifiedTime(System.currentTimeMillis());
      return new CompleteBean("Callback sent");
    } finally {
      state.close();
      HiveMetaStoreClient client = null;
      try {
        if(cancelMetastoreToken) {
          String metastoreTokenStrForm =
                  DelegationTokenCache.getStringFormTokenCache().getDelegationToken(id);
View Full Code Here

  }

  public void registerJob(String id, String user, String callback,
      Map<String, Object> userArgs)
    throws IOException {
    JobState state = null;
    try {
      state = new JobState(id, Main.getAppConfigInstance());
      state.setUser(user);
      state.setCallback(callback);
      state.setUserArgs(userArgs);
    } finally {
      if (state != null)
        state.close();
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hive.hcatalog.templeton.tool.JobState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.