Package com.netflix.suro.input.thrift

Examples of com.netflix.suro.input.thrift.MessageSetProcessor


                        binder.bindConfigurationProvider().toInstance(new PropertiesConfigurationProvider(props));
                    }
                }).build().createInjector();
        injector.getInstance(LifecycleManager.class).start();

        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);

        queue.stopTakingTraffic();
        assertEquals(queue.process(messageSet).getResultCode(), ResultCode.OTHER_ERROR);

        queue.startTakingTraffic();
        assertEquals(queue.getStatus(), ServiceStatus.ALIVE);

        assertEquals(queue.process(messageSet).getResultCode(), ResultCode.OK);

        injector.getInstance(LifecycleManager.class).close();
    }
View Full Code Here


       
        SinkManager sinkManager = startSinkMakager(injector);

        startMessageRouter(injector);

        MessageSetProcessor queue = injector.getInstance(MessageSetProcessor.class);
        queue.setInput(mock(SuroInput.class));
        queue.start();

        MessageSetBuilder builder = new MessageSetBuilder(new ClientConfig());

        for (int i = 0; i < 10; ++i) {
            builder.withMessage("topic1", Integer.toString(i).getBytes());
        }
        // sink1: 10
        // default: 10
        queue.process(builder.build());

        for (int i = 0; i < 5; ++i) {
            builder.withMessage("topic2", Integer.toString(i).getBytes());
        }
        // sink1: 5
        queue.process(builder.build());

        for (int i = 0; i < 15; ++i) {
            builder.withMessage("topic3", Integer.toString(i).getBytes());
        }
        queue.process(builder.build());
        // sink3: 15 with topic3_alias

        for (int i = 0; i < 20; ++i) {
            builder.withMessage("topic4", Integer.toString(i).getBytes());
        }
        // default: 20
        queue.process(builder.build());

        // total sink1: 15, default: 30
        int count = 10;
        while (!answer() && count > 0) {
            Thread.sleep(1000);
            --count;
        }
        assertTrue(count > 0);

        queue.shutdown();
        sinkManager.shutdown();
    }
View Full Code Here

        RoutingMap map = new RoutingMap();
        map.set(new ImmutableMap.Builder<String, RoutingMap.RoutingInfo>()
                .put(TOPIC_NAME, new RoutingMap.RoutingInfo(Lists.newArrayList(new RoutingMap.Route("local", null, null)), null))
                .build());

        MessageSetProcessor msgProcessor = new MessageSetProcessor(
                new Queue4Server(config),
                new MessageRouter(map, sinks, jsonMapper),
                config,
                jsonMapper
        );

        ThriftServer server = new ThriftServer(config, msgProcessor);
        server.start();

        SuroClient client = createSuroClient(server.getPort());

        Thread t = createClientThread(jsonMapper, client, TOPIC_NAME);

        // checking the traffic goes
        for (int i = 0; i < 10; ++i) {
            if (client.getSentMessageCount() > 0) {
                break;
            }
            Thread.sleep(1000);
        }
        assertTrue(client.getSentMessageCount() > 0);

        // shutting down the traffic
        hasEnoughSpace = false;
        int count = 0;
        while (count < 3) {
            if (msgProcessor.getStatus() == ServiceStatus.WARNING) {
                ++count;
            }
        }
        assertEquals(count, 3);
View Full Code Here

TOP

Related Classes of com.netflix.suro.input.thrift.MessageSetProcessor

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.