Package org.apache.hedwig.exceptions

Examples of org.apache.hedwig.exceptions.PubSubException$UnexpectedConditionException


            }
            // Check from the PubSubCallback if it was successful or not.
            if (!pubSubCallback.getIsCallSuccessful()) {
                // See what the exception was that was thrown when the operation
                // failed.
                PubSubException failureException = pubSubCallback.getFailureException();
                if (failureException == null) {
                    // This should not happen as the operation failed but a null
                    // PubSubException was passed. Log a warning message but
                    // throw a generic ServiceDownException.
                    logger.error("Sync SubUnsub operation failed but no PubSubException was passed!");
View Full Code Here


            // We've already exceeded the maximum number of server redirects
            // so consider this as an error condition for the client.
            // Invoke the operationFailed callback and just return.
            logger.debug("Exceeded the number of server redirects ({}) so error out.",
                         curNumServerRedirects);
            PubSubException exception = new ServiceDownException(
                new TooManyServerRedirectsException("Already reached max number of redirects: "
                                                    + curNumServerRedirects));
            pubSubData.getCallback().operationFailed(pubSubData.context, exception);
            return;
        }

        // We will redirect and try to connect to the correct server
        // stored in the StatusMsg of the response. First store the
        // server that we sent the PubSub request to for the topic.
        ByteString triedServer = ByteString.copyFromUtf8(HedwigSocketAddress.sockAddrStr(
                                                         NetUtils.getHostFromChannel(channel)));
        if (pubSubData.triedServers == null) {
            pubSubData.triedServers = new LinkedList<ByteString>();
        }
        pubSubData.shouldClaim = true;
        pubSubData.triedServers.add(triedServer);

        // Now get the redirected server host (expected format is
        // Hostname:Port:SSLPort) from the server's response message. If one is
        // not given for some reason, then redirect to the default server
        // host/VIP to repost the request.
        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;
        }

        // Make sure the redirected server is not one we've already attempted
        // already before in this PubSub request.
        if (pubSubData.triedServers.contains(ByteString.copyFromUtf8(HedwigSocketAddress.sockAddrStr(redirectedHost)))) {
            logger.error("We've already sent this PubSubRequest before to redirectedHost: {}, pubSubData: {}",
                         va(redirectedHost, pubSubData));
            PubSubException exception = new ServiceDownException(
                new ServerRedirectLoopException("Already made the request before to redirected host: "
                                                + redirectedHost));
            pubSubData.getCallback().operationFailed(pubSubData.context, exception);
            return;
        }
View Full Code Here

                postHandleSuccessResponse(ts, ss);
                // Response was success so invoke the callback's operationFinished
                // method.
                pubSubData.getCallback().operationFinished(pubSubData.context, null);
            } else {
                PubSubException exception = PubSubException.create(statusCode,
                    "Client is already subscribed for " + ts);
                pubSubData.getCallback().operationFailed(pubSubData.context, exception);
            }
            break;
        case CLIENT_ALREADY_SUBSCRIBED:
View Full Code Here

        if (null == hChannel) {
            InetSocketAddress host = NetUtils.getHostFromChannel(channel);
            hChannel = sChannelManager.getSubscriptionChannel(host);
            if (null == hChannel ||
                !channel.equals(hChannel.getChannel())) {
                PubSubException pse =
                    new UnexpectedConditionException("Failed to get subscription channel of " + host);
                pubSubData.getCallback().operationFailed(pubSubData.context, pse);
                return;
            }
        }
View Full Code Here

                logger.info("Successfully registered hub with zookeeper");
                ConcurrencyUtils.put(queue, Either.of(resultOfOperation, (PubSubException) null));
            }
        }, null);

        PubSubException pse = ConcurrencyUtils.take(queue).right();

        if (pse != null) {
            throw pse;
        }
    }
View Full Code Here

                        return;
                    }

                    if (null != sub2Channel.putIfAbsent(topicSub, channel)) {
                        // there was another channel mapped to this sub
                        PubSubException pse = new PubSubException.TopicBusyException(
                            "subscription for this topic, subscriberId is already being served on a different channel");
                        channel.write(PubSubResponseUtils.getResponseForException(pse, request.getTxnId()))
                        .addListener(ChannelFutureListener.CLOSE);
                        subStats.incrementFailedOps();
                        return;
View Full Code Here

TOP

Related Classes of org.apache.hedwig.exceptions.PubSubException$UnexpectedConditionException

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.