Package org.glite.lb

Examples of org.glite.lb.ContextIL


            reg.setNs(job.getCreamURL());
            reg.setJobtype(EventRegJob.Jobtype.CREAM);

            //ctxd.log(reg);

            ContextIL ctx = new ContextIL(ILPrefix);
            ctx.setJobid(lbjob);

            if (job.getSequenceCode() == null) {
                ctx.setSeqCode(new SeqCode(SeqCode.CREAM, "no_seqcodes_with_cream_register_cheat"));
            } else {
                ctx.setSeqCode(new SeqCode(SeqCode.CREAM, job.getSequenceCode()));
            }

            ctx.setSource(new Sources(Sources.CREAM_EXECUTOR));
            ctx.setUser(job.getExtraAttribute("USER_DN_X500"));

            //ctx.setUser(ctxd.getUser());
            reg.setJdl(job.getJDL());

            ctx.log(reg);
        } else {
            throw new LBException("LBLogger.register(): grid jobid set, not registering in LB");
        }
    }
View Full Code Here


    public void insertCommand(Job job, Command cmd, int phase, Throwable reason) throws LBException {
        if (job == null) {
            return;
        }

        ContextIL ctx = new ContextIL(ILPrefix);

        if (job.getSequenceCode() == null) {
            ctx.setSeqCode(new SeqCode(SeqCode.CREAM, "no_seqcodes_with_cream_insertcmd_" + cmd.getId() + "_" + phase));
        } else {
            SeqCode sc = new SeqCode(SeqCode.CREAMWMS, job.getSequenceCode());
            sc.incrementSeqCode(new Sources(Sources.CREAM_EXECUTOR));

            job.setSequenceCode(sc.toString());

            ctx.setSeqCode(sc);

            if (jobDB != null && !JobCommandConstant.JOB_PURGE.equals(cmd.getName())) {
                try {
                   jobDB.update(job);
                } catch (DatabaseException ex) {
                    throw new LBException(ex.getMessage());
                }
            }
        }

        ctx.setSource(new Sources(Sources.CREAM_INTERFACE));
        ctx.setUser(cmd.getUserId());

        Jobid jobid;
        if (job.getGridJobId() == null || Job.NOT_AVAILABLE_VALUE.equals(job.getGridJobId())) {
            jobid = new Jobid(defaultLBURI.getHost(), defaultLBURI.getPort(), job.getId());
        } else {
            jobid = new Jobid(job.getGridJobId());
        }

        ctx.setJobid(jobid);

        // logger.debug("insertCommand: id = "+ cmd.getId() + " name = " +
        // cmd.getName()+ " category = " + cmd.getCategory() +
        // " failureReason = " + cmd.getFailureReason() + " description = " +
        // cmd.getDescription());

        EventCREAMStore event = new EventCREAMStore();

         switch (phase) {
             case START:
                event.setResult(EventCREAMStore.Result.START);
                    break;
                case OK:
                    event.setResult(EventCREAMStore.Result.OK);
                    break;
                case FAILED:
                    event.setResult(EventCREAMStore.Result.FAILED);
                    event.setReason(reason.getMessage());
                    break;
            }

            event.setCmdid(""+cmd.getId());

        if (JobCommandConstant.JOB_START.equals(cmd.getName())) {
            event.setCommand(EventCREAMStore.Command.CMDSTART);
        } else if(JobCommandConstant.JOB_CANCEL.equals(cmd.getName())) {
            event.setCommand(EventCREAMStore.Command.CMDCANCEL);
        } else if(JobCommandConstant.JOB_PURGE.equals(cmd.getName())) {
            event.setCommand(EventCREAMStore.Command.CMDPURGE);
        } else if(JobCommandConstant.JOB_SUSPEND.equals(cmd.getName())) {
            event.setCommand(EventCREAMStore.Command.CMDSUSPEND);
        } else if(JobCommandConstant.JOB_RESUME.equals(cmd.getName())) {
            event.setCommand(EventCREAMStore.Command.CMDRESUME);
        } else {
            throw new LBException("LBLogger.insertCommand(): not handled " + cmd.getName());
        }

        ctx.log(event);
    }
View Full Code Here

    public void execute(Job job, Command cmd, int phase, String destid, Throwable reason) throws LBException {
        if (job == null) {
            return;
        }

        ContextIL ctx = new ContextIL(ILPrefix);

        if (job.getSequenceCode() == null) {
            ctx.setSeqCode(new SeqCode(SeqCode.CREAM, "no_seqcodes_with_cream_execute_" + cmd.getId() + "_" + phase));
        } else {
            SeqCode sc = new SeqCode(SeqCode.CREAMWMS, job.getSequenceCode());
            sc.incrementSeqCode(new Sources(Sources.CREAM_EXECUTOR));
            job.setSequenceCode(sc.toString());
            ctx.setSeqCode(sc);

            if (jobDB != null && !JobCommandConstant.JOB_PURGE.equals(cmd.getName())) {
                try {
                   jobDB.update(job);
                } catch (DatabaseException ex) {
                    throw new LBException(ex.getMessage());
                }
            }
        }

        ctx.setSource(new Sources(Sources.CREAM_EXECUTOR));
        ctx.setUser(cmd.getUserId());

        Jobid jobid;
        if (job.getGridJobId() == null || Job.NOT_AVAILABLE_VALUE.equals(job.getGridJobId())) {
            jobid = new Jobid(defaultLBURI.getHost(), defaultLBURI.getPort(), job.getId());
        } else {
            jobid = new Jobid(job.getGridJobId());
        }

        ctx.setJobid(jobid);

        EventCREAMCall event = new EventCREAMCall();
        event.setCallee(new Sources(Sources.LRMS));
        event.setCmdid(""+cmd.getId());
       
        // logger.debug("execute: id = " + cmd.getId() + " name = " +
        // cmd.getName()+ " category = " + cmd.getCategory() +
        // " failureReason = " + cmd.getFailureReason() + " description = " +
        // cmd.getDescription());

        switch (phase) {
            case START:
                event.setResult(EventCREAMCall.Result.START);
                break;
            case OK:
                event.setResult(EventCREAMCall.Result.OK);
                event.setDestid(destid);
                break;
            case FAILED:
                event.setResult(EventCREAMCall.Result.FAILED);
                event.setReason(reason.getMessage());
                break;
        }

        if (JobCommandConstant.JOB_START.equals(cmd.getName())) {
            event.setCommand(EventCREAMCall.Command.CMDSTART);
        } else if (JobCommandConstant.JOB_CANCEL.equals(cmd.getName())) {
            event.setCommand(EventCREAMCall.Command.CMDCANCEL);
        } else if (JobCommandConstant.JOB_PURGE.equals(cmd.getName())) {
            event.setCommand(EventCREAMCall.Command.CMDPURGE);
        } else if (JobCommandConstant.JOB_SUSPEND.equals(cmd.getName())) {
            event.setCommand(EventCREAMCall.Command.CMDSUSPEND);
        } else if (JobCommandConstant.JOB_RESUME.equals(cmd.getName())) {
            event.setCommand(EventCREAMCall.Command.CMDRESUME);
        } else {
            throw new LBException("LBLogger.execute(): not handled " + cmd.getName());
        }
       
        ctx.log(event);
    }
View Full Code Here

    public void statusChanged(Job job, JobStatus status, JobStatus lastStatus, int phase) throws LBException {
        if (job == null) {
            return;
        }

        ContextIL ctx = new ContextIL(ILPrefix);
       
        if (job.getSequenceCode() == null) {
            ctx.setSeqCode(new SeqCode(SeqCode.CREAM, "no_seqcodes_with_cream_statuschange_" + status.getName() + "_" + phase));
        } else {
            SeqCode sc = new SeqCode(SeqCode.CREAMWMS, job.getSequenceCode());
            sc.incrementSeqCode(new Sources(Sources.CREAM_EXECUTOR));
            job.setSequenceCode(sc.toString());
            ctx.setSeqCode(sc);

            if (jobDB != null) {
                try {
                   jobDB.update(job);
                } catch (DatabaseException ex) {
                    throw new LBException(ex.getMessage());
                }
            }
        }
       
        ctx.setSource(new Sources(Sources.CREAM_EXECUTOR));
        ctx.setUser(job.getUserId());

        Jobid jobid;
        if (job.getGridJobId() == null || Job.NOT_AVAILABLE_VALUE.equals(job.getGridJobId())) {
            jobid = new Jobid(defaultLBURI.getHost(), defaultLBURI.getPort(), job.getId());
        } else {
            jobid = new Jobid(job.getGridJobId());
        }
       
        ctx.setJobid(jobid);

        EventCREAMStatus event = new EventCREAMStatus();

        event.setNewState(status.getName());
        event.setNewState(status.getName());
        event.setDescr(status.getDescription());
       
        if (lastStatus != null) {
            event.setOldState(lastStatus.getName());
        }
       
        event.setExitCode(status.getExitCode()); /*
                                                  * reasonable only in Done
                                                  * state
                                                  */
        event.setWorkerNode(job.getWorkerNode());
        event.setLRMSJobid(job.getLRMSJobId());
        event.setFailureReason(status.getFailureReason());
        event.setOrigTimestamp(new Timeval(0, 0)); /* TODO */

        switch (phase) {
            case START:
                event.setResult(EventCREAMStatus.Result.ARRIVED);
                break;
            case OK:
                event.setResult(EventCREAMStatus.Result.DONE);
                break;
            default:
                break; /* XXX */
        }

        ctx.log(event);
    }
View Full Code Here

    public void accept(Job job) throws LBException {
        if (job ==null) {
            return;
        }

        ContextIL ctx = new ContextIL(ILPrefix);
        if (job.getSequenceCode() == null) {
            ctx.setSeqCode(new SeqCode(SeqCode.CREAM, "no_seqcodes_with_cream_accept"));
        } else {
            SeqCode sc = new SeqCode(SeqCode.CREAMWMS, job.getSequenceCode());
            sc.incrementSeqCode(new Sources(Sources.CREAM_EXECUTOR));
           
            job.setSequenceCode(sc.toString());
           
            ctx.setSeqCode(sc);

            if (jobDB != null) {
                try {
                   jobDB.update(job);
                } catch (DatabaseException ex) {
                    throw new LBException(ex.getMessage());
                }
            }
        }
       
        ctx.setSource(new Sources(Sources.CREAM_EXECUTOR));
        ctx.setUser(job.getUserId());

        Jobid jobid;
        if (job.getGridJobId() == null || Job.NOT_AVAILABLE_VALUE.equals(job.getGridJobId())) {
            jobid = new Jobid(defaultLBURI.getHost(), defaultLBURI.getPort(), job.getId());
        } else {
            jobid = new Jobid(job.getGridJobId());
        }
       
        ctx.setJobid(jobid);

        EventCREAMAccepted event = new EventCREAMAccepted();
        event.setLocalJobid(job.getId());

        ctx.log(event);
    }
View Full Code Here

TOP

Related Classes of org.glite.lb.ContextIL

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.