Package com.netflix.suro.queue

Examples of com.netflix.suro.queue.MemoryQueue4Sink


        this.indexInfo =
                indexInfo == null ? new DefaultIndexInfoBuilder(null, null, null, null, null, jsonMapper) : indexInfo;

        initialize(
                "es_" + clusterName,
                queue4Sink == null ? new MemoryQueue4Sink(10000) : queue4Sink,
                batchSize,
                batchTimeout,
                pauseOnLongQueue);

        ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder();
View Full Code Here


        Preconditions.checkNotNull(clientId);

        this.clientId = clientId;
        initialize(
                "kafka_" + clientId,
                queue4Sink == null ? new MemoryQueue4Sink(10000) : queue4Sink,
                batchSize,
                batchTimeout,
                pauseOnLongQueue);

        Properties props = new Properties();
View Full Code Here

import static org.junit.Assert.assertEquals;

public class TestMemoryQueue {
    @Test
    public void test() throws IOException {
        MemoryQueue4Sink queue = new MemoryQueue4Sink(100);
        assertEquals(queue.size(), 0);
        assertEquals(queue.isEmpty(), true);
        assertEquals(queue.drain(100, new LinkedList<Message>()), 0);

        for (int i = 0; i < 100; ++i) {
            queue.offer(new Message("routingkey" + i, ("value" + i).getBytes()));
        }

        assertEquals(queue.size(), 100);
        assertEquals(queue.isEmpty(), false);

        List<Message> msgList = new LinkedList<Message>();
        assertEquals(queue.drain(100, msgList), 100);
        int i = 0;
        for (Message m : msgList) {
            assertEquals(m.getRoutingKey(), "routingkey" + i);
            assertEquals(new String(m.getPayload()), "value" + i);
            ++i;
        }
        assertEquals(i, 100);

        assertEquals(queue.size(), 0);
        assertEquals(queue.isEmpty(), true);
    }
View Full Code Here

    private MessageQueue4Sink queue;

    @Inject
    public Queue4Client(ClientConfig config) {
        if (config.getAsyncQueueType().equals("memory")) {
            queue = new MemoryQueue4Sink(config.getAsyncMemoryQueueCapacity());
        } else {
            try {
                createQueuePathIfNeeded(config.getAsyncFileQueuePath());
                queue = new FileQueue4Sink(
                        config.getAsyncFileQueuePath(),
View Full Code Here

    }

    @Test
    public void shouldIncrementDroppedCounter() throws InterruptedException {
        final int queueCapacity = 200;
        final MemoryQueue4Sink queue = new MemoryQueue4Sink(queueCapacity);

        QueuedSink sink = new QueuedSink() {
            @Override
            protected void beforePolling() throws IOException {
            }
View Full Code Here

            }
        };

        int queueCapacity = 10000;
        final MemoryQueue4Sink queue = new MemoryQueue4Sink(queueCapacity);
        final int initialCount = queueCapacity / 2 - 10;
        for (int i = 0; i < initialCount; ++i) {
            queue.offer(new Message("routingKey", ("testMessage" + i).getBytes()));
        }

        sink.initialize(queue, 100, 1000);

        assertEquals(sink.checkPause(), 0);
View Full Code Here

            }
        };

        int queueCapacity = 10000;
        final MemoryQueue4Sink queue = new MemoryQueue4Sink(queueCapacity);
        final int initialCount = queueCapacity / 2 + 10;
        for (int i = 0; i < initialCount; ++i) {
            queue.offer(new Message("routingKey", ("testMessage" + i).getBytes()));
        }

        sink.initialize(null, queue, 100, 1000, true);

        assertEquals(sink.checkPause(), queue.size());

        queue.drain(Integer.MAX_VALUE, new LinkedList<Message>());

        ///////////////////////////
        sink = new QueuedSink() {
            @Override
            protected void beforePolling() throws IOException {

            }

            @Override
            protected void write(List<Message> msgList) throws IOException {
            }

            @Override
            protected void innerClose() throws IOException {

            }
        };

        QueuedSink.MAX_PENDING_MESSAGES_TO_PAUSE = 100;
        for (int i = 0; i < QueuedSink.MAX_PENDING_MESSAGES_TO_PAUSE + 1; ++i) {
            queue.offer(new Message("routingKey", ("testMessage" + i).getBytes()));
        }

        sink.initialize(null, queue, 100, 1000, true);

        assertEquals(sink.checkPause(), queue.size());

        QueuedSink.MAX_PENDING_MESSAGES_TO_PAUSE = 1000000;

        queue.drain(Integer.MAX_VALUE, new LinkedList<Message>());

        ////////////////////////////
        sink = new QueuedSink() {
            @Override
            protected void beforePolling() throws IOException {
            }

            @Override
            protected void write(List<Message> msgList) throws IOException {
            }

            @Override
            protected void innerClose() throws IOException {

            }
        };
        sink.initialize(null, queue, 100, 1000, true);
        sink.throughput.increment(initialCount);

        for (int i = 0; i < initialCount; ++i) {
            queue.offer(new Message("routingKey", ("testMessage" + i).getBytes()));
        }

        assertTrue(sink.checkPause() < queue.size() && sink.checkPause() > 0);
    }
View Full Code Here

        Preconditions.checkNotNull(clientId);

        this.clientId = clientId;
        initialize(
                "kafka_" + clientId,
                queue4Sink == null ? new MemoryQueue4Sink(10000) : queue4Sink,
                batchSize,
                batchTimeout,
                pauseOnLongQueue);

        Properties props = new Properties();
View Full Code Here

        this.notice = notice == null ? new QueueNotice<String>() : notice;
        this.spaceChecker = spaceChecker;

        Monitors.registerObject(outputDir.replace('/', '_'), this);
        initialize("localfile_" + outputDir.replace('/', '_'),
                queue4Sink == null ? new MemoryQueue4Sink(10000) : queue4Sink,
                batchSize,
                batchTimeout,
                pauseOnLongQueue);
    }
View Full Code Here

                null,
                null,
                0,
                "PT1s",
                10,
                new MemoryQueue4Sink(10000),
                100,
                1000,
                true,
                spaceChecker
        );
View Full Code Here

TOP

Related Classes of com.netflix.suro.queue.MemoryQueue4Sink

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.