Package org.apache.kahadb.util

Examples of org.apache.kahadb.util.ByteSequence


    void fireJob(JobLocation job) throws IllegalStateException, IOException {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Firing " + job);
        }
        ByteSequence bs = this.store.getPayload(job.getLocation());
        for (JobListener l : jobListeners) {
            l.scheduledJob(job.getJobId(), bs);
        }
    }
View Full Code Here


                                        // hence we won't fire the original cron
                                        // job to the listeners
                                        // but we do need to start a separate
                                        // schedule
                                        String jobId = ID_GENERATOR.generateId();
                                        ByteSequence payload = getPayload(job.getLocation());
                                        schedule(jobId, payload, "", job.getDelay(), job.getPeriod(), job.getRepeat());
                                        waitTime = job.getDelay() != 0 ? job.getDelay() : job.getPeriod();
                                        this.scheduleTime.setWaitTime(waitTime);
                                    }
                                }
View Full Code Here

            }

        });
        for (int i = 0; i < COUNT; i++) {
            String test = new String("test" + i);
            scheduler.schedule("id" + i, new ByteSequence(test.getBytes()), 1000);
        }
        latch.await(5, TimeUnit.SECONDS);
        assertEquals(0,latch.getCount());
    }
View Full Code Here

        });
        long time = 2000;
        for (int i = 0; i < COUNT; i++) {
            String test = new String("test" + i);
            scheduler.schedule("id" + i, new ByteSequence(test.getBytes()), "", time, 10, -1);
        }
        assertTrue(latch.getCount() == COUNT);
        latch.await(3000, TimeUnit.SECONDS);
        assertTrue(latch.getCount() == 0);
    }
View Full Code Here

        final int COUNT = 10;
        final CountDownLatch latch = new CountDownLatch(COUNT);
        long time =  2000;
        for (int i = 0; i < COUNT; i++) {
            String test = new String("test" + i);
            scheduler.schedule("id" + i, new ByteSequence(test.getBytes()), "", time, 1000, -1);
        }
        File directory = store.getDirectory();
        tearDown();
        startStore(directory);
        scheduler.addListener(new JobListener() {
View Full Code Here

        final int COUNT = 10;

        long time = 20000;
        for (int i = 0; i < COUNT; i++) {
            String str = new String("test" + i);
            scheduler.schedule("id" + i, new ByteSequence(str.getBytes()), "", time, 1000, -1);

        }
        int size = scheduler.getNextScheduleJobs().size();
        assertEquals(size, COUNT);
        long removeTime = scheduler.getNextScheduleTime();
View Full Code Here

        final int COUNT = 10;
        final String test = "TESTREMOVE";
        long time = 20000;
        for (int i = 0; i < COUNT; i++) {
            String str = new String("test" + i);
            scheduler.schedule("id" + i, new ByteSequence(str.getBytes()), "", time, 10, -1);
            if (i == COUNT / 2) {
                scheduler.schedule(test, new ByteSequence(test.getBytes()), "", time, 10, -1);
            }
        }

        int size = scheduler.getNextScheduleJobs().size();
        assertEquals(size, COUNT + 1);
View Full Code Here

        final int COUNT = 10;
        final String ID = "id:";
        long time =  20000;
        for (int i = 0; i < COUNT; i++) {
            String str = new String("test" + i);
            scheduler.schedule(ID + i, new ByteSequence(str.getBytes()), "", time, 10 + i, -1);
        }
        List<Job> list = scheduler.getAllJobs();

        assertEquals(list.size(), COUNT);
        int count = 0;
View Full Code Here

        long start = 10000;

        for (int i = 0; i < COUNT; i++) {
            String str = new String("test" + i);
          
                scheduler.schedule(ID + i, new ByteSequence(str.getBytes()), "", start + (i * 1000), 10000 + i, 0);
          
        }
        start = System.currentTimeMillis();
        long finish = start + 12000+ (COUNT * 1000);
        List<Job> list = scheduler.getAllJobs(start, finish);
View Full Code Here

        long start = 10000;

        for (int i = 0; i < COUNT; i++) {
            String str = new String("test" + i);
          
                scheduler.schedule(ID + i, new ByteSequence(str.getBytes()), "", start + (i * 1000), 10000 + i, 0);
          
        }
        start = System.currentTimeMillis();
        long finish = start + 12000+ (COUNT * 1000);
        scheduler.removeAllJobs(start, finish);
View Full Code Here

TOP

Related Classes of org.apache.kahadb.util.ByteSequence

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.