Package org.apache.kahadb.util

Examples of org.apache.kahadb.util.ByteSequence


                        }
                    }
                }
                systemUsage.getTempUsage().waitForSpace();
                node.decrementReferenceCount();
                ByteSequence bs = getByteSequence(node.getMessage());
                getDiskList().addFirst(node.getMessageId().toString(), bs);

            } catch (Exception e) {
                LOG.error("Caught an Exception adding a message: " + node + " first to FilePendingMessageCursor ", e);
                throw new RuntimeException(e);
View Full Code Here


                LOG.trace("" + name + ", flushToDisk() mem list size: " +memoryList.size()  + " " (systemUsage != null ? systemUsage.getMemoryUsage() : "") );
             }
            for (Iterator<MessageReference> iterator = memoryList.iterator(); iterator.hasNext();) {
                MessageReference node = iterator.next();
                node.decrementReferenceCount();
                ByteSequence bs;
                try {
                    bs = getByteSequence(node.getMessage());
                    getDiskList().addLast(node.getMessageId().toString(), bs);
                } catch (IOException e) {
                    LOG.error("Failed to write to disk list", e);
View Full Code Here

        }
    }

    protected ByteSequence getByteSequence(Message message) throws IOException {
        org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(message);
        return new ByteSequence(packet.data, packet.offset, packet.length);
    }
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

        int day = current.get(Calendar.DAY_OF_WEEK) - 1;

        String cronTab = String.format("%d %d * * %d", minutes, hour, day);

        String str = new String("test1");
        scheduler.schedule("id:1", new ByteSequence(str.getBytes()), cronTab, 0, 0, 0);

        assertTrue(latch.await(60, 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

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.