editorconfig: max line length set

max line length warnings removed
missing Copyright added
useless publics removed
unmaintainable Javadoc tags: @author removed
helper class warnings removed
field default value initialization removed
Multiple warnings removed
pref: checkstyle warnings removed
Checkstyle will fail the build process if it detects violations
switch default cases error logger added
This commit is contained in:
Andreas Mager
2017-04-13 22:16:57 +02:00
parent 6dc762f47f
commit 9221a87812
122 changed files with 999 additions and 454 deletions
@@ -1,5 +1,20 @@
package io.moquette.parser.netty.performance;
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.parser.netty.performance;
import org.eclipse.jetty.toolchain.perf.PlatformTimer;
import org.eclipse.paho.client.mqttv3.*;
@@ -27,13 +42,11 @@ class BenchmarkPublisher {
private final long startedTime;
private final long numToSend;
private final IMqttAsyncClient connection;
private final CountDownLatch stopLatch;
ExitTopicCallback(long startedTime, long numToSend, IMqttAsyncClient connection, CountDownLatch stopLatch) {
this.startedTime = startedTime;
this.numToSend = numToSend;
this.connection = connection;
this.stopLatch = stopLatch;
}
@@ -48,7 +61,7 @@ class BenchmarkPublisher {
// LOG.error("Disconnect error", mex);
// }
double msgPerSec = (numToSend / spentTime) * 1000;
LOG.info( "PUB: speed {} msg/sec", msgPerSec);
LOG.info("PUB: speed {} msg/sec", msgPerSec);
this.stopLatch.countDown();
}
@@ -58,15 +71,15 @@ class BenchmarkPublisher {
}
}
private int qos = 0;
private boolean retain = false;
private int qos;
private boolean retain;
private final int numToSend;
private final int messagesPerSecond;
private final String dialog_id;
private final IMqttAsyncClient client;
private CountDownLatch m_latch;
public BenchmarkPublisher(MqttAsyncClient client, int numToSend, int messagesPerSecond, String dialog_id) {
BenchmarkPublisher(MqttAsyncClient client, int numToSend, int messagesPerSecond, String dialog_id) {
this.client = client;
this.numToSend = numToSend;
this.messagesPerSecond = messagesPerSecond;
@@ -91,7 +104,7 @@ class BenchmarkPublisher {
}
public void firePublishes() throws MqttException {
long pauseMicroseconds = (int)((1.0 / messagesPerSecond) * 1000 * 1000);
long pauseMicroseconds = (int) ((1.0 / messagesPerSecond) * 1000 * 1000);
LOG.info("PUB: Pause over the each message sent {} microsecs", pauseMicroseconds);
LOG.info("PUB: publishing..");
@@ -101,7 +114,7 @@ class BenchmarkPublisher {
//initialize the timer
PlatformTimer timer = PlatformTimer.detect();
IMqttActionListener pubCallback = new PublishCallback();
for (int i=0; i < numToSend; i++) {
for (int i = 0; i < numToSend; i++) {
long nanos = System.nanoTime();
byte[] message = ("Hello world!!-" + nanos).getBytes();
this.client.publish("/topic" + dialog_id, message, qos, retain, null, pubCallback);
@@ -114,7 +127,6 @@ class BenchmarkPublisher {
this.client.publish("/exit" + dialog_id, exitMessage, qos, retain, null, exitCallback);
}
public void waitFinish() throws InterruptedException {
m_latch.await();
try {
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.parser.netty.performance;
import org.HdrHistogram.Histogram;
@@ -23,7 +39,6 @@ class BenchmarkSubscriber {
//println "Received a publish on topic ${topic}"
if (topic.startsWith("/exit")) {
LOG.info("SUB: ok Exit!");
exit = true;
LOG.debug("Before disconnect");
// client.disconnect(1000) //wait max 1 sec
//client.disconnectForcibly()
@@ -31,11 +46,11 @@ class BenchmarkSubscriber {
LOG.debug("After disconnect");
long stopTime = System.currentTimeMillis();
long spentTime = stopTime - startTime;
LOG.info( "SUB: {} received", topic);
LOG.info( "SUB: subscriber disconnected, received {} messages in {} ms", numReceived, spentTime);
LOG.info("SUB: {} received", topic);
LOG.info("SUB: subscriber disconnected, received {} messages in {} ms", numReceived, spentTime);
double msgPerSec = (numReceived / spentTime) * 1000;
LOG.info( "SUB: Speed: {} msg/sec", msgPerSec);
LOG.info( "SUB: Latency diagram [microsecs]");
LOG.info("SUB: Speed: {} msg/sec", msgPerSec);
LOG.info("SUB: Latency diagram [microsecs]");
histogram.outputPercentileDistribution(System.out, 1000.0); //nanos/1000
m_latch.countDown();
} else {
@@ -50,7 +65,6 @@ class BenchmarkSubscriber {
// print '.'
// }
}
}
public void connectionLost(Throwable cause) {
@@ -65,22 +79,19 @@ class BenchmarkSubscriber {
}
public void deliveryComplete(IMqttDeliveryToken token) {
}
}
private int numReceived = 0;
private int numReceived;
private long startTime = System.currentTimeMillis();
private boolean exit = false;
private CountDownLatch m_latch = new CountDownLatch(1);
private boolean alreadyStarted = false;
private boolean alreadyStarted;
private Histogram histogram = new Histogram(5);
private final IMqttAsyncClient client;
private final String dialog_id;
public BenchmarkSubscriber(MqttAsyncClient client, String dialog_id) {
BenchmarkSubscriber(MqttAsyncClient client, String dialog_id) {
this.client = client;
this.dialog_id = dialog_id;
}
@@ -92,7 +103,7 @@ class BenchmarkSubscriber {
this.client.connect(connectOptions, null, new IMqttActionListener() {
public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
LOG.error( "SUB: connect fail", exception);
LOG.error("SUB: connect fail", exception);
System.exit(2);
}
@@ -137,10 +148,9 @@ class BenchmarkSubscriber {
});
}
public void waitFinish() throws InterruptedException, MqttException {
this.m_latch.await();
this.client.disconnect(1000);
}
}
}
@@ -1,6 +1,21 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.parser.netty.performance;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
@@ -24,7 +39,7 @@ class LoopMQTTHandler extends ChannelInboundHandlerAdapter {
Histogram processingTime = new Histogram(5);
Histogram forthNetworkTime = new Histogram(5);
public LoopMQTTHandler(ProtocolDecodingServer.SharedState state) {
LoopMQTTHandler(ProtocolDecodingServer.SharedState state) {
this.m_state = state;
}
@@ -63,7 +78,12 @@ class LoopMQTTHandler extends ChannelInboundHandlerAdapter {
// m_messaging.handleProtocolMessage(channel, msg);
break;
case PINGREQ:
MqttFixedHeader pingHeader = new MqttFixedHeader(MqttMessageType.PINGRESP, false, AT_MOST_ONCE, false, 0);
MqttFixedHeader pingHeader = new MqttFixedHeader(
MqttMessageType.PINGRESP,
false,
AT_MOST_ONCE,
false,
0);
MqttMessage pingResp = new MqttMessage(pingHeader);
ctx.writeAndFlush(pingResp);
break;
@@ -111,7 +131,10 @@ class LoopMQTTHandler extends ChannelInboundHandlerAdapter {
LOG.debug(" new value of flag {}, LoopHandler instance is {}", m_state.isForwardable(), this);
MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.SUBACK, false, AT_LEAST_ONCE, false, 0);
MqttSubAckPayload payload = new MqttSubAckPayload(AT_MOST_ONCE.value());
MqttSubAckMessage ackMessage = new MqttSubAckMessage(fixedHeader, from(msg.variableHeader().messageId()), payload);
MqttSubAckMessage ackMessage = new MqttSubAckMessage(
fixedHeader,
from(msg.variableHeader().messageId()),
payload);
ctx.writeAndFlush(ackMessage);
LOG.debug("subscribed client to {}", msg.payload().topicSubscriptions());
}
@@ -183,4 +206,4 @@ class LoopMQTTHandler extends ChannelInboundHandlerAdapter {
private static String clientID(Channel channel) {
return (String) channel.attr(ATTR_KEY_CLIENTID).get();
}
}
}
@@ -1,7 +1,22 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.parser.netty.performance;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
@@ -12,14 +27,13 @@ import org.HdrHistogram.Histogram;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ChannelHandler.Sharable
class NettyPublishReceiverHandler extends ChannelInboundHandlerAdapter {
private static final Logger LOG = LoggerFactory.getLogger(NettyPublishReceiverHandler.class);
Histogram forthNetworkTime = new Histogram(5);
public NettyPublishReceiverHandler() {
NettyPublishReceiverHandler() {
}
@Override
@@ -34,7 +48,7 @@ class NettyPublishReceiverHandler extends ChannelInboundHandlerAdapter {
handlePublish((MqttPublishMessage) msg);
return;
default:
LOG.info("Received a message of type {}",type);
LOG.info("Received a message of type {}", type);
}
} catch (Exception ex) {
LOG.error("Bad error in processing the message", ex);
@@ -65,7 +79,6 @@ class NettyPublishReceiverHandler extends ChannelInboundHandlerAdapter {
return new String(rawBytes);
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
LOG.info("Received channel inactive");
@@ -75,4 +88,4 @@ class NettyPublishReceiverHandler extends ChannelInboundHandlerAdapter {
this.forthNetworkTime.outputPercentileDistribution(System.out, 1000.0);
}
}
}
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.parser.netty.performance;
import io.netty.bootstrap.ServerBootstrap;
@@ -47,7 +63,7 @@ public class ProtocolDecodingServer {
static final class SharedState {
private volatile Channel subscriberCh;
private volatile Channel publisherCh;
private volatile boolean forwardPublish = false;
private volatile boolean forwardPublish;
public boolean isForwardable() {
return forwardPublish;
@@ -68,6 +84,10 @@ public class ProtocolDecodingServer {
public void setPublisherCh(Channel publisherCh) {
this.publisherCh = publisherCh;
}
public Channel getPublisherCh() {
return publisherCh;
}
}
final SharedState state = new SharedState();
@@ -111,7 +131,6 @@ public class ProtocolDecodingServer {
}
}
public void stop() {
if (m_workerGroup == null) {
throw new IllegalStateException("Invoked close on an Acceptor that wasn't initialized");
@@ -149,9 +168,10 @@ public class ProtocolDecodingServer {
String tmpDir = System.getProperty("java.io.tmpdir");
MqttDefaultFilePersistence dataStore = new MqttDefaultFilePersistence(tmpDir);
MqttAsyncClient pub = new MqttAsyncClient("tcp://" + host +":1883", "PublisherClient"+dialog_id, dataStore);
MqttAsyncClient pub = new MqttAsyncClient("tcp://" + host + ":1883", "PublisherClient" + dialog_id, dataStore);
MqttDefaultFilePersistence dataStoreSub = new MqttDefaultFilePersistence(tmpDir);
MqttAsyncClient sub = new MqttAsyncClient("tcp://" + host +":1883", "SubscriberClient"+dialog_id, dataStoreSub);
MqttAsyncClient sub = new MqttAsyncClient("tcp://" + host + ":1883", "SubscriberClient" + dialog_id,
dataStoreSub);
BenchmarkSubscriber suscriberBench = new BenchmarkSubscriber(sub, dialog_id);
suscriberBench.connect();
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.parser.netty.performance;
import io.netty.bootstrap.ServerBootstrap;
@@ -63,7 +79,6 @@ public class ProtocolPublishDecodingServer {
}
}
public void stop() {
if (m_workerGroup == null) {
throw new IllegalStateException("Invoked close on an Acceptor that wasn't initialized");
@@ -1,5 +1,20 @@
package io.moquette.parser.netty.performance;
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.parser.netty.performance;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
@@ -52,9 +67,8 @@ class PublishBomber {
}
}
public void publishLoop(int messagesPerSecond, int numToSend) {
long pauseMicroseconds = (int)((1.0 / messagesPerSecond) * 1000 * 1000);
long pauseMicroseconds = (int) ((1.0 / messagesPerSecond) * 1000 * 1000);
LOG.warn("PUB: Pause over the each message sent {} microsecs", pauseMicroseconds);
LOG.info("PUB: publishing..");
@@ -62,7 +76,7 @@ class PublishBomber {
//initialize the timer
PlatformTimer timer = PlatformTimer.detect();
for (int i=0; i < numToSend; i++) {
for (int i = 0; i < numToSend; i++) {
long nanos = System.nanoTime();
byte[] rawContent = ("Hello world!!-" + nanos).getBytes();
ByteBuf payload = Unpooled.copiedBuffer(rawContent);
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.parser.netty.performance;
import io.netty.channel.ChannelHandler;
@@ -18,7 +34,7 @@ class PublishReceiverHandler extends ChannelInboundHandlerAdapter {
private static final Logger LOG = LoggerFactory.getLogger(PublishReceiverHandler.class);
Histogram forthNetworkTime = new Histogram(5);
public PublishReceiverHandler() {
PublishReceiverHandler() {
}
@Override
@@ -61,4 +77,4 @@ class PublishReceiverHandler extends ChannelInboundHandlerAdapter {
this.forthNetworkTime.outputPercentileDistribution(System.out, 1000.0);
}
}
}
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2012-2017 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.moquette.spi.impl.subscriptions;
@@ -9,7 +24,7 @@ import io.moquette.persistence.MemoryStorageService;
import io.moquette.spi.ISessionsStore;
import io.netty.handler.codec.mqtt.MqttQoS;
public class PerformanceTest {
public final class PerformanceTest {
// Set CPU governor and max frequency to lowest value for this test
/* debian:
@@ -75,11 +90,12 @@ public class PerformanceTest {
min = Math.min(min, time2);
// min.updateAndGet(c -> Math.min(c, time2));
System.out.println(".." + j + ": " + time2 + " min:" + min);
}
// });
System.out.println("min:" + min);
}
private PerformanceTest() {
}
}