Examples of HedwigSocketAddress


Examples of org.apache.hedwig.util.HedwigSocketAddress

                         ScheduledExecutorService scheduler, HedwigHubClientFactory hubClientFactory) {
        this.pm = pm;
        mySubId = ByteString.copyFromUtf8(SubscriptionStateUtils.HUB_SUBSCRIBER_PREFIX + cfg.getMyRegion());
        queue = new TopicOpQueuer(scheduler);
        for (final String hub : cfg.getRegions()) {
            clients.add(hubClientFactory.create(new HedwigSocketAddress(hub)));
        }
        myRegion = cfg.getMyRegionByteString().toStringUtf8();
        if (cfg.getRetryRemoteSubscribeThreadRunInterval() > 0) {
            timer.schedule(new RetrySubscribeTask(), 0, cfg.getRetryRemoteSubscribeThreadRunInterval());
        }
View Full Code Here

Examples of org.apache.hedwig.util.HedwigSocketAddress

        StubCallback<Versioned<HubInfo>> readCallback = new StubCallback<Versioned<HubInfo>>();
        StubCallback<Version> writeCallback = new StubCallback<Version>();
        StubCallback<Void> deleteCallback = new StubCallback<Void>();

        Either<Version, PubSubException> res;
        HubInfo owner = new HubInfo(new HedwigSocketAddress("127.0.0.1", 8008), 999);

        // Write non-existed owner info
        toManager.writeOwnerInfo(topic, owner, Version.NEW, writeCallback, null);
        res = writeCallback.queue.take();
        Assert.assertEquals(null, res.right());
        Version v1 = res.left();

        // read owner info
        toManager.readOwnerInfo(topic, readCallback, null);
        Versioned<HubInfo> hubInfo = readCallback.queue.take().left();
        Assert.assertEquals(Version.Occurred.CONCURRENTLY, v1.compare(hubInfo.getVersion()));
        Assert.assertEquals(owner, hubInfo.getValue());

        HubInfo newOwner = new HubInfo(new HedwigSocketAddress("127.0.0.1", 8008), 1000);

        // write exsited owner info with null version
        toManager.writeOwnerInfo(topic, newOwner, Version.NEW, writeCallback, null);
        res = writeCallback.queue.take();
        Assert.assertNotNull(res.right());
        Assert.assertTrue(res.right() instanceof PubSubException.TopicOwnerInfoExistsException);

        // write existed owner info with right version
        toManager.writeOwnerInfo(topic, newOwner, v1, writeCallback, null);
        res = writeCallback.queue.take();
        Assert.assertEquals(null, res.right());
        Version v2 = res.left();
        Assert.assertEquals(Version.Occurred.AFTER, v2.compare(v1));

        // read owner info
        toManager.readOwnerInfo(topic, readCallback, null);
        hubInfo = readCallback.queue.take().left();
        Assert.assertEquals(Version.Occurred.CONCURRENTLY, v2.compare(hubInfo.getVersion()));
        Assert.assertEquals(newOwner, hubInfo.getValue());

        HubInfo newOwner2 = new HubInfo(new HedwigSocketAddress("127.0.0.1", 8008), 1001);

        // write existed owner info with bad version
        toManager.writeOwnerInfo(topic, newOwner2, v1,
                                 writeCallback, null);
        res = writeCallback.queue.take();
View Full Code Here

Examples of org.apache.hedwig.util.HedwigSocketAddress

        // TODO change cfg1 cfg2 params
        ZkTopicManager tm1 = new ZkTopicManager(zk, cfg1, scheduler),
                       tm2 = new ZkTopicManager(zk, cfg2, scheduler);

        tm.getOwner(topic, false, addrCbq, null);
        HedwigSocketAddress owner = check(addrCbq.take());

        // If we were told to have another person claim the topic, make them
        // claim the topic.
        if (owner.getPort() == cfg1.getServerPort())
            tm1.getOwner(topic, true, addrCbq, null);
        else if (owner.getPort() == cfg2.getServerPort())
            tm2.getOwner(topic, true, addrCbq, null);
        if (owner.getPort() != cfg.getServerPort())
            Assert.assertEquals(owner, check(addrCbq.take()));

        for (int i = 0; i < 100; ++i) {
            tm.getOwner(topic, false, addrCbq, null);
            Assert.assertEquals(owner, check(addrCbq.take()));

            tm1.getOwner(topic, false, addrCbq, null);
            Assert.assertEquals(owner, check(addrCbq.take()));

            tm2.getOwner(topic, false, addrCbq, null);
            Assert.assertEquals(owner, check(addrCbq.take()));
        }

        // Give us 100 chances to choose another owner if not shouldClaim.
        for (int i = 0; i < 100; ++i) {
            if (!owner.equals(me))
                break;
            tm.getOwner(mkTopic(i), false, addrCbq, null);
            owner = check(addrCbq.take());
            if (i == 99)
                Assert.fail("Never chose another owner");
View Full Code Here

Examples of org.apache.hedwig.util.HedwigSocketAddress

public class TestHubInfo {

    @Test(timeout=60000)
    public void testParseHubInfo() throws Exception {
        HedwigSocketAddress addr = new HedwigSocketAddress("localhost", 9086, 9087);
        HubInfo hubInfo1 = new HubInfo(addr, 9999);

        String strHubInfo1 = hubInfo1.toString();
        HubInfo parsedHubInfo1 = HubInfo.parse(strHubInfo1);
        Assert.assertEquals("Hub infos should be same", hubInfo1, parsedHubInfo1);
View Full Code Here

Examples of org.apache.hedwig.util.HedwigSocketAddress

                || shouldOwnEveryNewTopic) {
            super.realGetOwner(topic, shouldClaim, cb, ctx);
            return;
        } else {
            // return some other address
            cb.operationFinished(ctx, new HedwigSocketAddress("124.31.0.1:80"));
        }
    }
View Full Code Here

Examples of org.apache.hedwig.util.HedwigSocketAddress

                            conf2 = new CustomServerConfiguration(conf.getServerPort() + 2);
        MMTopicManager tm1 = new MMTopicManager(conf1, zk, metadataManagerFactory, scheduler),
                       tm2 = new MMTopicManager(conf2, zk, metadataManagerFactory, scheduler);

        tm.getOwner(topic, false, addrCbq, null);
        HedwigSocketAddress owner = check(addrCbq.take());

        for (int i = 0; i < 100; ++i) {
            tm.getOwner(topic, false, addrCbq, null);
            Assert.assertEquals(owner, check(addrCbq.take()));

            tm1.getOwner(topic, false, addrCbq, null);
            Assert.assertEquals(owner, check(addrCbq.take()));

            tm2.getOwner(topic, false, addrCbq, null);
            Assert.assertEquals(owner, check(addrCbq.take()));
        }

        for (int i = 0; i < 100; ++i) {
            if (!owner.equals(me))
                break;
            tm.getOwner(mkTopic(i), false, addrCbq, null);
            owner = check(addrCbq.take());
            if (i == 99)
                Assert.fail("Never chose another owner");
View Full Code Here

Examples of org.apache.hedwig.util.HedwigSocketAddress

    // This should point to the default server host, or the VIP fronting all of
    // the server hubs. This will return the HedwigSocketAddress which
    // encapsulates both the regular and SSL port connection to the server host.
    protected HedwigSocketAddress getDefaultServerHedwigSocketAddress() {
        if (myDefaultServerAddress == null)
            myDefaultServerAddress = new HedwigSocketAddress(conf.getString(DEFAULT_SERVER_HOST, "localhost:4080:9876"));
        return myDefaultServerAddress;
    }
View Full Code Here

Examples of org.apache.hedwig.util.HedwigSocketAddress

            System.exit(-1);
        }

        ClientConfiguration cfg = new ClientConfiguration() {
                public HedwigSocketAddress getDefaultServerHedwigSocketAddress() {
                    return new HedwigSocketAddress(cmd.getOptionValue("defaultHub",
                                                                      "localhost:4080"));
                }

                public boolean isSSLEnabled() {
                    return false;
View Full Code Here

Examples of org.apache.hedwig.util.HedwigSocketAddress

        String statusMsg = response.getStatusMsg();
        InetSocketAddress redirectedHost;
        boolean redirectToDefaultServer;
        if (statusMsg != null && statusMsg.length() > 0) {
            if (cfg.isSSLEnabled()) {
                redirectedHost = new HedwigSocketAddress(statusMsg).getSSLSocketAddress();
            } else {
                redirectedHost = new HedwigSocketAddress(statusMsg).getSocketAddress();
            }
            redirectToDefaultServer = false;
        } else {
            redirectedHost = cfg.getDefaultServerHost();
            redirectToDefaultServer = true;
View Full Code Here

Examples of org.apache.hedwig.util.HedwigSocketAddress

            } catch (KeeperException ke) {
                LOG.warn("Couldn't read hub data from ZooKeeper", ke);
            } catch (InterruptedException ie) {
                LOG.warn("Interrupted during read", ie);
            }
            hubs.put(new HedwigSocketAddress(host), load);
        }
        return hubs;
    }
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.