Package org.apache.hcatalog.templeton.tool

Examples of org.apache.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", null);

            Long notified = state.getNotifiedTime();
            if (notified != null)
                return acceptWithError("Callback already run on "
                    + new Date(notified.longValue()));

            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


        super(appConf);
    }

    public void registerJob(String id, String user, String callback)
        throws IOException {
        JobState state = null;
        try {
            state = new JobState(id, Main.getAppConfigInstance());
            state.setUser(user);
            state.setCallback(callback);
        } 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 (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 {
        UserGroupInformation ugi = UserGroupInformation.createRemoteUser(user);
        TempletonJobTracker tracker = null;
        JobState state = null;
        try {
            tracker = new TempletonJobTracker(ugi,
                JobTracker.getAddress(appConf),
                appConf);
            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
    {
        UserGroupInformation ugi = UserGroupInformation.createRemoteUser(user);
        TempletonJobTracker tracker = null;
        JobState state = null;
        try {
            tracker = new TempletonJobTracker(ugi,
                                              JobTracker.getAddress(appConf),
                                              appConf);
            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

            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 (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
    {
        TempletonJobTracker tracker = null;
        JobState state = null;
        try {
            tracker = new TempletonJobTracker(getAddress(appConf),
                                              appConf);
            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 = UserGroupInformation.createRemoteUser(user);
        TempletonJobTracker tracker = null;
        JobState state = null;
        try {
            tracker = new TempletonJobTracker(getAddress(appConf),
                                              appConf);
            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

TOP

Related Classes of org.apache.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.