Browse code

FEATBL-412 Feat: Changed Json format for dropwizard compatibility

qvigand authored on 14/05/2018 15:26:10
Showing 7 changed files
... ...
@@ -46,6 +46,7 @@ public class WebSocketClient {
46 46
 		Bootstrap bootstrap = ClientBootstrap.create(chanInit);
47 47
 		ch = bootstrap.connect().sync().channel();
48 48
 		handler.handshakeFuture().sync();
49
+		logger.info("Websocket created");
49 50
 	}
50 51
 
51 52
 	public void close() throws InterruptedException {
... ...
@@ -9,10 +9,7 @@ import io.netty.channel.ChannelHandlerContext;
9 9
 import io.netty.channel.ChannelPromise;
10 10
 import io.netty.channel.SimpleChannelInboundHandler;
11 11
 import io.netty.handler.codec.http.FullHttpResponse;
12
-import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
13 12
 import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
14
-import io.netty.handler.codec.http.websocketx.PongWebSocketFrame;
15
-import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
16 13
 import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
17 14
 import io.netty.handler.codec.http.websocketx.WebSocketFrame;
18 15
 import io.netty.util.CharsetUtil;
... ...
@@ -15,7 +15,7 @@ import com.netflix.spectator.api.Measurement;
15 15
 import com.netflix.spectator.api.Statistic;
16 16
 
17 17
 import net.bluemind.metrics.registry.client.WebSocketClient;
18
-import net.bluemind.metrics.registry.json.DistributionSummaryJson;
18
+import net.bluemind.metrics.registry.json.AmountJson;
19 19
 
20 20
 public class BMDistributionSummary implements DistributionSummary {
21 21
 	private static final Logger logger = LoggerFactory.getLogger(BMDistributionSummary.class);
... ...
@@ -51,8 +51,7 @@ public class BMDistributionSummary implements DistributionSummary {
51 51
 			count.increment();
52 52
 		}
53 53
 		try {
54
-			DistributionSummaryJson distributionSummaryJson = new DistributionSummaryJson(id, this.count,
55
-					this.totalAmount);
54
+			AmountJson distributionSummaryJson = new AmountJson(id, amount);
56 55
 			this.webSockClient.sendTextFrame(Mapper.get().writeValueAsString(distributionSummaryJson));
57 56
 		} catch (IOException e) {
58 57
 			logger.error("IOException : ", e);
... ...
@@ -16,7 +16,7 @@ import com.netflix.spectator.api.Measurement;
16 16
 import com.netflix.spectator.api.Statistic;
17 17
 
18 18
 import net.bluemind.metrics.registry.client.WebSocketClient;
19
-import net.bluemind.metrics.registry.json.TimerJson;
19
+import net.bluemind.metrics.registry.json.AmountJson;
20 20
 
21 21
 public class BMTimer extends AbstractTimer {
22 22
 	private static final Logger logger = LoggerFactory.getLogger(BMTimer.class);
... ...
@@ -52,7 +52,7 @@ public class BMTimer extends AbstractTimer {
52 52
 			count.increment();
53 53
 		}
54 54
 		try {
55
-			TimerJson timerJson = new TimerJson(id, this.count, this.totalTime);
55
+			AmountJson timerJson = new AmountJson(id, amount);
56 56
 			this.webSockClient.sendTextFrame(Mapper.get().writeValueAsString(timerJson));
57 57
 		} catch (IOException e) {
58 58
 			logger.error("IOException : ", e);
59 59
new file mode 100644
... ...
@@ -0,0 +1,17 @@
0
+package net.bluemind.metrics.registry.json;
1
+
2
+import com.netflix.spectator.api.Id;
3
+
4
+public class AmountJson extends RegJson {
5
+	public static String METRICTYPE = "DistributionSummmary";
6
+	private final long amount;
7
+
8
+	public AmountJson(Id id, long amount) {
9
+		super(METRICTYPE, id);
10
+		this.amount = amount;
11
+	}
12
+
13
+	public long getAmount() {
14
+		return this.amount;
15
+	}
16
+}
0 17
deleted file mode 100644
... ...
@@ -1,25 +0,0 @@
1
-package net.bluemind.metrics.registry.json;
2
-
3
-import java.util.concurrent.atomic.LongAdder;
4
-
5
-import com.netflix.spectator.api.Id;
6
-
7
-public class DistributionSummaryJson extends RegJson {
8
-	public static String METRICTYPE = "DistributionSummmary";
9
-	private final LongAdder count;
10
-	private final LongAdder totalAmount;
11
-
12
-	public DistributionSummaryJson(Id id, LongAdder count, LongAdder totalAmount) {
13
-		super(METRICTYPE, id);
14
-		this.count = count;
15
-		this.totalAmount = totalAmount;
16
-	}
17
-
18
-	public LongAdder getCount() {
19
-		return this.count;
20
-	}
21
-
22
-	public LongAdder getTotalAmount() {
23
-		return this.totalAmount;
24
-	}
25
-}
26 1
deleted file mode 100644
... ...
@@ -1,31 +0,0 @@
1
-package net.bluemind.metrics.registry.json;
2
-
3
-import java.util.concurrent.atomic.LongAdder;
4
-
5
-import com.netflix.spectator.api.Id;
6
-
7
-public class TimerJson extends RegJson {
8
-	public static String METRICTYPE = "Timer";
9
-	private final LongAdder count;
10
-	private final LongAdder totalTime;
11
-
12
-	public TimerJson(Id id, LongAdder count, LongAdder totalTime) {
13
-		super(METRICTYPE, id);
14
-		this.count = count;
15
-		this.totalTime = totalTime;
16
-	}
17
-
18
-	public TimerJson(String id, LongAdder count, LongAdder totalTime) {
19
-		super(METRICTYPE, id);
20
-		this.count = count;
21
-		this.totalTime = totalTime;
22
-	}
23
-
24
-	public LongAdder getCount() {
25
-		return this.count;
26
-	}
27
-
28
-	public LongAdder getTotalTime() {
29
-		return this.totalTime;
30
-	}
31
-}