Skip to content
This repository
Browse code

Merge branch '2.x-maintenance'

Conflicts:
	docs/source/about/release-notes.rst
	docs/source/conf.py
	metrics-annotation/pom.xml
	metrics-core/pom.xml
	metrics-core/src/main/java/com/yammer/metrics/stats/ExponentiallyDecayingSample.java
	metrics-core/src/test/java/com/yammer/metrics/stats/tests/ExponentiallyDecayingSampleTest.java
	metrics-ehcache/pom.xml
	metrics-ganglia/pom.xml
	metrics-graphite/pom.xml
	metrics-guice/pom.xml
	metrics-httpclient/pom.xml
	metrics-httpclient/src/main/java/com/yammer/metrics/httpclient/InstrumentedClientConnManager.java
	metrics-jdbi/pom.xml
	metrics-jersey/pom.xml
	metrics-jetty/pom.xml
	metrics-log4j/pom.xml
	metrics-logback/pom.xml
	metrics-scala_2.9.1/pom.xml
	metrics-servlet/pom.xml
	metrics-spring/pom.xml
	metrics-web/pom.xml
	pom.xml
  • Loading branch information...
commit 9cea37b1ad4d3fa8720d3be4ae72bf43e25cd781 2 parents 8d25559 + b18eb9b
Coda Hale authored August 06, 2012
16  docs/source/about/release-notes.rst
Source Rendered
@@ -10,12 +10,10 @@ v3.0.0-SNAPSHOT
10 10
 ===============
11 11
 
12 12
 * Added ``AdminServlet#setServiceName()``.
13  
-* Fixed a bug in ``ExponentiallyDecayingSample`` for long periods of inactivity.
14 13
 * Switched all getters to the standard ``#getValue()``.
15 14
 * Use the full metric name in ``CsvReporter``.
16 15
 * Made ``DefaultWebappMetricsFilter``'s registry configurable.
17 16
 * Switched to ``HttpServletRequest#getContextPath()`` in ``AdminServlet``.
18  
-* Upgraded to HttpClient 4.2.
19 17
 * Upgraded to Logback 1.0.3.
20 18
 * Upgraded to Log4j 1.2.17.
21 19
 * Upgraded to JDBI 2.34.
@@ -26,6 +24,20 @@ v3.0.0-SNAPSHOT
26 24
 * Changed package names in ``metrics-ganglia``, ``metrics-graphite``, and ``metrics-servlet``.
27 25
 * Removed ``metrics-guice`` and ``metrics-spring``.
28 26
 
  27
+.. _rel-2.1.3:
  28
+
  29
+v2.1.3: Aug 06 2012
  30
+===================
  31
+
  32
+* Upgraded to Apache HttpClient 4.2.1.
  33
+* Changed ``InstrumentedClientConnManager`` to extend ``PoolingClientConnectionManager`` instead of
  34
+  the deprecated ``ThreadSafeClientConnManager``.
  35
+* Fixed a bug in ``ExponentiallyDecayingSample`` with long periods of inactivity.
  36
+* Fixed problems with re-registering metrics in JMX.
  37
+* Added support for ``DnsResolver`` instances to ``InstrumentedClientConnManager``.
  38
+* Added support for formatted health check error messages.
  39
+>>>>>>> 2.x-maintenance
  40
+
29 41
 .. _rel-2.1.2:
30 42
 
31 43
 v2.1.2: Apr 11 2012
2  docs/source/conf.py
@@ -50,7 +50,7 @@
50 50
 # The short X.Y version.
51 51
 version = '2.1'
52 52
 # The full version, including alpha/beta/rc tags.
53  
-release = '2.1.2'
  53
+release = '2.1.3'
54 54
 
55 55
 # The language for content autogenerated by Sphinx. Refer to documentation
56 56
 # for a list of supported languages.
30  metrics-core/src/main/java/com/yammer/metrics/core/HealthCheck.java
@@ -32,6 +32,21 @@ public static Result healthy(String message) {
32 32
         }
33 33
 
34 34
         /**
  35
+         * Returns a healthy {@link Result} with a formatted message.
  36
+         *
  37
+         * Message formatting follows the same rules as 
  38
+         * {@link String#format(String, Object...)}.
  39
+         *
  40
+         * @param message a message format
  41
+         * @param args    the arguments apply to the message format
  42
+         * @return a healthy {@link Result} with an additional message
  43
+         * @see String#format(String, Object...)
  44
+         */
  45
+        public static Result healthy(String message, Object... args) {
  46
+            return healthy(String.format(message, args));
  47
+        }
  48
+
  49
+        /**
35 50
          * Returns an unhealthy {@link Result} with the given message.
36 51
          *
37 52
          * @param message    an informative message describing how the health check failed
@@ -42,6 +57,21 @@ public static Result unhealthy(String message) {
42 57
         }
43 58
 
44 59
         /**
  60
+         * Returns an unhealthy {@link Result} with a formatted message.
  61
+         *
  62
+         * Message formatting follows the same rules as 
  63
+         * {@link String#format(String, Object...)}.
  64
+         *
  65
+         * @param message a message format
  66
+         * @param args    the arguments apply to the message format
  67
+         * @return an unhealthy {@link Result} with an additional message
  68
+         * @see String#format(String, Object...)
  69
+         */
  70
+        public static Result unhealthy(String message, Object... args) {
  71
+            return unhealthy(String.format(message, args));
  72
+        }
  73
+
  74
+        /**
45 75
          * Returns an unhealthy {@link Result} with the given error.
46 76
          *
47 77
          * @param error    an exception thrown during the health check
22  metrics-core/src/main/java/com/yammer/metrics/core/Histogram.java
@@ -50,16 +50,6 @@ public Sample newSample() {
50 50
         public abstract Sample newSample();
51 51
     }
52 52
 
53  
-    /**
54  
-     * Cache arrays for the variance calculation, so as to avoid memory allocation.
55  
-     */
56  
-    private static class ArrayCache extends ThreadLocal<double[]> {
57  
-        @Override
58  
-        protected double[] initialValue() {
59  
-            return new double[2];
60  
-        }
61  
-    }
62  
-
63 53
     private final Sample sample;
64 54
     private final AtomicLong min = new AtomicLong();
65 55
     private final AtomicLong max = new AtomicLong();
@@ -69,7 +59,6 @@ public Sample newSample() {
69 59
     private final AtomicReference<double[]> variance =
70 60
             new AtomicReference<double[]>(new double[]{-1, 0}); // M, S
71 61
     private final AtomicLong count = new AtomicLong();
72  
-    private final ArrayCache arrayCache = new ArrayCache();
73 62
 
74 63
     /**
75 64
      * Creates a new {@link Histogram} with the given sample type.
@@ -215,10 +204,9 @@ private void setMin(long potentialMin) {
215 204
     }
216 205
 
217 206
     private void updateVariance(long value) {
218  
-        boolean done = false;
219  
-        while (!done) {
  207
+        while (true) {
220 208
             final double[] oldValues = variance.get();
221  
-            final double[] newValues = arrayCache.get();
  209
+            final double[] newValues = new double[2];
222 210
             if (oldValues[0] == -1) {
223 211
                 newValues[0] = value;
224 212
                 newValues[1] = 0;
@@ -232,10 +220,8 @@ private void updateVariance(long value) {
232 220
                 newValues[0] = newM;
233 221
                 newValues[1] = newS;
234 222
             }
235  
-            done = variance.compareAndSet(oldValues, newValues);
236  
-            if (done) {
237  
-                // recycle the old array into the cache
238  
-                arrayCache.set(oldValues);
  223
+            if (variance.compareAndSet(oldValues, newValues)) {
  224
+                return;
239 225
             }
240 226
         }
241 227
     }
28  metrics-core/src/test/java/com/yammer/metrics/core/tests/HealthCheckTest.java
@@ -63,6 +63,20 @@ public void canHaveHealthyResultsWithMessages() throws Exception {
63 63
     }
64 64
 
65 65
     @Test
  66
+    public void canHaveHealthyResultsWithFormattedMessages() throws Exception {
  67
+        final Result result = Result.healthy("foo %s", "bar");
  68
+
  69
+        assertThat(result.isHealthy(),
  70
+                    is(true));
  71
+        
  72
+        assertThat(result.getMessage(),
  73
+                    is("foo bar"));
  74
+
  75
+        assertThat(result.getError(),
  76
+                    is(nullValue()));
  77
+    }
  78
+
  79
+    @Test
66 80
     public void canHaveUnhealthyResults() throws Exception {
67 81
         final Result result = Result.unhealthy("bad");
68 82
 
@@ -77,6 +91,20 @@ public void canHaveUnhealthyResults() throws Exception {
77 91
     }
78 92
 
79 93
     @Test
  94
+    public void canHaveUnhealthyResultsWithFormattedMessages() throws Exception {
  95
+        final Result result = Result.unhealthy("foo %s %d", "bar", 123);
  96
+
  97
+        assertThat(result.isHealthy(),
  98
+                    is(false));
  99
+        
  100
+        assertThat(result.getMessage(),
  101
+                    is("foo bar 123"));
  102
+
  103
+        assertThat(result.getError(),
  104
+                    is(nullValue()));
  105
+    }
  106
+
  107
+    @Test
80 108
     public void canHaveUnhealthyResultsWithExceptions() throws Exception {
81 109
         final RuntimeException e = mock(RuntimeException.class);
82 110
         when(e.getMessage()).thenReturn("oh noes");
2  metrics-httpclient/pom.xml
@@ -21,7 +21,7 @@
21 21
         <dependency>
22 22
             <groupId>org.apache.httpcomponents</groupId>
23 23
             <artifactId>httpclient</artifactId>
24  
-            <version>4.2</version>
  24
+            <version>4.2.1</version>
25 25
         </dependency>
26 26
     </dependencies>
27 27
 </project>
12  metrics-httpclient/src/main/java/com/yammer/metrics/httpclient/InstrumentedClientConnManager.java
@@ -4,9 +4,11 @@
4 4
 import com.yammer.metrics.core.Gauge;
5 5
 import com.yammer.metrics.core.MetricsRegistry;
6 6
 import org.apache.http.conn.ClientConnectionManager;
  7
+import org.apache.http.conn.DnsResolver;
7 8
 import org.apache.http.conn.scheme.SchemeRegistry;
8 9
 import org.apache.http.impl.conn.PoolingClientConnectionManager;
9 10
 import org.apache.http.impl.conn.SchemeRegistryFactory;
  11
+import org.apache.http.impl.conn.SystemDefaultDnsResolver;
10 12
 
11 13
 import java.util.concurrent.TimeUnit;
12 14
 
@@ -32,7 +34,15 @@ public InstrumentedClientConnManager(MetricsRegistry metricsRegistry,
32 34
                                          SchemeRegistry registry,
33 35
                                          long connTTL,
34 36
                                          TimeUnit connTTLTimeUnit) {
35  
-        super(registry, connTTL, connTTLTimeUnit);
  37
+        this(metricsRegistry, registry, connTTL, connTTLTimeUnit, new SystemDefaultDnsResolver());
  38
+    }
  39
+
  40
+    public InstrumentedClientConnManager(MetricsRegistry metricsRegistry,
  41
+                                         SchemeRegistry schemeRegistry,
  42
+                                         long connTTL,
  43
+                                         TimeUnit connTTLTimeUnit,
  44
+                                         DnsResolver dnsResolver) {
  45
+        super(schemeRegistry, connTTL, connTTLTimeUnit, dnsResolver);
36 46
         metricsRegistry.newGauge(ClientConnectionManager.class,
37 47
                                  "available-connections",
38 48
                                  new Gauge<Integer>() {
19  metrics-scala_2.9.1/pom.xml
@@ -28,20 +28,19 @@
28 28
             <version>${scala.version}</version>
29 29
         </dependency>
30 30
         <dependency>
31  
-            <groupId>com.codahale</groupId>
32  
-            <artifactId>simplespec_${scala.version}</artifactId>
33  
-            <version>0.5.2</version>
  31
+            <groupId>com.simple</groupId>
  32
+            <artifactId>simplespec_2.9.1</artifactId>
  33
+            <version>0.6.0</version>
34 34
             <scope>test</scope>
  35
+            <exclusions>
  36
+                <exclusion>
  37
+                    <groupId>junit</groupId>
  38
+                    <artifactId>junit</artifactId>
  39
+                </exclusion>
  40
+            </exclusions>
35 41
         </dependency>
36 42
     </dependencies>
37 43
 
38  
-    <repositories>
39  
-        <repository>
40  
-            <id>repo.codahale.com</id>
41  
-            <url>http://repo.codahale.com</url>
42  
-        </repository>
43  
-    </repositories>
44  
-
45 44
     <build>
46 45
         <plugins>
47 46
             <plugin>
2  metrics-scala_2.9.1/src/test/scala/com/yammer/metrics/scala/tests/CounterSpec.scala
... ...
@@ -1,7 +1,7 @@
1 1
 package com.yammer.metrics.scala.tests
2 2
 
3 3
 import org.junit.Test
4  
-import com.codahale.simplespec.Spec
  4
+import com.simple.simplespec.Spec
5 5
 import com.yammer.metrics.scala.Counter
6 6
 
7 7
 class CounterSpec extends Spec {
2  metrics-scala_2.9.1/src/test/scala/com/yammer/metrics/scala/tests/MeterSpec.scala
... ...
@@ -1,7 +1,7 @@
1 1
 package com.yammer.metrics.scala.tests
2 2
 
3 3
 import org.junit.Test
4  
-import com.codahale.simplespec.Spec
  4
+import com.simple.simplespec.Spec
5 5
 import com.yammer.metrics.scala.Meter
6 6
 
7 7
 class MeterSpec extends Spec {
2  metrics-scala_2.9.1/src/test/scala/com/yammer/metrics/scala/tests/TimerSpec.scala
... ...
@@ -1,7 +1,7 @@
1 1
 package com.yammer.metrics.scala.tests
2 2
 
3 3
 import org.junit.Test
4  
-import com.codahale.simplespec.Spec
  4
+import com.simple.simplespec.Spec
5 5
 import com.yammer.metrics.Metrics
6 6
 import com.yammer.metrics.scala.Timer
7 7
 
3  pom.xml
... ...
@@ -1,6 +1,9 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3 3
     <modelVersion>4.0.0</modelVersion>
  4
+    <prerequisites>
  5
+        <maven>3.0.0</maven>
  6
+    </prerequisites>
4 7
 
5 8
     <groupId>com.yammer.metrics</groupId>
6 9
     <artifactId>metrics-parent</artifactId>

0 notes on commit 9cea37b

Please sign in to comment.
Something went wrong with that request. Please try again.