public class SimpleHChannelManager extends AbstractHChannelManager
Modifier and Type | Field and Description |
---|---|
protected CleanupChannelMap<TopicSubscriber> |
topicSubscriber2Channel |
protected ConcurrentMap<TopicSubscriber,MessageHandler> |
topicSubscriber2MessageHandler |
closed, closedLock, globalCounter, host2NonSubscriptionChannels, host2Topics, socketFactory, topic2Host
Constructor and Description |
---|
SimpleHChannelManager(ClientConfiguration cfg,
org.jboss.netty.channel.ChannelFactory socketFactory) |
Modifier and Type | Method and Description |
---|---|
void |
asyncCloseSubscription(TopicSubscriber topicSubscriber,
Callback<PubSubProtocol.ResponseBody> callback,
Object context)
Close the subscription of the given
topicSubscriber . |
protected void |
checkTimeoutRequestsOnSubscriptionChannels()
Chekout the pub/sub requests on subscription channels.
|
protected void |
closeSubscriptionChannels()
Close all subscription channels when close channel manager.
|
protected HChannel |
createAndStoreSubscriptionChannel(org.jboss.netty.channel.Channel channel)
Create and store a subscription
HChannel thru the underlying established
channel |
protected HChannel |
createAndStoreSubscriptionChannel(InetSocketAddress host)
Create and store a subscription
HChannel to target host. |
SubscribeResponseHandler |
getSubscribeResponseHandler(TopicSubscriber topicSubscriber)
Get the subscribe response handler managed the given
topicSubscriber . |
protected HChannel |
getSubscriptionChannel(InetSocketAddress host)
Is there a subscription
HChannel existed for a given host. |
protected HChannel |
getSubscriptionChannelByTopicSubscriber(TopicSubscriber subscriber)
Get a subscription channel for a given
topicSubscriber . |
protected ClientChannelPipelineFactory |
getSubscriptionChannelPipelineFactory() |
protected void |
onSubscriptionChannelDisconnected(InetSocketAddress host,
org.jboss.netty.channel.Channel channel)
Handle the disconnected event from a subscription
HChannel . |
protected void |
restartDelivery(TopicSubscriber topicSubscriber) |
void |
startDelivery(TopicSubscriber topicSubscriber,
MessageHandler messageHandler)
Start delivering messages for a given topic subscriber.
|
void |
stopDelivery(TopicSubscriber topicSubscriber)
Stop delivering messages for a given topic subscriber.
|
protected Either<Boolean,HChannel> |
storeSubscriptionChannel(TopicSubscriber topicSubscriber,
PubSubData txn,
org.jboss.netty.channel.Channel channel) |
void |
submitOp(PubSubData pubSubData)
Submit a pub/sub request.
|
clearAllTopicsForHost, clearHostForTopic, close, getChannelFactory, getConsumeCallback, getNonSubscriptionChannelPipelineFactory, getSslFactory, getSubscriptionEventEmitter, isClosed, nextTxnId, onNonSubscriptionChannelDisconnected, redirectToHost, schedule, storeTopic2HostMapping, submitOpAfterDelay, submitOpToDefaultServer
protected final CleanupChannelMap<TopicSubscriber> topicSubscriber2Channel
protected final ConcurrentMap<TopicSubscriber,MessageHandler> topicSubscriber2MessageHandler
public SimpleHChannelManager(ClientConfiguration cfg, org.jboss.netty.channel.ChannelFactory socketFactory)
public void submitOp(PubSubData pubSubData)
HChannelManager
submitOp
in interface HChannelManager
submitOp
in class AbstractHChannelManager
pubSubData
- Pub/Sub Request.protected ClientChannelPipelineFactory getSubscriptionChannelPipelineFactory()
getSubscriptionChannelPipelineFactory
in class AbstractHChannelManager
protected HChannel createAndStoreSubscriptionChannel(org.jboss.netty.channel.Channel channel)
AbstractHChannelManager
HChannel
thru the underlying established
channel
createAndStoreSubscriptionChannel
in class AbstractHChannelManager
channel
- The underlying established subscription channel.protected HChannel createAndStoreSubscriptionChannel(InetSocketAddress host)
AbstractHChannelManager
HChannel
to target host.createAndStoreSubscriptionChannel
in class AbstractHChannelManager
host
- Target host address.protected Either<Boolean,HChannel> storeSubscriptionChannel(TopicSubscriber topicSubscriber, PubSubData txn, org.jboss.netty.channel.Channel channel)
protected HChannel getSubscriptionChannel(InetSocketAddress host)
AbstractHChannelManager
HChannel
existed for a given host.getSubscriptionChannel
in class AbstractHChannelManager
host
- Target host address.protected HChannel getSubscriptionChannelByTopicSubscriber(TopicSubscriber subscriber)
AbstractHChannelManager
topicSubscriber
.getSubscriptionChannelByTopicSubscriber
in class AbstractHChannelManager
subscriber
- Topic Subscribertopic
's owner is unknown, return null.
if topic
's owner is know and there is a channel
existed before, return the existed channel, otherwise created
a new one for the topicSubscriber
.protected void onSubscriptionChannelDisconnected(InetSocketAddress host, org.jboss.netty.channel.Channel channel)
AbstractHChannelManager
HChannel
.onSubscriptionChannelDisconnected
in class AbstractHChannelManager
host
- Which host is disconnected.channel
- The underlying established channel.public SubscribeResponseHandler getSubscribeResponseHandler(TopicSubscriber topicSubscriber)
HChannelManager
topicSubscriber
.topicSubscriber
- Topic Subscriberpublic void startDelivery(TopicSubscriber topicSubscriber, MessageHandler messageHandler) throws PubSubException.ClientNotSubscribedException, AlreadyStartDeliveryException
HChannelManager
topicSubscriber
- Topic SubscribermessageHandler
- MessageHandler to register for this ResponseHandler instance.PubSubException.ClientNotSubscribedException
- If the client is not currently subscribed to the topicAlreadyStartDeliveryException
- If someone started delivery a message handler before stopping existed one.protected void restartDelivery(TopicSubscriber topicSubscriber) throws PubSubException.ClientNotSubscribedException, AlreadyStartDeliveryException
restartDelivery
in class AbstractHChannelManager
PubSubException.ClientNotSubscribedException
AlreadyStartDeliveryException
public void stopDelivery(TopicSubscriber topicSubscriber) throws PubSubException.ClientNotSubscribedException
HChannelManager
topicSubscriber
- Topic SubscriberPubSubException.ClientNotSubscribedException
- If the client is not currently subscribed to the topicpublic void asyncCloseSubscription(TopicSubscriber topicSubscriber, Callback<PubSubProtocol.ResponseBody> callback, Object context)
HChannelManager
topicSubscriber
.topicSubscriber
- Topic Subscribercallback
- Callbackcontext
- Callback contextprotected void checkTimeoutRequestsOnSubscriptionChannels()
AbstractHChannelManager
checkTimeoutRequestsOnSubscriptionChannels
in class AbstractHChannelManager
protected void closeSubscriptionChannels()
AbstractHChannelManager
closeSubscriptionChannels
in class AbstractHChannelManager
Copyright © 2011–2018 The Apache Software Foundation. All rights reserved.