public abstract class AbstractHChannelManager extends Object implements HChannelManager
Modifier and Type | Field and Description |
---|---|
protected boolean |
closed |
protected ReentrantReadWriteLock |
closedLock |
protected AtomicLong |
globalCounter |
protected CleanupChannelMap<InetSocketAddress> |
host2NonSubscriptionChannels |
protected ConcurrentMap<InetSocketAddress,Set<com.google.protobuf.ByteString>> |
host2Topics |
protected org.jboss.netty.channel.ChannelFactory |
socketFactory |
protected ConcurrentMap<com.google.protobuf.ByteString,InetSocketAddress> |
topic2Host |
Modifier | Constructor and Description |
---|---|
protected |
AbstractHChannelManager(ClientConfiguration cfg,
org.jboss.netty.channel.ChannelFactory socketFactory) |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
checkTimeoutRequestsOnSubscriptionChannels()
Chekout the pub/sub requests on subscription channels.
|
protected void |
clearAllTopicsForHost(InetSocketAddress host) |
void |
clearHostForTopic(com.google.protobuf.ByteString topic,
InetSocketAddress host) |
void |
close()
Close the channel manager.
|
protected abstract void |
closeSubscriptionChannels()
Close all subscription channels when close channel manager.
|
protected abstract HChannel |
createAndStoreSubscriptionChannel(org.jboss.netty.channel.Channel channel)
Create and store a subscription
HChannel thru the underlying established
channel |
protected abstract HChannel |
createAndStoreSubscriptionChannel(InetSocketAddress host)
Create and store a subscription
HChannel to target host. |
protected org.jboss.netty.channel.ChannelFactory |
getChannelFactory() |
MessageConsumeCallback |
getConsumeCallback() |
protected ClientChannelPipelineFactory |
getNonSubscriptionChannelPipelineFactory() |
SslClientContextFactory |
getSslFactory() |
protected abstract HChannel |
getSubscriptionChannel(InetSocketAddress host)
Is there a subscription
HChannel existed for a given host. |
protected abstract HChannel |
getSubscriptionChannelByTopicSubscriber(TopicSubscriber topicSubscriber)
Get a subscription channel for a given
topicSubscriber . |
protected abstract ClientChannelPipelineFactory |
getSubscriptionChannelPipelineFactory() |
SubscriptionEventEmitter |
getSubscriptionEventEmitter()
Return the subscription event emitter to emit subscription events.
|
boolean |
isClosed()
Is the channel manager closed.
|
long |
nextTxnId()
Generate next transaction id for pub/sub request sending thru this manager.
|
protected void |
onNonSubscriptionChannelDisconnected(InetSocketAddress host,
org.jboss.netty.channel.Channel channel)
Handle the disconnected event from a non-subscription
HChannel . |
protected abstract void |
onSubscriptionChannelDisconnected(InetSocketAddress host,
org.jboss.netty.channel.Channel channel)
Handle the disconnected event from a subscription
HChannel . |
void |
redirectToHost(PubSubData pubSubData,
InetSocketAddress host)
Submit a pub/sub request to a given host.
|
protected abstract void |
restartDelivery(TopicSubscriber topicSubscriber) |
void |
schedule(TimerTask task,
long delay)
Schedule a timer task after a given
delay . |
protected void |
storeTopic2HostMapping(com.google.protobuf.ByteString topic,
InetSocketAddress host)
Helper method to store the topic2Host mapping in the channel manager cache
map.
|
void |
submitOp(PubSubData pubSubData)
Submit a pub/sub request.
|
void |
submitOpAfterDelay(PubSubData pubSubData,
long delay)
Submit a pub/sub request after a given
delay . |
void |
submitOpToDefaultServer(PubSubData pubSubData)
Submit a pub/sub request to default server.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
asyncCloseSubscription, getSubscribeResponseHandler, startDelivery, stopDelivery
protected boolean closed
protected final ReentrantReadWriteLock closedLock
protected final AtomicLong globalCounter
protected final ConcurrentMap<com.google.protobuf.ByteString,InetSocketAddress> topic2Host
protected final ConcurrentMap<InetSocketAddress,Set<com.google.protobuf.ByteString>> host2Topics
protected final CleanupChannelMap<InetSocketAddress> host2NonSubscriptionChannels
protected final org.jboss.netty.channel.ChannelFactory socketFactory
protected AbstractHChannelManager(ClientConfiguration cfg, org.jboss.netty.channel.ChannelFactory socketFactory)
public SubscriptionEventEmitter getSubscriptionEventEmitter()
HChannelManager
getSubscriptionEventEmitter
in interface HChannelManager
public MessageConsumeCallback getConsumeCallback()
public SslClientContextFactory getSslFactory()
protected org.jboss.netty.channel.ChannelFactory getChannelFactory()
protected ClientChannelPipelineFactory getNonSubscriptionChannelPipelineFactory()
protected abstract ClientChannelPipelineFactory getSubscriptionChannelPipelineFactory()
public void schedule(TimerTask task, long delay)
HChannelManager
delay
.schedule
in interface HChannelManager
task
- A timer taskdelay
- Delay time in ms.public void submitOpAfterDelay(PubSubData pubSubData, long delay)
HChannelManager
delay
.submitOpAfterDelay
in interface HChannelManager
pubSubData
- Pub/Sub Request.delay
- Delay time in ms.public void submitOp(PubSubData pubSubData)
HChannelManager
submitOp
in interface HChannelManager
pubSubData
- Pub/Sub Request.public void redirectToHost(PubSubData pubSubData, InetSocketAddress host)
HChannelManager
redirectToHost
in interface HChannelManager
pubSubData
- Pub/Sub request.host
- Given host address.public void submitOpToDefaultServer(PubSubData pubSubData)
HChannelManager
submitOpToDefaultServer
in interface HChannelManager
pubSubData
- Pub/Sub request.protected void onNonSubscriptionChannelDisconnected(InetSocketAddress host, org.jboss.netty.channel.Channel channel)
HChannel
.host
- Which host is disconnected.channel
- The underlying established channel.protected abstract HChannel createAndStoreSubscriptionChannel(org.jboss.netty.channel.Channel channel)
HChannel
thru the underlying established
channel
channel
- The underlying established subscription channel.protected abstract HChannel createAndStoreSubscriptionChannel(InetSocketAddress host)
HChannel
to target host.host
- Target host address.protected abstract HChannel getSubscriptionChannel(InetSocketAddress host)
HChannel
existed for a given host.host
- Target host address.protected abstract HChannel getSubscriptionChannelByTopicSubscriber(TopicSubscriber topicSubscriber)
topicSubscriber
.topicSubscriber
- 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 abstract void onSubscriptionChannelDisconnected(InetSocketAddress host, org.jboss.netty.channel.Channel channel)
HChannel
.host
- Which host is disconnected.channel
- The underlying established channel.protected void storeTopic2HostMapping(com.google.protobuf.ByteString topic, InetSocketAddress host)
topic
- Topic Namehost
- Host Addressprotected void clearAllTopicsForHost(InetSocketAddress host)
public void clearHostForTopic(com.google.protobuf.ByteString topic, InetSocketAddress host)
public long nextTxnId()
HChannelManager
nextTxnId
in interface HChannelManager
protected abstract void restartDelivery(TopicSubscriber topicSubscriber) throws PubSubException.ClientNotSubscribedException, AlreadyStartDeliveryException
protected abstract void checkTimeoutRequestsOnSubscriptionChannels()
public boolean isClosed()
HChannelManager
isClosed
in interface HChannelManager
protected abstract void closeSubscriptionChannels()
public void close()
HChannelManager
close
in interface HChannelManager
Copyright © 2011–2019 The Apache Software Foundation. All rights reserved.