Package org.apache.hedwig.util

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)));
        }
    }
View Full Code Here


    // Default ClientConfiguration to use. This just points to the first
    // Hedwig hub server in each region as the "default server host" to connect
    // to.
    protected class RegionClientConfiguration extends ClientConfiguration {
        public RegionClientConfiguration(int serverPort, int sslServerPort) {
            myDefaultServerAddress = new HedwigSocketAddress("localhost:" + serverPort + ":" + sslServerPort);
        }
View Full Code Here

    }

    protected void refreshMyServerAddress() {
        try {
            // Use the raw IP address as the hostname
            myServerAddress = new HedwigSocketAddress(InetAddress.getLocalHost().getHostAddress(), getServerPort(),
                    getSSLServerPort());
        } catch (UnknownHostException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

        // Validate that if Regions exist and inter-region communication is SSL
        // enabled, that the Regions correspond to valid HedwigSocketAddresses,
        // namely that SSL ports are present.
        if (isInterRegionSSLEnabled() && getRegions().size() > 0) {
            for (String hubString : getRegions()) {
                HedwigSocketAddress hub = new HedwigSocketAddress(hubString);
                if (hub.getSSLSocketAddress() == null)
                    throw new ConfigurationException("Region defined does not have required SSL port: " + hubString);
            }
        }
        // Validate that the Bookkeeper ensemble size >= quorum size.
        if (getBkEnsembleSize() < getBkQuorumSize()) {
View Full Code Here

            cfg.getServerPort() + 2);
        // 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

    }

    public void assertOwnershipNodeExists() throws Exception {
        byte[] data = zk.getData(tm.hubPath(topic), false, null);
        Assert.assertEquals(new HedwigSocketAddress(new String(data)), tm.addr);
    }
View Full Code Here

        // host/VIP to repost the request.
        String statusMsg = response.getStatusMsg();
        InetSocketAddress redirectedHost;
        if (statusMsg != null && statusMsg.length() > 0) {
            if (cfg.isSSLEnabled()) {
                redirectedHost = new HedwigSocketAddress(statusMsg).getSSLSocketAddress();
            } else {
                redirectedHost = new HedwigSocketAddress(statusMsg).getSocketAddress();
            }
        } else {
            redirectedHost = cfg.getDefaultServerHost();
        }
View Full Code Here

    // 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

                                            "Failed to delete self-ownership node for topic: " + topic.toStringUtf8(), path, rc);
                    cb.operationFailed(ctx, new PubSubException.ServiceDownException(e));
                    return;
                }

                HedwigSocketAddress owner = new HedwigSocketAddress(new String(data));
                if (!owner.equals(addr)) {
                    logger.warn("Wanted to delete self-node for topic: " + topic.toStringUtf8() + " but node for "
                                + owner + " found, leaving untouched");
                    // Not our node, someone else's, leave it alone
                    cb.operationFinished(ctx, null);
                    return;
View Full Code Here

                            if (leastLoaded == null) {
                                cb.operationFailed(ZkGetOwnerOp.this.ctx, new PubSubException.ServiceDownException(
                                                       "No hub available"));
                                return;
                            }
                            HedwigSocketAddress owner = new HedwigSocketAddress(leastLoaded);
                            if (owner.equals(addr)) {
                                claim();
                            } else {
                                cb.operationFinished(ZkGetOwnerOp.this.ctx, owner);
                            }
                        }
View Full Code Here

TOP

Related Classes of org.apache.hedwig.util.HedwigSocketAddress

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.