Package org.apache.hedwig.util

Examples of org.apache.hedwig.util.HedwigSocketAddress


    }

    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() < getBkWriteQuorumSize()) {
View Full Code Here

    protected HedwigHubTestBase(int numServers) {
        this.numServers = numServers;

        serverAddresses = new LinkedList<HedwigSocketAddress>();
        for (int i = 0; i < numServers; i++) {
            serverAddresses.add(new HedwigSocketAddress("localhost",
                                        PortManager.nextFreePort(), PortManager.nextFreePort()));
        }
    }
View Full Code Here

    protected HedwigSocketAddress getDefaultHedwigAddress() {
        return defaultAddress;
    }

    protected void startHubServer(ServerConfiguration conf) throws Exception {
        defaultAddress = new HedwigSocketAddress("localhost", conf.getServerPort(),
                                                 conf.getSSLServerPort());
        server = new PubSubServer(conf, new ClientConfiguration(), new LoggingExceptionHandler());
        server.start();
    }
View Full Code Here

                }

                String hubInfoStr = new String(data);
                try {
                    HubInfo ownerHubInfo = HubInfo.parse(hubInfoStr);
                    HedwigSocketAddress owner = ownerHubInfo.getAddress();
                    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

                    }

                    // successfully did a read
                    try {
                        HubInfo ownerHubInfo = HubInfo.parse(new String(data));
                        HedwigSocketAddress owner = ownerHubInfo.getAddress();
                        if (!owner.equals(addr)) {
                            if (logger.isDebugEnabled()) {
                                logger.debug("topic: " + topic.toStringUtf8() + " belongs to someone else: " + owner);
                            }
                            cb.operationFinished(ctx, owner);
                            return;
View Full Code Here

     *         string representation of hub info.
     */
    public static HubInfo parse(String hubInfoStr) throws InvalidHubInfoException {
        // it is not protobuf encoded hub info, it might be generated by ZkTopicManager
        if (!hubInfoStr.startsWith("hostname")) {
            final HedwigSocketAddress owner;
            try {
                owner = new HedwigSocketAddress(hubInfoStr);
            } catch (Exception e) {
                throw new InvalidHubInfoException("Corrupted hub server address : " + hubInfoStr, e);
            }
            return new HubInfo(owner, 0L);
        }

        // it is a protobuf encoded hub info.
        HubInfoData hubInfoData;

        try {
            BufferedReader reader = new BufferedReader(
                new StringReader(hubInfoStr));
            HubInfoData.Builder dataBuilder = HubInfoData.newBuilder();
            TextFormat.merge(reader, dataBuilder);
            hubInfoData = dataBuilder.build();
        } catch (InvalidProtocolBufferException ipbe) {
            throw new InvalidHubInfoException("Corrupted hub info : " + hubInfoStr, ipbe);
        } catch (IOException ie) {
            throw new InvalidHubInfoException("Corrupted hub info : " + hubInfoStr, ie);
        }

        final HedwigSocketAddress owner;
        try {
            owner = new HedwigSocketAddress(hubInfoData.getHostname().trim());
        } catch (Exception e) {
            throw new InvalidHubInfoException("Corrupted hub server address : " + hubInfoData.getHostname(), e);
        }
        long ownerZxid = hubInfoData.getCzxid();
        return new HubInfo(owner, ownerZxid, hubInfoData);
View Full Code Here

                            callback.operationFailed(ctx,
                                new PubSubException.ServiceDownException("No hub available"));
                            return;
                        }
                        try {
                            HedwigSocketAddress owner = new HedwigSocketAddress(leastLoaded);
                            callback.operationFinished(ctx, new HubInfo(owner, leastLoadedCzxid));
                        } catch (Throwable t) {
                            callback.operationFailed(ctx,
                                new PubSubException.ServiceDownException("Least loaded hub server "
                                                                       + leastLoaded + " is invalid."));
View Full Code Here

                if (null == owner.getValue()) {
                    logger.warn("No valid owner info found when cleaning up topic " + topic.toStringUtf8());
                    cb.operationFinished(ctx, null);
                    return;
                }
                HedwigSocketAddress ownerAddr = owner.getValue().getAddress();
                if (!ownerAddr.equals(addr)) {
                    logger.warn("Wanted to clean up self owner info for topic " + topic.toStringUtf8()
                                + " but owner " + owner + " found, leaving untouched");
                    // Not our node, someone else's, leave it alone
                    cb.operationFinished(ctx, null);
                    return;
View Full Code Here

            new HashMap<HedwigSocketAddress, HubStats>();
        List<String> hosts = zk.getChildren(zkHubsPath, false);
        for (String host : hosts) {
            String zkHubPath = serverConf.getZkHostsPrefix(new StringBuilder())
                                         .append("/").append(host).toString();
            HedwigSocketAddress addr = new HedwigSocketAddress(host);
            try {
                Stat stat = new Stat();
                byte[] data = zk.getData(zkHubPath, false, stat);
                if (data == null) {
                    continue;
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.