Package org.apache.hedwig.client.netty

Examples of org.apache.hedwig.client.netty.HChannel


        }
    }

    @Override
    public void submitOp(PubSubData pubSubData) {
        HChannel hChannel;
        if (OperationType.PUBLISH.equals(pubSubData.operationType) ||
            OperationType.UNSUBSCRIBE.equals(pubSubData.operationType)) {
            hChannel = getNonSubscriptionChannelByTopic(pubSubData.topic);
        } else {
            TopicSubscriber ts = new TopicSubscriber(pubSubData.topic,
                                                     pubSubData.subscriberId);
            hChannel = getSubscriptionChannelByTopicSubscriber(ts);
        }
        // no channel found to submit pubsub data
        // choose the default server
        if (null == hChannel) {
            hChannel = defaultServerChannel;
        }
        hChannel.submitOp(pubSubData);
    }
View Full Code Here


    @Override
    public void redirectToHost(PubSubData pubSubData, InetSocketAddress host) {
        logger.debug("Submit operation {} to host {}.",
                     va(pubSubData, host));
        HChannel hChannel;
        if (OperationType.PUBLISH.equals(pubSubData.operationType) ||
            OperationType.UNSUBSCRIBE.equals(pubSubData.operationType)) {
            hChannel = getNonSubscriptionChannel(host);
            if (null == hChannel) {
                // create a channel to connect to specified host
                hChannel = createAndStoreNonSubscriptionChannel(host);
            }
        } else {
            hChannel = getSubscriptionChannel(host);
            if (null == hChannel) {
                // create a subscription channel to specified host
                hChannel = createAndStoreSubscriptionChannel(host);
            }
        }
        // no channel found to submit pubsub data
        // choose the default server
        if (null == hChannel) {
            hChannel = defaultServerChannel;
        }
        hChannel.submitOp(pubSubData);
    }
View Full Code Here

    }

    void submitOpThruChannel(PubSubData pubSubData, Channel channel) {
        logger.debug("Submit operation {} to thru channel {}.",
                     va(pubSubData, channel));
        HChannel hChannel;
        if (OperationType.PUBLISH.equals(pubSubData.operationType) ||
            OperationType.UNSUBSCRIBE.equals(pubSubData.operationType)) {
            hChannel = createAndStoreNonSubscriptionChannel(channel);
        } else {
            hChannel = createAndStoreSubscriptionChannel(channel);
        }
        hChannel.submitOp(pubSubData);
    }
View Full Code Here

    // Synchronized method to store the host2Channel mapping (if it doesn't
    // exist yet). Retrieve the hostname info from the Channel created via the
    // RemoteAddress tied to it.
    private HChannel createAndStoreNonSubscriptionChannel(Channel channel) {
        InetSocketAddress host = NetUtils.getHostFromChannel(channel);
        HChannel newHChannel = new HChannelImpl(host, channel, this,
                                                getNonSubscriptionChannelPipelineFactory());
        return storeNonSubscriptionChannel(host, newHChannel);
    }
View Full Code Here

                                                getNonSubscriptionChannelPipelineFactory());
        return storeNonSubscriptionChannel(host, newHChannel);
    }

    private HChannel createAndStoreNonSubscriptionChannel(InetSocketAddress host) {
        HChannel newHChannel = new HChannelImpl(host, this,
                                                getNonSubscriptionChannelPipelineFactory());
        return storeNonSubscriptionChannel(host, newHChannel);
    }
View Full Code Here

        if (null == host) {
            // we don't know where is the topic
            return null;
        } else {
            // we had know which server owned the topic
            HChannel channel = getNonSubscriptionChannel(host);
            if (null == channel) {
                // create a channel to connect to specified host
                channel = createAndStoreNonSubscriptionChannel(host);
            }
            return channel;
View Full Code Here

        // Only remove the Channel from the mapping if this current
        // disconnected channel is the same as the cached entry.
        // Due to race concurrency situations, it is possible to
        // create multiple channels to the same host for publish
        // and unsubscribe requests.
        HChannel hChannel = host2NonSubscriptionChannels.getChannel(host);
        if (null == hChannel) {
            return;
        }
        Channel underlyingChannel = hChannel.getChannel();
        if (null == underlyingChannel ||
            !underlyingChannel.equals(channel)) {
            return;
        }
        logger.info("NonSubscription Channel {} to {} disconnected.",
View Full Code Here

    @Override
    protected HChannel createAndStoreSubscriptionChannel(Channel channel) {
        // store the channel connected to target host for future usage
        InetSocketAddress host = NetUtils.getHostFromChannel(channel);
        HChannel newHChannel = new HChannelImpl(host, channel, this,
                                                getSubscriptionChannelPipelineFactory());
        return storeSubscriptionChannel(host, newHChannel);
    }
View Full Code Here

        return storeSubscriptionChannel(host, newHChannel);
    }

    @Override
    protected HChannel createAndStoreSubscriptionChannel(InetSocketAddress host) {
        HChannel newHChannel = new HChannelImpl(host, this,
                                                getSubscriptionChannelPipelineFactory());
        return storeSubscriptionChannel(host, newHChannel);
    }
View Full Code Here

        if (null == host) {
            // we don't know where is the topic
            return null;
        } else {
            // we had know which server owned the topic
            HChannel channel = getSubscriptionChannel(host);
            if (null == channel) {
                // create a channel to connect to sepcified host
                channel = createAndStoreSubscriptionChannel(host);
            }
            return channel;
View Full Code Here

TOP

Related Classes of org.apache.hedwig.client.netty.HChannel

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.