Examples of HedwigClient


Examples of org.apache.hedwig.client.HedwigClient

        }
        // Store this list of servers created for the current region
        regionServersMap.put(regionName, 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(regionName, regionClient);
    }
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

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

Examples of org.apache.hedwig.client.HedwigClient

    public void setUp() throws Exception {
        numServers = 1;
        numBookies = 1;
        readDelay = 1000L; // 1s
        super.setUp();
        client = new HedwigClient(new ClientConfiguration());
        publisher = client.getPublisher();
        subscriber = client.getSubscriber();
    }
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() {
            @Override
            public HedwigSocketAddress getDefaultServerHedwigSocketAddress() {
                return getDefaultHedwigAddress();
            }
View Full Code Here

Examples of org.apache.hedwig.client.HedwigClient

            fail("Should not reach here!");
        }
        subscriber.startDelivery(topic, subscriberId, new TestMessageHandler());

        // new a client
        HedwigClient client2 = new HedwigClient(new ClientConfiguration() {
                @Override
                public HedwigSocketAddress getDefaultServerHedwigSocketAddress() {
                    return getDefaultHedwigAddress();
                }
            });
        Subscriber subscriber2 = client2.getSubscriber();
        Publisher publisher2 = client2.getPublisher();
        SynchronousQueue<SubscriptionEvent> eventQueue2 =
            new SynchronousQueue<SubscriptionEvent>();
        subscriber2.addSubscriptionListener(new TestSubscriptionListener(eventQueue2));
        try {
            subscriber2.subscribe(topic, subscriberId, options);
        } catch (PubSubException.ServiceDownException e) {
            fail("Should not reach here!");
        }

        SynchronousQueue<Boolean> consumeQueue2 = new SynchronousQueue<Boolean>();
        subscriber2.startDelivery(topic, subscriberId, new TestMessageHandler(consumeQueue2));

        assertEquals(SubscriptionEvent.SUBSCRIPTION_FORCED_CLOSED, eventQueue.take());
        assertTrue(eventQueue2.isEmpty());

        // Now publish some messages for the topic to be consumed by the
        // subscriber.
        publisher.asyncPublish(topic, Message.newBuilder().setBody(ByteString.copyFromUtf8("Message #1")).build(),
                               new TestCallback(), null);
        assertTrue(queue.take());
        assertTrue(consumeQueue2.take());
        assertTrue(consumeQueue.isEmpty());

        publisher2.asyncPublish(topic, Message.newBuilder().setBody(ByteString.copyFromUtf8("Message #2")).build(),
                               new TestCallback(), null);
        assertTrue(queue.take());
        assertTrue(consumeQueue2.take());
        assertTrue(consumeQueue.isEmpty());

        client2.close();
    }
View Full Code Here

Examples of org.apache.hedwig.client.HedwigClient

    public void testSyncSubscribeWithListenerWhenReleasingTopic() throws Exception {
        client.close();

        tearDownHubServer();
        startHubServer(new RetentionServerConfiguration());
        client = new HedwigClient(new ClientConfiguration() {
            @Override
            public HedwigSocketAddress getDefaultServerHedwigSocketAddress() {
                return getDefaultHedwigAddress();
            }
View Full Code Here

Examples of org.apache.hedwig.client.HedwigClient

    @Test
    public void testCloseSubscribeDuringResubscribe() throws Exception {
        client.close();

        final long reconnectWaitTime = 2000L;
        client = new HedwigClient(new ClientConfiguration() {
            @Override
            public HedwigSocketAddress getDefaultServerHedwigSocketAddress() {
                return getDefaultHedwigAddress();
            }
View Full Code Here

Examples of org.apache.hedwig.client.HedwigClient

    protected void stopRegion(int regionIdx) throws Exception {
        String regionName = REGION_PREFIX + regionIdx;
        if (logger.isDebugEnabled()) {
            logger.debug("Stop region : " + regionName);
        }
        HedwigClient regionClient = regionClientsMap.remove(regionName);
        if (null != regionClient) {
            regionClient.close();
        }
        List<PubSubServer> serversList = regionServersMap.remove(regionName);
        if (null == serversList) {
            return;
        }
View Full Code Here

Examples of org.apache.hedwig.client.HedwigClient

        }
        // Store this list of servers created for the current region
        regionServersMap.put(regionName, 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(regionHubAddresses.get(i).get(0).getPort(),
                                       regionHubAddresses.get(i).get(0).getSSLPort()));
        regionClientsMap.put(regionName, regionClient);
    }
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.