broker/Qos2PublishHandler: code formatter used

This commit is contained in:
Andreas Mager
2017-02-01 17:13:40 +01:00
parent b7f3e1beba
commit 127894b2f9
@@ -1,3 +1,4 @@
package io.moquette.spi.impl; package io.moquette.spi.impl;
import io.moquette.server.ConnectionDescriptorStore; import io.moquette.server.ConnectionDescriptorStore;
@@ -13,9 +14,7 @@ import io.netty.channel.Channel;
import io.netty.handler.codec.mqtt.*; import io.netty.handler.codec.mqtt.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import static io.moquette.spi.impl.ProtocolProcessor.asStoredMessage; import static io.moquette.spi.impl.ProtocolProcessor.asStoredMessage;
import static io.moquette.spi.impl.Utils.messageId; import static io.moquette.spi.impl.Utils.messageId;
import static io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader.from; import static io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader.from;
@@ -34,8 +33,8 @@ class Qos2PublishHandler extends QosPublishHandler {
public Qos2PublishHandler(IAuthorizator authorizator, SubscriptionsStore subscriptions, public Qos2PublishHandler(IAuthorizator authorizator, SubscriptionsStore subscriptions,
IMessagesStore messagesStore, BrokerInterceptor interceptor, IMessagesStore messagesStore, BrokerInterceptor interceptor,
ConnectionDescriptorStore connectionDescriptors, ConnectionDescriptorStore connectionDescriptors, ISessionsStore sessionsStore, String brokerPort,
ISessionsStore sessionsStore, String brokerPort, MessagesPublisher messagesPublisher) { MessagesPublisher messagesPublisher) {
super(authorizator); super(authorizator);
this.subscriptions = subscriptions; this.subscriptions = subscriptions;
this.m_messagesStore = messagesStore; this.m_messagesStore = messagesStore;
@@ -58,13 +57,20 @@ class Qos2PublishHandler extends QosPublishHandler {
toStoreMsg.setClientID(clientID); toStoreMsg.setClientID(clientID);
if (LOG.isTraceEnabled()) { if (LOG.isTraceEnabled()) {
LOG.trace("Sending publish message to subscribers. MqttClientId = {}, topic = {}, messageId = {}, " + LOG.trace(
"payload = {}, subscriptionTree = {}.", "Sending publish message to subscribers. MqttClientId = {}, topic = {}, messageId = {}, "
clientID, topic, messageID, DebugUtils.payload2Str(toStoreMsg.getMessage()), + "payload = {}, subscriptionTree = {}.",
clientID,
topic,
messageID,
DebugUtils.payload2Str(toStoreMsg.getMessage()),
subscriptions.dumpTree()); subscriptions.dumpTree());
} else { } else {
LOG.info("Sending publish message to subscribers. MqttClientId = {}, topic = {}, messageId = {}.", LOG.info(
clientID, topic, messageID); "Sending publish message to subscribers. MqttClientId = {}, topic = {}, messageId = {}.",
clientID,
topic,
messageID);
} }
// QoS2 // QoS2
@@ -87,9 +93,9 @@ class Qos2PublishHandler extends QosPublishHandler {
} }
/** /**
* Second phase of a publish QoS2 protocol, sent by publisher to the broker. Search the stored message and publish * Second phase of a publish QoS2 protocol, sent by publisher to the broker. Search the stored
* to all interested subscribers. * message and publish to all interested subscribers.
* */ */
void processPubRel(Channel channel, MqttMessage msg) { void processPubRel(Channel channel, MqttMessage msg) {
String clientID = NettyUtils.clientID(channel); String clientID = NettyUtils.clientID(channel);
int messageID = messageId(msg); int messageID = messageId(msg);
@@ -100,12 +106,20 @@ class Qos2PublishHandler extends QosPublishHandler {
List<Subscription> topicMatchingSubscriptions = subscriptions.matches(topic); List<Subscription> topicMatchingSubscriptions = subscriptions.matches(topic);
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("Sending publish message to subscribers. MqttClientId = {}, topic = {}, messageId = {}, payload = {}, subscriptionTree = {}.", LOG.debug(
clientID, topic, messageID, DebugUtils.payload2Str(evt.getMessage()), "Sending publish message to subscribers. "
+ "MqttClientId = {}, topic = {}, messageId = {}, payload = {}, subscriptionTree = {}.",
clientID,
topic,
messageID,
DebugUtils.payload2Str(evt.getMessage()),
subscriptions.dumpTree()); subscriptions.dumpTree());
} else { } else {
LOG.info("Sending publish message to subscribers. MqttClientId = {}, topic = {}, messageId = {}.", clientID, LOG.info(
topic, messageID); "Sending publish message to subscribers. MqttClientId = {}, topic = {}, messageId = {}.",
clientID,
topic,
messageID);
} }
this.publisher.publish2Subscribers(evt, topicMatchingSubscriptions); this.publisher.publish2Subscribers(evt, topicMatchingSubscriptions);
@@ -120,7 +134,6 @@ class Qos2PublishHandler extends QosPublishHandler {
sendPubComp(clientID, messageID); sendPubComp(clientID, messageID);
} }
private void sendPubRec(String clientID, int messageID) { private void sendPubRec(String clientID, int messageID) {
LOG.debug("Sending PUBREC message. MqttClientId = {}, messageId = {}.", clientID, messageID); LOG.debug("Sending PUBREC message. MqttClientId = {}, messageId = {}.", clientID, messageID);
MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.PUBREC, false, AT_MOST_ONCE, false, 0); MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.PUBREC, false, AT_MOST_ONCE, false, 0);