Package org.apache.hedwig.client.data

Examples of org.apache.hedwig.client.data.PubSubData


                debugMsg.append(", createOrAttach: ").append(options.getCreateOrAttach())
                        .append(", messageBound: ").append(options.getMessageBound());
            }
            logger.debug(debugMsg.toString());
        }
        PubSubData pubSubData = new PubSubData(topic, null, subscriberId, operationType, options, null, null);
        synchronized (pubSubData) {
            PubSubCallback pubSubCallback = new PubSubCallback(pubSubData);
            asyncSubUnsub(topic, subscriberId, pubSubCallback, null, operationType, options);
            try {
                while (!pubSubData.isDone)
                    pubSubData.wait();
            } catch (InterruptedException e) {
                throw new ServiceDownException("Interrupted Exception while waiting for async subUnsub call");
            }
            // Check from the PubSubCallback if it was successful or not.
            if (!pubSubCallback.getIsCallSuccessful()) {
View Full Code Here


            }
            logger.debug(debugMsg.toString());
        }
        // Check if we know which server host is the master for the topic we are
        // subscribing to.
        PubSubData pubSubData = new PubSubData(topic, null, subscriberId, operationType, options, callback,
                                               context);
        if (client.topic2Host.containsKey(topic)) {
            InetSocketAddress host = client.topic2Host.get(topic);
            if (operationType.equals(OperationType.UNSUBSCRIBE) && client.getPublisher().host2Channel.containsKey(host)) {
                // For unsubscribes, we can reuse the channel connections to the
View Full Code Here

        if (!topicSubscriber2Channel.containsKey(topicSubscriber)) {
            throw new ClientNotSubscribedException(
                "Cannot send consume message since client is not subscribed to topic: " + topic.toStringUtf8()
                + ", subscriberId: " + subscriberId.toStringUtf8());
        }
        PubSubData pubSubData = new PubSubData(topic, null, subscriberId, OperationType.CONSUME, null, null, null);
        // Send the consume message to the server using the same subscribe
        // channel that the topic subscription uses.
        doConsume(pubSubData, topicSubscriber2Channel.get(topicSubscriber), messageSeqId);
    }
View Full Code Here

            }
        });
    }

    public void closeSubscription(ByteString topic, ByteString subscriberId) throws ServiceDownException {
        PubSubData pubSubData = new PubSubData(topic, null, subscriberId, null, null, null, null);
        synchronized (pubSubData) {
            PubSubCallback pubSubCallback = new PubSubCallback(pubSubData);
            asyncCloseSubscription(topic, subscriberId, pubSubCallback, null);
            try {
                while (!pubSubData.isDone)
                    pubSubData.wait();
            } catch (InterruptedException e) {
                throw new ServiceDownException("Interrupted Exception while waiting for asyncCloseSubscription call");
            }
            // Check from the PubSubCallback if it was successful or not.
            if (!pubSubCallback.getIsCallSuccessful()) {
View Full Code Here

    }

    public void publish(ByteString topic, Message msg) throws CouldNotConnectException, ServiceDownException {
        if (logger.isDebugEnabled())
            logger.debug("Calling a sync publish for topic: " + topic.toStringUtf8() + ", msg: " + msg);
        PubSubData pubSubData = new PubSubData(topic, msg, null, OperationType.PUBLISH, null, null, null);
        synchronized (pubSubData) {
            PubSubCallback pubSubCallback = new PubSubCallback(pubSubData);
            asyncPublish(topic, msg, pubSubCallback, null);
            try {
                while (!pubSubData.isDone)
                    pubSubData.wait();
            } catch (InterruptedException e) {
                throw new ServiceDownException("Interrupted Exception while waiting for async publish call");
            }
            // Check from the PubSubCallback if it was successful or not.
            if (!pubSubCallback.getIsCallSuccessful()) {
View Full Code Here

    public void asyncPublish(ByteString topic, Message msg, Callback<Void> callback, Object context) {
        if (logger.isDebugEnabled())
            logger.debug("Calling an async publish for topic: " + topic.toStringUtf8() + ", msg: " + msg);
        // Check if we already have a Channel connection set up to the server
        // for the given Topic.
        PubSubData pubSubData = new PubSubData(topic, msg, null, OperationType.PUBLISH, null, callback, context);
        if (client.topic2Host.containsKey(topic)) {
            InetSocketAddress host = client.topic2Host.get(topic);
            if (host2Channel.containsKey(host)) {
                // We already have the Channel connection for the server host so
                // do the publish directly. We will deal with redirect logic
View Full Code Here

        if (logger.isDebugEnabled()) {
            logger.debug("Calling a sync publish for topic: {}, msg: {}.",
                         topic.toStringUtf8(), msg);
        }
        PubSubData pubSubData = new PubSubData(topic, msg, null, OperationType.PUBLISH, null, null, null);
        synchronized (pubSubData) {
            PubSubCallback pubSubCallback = new PubSubCallback(pubSubData);
            asyncPublishWithResponseImpl(topic, msg, pubSubCallback, null);
            try {
                while (!pubSubData.isDone)
                    pubSubData.wait();
            } catch (InterruptedException e) {
                throw new ServiceDownException("Interrupted Exception while waiting for async publish call");
            }
            // Check from the PubSubCallback if it was successful or not.
            if (!pubSubCallback.getIsCallSuccessful()) {
View Full Code Here

                                              Object context) {
        if (logger.isDebugEnabled()) {
            logger.debug("Calling an async publish for topic: {}, msg: {}.",
                         topic.toStringUtf8(), msg);
        }
        PubSubData pubSubData = new PubSubData(topic, msg, null, OperationType.PUBLISH, null,
                                               callback, context);
        channelManager.submitOp(pubSubData);
    }
View Full Code Here

                debugMsg.append(", createOrAttach: ").append(options.getCreateOrAttach())
                        .append(", messageBound: ").append(options.getMessageBound());
            }
            logger.debug(debugMsg.toString());
        }
        PubSubData pubSubData = new PubSubData(topic, null, subscriberId, operationType, options, null, null);
        synchronized (pubSubData) {
            PubSubCallback pubSubCallback = new PubSubCallback(pubSubData);
            asyncSubUnsub(topic, subscriberId, pubSubCallback, null, operationType, options);
            try {
                while (!pubSubData.isDone)
                    pubSubData.wait();
            } catch (InterruptedException e) {
                throw new ServiceDownException("Interrupted Exception while waiting for async subUnsub call");
            }
            // Check from the PubSubCallback if it was successful or not.
            if (!pubSubCallback.getIsCallSuccessful()) {
View Full Code Here

                    SubscriptionOptions.newBuilder(options).setMessageBound(
                        cfg.getSubscriptionMessageBound());
                options = soBuilder.build();
            }
        }
        PubSubData pubSubData = new PubSubData(topic, null, subscriberId, operationType,
                                               options, callback, context);
        channelManager.submitOp(pubSubData);
    }
View Full Code Here

TOP

Related Classes of org.apache.hedwig.client.data.PubSubData

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.