[GitHub] [flink] Xeli commented on a change in pull request #8259: [FLINK-12325][metrics] Fix bug in statsd exporter when using negative values

2019-05-04 Thread GitBox
Xeli commented on a change in pull request #8259: [FLINK-12325][metrics] Fix 
bug in statsd exporter when using negative values
URL: https://github.com/apache/flink/pull/8259#discussion_r280971043
 
 

 ##
 File path: 
flink-metrics/flink-metrics-statsd/src/main/java/org/apache/flink/metrics/statsd/StatsDReporter.java
 ##
 @@ -240,12 +240,6 @@ public String filterCharacters(String input) {
}
 
private boolean numberIsNegative(Number input) {
-   try {
-   return new 
BigDecimal(input.toString()).compareTo(BigDecimal.ZERO) == -1;
-   } catch (Exception e) {
-   //not all Number's can be converted to a BigDecimal, 
such as Infinity or NaN
-   //in this case we just say it isn't a negative number
-   return false;
-   }
+   return input.doubleValue() < 0;
 
 Review comment:
   Ah sorry, no reason! 
   
   I've changed it to Double.compare(), I've also changed line #190 to use this 
method so the double check there works in the same way.  


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] Xeli commented on a change in pull request #8259: [FLINK-12325][metrics] Fix bug in statsd exporter when using negative values

2019-05-02 Thread GitBox
Xeli commented on a change in pull request #8259: [FLINK-12325][metrics] Fix 
bug in statsd exporter when using negative values
URL: https://github.com/apache/flink/pull/8259#discussion_r280538063
 
 

 ##
 File path: 
flink-metrics/flink-metrics-statsd/src/main/java/org/apache/flink/metrics/statsd/StatsDReporter.java
 ##
 @@ -216,4 +238,14 @@ public String filterCharacters(String input) {
 
return chars == null ? input : new String(chars, 0, pos);
}
+
+   private boolean numberIsNegative(Number input) {
+   try {
+   return new 
BigDecimal(input.toString()).compareTo(BigDecimal.ZERO) == -1;
 
 Review comment:
   Yeah good call, in this case the rounding that doubleValue might do wouldn't 
matter anyhow. Changed it!


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] Xeli commented on a change in pull request #8259: [FLINK-12325][metrics] Fix bug in statsd exporter when using negative values

2019-04-26 Thread GitBox
Xeli commented on a change in pull request #8259: [FLINK-12325][metrics] Fix 
bug in statsd exporter when using negative values
URL: https://github.com/apache/flink/pull/8259#discussion_r279071512
 
 

 ##
 File path: 
flink-metrics/flink-metrics-statsd/src/test/java/org/apache/flink/metrics/statsd/StatsDReporterTest.java
 ##
 @@ -262,6 +262,69 @@ public void testStatsDMetersReporting() throws Exception {
}
}
 
+   /**
+* Tests that meters are properly reported via the StatsD reporter.
+*/
+   @Test
+   public void testStatsDMetersReportingOfNegativeValues() throws 
Exception {
+   MetricRegistryImpl registry = null;
+   DatagramSocketReceiver receiver = null;
+   Thread receiverThread = null;
+   long timeout = 5000;
+   long joinTimeout = 3;
+
+   String meterName = "meter";
+
+   try {
+   receiver = new DatagramSocketReceiver();
+
+   receiverThread = new Thread(receiver);
+
+   receiverThread.start();
+
+   int port = receiver.getPort();
+
+   MetricConfig config = new MetricConfig();
+   
config.setProperty(ConfigConstants.METRICS_REPORTER_INTERVAL_SUFFIX, "1 
SECONDS");
+   config.setProperty("host", "localhost");
+   config.setProperty("port", String.valueOf(port));
+
+   registry = new MetricRegistryImpl(
+   
MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+   
Collections.singletonList(ReporterSetup.forReporter("test", config, new 
StatsDReporter(;
+   TaskManagerMetricGroup metricGroup = new 
TaskManagerMetricGroup(registry, "localhost", "tmId");
+   TestMeter meter = new TestMeter(-50, -5.3);
 
 Review comment:
   Done


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] Xeli commented on a change in pull request #8259: [FLINK-12325][metrics] Fix bug in statsd exporter when using negative values

2019-04-26 Thread GitBox
Xeli commented on a change in pull request #8259: [FLINK-12325][metrics] Fix 
bug in statsd exporter when using negative values
URL: https://github.com/apache/flink/pull/8259#discussion_r279071445
 
 

 ##
 File path: 
flink-metrics/flink-metrics-statsd/src/test/java/org/apache/flink/metrics/statsd/StatsDReporterTest.java
 ##
 @@ -262,6 +262,69 @@ public void testStatsDMetersReporting() throws Exception {
}
}
 
+   /**
+* Tests that meters are properly reported via the StatsD reporter.
+*/
+   @Test
+   public void testStatsDMetersReportingOfNegativeValues() throws 
Exception {
+   MetricRegistryImpl registry = null;
+   DatagramSocketReceiver receiver = null;
+   Thread receiverThread = null;
+   long timeout = 5000;
+   long joinTimeout = 3;
+
+   String meterName = "meter";
+
+   try {
+   receiver = new DatagramSocketReceiver();
+
+   receiverThread = new Thread(receiver);
+
+   receiverThread.start();
+
+   int port = receiver.getPort();
+
+   MetricConfig config = new MetricConfig();
+   
config.setProperty(ConfigConstants.METRICS_REPORTER_INTERVAL_SUFFIX, "1 
SECONDS");
+   config.setProperty("host", "localhost");
+   config.setProperty("port", String.valueOf(port));
+
+   registry = new MetricRegistryImpl(
+   
MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
+   
Collections.singletonList(ReporterSetup.forReporter("test", config, new 
StatsDReporter(;
 
 Review comment:
   Done, it's a lot cleaner now. I've adjusted the other unit tests in the 
class like this as well


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services