Package com.netflix.suro.thrift

Examples of com.netflix.suro.thrift.TMessageSet$TMessageSetStandardScheme


import static org.junit.Assert.assertTrue;

public class TestMessageSetSerDe {
    @Test
    public void test() {
        TMessageSet messageSet = TestConnectionPool.createMessageSet(100);
        MessageSetSerDe serde = new MessageSetSerDe();
        byte[] payload = serde.serialize(messageSet);
        TMessageSet d = serde.deserialize(payload);

        assertTrue(Arrays.equals(d.getMessages(), messageSet.getMessages()));

        List<Message> messageList = new LinkedList<Message>();
        for (Message m : new MessageSetReader(messageSet)) {
            messageList.add(m);
        }
View Full Code Here


        MessageSetProcessor queue = injector.getInstance(MessageSetProcessor.class);

        assertEquals(queue.getQueueSize(), 0);
        assertEquals(queue.getStatus(), ServiceStatus.ALIVE);

        TMessageSet messageSet = TestConnectionPool.createMessageSet(100);
        assertEquals(queue.process(messageSet).getResultCode(), ResultCode.OK);

        assertEquals(queue.getQueueSize(), 1);
        assertEquals(queue.poll(1, TimeUnit.MILLISECONDS), messageSet);
        assertEquals(queue.getQueueSize(), 0);
View Full Code Here

            byte compression = inBuffer.readByte();
            long crc = inBuffer.readLong();
            byte[] messages = new byte[inBuffer.readInt()];
            inBuffer.read(messages);

            return new TMessageSet(
                app,
                numMessages,
                compression,
                crc,
                ByteBuffer.wrap(messages)
View Full Code Here

                10, TimeUnit.SECONDS,
                jobQueue,
                new RejectedExecutionHandler() {
                    @Override
                    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                        TMessageSet messageSet = ((AsyncSuroSender) r).getMessageSet();
                        for (Message m : new MessageSetReader(messageSet)) {
                            restore(m);
                        }
                    }
                });
View Full Code Here

        try {
            byte[] buffer = createPayload(messageList, compression);
            long crc = getCRC(buffer);


            return new TMessageSet(
                    config.getApp(),
                    messageList.size(),
                    (byte) compression.getId(),
                    crc,
                    ByteBuffer.wrap(buffer));
View Full Code Here

        messageList = createMessageList(routingKeyList, payloadList);
    }

    @Test
    public void testEmptyBuilder() {
        TMessageSet messageSet = new MessageSetBuilder(new ClientConfig()).build();
        assertEquals(messageSet.getNumMessages(), 0);
    }
View Full Code Here

        assertEquals(messageSet.getNumMessages(), 0);
    }
   
    @Test
    public void testBuilder() throws IOException {
        TMessageSet messageSet = buildMessageSet();

        assertEquals(messageSet.getCompression(), 1);
        byte[] bytePayload = messageSet.getMessages();
        byte[] payload = MessageSetBuilder.createPayload(messageList, Compression.LZF);
        assertEquals(bytePayload.length, payload.length);
        for (int i = 0; i < bytePayload.length; ++i) {
            assertEquals(bytePayload[i], payload[i]);
        }
View Full Code Here

        return builder.build();
    }

    @Test
    public void testReader() throws Exception {
        TMessageSet messageSet = buildMessageSet();

        MessageSetReader reader = new MessageSetReader(messageSet);
        assertTrue(reader.checkCRC());

        SerDe<String> serde = new StringSerDe();
View Full Code Here

    public void testReaderException() throws IOException {
        MessageSetBuilder builder = new MessageSetBuilder(new ClientConfig()).withCompression(Compression.NO);
        for (Message message : messageList) {
            builder.withMessage(message.getRoutingKey(), message.getPayload());
        }
        TMessageSet messageSet = builder.build();
        byte[] b = messageSet.getMessages();
        // corrup the data
        b[0] = (byte) 0xff;
        b[1] = (byte) 0xff;
        b[2] = (byte) 0xff;
        b[3] = (byte) 0xff;
View Full Code Here

        ExecutorService executors = Executors.newFixedThreadPool(numThreads);
        for (int i = 0; i < numThreads; ++i) {
            executors.execute(new Runnable() {
                @Override
                public void run() {
                    TMessageSet messageSet = TestConnectionPool.createMessageSet(100);
                    boolean set = true;
                    while (true) {
                        ConnectionPool.SuroConnection connection = pool.chooseConnection();
                        if (set) {
                            latch.countDown();
View Full Code Here

TOP

Related Classes of com.netflix.suro.thrift.TMessageSet$TMessageSetStandardScheme

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.