Examples of JobScheduler


Examples of com.asakusafw.yaess.core.JobScheduler

    public void multiple() throws Exception {
        Map<String, String> conf = new HashMap<String, String>();
        ServiceProfile<JobScheduler> profile = new ServiceProfile<JobScheduler>(
                "testing", BasicJobScheduler.class, conf, ProfileContext.system(getClass().getClassLoader()));

        JobScheduler instance = profile.newInstance();

        List<Mock> jobs = new ArrayList<Mock>();
        jobs.add(new Mock("a"));
        jobs.add(new Mock("b"));
        jobs.add(new Mock("c"));
        instance.execute(PhaseMonitor.NULL, CONTEXT, jobs, JobScheduler.STRICT);
        Set<String> rest = collectRest(jobs);
        assertThat(rest.size(), is(0));
    }
View Full Code Here

Examples of com.asakusafw.yaess.core.JobScheduler

    public void dependencies() throws Exception {
        Map<String, String> conf = new HashMap<String, String>();
        ServiceProfile<JobScheduler> profile = new ServiceProfile<JobScheduler>(
                "testing", BasicJobScheduler.class, conf, ProfileContext.system(getClass().getClassLoader()));

        JobScheduler instance = profile.newInstance();

        AtomicInteger group = new AtomicInteger();
        List<Mock> jobs = new ArrayList<Mock>();
        jobs.add(new Mock(group, "b", "a"));
        jobs.add(new Mock(group, "d", "b", "c"));
        jobs.add(new Mock(group, "a"));
        jobs.add(new Mock(group, "c", "a"));
        instance.execute(PhaseMonitor.NULL, CONTEXT, jobs, JobScheduler.STRICT);
        Set<String> rest = collectRest(jobs);
        assertThat(rest.size(), is(0));

        assertThat(ordinary(jobs, "a"), lessThan(ordinary(jobs, "b")));
        assertThat(ordinary(jobs, "a"), lessThan(ordinary(jobs, "c")));
View Full Code Here

Examples of com.asakusafw.yaess.core.JobScheduler

    public void cyclic() throws Exception {
        Map<String, String> conf = new HashMap<String, String>();
        ServiceProfile<JobScheduler> profile = new ServiceProfile<JobScheduler>(
                "testing", BasicJobScheduler.class, conf, ProfileContext.system(getClass().getClassLoader()));

        JobScheduler instance = profile.newInstance();

        AtomicInteger group = new AtomicInteger();
        List<Mock> jobs = new ArrayList<Mock>();
        jobs.add(new Mock(group, "a"));
        jobs.add(new Mock(group, "b", "a", "d"));
        jobs.add(new Mock(group, "c", "b"));
        jobs.add(new Mock(group, "d", "c"));
        jobs.add(new Mock(group, "e", "d"));
        try {
            instance.execute(PhaseMonitor.NULL, CONTEXT, jobs, JobScheduler.STRICT);
            fail();
        } catch (IOException e) {
            // ok.
        }
        Set<String> rest = collectRest(jobs);
View Full Code Here

Examples of com.asakusafw.yaess.core.JobScheduler

    public void fail_job() throws Exception {
        Map<String, String> conf = new HashMap<String, String>();
        ServiceProfile<JobScheduler> profile = new ServiceProfile<JobScheduler>(
                "testing", BasicJobScheduler.class, conf, ProfileContext.system(getClass().getClassLoader()));

        JobScheduler instance = profile.newInstance();

        List<Mock> jobs = new ArrayList<Mock>();
        jobs.add(new Mock("a") {
            @Override
            protected void hook() throws IOException {
                throw new IOException();
            }
        });
        try {
            instance.execute(PhaseMonitor.NULL, CONTEXT, jobs, JobScheduler.STRICT);
            fail();
        } catch (IOException e) {
            // ok.
        }
        Set<String> rest = collectRest(jobs);
View Full Code Here

Examples of com.asakusafw.yaess.core.JobScheduler

    public void fail_besteffort() throws Exception {
        Map<String, String> conf = new HashMap<String, String>();
        ServiceProfile<JobScheduler> profile = new ServiceProfile<JobScheduler>(
                "testing", BasicJobScheduler.class, conf, ProfileContext.system(getClass().getClassLoader()));

        JobScheduler instance = profile.newInstance();

        List<Mock> jobs = new ArrayList<Mock>();
        jobs.add(new Mock("a") {
            @Override
            protected void hook() throws IOException {
                throw new IOException();
            }
        });
        jobs.add(new Mock("b"));
        jobs.add(new Mock("c"));
        try {
            instance.execute(PhaseMonitor.NULL, CONTEXT, jobs, JobScheduler.BEST_EFFORT);
            fail();
        } catch (IOException e) {
            // ok.
        }
        Set<String> rest = collectRest(jobs);
View Full Code Here

Examples of com.asakusafw.yaess.core.JobScheduler

    public void fail_stuck() throws Exception {
        Map<String, String> conf = new HashMap<String, String>();
        ServiceProfile<JobScheduler> profile = new ServiceProfile<JobScheduler>(
                "testing", BasicJobScheduler.class, conf, ProfileContext.system(getClass().getClassLoader()));

        JobScheduler instance = profile.newInstance();

        List<Mock> jobs = new ArrayList<Mock>();
        jobs.add(new Mock("a") {
            @Override
            protected void hook() throws IOException {
                throw new IOException();
            }
        });
        jobs.add(new Mock("b"));
        jobs.add(new Mock("c", "a", "b"));
        try {
            instance.execute(PhaseMonitor.NULL, CONTEXT, jobs, JobScheduler.BEST_EFFORT);
            fail();
        } catch (IOException e) {
            // ok.
        }
        Set<String> rest = collectRest(jobs);
View Full Code Here

Examples of com.asakusafw.yaess.core.JobScheduler

        LOG.debug("Loading execution lock feature");
        ExecutionLockProvider locks = profile.getLocks().newInstance();

        LOG.debug("Loading job scheduling feature");
        JobScheduler scheduler = profile.getScheduler().newInstance();

        LOG.debug("Loading hadoop execution feature");
        HadoopScriptHandler hadoopHandler = profile.getHadoopHandler().newInstance();

        LOG.debug("Loading command execution features");
View Full Code Here

Examples of org.apache.activemq.broker.scheduler.JobScheduler

        for (int i = 0; i < NUMBER; i++) {
            ByteSequence buff = new ByteSequence(new String("testjob" + i).getBytes());
            list.add(buff);
        }

        JobScheduler js = store.getJobScheduler("test");
        js.startDispatching();
        int count = 0;
        long startTime = 10 * 60 * 1000;
        long period = startTime;
        for (ByteSequence job : list) {
            js.schedule("id:" + (count++), job, "", startTime, period, -1);
        }

        List<Job> test = js.getAllJobs();
        LOG.debug("Found {} jobs in the store before restart", test.size());
        assertEquals(list.size(), test.size());
        store.stop();
        store.start();
        js = store.getJobScheduler("test");
        test = js.getAllJobs();
        LOG.debug("Found {} jobs in the store after restart", test.size());
        assertEquals(0, test.size());
    }
View Full Code Here

Examples of org.apache.cocoon.components.cron.JobScheduler

    /**
     * @see org.apache.lenya.cms.usecase.scheduling.UsecaseScheduler#schedule(org.apache.lenya.cms.usecase.Usecase,
     *      java.util.Date)
     */
    public void schedule(Usecase usecase, Date date) {
        JobScheduler scheduler = null;
        try {
            scheduler = (JobScheduler) this.manager.lookup(JobScheduler.ROLE);

            Parameters parameters = new Parameters();
            String[] names = usecase.getParameterNames();
            for (int i = 0; i < names.length; i++) {
                Object value = usecase.getParameter(names[i]);
                if (value instanceof String) {
                    parameters.setParameter(names[i], (String) value);
                } else {
                    getLogger().warn(
                            "Parameter [" + names[i] + "] = [" + value + "] ("
                                    + value.getClass().getName()
                                    + ") ignored, only string values are supported.");
                }
            }

            Map objects = new HashMap();
            objects.put(UsecaseCronJob.USECASE_NAME, usecase.getName());
            objects.put(UsecaseCronJob.SOURCE_URL, usecase.getSourceURL());

            String userId = "";
            Request request = ContextHelper.getRequest(this.context);
            Session session = request.getSession(false);
            if (session != null) {
                Identity identity = (Identity) session.getAttribute(Identity.class.getName());
                if (identity != null) {
                    User user = identity.getUser();
                    if (user != null) {
                        userId = user.getId();
                        objects.put(UsecaseCronJob.USER_ID, userId);
                    }
                    Machine machine = identity.getMachine();
                    if (machine != null) {
                        objects.put(UsecaseCronJob.MACHINE_IP, machine.getIp());
                    }
                }
            }

            String role = CronJob.class.getName() + "/usecase";
            String name = getJobName(usecase, userId);
            scheduler.fireJobAt(date, name, role, parameters, objects);

        } catch (Exception e) {
            getLogger().error("Could not create job: ", e);
            throw new RuntimeException(e);
        } finally {
View Full Code Here

Examples of org.apache.cocoon.components.cron.JobScheduler

    /**
     * @see org.apache.lenya.cms.usecase.scheduling.UsecaseScheduler#getJobs()
     */
    public JobSchedulerEntry[] getJobs() {
        JobScheduler scheduler = null;
        JobSchedulerEntry[] entries = null;
        try {
            scheduler = (JobScheduler) this.manager.lookup(JobScheduler.ROLE);

            String[] jobNames = scheduler.getJobNames();
            entries = new JobSchedulerEntry[jobNames.length];

            for (int i = 0; i < jobNames.length; i++) {
                JobSchedulerEntry entry = scheduler.getJobSchedulerEntry(jobNames[i]);
                entries[i] = entry;
            }

        } catch (Exception e) {
            getLogger().error("Could not obtain job list: ", e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.