Skip to content

Commit 8dc2668

Browse files
vjkoskelaBrandonArp
authored andcommitted
Fixes to improve telegraf integration. (#103)
1 parent 511b982 commit 8dc2668

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171

7272
<properties>
7373
<!--Dependency versions-->
74-
<akka.version>2.5.6</akka.version>
75-
<akka.http.version>10.0.11</akka.http.version>
74+
<akka.version>2.5.13</akka.version>
75+
<akka.http.version>10.1.3</akka.http.version>
7676
<apache.httpclient.version>4.5.1</apache.httpclient.version>
7777
<apache.httpcore.version>4.4.3</apache.httpcore.version>
7878
<arpnetworking.commons.version>1.16.0</arpnetworking.commons.version>

src/main/java/com/arpnetworking/metrics/common/sources/BaseTcpSource.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ protected BaseTcpSource(final Builder<?, ?> builder) {
7272

7373
@Override
7474
public void preStart() {
75-
_tcpManager.tell(
75+
final ActorRef tcpManager = Tcp.get(getContext().system()).manager();
76+
tcpManager.tell(
7677
TcpMessage.bind(
7778
getSelf(),
7879
new InetSocketAddress(_host, _port),
@@ -87,24 +88,24 @@ public Receive createReceive() {
8788
getSender().tell(_isReady, getSelf());
8889
})
8990
.match(Tcp.Bound.class, tcpBound -> {
90-
_isReady = true;
91-
_tcpManager.tell(tcpBound, getSelf());
9291
LOGGER.info()
9392
.setMessage("Tcp server binding complete")
9493
.addData("name", _sink.getName())
9594
.addData("address", tcpBound.localAddress().getAddress().getHostAddress())
9695
.addData("port", tcpBound.localAddress().getPort())
9796
.log();
97+
98+
_isReady = true;
9899
})
99100
.match(Tcp.CommandFailed.class, failed -> {
100-
getContext().stop(getSelf());
101101
LOGGER.warn()
102102
.setMessage("Tcp server bad command")
103103
.addData("name", _sink.getName())
104104
.log();
105+
106+
getContext().stop(getSelf());
105107
})
106108
.match(Tcp.Connected.class, tcpConnected -> {
107-
_tcpManager.tell(tcpConnected, getSelf());
108109
LOGGER.debug()
109110
.setMessage("Tcp connection established")
110111
.addData("name", _sink.getName())
@@ -141,16 +142,13 @@ protected BaseTcpListenerActor(final BaseTcpSource source) {
141142
_host = source._host;
142143
_port = source._port;
143144
_acceptQueue = source._acceptQueue;
144-
145-
_tcpManager = Tcp.get(getContext().system()).manager();
146145
}
147146

148147
private boolean _isReady = false;
149148
private final BaseTcpSource _sink;
150149
private final String _host;
151150
private final int _port;
152151
private final int _acceptQueue;
153-
private final ActorRef _tcpManager;
154152

155153
private static final String IS_READY = "IsReady";
156154
}

src/main/java/com/arpnetworking/metrics/mad/parsers/TelegrafJsonToRecordParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public ZonedDateTime create(final long timestamp) {
258258
NANOSECONDS {
259259
@Override
260260
public ZonedDateTime create(final long timestamp) {
261-
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(timestamp * 1000000), ZoneOffset.UTC);
261+
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(timestamp / 1000000), ZoneOffset.UTC);
262262
}
263263
};
264264

src/test/java/com/arpnetworking/metrics/common/sources/StatsdSourceTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public void tearDown() {
6666
}
6767

6868
@Test
69+
@SuppressWarnings("deprecation")
6970
public void test() {
7071
final StatsdSource statsdSource = new StatsdSource.Builder()
7172
.setActorSystem(_actorSystem)

0 commit comments

Comments
 (0)