@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);
}