Examples of HedwigClient


Examples of org.apache.hedwig.client.HedwigClient

        numServers = 3;
        super.setUp();
        if (mode == Mode.PROXY) {
            proxy = new HedwigProxy(proxyConf);
        }
        client = new HedwigClient(getClientConfiguration());
        publisher = client.getPublisher();
        subscriber = client.getSubscriber();
    }
View Full Code Here

Examples of org.apache.hedwig.client.HedwigClient

    // This tests out the manual sending of consume messages to the server
    // instead of relying on the automatic sending by the client lib for it.
    @Test
    public void testManualConsumeClient() throws Exception {
        HedwigClient myClient = new HedwigClient(new TestClientConfiguration() {
            @Override
            public boolean isAutoSendConsumeMessageEnabled() {
                return false;
            }

        });
        Subscriber mySubscriber = myClient.getSubscriber();
        Publisher myPublisher = myClient.getPublisher();
        ByteString myTopic = getTopic(0);
        // Subscribe to a topic and start delivery on it
        mySubscriber.asyncSubscribe(myTopic, localSubscriberId, CreateOrAttach.CREATE_OR_ATTACH,
                                    new TestCallback(queue), null);
        assertTrue(queue.take());
        startDelivery(mySubscriber, myTopic, localSubscriberId, new TestMessageHandler(consumeQueue));
        // Publish some messages
        int batchSize = 10;
        for (int i = 0; i < batchSize; i++) {
            myPublisher.asyncPublish(myTopic, getMsg(i), new TestCallback(queue), null);
            assertTrue(queue.take());
            assertTrue(consumeQueue.take());
        }
        // Now manually send a consume message for each message received
        for (int i = 0; i < batchSize; i++) {
            boolean success = true;
            try {
                mySubscriber.consume(myTopic, localSubscriberId, MessageSeqId.newBuilder().setLocalComponent(i + 1)
                                     .build());
            } catch (ClientNotSubscribedException e) {
                success = false;
            }
            assertTrue(success);
        }
        // Since the consume call eventually does an async write to the Netty
        // channel, the writing of the consume requests may not have completed
        // yet before we stop the client. Sleep a little before we stop the
        // client just so error messages are not logged.
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            logger.error("Thread was interrupted while waiting to stop client for manual consume test!!", e);
        }
        myClient.close();
    }
View Full Code Here

Examples of org.apache.hedwig.client.HedwigClient

        final LinkedBlockingQueue<Boolean> queue = new LinkedBlockingQueue<Boolean>();

        new Thread(tg, new Runnable() {
            @Override
            public void run() {
                client = new HedwigClient(cfg);

                serverSocketChannelFactory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),
                        Executors.newCachedThreadPool());
                initializeHandlers();
                initializeNetty();
View Full Code Here

Examples of org.apache.hedwig.client.HedwigClient

    @Override
    @Before
    public void setUp() throws Exception {
        super.setUp();
        client = new HedwigClient(new ClientConfiguration());
        publisher = client.getPublisher();
        subscriber = client.getSubscriber();
    }
View Full Code Here

Examples of org.apache.hedwig.client.HedwigClient

            // Store this list of servers created for the current region
            regionServersMap.put(REGION_PREFIX + i, serversList);

            // Create a Hedwig Client that points to the first Hub server
            // created in the loop above for the current region.
            HedwigClient regionClient = new HedwigClient(getClientConfiguration(initialServerPort
                    + (i * numServersPerRegion), initialSSLServerPort + (i * numServersPerRegion)));
            regionClientsMap.put(REGION_PREFIX + i, regionClient);
        }
        logger.info("HedwigRegion test setup finished");
    }
View Full Code Here

Examples of org.apache.hedwig.client.HedwigClient

    }
   
    @Override
    public void setUp() throws Exception {
        super.setUp();
        client = new HedwigClient(new ClientConfiguration());

        publisher = client.getPublisher();
        subscriber = client.getSubscriber();
    }
View Full Code Here

Examples of org.apache.hedwig.client.HedwigClient

    private final HedwigClient client;
    private final Publisher publisher;
    private final Subscriber subscriber;

    public HedwigBenchmark(ClientConfiguration cfg) {
        client = new HedwigClient(cfg);
        publisher = client.getPublisher();
        subscriber = client.getSubscriber();
    }
View Full Code Here

Examples of org.apache.hedwig.client.HedwigClient

        return server;

    }

    public void runPublishRequest(final int port) throws Exception {
        Publisher publisher = new HedwigClient(new ClientConfiguration() {
            @Override
            public InetSocketAddress getDefaultServerHost() {
                return new InetSocketAddress("localhost", port);
            }
        }).getPublisher();
View Full Code Here

Examples of org.apache.hedwig.client.HedwigClient

    @Before
    public void setUp() throws Exception {
        numBookies = 1;
        readDelay = 1000L; // 1s
        super.setUp();
        client = new HedwigClient(new HubClientConfiguration());
        publisher = client.getPublisher();
        subscriber = client.getSubscriber();
    }
View Full Code Here

Examples of org.apache.hedwig.client.HedwigClient

    @Test(timeout=60000)
    public void testServerSideThrottle() throws Exception {
        int messageWindowSize = DEFAULT_MESSAGE_WINDOW_SIZE;
        ThrottleDeliveryClientConfiguration conf =
            new ThrottleDeliveryClientConfiguration();
        HedwigClient client = new HedwigClient(conf);
        Publisher pub = client.getPublisher();
        Subscriber sub = client.getSubscriber();

        ByteString topic = ByteString.copyFromUtf8("testServerSideThrottle");
        ByteString subid = ByteString.copyFromUtf8("serverThrottleSub");
        sub.subscribe(topic, subid, CreateOrAttach.CREATE);
        sub.closeSubscription(topic, subid);

        // throttle with hub server's setting
        throttleX(pub, sub, topic, subid, DEFAULT_MESSAGE_WINDOW_SIZE);

        messageWindowSize = DEFAULT_MESSAGE_WINDOW_SIZE / 2;
        // throttle with a lower value than hub server's setting
        SubscriptionOptions.Builder optionsBuilder = SubscriptionOptions.newBuilder()
            .setCreateOrAttach(CreateOrAttach.CREATE)
            .setMessageWindowSize(messageWindowSize);
        topic = ByteString.copyFromUtf8("testServerSideThrottleWithLowerValue");
        sub.subscribe(topic, subid, optionsBuilder.build());
        sub.closeSubscription(topic, subid);
        throttleX(pub, sub, topic, subid, messageWindowSize);

        messageWindowSize = DEFAULT_MESSAGE_WINDOW_SIZE + 5;
        // throttle with a higher value than hub server's setting
        optionsBuilder = SubscriptionOptions.newBuilder()
                         .setCreateOrAttach(CreateOrAttach.CREATE)
                         .setMessageWindowSize(messageWindowSize);
        topic = ByteString.copyFromUtf8("testServerSideThrottleWithHigherValue");
        sub.subscribe(topic, subid, optionsBuilder.build());
        sub.closeSubscription(topic, subid);
        throttleX(pub, sub, topic, subid, messageWindowSize);

        client.close();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.