From 13715c0c075e20e747e3eb3cefabc60db13525a7 Mon Sep 17 00:00:00 2001 From: davidartplus Date: Wed, 23 Aug 2017 11:33:09 +0100 Subject: [PATCH 01/20] Implementation for convertFromJson with TypeReference Useful for converting from Json to Generic Types. --- .../com/aol/micro/server/rest/jackson/JacksonUtil.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/micro-jackson-configuration/src/main/java/com/aol/micro/server/rest/jackson/JacksonUtil.java b/micro-jackson-configuration/src/main/java/com/aol/micro/server/rest/jackson/JacksonUtil.java index c3459c4be..3a870ea44 100644 --- a/micro-jackson-configuration/src/main/java/com/aol/micro/server/rest/jackson/JacksonUtil.java +++ b/micro-jackson-configuration/src/main/java/com/aol/micro/server/rest/jackson/JacksonUtil.java @@ -94,6 +94,15 @@ public static T convertFromJson(final String jsonString, final JavaType type return null; } + + public static T convertFromJson(String json, final TypeReference type) { + try { + return JacksonUtil.getMapper().readValue(json, type); + } catch (final Exception ex) { + ExceptionSoftener.throwSoftenedException(ex); + } + return null; + } public static Object serializeToJsonLogFailure(Object value) { try { From e10f913a28be47ee16a21bf06bde26d5c6f9f9b7 Mon Sep 17 00:00:00 2001 From: Philip Clarke Date: Thu, 24 Aug 2017 11:23:26 +0100 Subject: [PATCH 02/20] upgrade dropwizard metrics-core to 3.2.2 --- micro-jmx-metrics/build.gradle | 7 ++++++- micro-metrics/build.gradle | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/micro-jmx-metrics/build.gradle b/micro-jmx-metrics/build.gradle index 423b7ac0a..a2ad41057 100644 --- a/micro-jmx-metrics/build.gradle +++ b/micro-jmx-metrics/build.gradle @@ -3,7 +3,12 @@ description = 'micro-jmx-metrics' dependencies { - compile ('com.ryantenney.metrics:metrics-spring:'+springMetricsVersion){ exclude(module: 'org.springframework') } + compile ('com.ryantenney.metrics:metrics-spring:'+springMetricsVersion){ + exclude(module: 'org.springframework') + exclude(group: 'io.dropwizard.metrics', module: 'metrics-core') + } + + compile("io.dropwizard.metrics:metrics-core:3.2.2") compile ("com.aol.simplereact:cyclops-react:$cyclopsReactVersion") compile project(':micro-core') diff --git a/micro-metrics/build.gradle b/micro-metrics/build.gradle index 693dc6b32..fcefead3d 100644 --- a/micro-metrics/build.gradle +++ b/micro-metrics/build.gradle @@ -1,8 +1,12 @@ description = 'micro-metrics' dependencies { - compile ('com.ryantenney.metrics:metrics-spring:'+springMetricsVersion){ + compile('com.ryantenney.metrics:metrics-spring:' + springMetricsVersion) { exclude(module: 'org.springframework') + exclude(group: 'io.dropwizard.metrics', module: 'metrics-core') } + + compile("io.dropwizard.metrics:metrics-core:3.2.2") + compile project(':micro-core') testCompile project(':micro-jackson-configuration') testCompile project(':micro-grizzly') From 8566b012e940df5359615e162b8bc87d90c76022 Mon Sep 17 00:00:00 2001 From: Philip Clarke Date: Tue, 22 Aug 2017 18:01:38 +0100 Subject: [PATCH 03/20] MetricsCatcher will now produce *-interval-count metrics based on InstantGauge --- .../server/event/metrics/MetricsCatcher.java | 8 +++++- .../event/metrics/MetricsCatcherTest.java | 25 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java b/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java index 6583ac37e..21baa09a8 100644 --- a/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java +++ b/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java @@ -1,6 +1,7 @@ package com.aol.micro.server.event.metrics; import com.aol.micro.server.events.GenericEvent; +import com.aol.micro.server.spring.metrics.InstantGauge; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -39,6 +40,7 @@ public MetricsCatcher(MetricRegistry registry, EventBus bus, Configuration confi jobs = new TimerManager( configuration.getNumJobs(), configuration.getHoldJobsForMinutes()); this.configuration = configuration; + } @Subscribe @@ -47,6 +49,8 @@ public void requestStart(AddQuery data) { .mark(); registry.counter(prefix + ".requests-started-count") .inc(); + ((InstantGauge) registry.gauge(prefix + ".requests-started-interval-count", () -> new InstantGauge())).increment(); + if (this.configuration.isQueriesByType()) { RequestData rd = data.getData(); @@ -74,6 +78,9 @@ public void requestComplete(RemoveQuery data) { .mark(); registry.counter(prefix + ".requests-completed-count") .inc(); + ((InstantGauge) registry.gauge(prefix + ".requests-completed-interval-count", () -> new InstantGauge())) + .increment(); + if (this.configuration.isQueriesByType()) { RequestData rd = data.getData(); registry.meter(queryEndName(rd)) @@ -84,7 +91,6 @@ public void requestComplete(RemoveQuery data) { registry.counter(prefix + ".requests-active-" + rd.getType() + "-count") .dec(); } - } @Subscribe diff --git a/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherTest.java b/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherTest.java index d1d243022..3daeed666 100644 --- a/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherTest.java +++ b/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherTest.java @@ -86,6 +86,31 @@ public void queriesCounterDec() { equalTo(-1l)); } + @Test + public void queriesIntervalCounterInc() { + + catcher.requestStart(new AddQuery( + RequestData.builder() + .correlationId(10l) + .type("test") + .build())); + assertThat(registry.getGauges().size(), equalTo(1)); + assertThat(registry.getGauges().get(this.config.getPrefix() + ".requests-started-interval-count").getValue(), equalTo(1l)); + } + + @Test + public void queriesIntervalCounterDec() { + + catcher.requestComplete(new RemoveQuery( + RequestData.builder() + .correlationId(10l) + .type("test") + .build())); + assertThat(registry.getGauges().size(), equalTo(1)); + assertThat(registry.getGauges().get(this.config.getPrefix() + ".requests-completed-interval-count").getValue(), + equalTo(1l)); + } + @Test public void jobsCounterDec() { From 8f3cd430f1e41e5390727ed9a9d68a70dcd5080f Mon Sep 17 00:00:00 2001 From: Philip Clarke Date: Tue, 22 Aug 2017 17:08:10 +0100 Subject: [PATCH 04/20] add new RequestTypes for user queries --- .../aol/micro/server/events/RequestTypes.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/micro-events/src/main/java/com/aol/micro/server/events/RequestTypes.java b/micro-events/src/main/java/com/aol/micro/server/events/RequestTypes.java index e17be567c..bc1f22086 100644 --- a/micro-events/src/main/java/com/aol/micro/server/events/RequestTypes.java +++ b/micro-events/src/main/java/com/aol/micro/server/events/RequestTypes.java @@ -79,6 +79,24 @@ public RemoveQuery(RequestData data) { } + public static class AddLabelledQuery extends AddEvent> { + + public AddLabelledQuery(RequestData data) { + super( + data); + } + + } + + public static class RemoveLabelledQuery extends RemoveEvent> { + + public RemoveLabelledQuery(RequestData data) { + super( + data); + } + + } + @AllArgsConstructor @Builder @XmlAccessorType(XmlAccessType.FIELD) From b6f48778d9b0a78437a99540e572359935aadcf0 Mon Sep 17 00:00:00 2001 From: Philip Clarke Date: Tue, 22 Aug 2017 17:29:30 +0100 Subject: [PATCH 05/20] add UserEvents class with API to create Add/RemoveUserQuery events --- .../aol/micro/server/events/UserEvents.java | 65 +++++++++++++++++++ .../micro/server/events/UserEventsTest.java | 62 ++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 micro-events/src/main/java/com/aol/micro/server/events/UserEvents.java create mode 100644 micro-events/src/test/java/com/aol/micro/server/events/UserEventsTest.java diff --git a/micro-events/src/main/java/com/aol/micro/server/events/UserEvents.java b/micro-events/src/main/java/com/aol/micro/server/events/UserEvents.java new file mode 100644 index 000000000..2b7c2e9dd --- /dev/null +++ b/micro-events/src/main/java/com/aol/micro/server/events/UserEvents.java @@ -0,0 +1,65 @@ +package com.aol.micro.server.events; + +import com.aol.micro.server.events.RequestTypes.AddLabelledQuery; +import com.aol.micro.server.events.RequestTypes.RemoveLabelledQuery; +import com.aol.micro.server.events.RequestTypes.RequestData; + +import com.google.common.eventbus.EventBus; + +/** + * Factory class for creating Start and End events which are identified by user + * + */ +public class UserEvents { + + + /** + * Marks the start of a query identified by the provided correlationId, with additional query type and data parameters + * + * @param query - Query data + * @param correlationId - Identifier + * @param user - allows queries to be grouped by user + * @return Start event to pass to the Events systems EventBus + */ + public static AddLabelledQuery start(T query, long correlationId, String user) { + return start(query, correlationId, user, null); + } + + /** + * Marks the start of a query identified by the provided correlationId, with additional query type and data parameters + * + * @param query - Query data + * @param correlationId - Identifier + * @param user - allows queries to be grouped by user + * @param additionalData - Any additional info about the request to be rendered in the JSON view / rest endpoint + * @return Start event to pass to the Events systems EventBus + */ + public static AddLabelledQuery start(T query, long correlationId, String user, Object additionalData) { + + return new AddLabelledQuery( + RequestData.builder() + .query(query) + .correlationId(correlationId) + .type(user) + .additionalData(additionalData) + .build()); + } + + /** + * Marks the end of a query identified by the provided correlationId + * + * @param query - Query data + * @param correlationId - Identifier + * @param user - allows queries to be grouped by type + * @return + */ + public static RemoveLabelledQuery finish(T query, long correlationId, String user) { + + return new RemoveLabelledQuery<>( + RequestData.builder() + .query(query) + .correlationId(correlationId) + .type(user) + .build()); + } +} diff --git a/micro-events/src/test/java/com/aol/micro/server/events/UserEventsTest.java b/micro-events/src/test/java/com/aol/micro/server/events/UserEventsTest.java new file mode 100644 index 000000000..b9ac28f53 --- /dev/null +++ b/micro-events/src/test/java/com/aol/micro/server/events/UserEventsTest.java @@ -0,0 +1,62 @@ +package com.aol.micro.server.events; + +import org.junit.Before; +import org.junit.Test; + +import com.aol.micro.server.events.RequestTypes.AddLabelledQuery; +import com.aol.micro.server.events.RequestTypes.RemoveLabelledQuery; +import com.aol.micro.server.events.RequestTypes.RequestData; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + + +public class UserEventsTest { + + String query; + long corrId; + String user; + String addData; + + @Before + public void setUp() { + query = "query as string"; + corrId = 1234; + user = "user"; + addData = "additional data"; + } + + @Test + public void createAddLabelledQuery() { + + AddLabelledQuery userQuery = UserEvents.start(query, corrId, user); + RequestData rd = userQuery.getData(); + + assertThat(rd.getQuery(), is(query)); + assertThat(rd.getType(), is(user)); + assertThat(rd.getCorrelationId(), is(corrId)); + } + + @Test + public void createAddLabelledQueryWithAdditionalData() { + + AddLabelledQuery userQuery = UserEvents.start(query, corrId, user, addData); + RequestData rd = userQuery.getData(); + + assertThat(rd.getQuery(), is(query)); + assertThat(rd.getType(), is(user)); + assertThat(rd.getCorrelationId(), is(corrId)); + assertThat(rd.getAdditionalData(), is(addData)); + } + + @Test + public void createRemoveLabelledQuery() { + + RemoveLabelledQuery userQuery = UserEvents.finish(query, corrId, user); + RequestData rd = userQuery.getData(); + + assertThat(rd.getQuery(), is(query)); + assertThat(rd.getType(), is(user)); + assertThat(rd.getCorrelationId(), is(corrId)); + } +} From 11cca2262d66abd2ba8fd81bde1293c7c8e4041f Mon Sep 17 00:00:00 2001 From: Philip Clarke Date: Tue, 22 Aug 2017 18:07:39 +0100 Subject: [PATCH 06/20] MetricsCatcher now handles InstantGauges for requests by user --- .../server/event/metrics/MetricsCatcher.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java b/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java index 21baa09a8..9031c00dc 100644 --- a/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java +++ b/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java @@ -10,6 +10,8 @@ import com.aol.micro.server.events.JobStartEvent; import com.aol.micro.server.events.RequestTypes.AddQuery; import com.aol.micro.server.events.RequestTypes.RemoveQuery; +import com.aol.micro.server.events.RequestTypes.AddLabelledQuery; +import com.aol.micro.server.events.RequestTypes.RemoveLabelledQuery; import com.aol.micro.server.events.RequestTypes.RequestData; import com.aol.micro.server.events.SystemData; import com.aol.micro.server.health.ErrorEvent; @@ -93,6 +95,25 @@ public void requestComplete(RemoveQuery data) { } } + @Subscribe + public void requestStart(AddLabelledQuery data) { + if (this.configuration.isQueriesByType()) { + RequestData rd = data.getData(); + + ((InstantGauge) registry.gauge(prefix + ".requests-started-" + rd.getType() + "-interval-count", () -> new InstantGauge())) + .increment(); + } + } + + @Subscribe + public void requestComplete(RemoveLabelledQuery data) { + if (this.configuration.isQueriesByType()) { + RequestData rd = data.getData(); + ((InstantGauge) registry.gauge(prefix + ".requests-completed-" + rd.getType() + "-interval-count", () -> new InstantGauge())) + .increment(); + } + } + @Subscribe public void finished(SystemData data) { registry.meter(prefix + ".jobs-completed") From af65672cf3aebfdf1146596163aad6c028260a43 Mon Sep 17 00:00:00 2001 From: Philip Clarke Date: Tue, 29 Aug 2017 13:18:51 +0100 Subject: [PATCH 07/20] renaming UserEvents to LabelledEvents --- .../micro/server/events/LabelledEvents.java | 119 ++++++++++++++++++ .../aol/micro/server/events/UserEvents.java | 65 ---------- ...ventsTest.java => LabelledEventsTest.java} | 18 +-- 3 files changed, 128 insertions(+), 74 deletions(-) create mode 100644 micro-events/src/main/java/com/aol/micro/server/events/LabelledEvents.java delete mode 100644 micro-events/src/main/java/com/aol/micro/server/events/UserEvents.java rename micro-events/src/test/java/com/aol/micro/server/events/{UserEventsTest.java => LabelledEventsTest.java} (72%) diff --git a/micro-events/src/main/java/com/aol/micro/server/events/LabelledEvents.java b/micro-events/src/main/java/com/aol/micro/server/events/LabelledEvents.java new file mode 100644 index 000000000..e77d6f512 --- /dev/null +++ b/micro-events/src/main/java/com/aol/micro/server/events/LabelledEvents.java @@ -0,0 +1,119 @@ +package com.aol.micro.server.events; + +import com.aol.micro.server.events.RequestTypes.AddLabelledQuery; +import com.aol.micro.server.events.RequestTypes.RemoveLabelledQuery; +import com.aol.micro.server.events.RequestTypes.RequestData; + +import com.google.common.eventbus.EventBus; + +/** + * Factory class for creating Start and End events which are identified by a custom label + * + */ +public class LabelledEvents { + + /** + * Publish start events for each of the specified query types + * + *
+     * {@code
+        LabelledEvents.start("get", 1l, bus, "typeA", "custom");
+        try {
+            return "ok";
+        } finally {
+            RequestEvents.finish("get", 1l, bus, "typeA", "custom");
+        }
+     * }
+     * 
+ * + * @param query Completed query + * @param correlationId Identifier + * @param bus EventBus to post events to + * @param labels Query labels to post to event bus + */ + public static void start(T query, long correlationId, EventBus bus, String... labels) { + + for (String label : labels) { + AddLabelledQuery next = start(query, correlationId, label, null); + bus.post(next); + } + + } + + /** + * Marks the start of a query identified by the provided correlationId, with additional query type and data parameters + * + * @param query - Query data + * @param correlationId - Identifier + * @param label - allows queries to be grouped by label + * @return Start event to pass to the Events systems EventBus + */ + public static AddLabelledQuery start(T query, long correlationId, String label) { + return start(query, correlationId, label, null); + } + + /** + * Marks the start of a query identified by the provided correlationId, with additional query type and data parameters + * + * @param query - Query data + * @param correlationId - Identifier + * @param label - allows queries to be grouped by label + * @param additionalData - Any additional info about the request to be rendered in the JSON view / rest endpoint + * @return Start event to pass to the Events systems EventBus + */ + public static AddLabelledQuery start(T query, long correlationId, String label, Object additionalData) { + + return new AddLabelledQuery( + RequestData.builder() + .query(query) + .correlationId(correlationId) + .type(label) + .additionalData(additionalData) + .build()); + } + + /** + * Publish finish events for each of the specified query labels + * + *
+     * {@code
+     * LabelledEvents.start("get", 1l, bus, "typeA", "custom");
+       try {
+            return "ok";
+        } finally {
+            RequestEvents.finish("get", 1l, bus, "typeA", "custom");
+        }
+     *
+     * }
+     * 
+ * + * + * @param query Completed query + * @param correlationId Identifier + * @param bus EventBus to post events to + * @param labels Query types to post to event bus + */ + public static void finish(T query, long correlationId, EventBus bus, String... labels) { + for (String type : labels) { + RemoveLabelledQuery next = finish(query, correlationId, type); + bus.post(next); + } + } + /** + * Marks the end of a query identified by the provided correlationId + * + * @param query - Query data + * @param correlationId - Identifier + * @param label - allows queries to be grouped by type + * @return RemoveLabelledQuery event to pass to the Events systems EventBus + */ + public static RemoveLabelledQuery finish(T query, long correlationId, String label) { + + return new RemoveLabelledQuery<>( + RequestData.builder() + .query(query) + .correlationId(correlationId) + .type(label) + .build()); + } +} diff --git a/micro-events/src/main/java/com/aol/micro/server/events/UserEvents.java b/micro-events/src/main/java/com/aol/micro/server/events/UserEvents.java deleted file mode 100644 index 2b7c2e9dd..000000000 --- a/micro-events/src/main/java/com/aol/micro/server/events/UserEvents.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.aol.micro.server.events; - -import com.aol.micro.server.events.RequestTypes.AddLabelledQuery; -import com.aol.micro.server.events.RequestTypes.RemoveLabelledQuery; -import com.aol.micro.server.events.RequestTypes.RequestData; - -import com.google.common.eventbus.EventBus; - -/** - * Factory class for creating Start and End events which are identified by user - * - */ -public class UserEvents { - - - /** - * Marks the start of a query identified by the provided correlationId, with additional query type and data parameters - * - * @param query - Query data - * @param correlationId - Identifier - * @param user - allows queries to be grouped by user - * @return Start event to pass to the Events systems EventBus - */ - public static AddLabelledQuery start(T query, long correlationId, String user) { - return start(query, correlationId, user, null); - } - - /** - * Marks the start of a query identified by the provided correlationId, with additional query type and data parameters - * - * @param query - Query data - * @param correlationId - Identifier - * @param user - allows queries to be grouped by user - * @param additionalData - Any additional info about the request to be rendered in the JSON view / rest endpoint - * @return Start event to pass to the Events systems EventBus - */ - public static AddLabelledQuery start(T query, long correlationId, String user, Object additionalData) { - - return new AddLabelledQuery( - RequestData.builder() - .query(query) - .correlationId(correlationId) - .type(user) - .additionalData(additionalData) - .build()); - } - - /** - * Marks the end of a query identified by the provided correlationId - * - * @param query - Query data - * @param correlationId - Identifier - * @param user - allows queries to be grouped by type - * @return - */ - public static RemoveLabelledQuery finish(T query, long correlationId, String user) { - - return new RemoveLabelledQuery<>( - RequestData.builder() - .query(query) - .correlationId(correlationId) - .type(user) - .build()); - } -} diff --git a/micro-events/src/test/java/com/aol/micro/server/events/UserEventsTest.java b/micro-events/src/test/java/com/aol/micro/server/events/LabelledEventsTest.java similarity index 72% rename from micro-events/src/test/java/com/aol/micro/server/events/UserEventsTest.java rename to micro-events/src/test/java/com/aol/micro/server/events/LabelledEventsTest.java index b9ac28f53..421940ff9 100644 --- a/micro-events/src/test/java/com/aol/micro/server/events/UserEventsTest.java +++ b/micro-events/src/test/java/com/aol/micro/server/events/LabelledEventsTest.java @@ -11,40 +11,40 @@ import static org.junit.Assert.assertThat; -public class UserEventsTest { +public class LabelledEventsTest { String query; long corrId; - String user; + String label; String addData; @Before public void setUp() { query = "query as string"; corrId = 1234; - user = "user"; + label = "label"; addData = "additional data"; } @Test public void createAddLabelledQuery() { - AddLabelledQuery userQuery = UserEvents.start(query, corrId, user); + AddLabelledQuery userQuery = LabelledEvents.start(query, corrId, label); RequestData rd = userQuery.getData(); assertThat(rd.getQuery(), is(query)); - assertThat(rd.getType(), is(user)); + assertThat(rd.getType(), is(label)); assertThat(rd.getCorrelationId(), is(corrId)); } @Test public void createAddLabelledQueryWithAdditionalData() { - AddLabelledQuery userQuery = UserEvents.start(query, corrId, user, addData); + AddLabelledQuery userQuery = LabelledEvents.start(query, corrId, label, addData); RequestData rd = userQuery.getData(); assertThat(rd.getQuery(), is(query)); - assertThat(rd.getType(), is(user)); + assertThat(rd.getType(), is(label)); assertThat(rd.getCorrelationId(), is(corrId)); assertThat(rd.getAdditionalData(), is(addData)); } @@ -52,11 +52,11 @@ public void createAddLabelledQueryWithAdditionalData() { @Test public void createRemoveLabelledQuery() { - RemoveLabelledQuery userQuery = UserEvents.finish(query, corrId, user); + RemoveLabelledQuery userQuery = LabelledEvents.finish(query, corrId, label); RequestData rd = userQuery.getData(); assertThat(rd.getQuery(), is(query)); - assertThat(rd.getType(), is(user)); + assertThat(rd.getType(), is(label)); assertThat(rd.getCorrelationId(), is(corrId)); } } From a018090ff42d0488ffbaede7e5e11f4f265390dd Mon Sep 17 00:00:00 2001 From: Philip Clarke Date: Thu, 24 Aug 2017 11:44:28 +0100 Subject: [PATCH 08/20] upgrade micro-server to 0.91.6 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 2a2714098..b75ff08a1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=0.91.5 +version=0.91.6 springVersion=4.3.3.RELEASE springBootVersion=1.4.1.RELEASE jerseyVersion=2.24 From c323bae44d414cac635e09db9d1ed51e850cec27 Mon Sep 17 00:00:00 2001 From: davidartplus Date: Mon, 4 Sep 2017 14:58:17 +0100 Subject: [PATCH 09/20] Update JacksonUtil.java --- .../main/java/com/aol/micro/server/rest/jackson/JacksonUtil.java | 1 + 1 file changed, 1 insertion(+) diff --git a/micro-jackson-configuration/src/main/java/com/aol/micro/server/rest/jackson/JacksonUtil.java b/micro-jackson-configuration/src/main/java/com/aol/micro/server/rest/jackson/JacksonUtil.java index 3a870ea44..d305da6c3 100644 --- a/micro-jackson-configuration/src/main/java/com/aol/micro/server/rest/jackson/JacksonUtil.java +++ b/micro-jackson-configuration/src/main/java/com/aol/micro/server/rest/jackson/JacksonUtil.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.core.type.TypeReference; public final class JacksonUtil { From 9742ed83a15446039b0baba05f72ebd26fe8c4cf Mon Sep 17 00:00:00 2001 From: Philip Clarke Date: Mon, 4 Sep 2017 15:50:59 +0100 Subject: [PATCH 10/20] fix failing integration test --- .../com/aol/micro/server/curator/lock/IntegrationTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/micro-curator/src/integration/java/com/aol/micro/server/curator/lock/IntegrationTest.java b/micro-curator/src/integration/java/com/aol/micro/server/curator/lock/IntegrationTest.java index e6974c67e..dd5be2033 100644 --- a/micro-curator/src/integration/java/com/aol/micro/server/curator/lock/IntegrationTest.java +++ b/micro-curator/src/integration/java/com/aol/micro/server/curator/lock/IntegrationTest.java @@ -48,6 +48,12 @@ public void initialize() { } }).start(); + try { + // allow zooKeeperServer enough time to initialize + Thread.sleep(1000); + } catch (InterruptedException e) { + } + provider = new CuratorDistributedLockServiceProvider("localhost:12181", "1000", "1", "/test"); } From 502b337605a6f274827f23a51b476001b67ef0f3 Mon Sep 17 00:00:00 2001 From: Nikita Sapozhnikov Date: Wed, 6 Sep 2017 12:52:30 +0100 Subject: [PATCH 11/20] Skipping upload of micro-tutorial --- build.gradle | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4ea11ee18..aa1d137e0 100644 --- a/build.gradle +++ b/build.gradle @@ -24,9 +24,14 @@ task wrapper(type: Wrapper) { } subprojects { + + + apply plugin:'java' // apply plugin: 'com.github.johnrengelman.shadow' - apply plugin: 'com.bmuschko.nexus' + if(project.name != "micro-tutorial") { + apply plugin: 'com.bmuschko.nexus' + } sourceCompatibility = 1.8 targetCompatibility = 1.8 From 4931bef481e411783e7334c01d89c350af0f0afc Mon Sep 17 00:00:00 2001 From: jijisv Date: Thu, 7 Sep 2017 23:20:37 +0100 Subject: [PATCH 12/20] filtering added to application registry list endpoint --- .../server/application/registry/Finder.java | 11 +++- .../application/registry/RegisterEntry.java | 66 ++++++++++--------- .../registry/ServiceRegistryResource.java | 14 ++-- .../application/registry/UriInfoParser.java | 17 +++++ 4 files changed, 67 insertions(+), 41 deletions(-) create mode 100644 micro-application-register/src/main/java/com/aol/micro/server/application/registry/UriInfoParser.java diff --git a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/Finder.java b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/Finder.java index 57e3d13eb..1153989b6 100644 --- a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/Finder.java +++ b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/Finder.java @@ -3,6 +3,8 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.commons.io.FileUtils; @@ -24,8 +26,13 @@ public Finder(RegisterConfig config) { this.config = config; } - public List find() { - return findDir(new File(config.getOutputDir())); + public List find(final Optional re) { + + List entries = findDir(new File(config.getOutputDir())); + if (re.isPresent()) { + entries = entries.stream().filter( e -> e.matches(re.get())).collect(Collectors.toList()); + } + return entries; } private List findDir(File dir) { diff --git a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/RegisterEntry.java b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/RegisterEntry.java index 18d9d1406..8b74716b5 100644 --- a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/RegisterEntry.java +++ b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/RegisterEntry.java @@ -1,11 +1,9 @@ package com.aol.micro.server.application.registry; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; +import javax.ws.rs.QueryParam; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; @@ -26,45 +24,40 @@ @Builder public class RegisterEntry { - private static SimpleDateFormat f = new SimpleDateFormat( - "EEE, d MMM yyyy HH:mm:ss Z"); + private static SimpleDateFormat f = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z"); @Wither - int port; + private final int port; @Wither - String hostname; + private final String hostname; @Wither - String module; + private final String module; @Wither - String context; - Date time; + private final String context; + private final Date time; @Wither - String uuid; + private final String uuid; @Wither - String target; - String formattedDate; - Map manifest = ManifestLoader.instance.getManifest(); + private final String target; + private final String formattedDate; + private final Map manifest = ManifestLoader.instance.getManifest(); @Wither - Health health; + private final Health health; @Wither - List>> stats; + private final List>> stats; @Wither - int externalPort; + private final int externalPort; public RegisterEntry() { - this( - -1, null, null, null, null, null, null, -1); + this(-1, null, null, null, null, null, null, -1); } public RegisterEntry(int port, String hostname, String module, String context, Date time, String uuid, - String target, int externalPort) { - this( - port, hostname, module, context, time, UUID.randomUUID() - .toString(), - target, null, Health.OK, null, externalPort); + String target, int externalPort) { + this(port, hostname, module, context, time, UUID.randomUUID().toString(), target, Health.OK, null, externalPort); } private RegisterEntry(int port, String hostname, String module, String context, Date time, String uuid, - String target, String ignoreDate, Health health, List>> stats, + String target, Health health, List>> stats, int externalPort) { this.port = port; this.hostname = hostname; @@ -85,11 +78,22 @@ private RegisterEntry(int port, String hostname, String module, String context, } public RegisterEntry(int port, String hostname, String module, String context, Date time, String target, - int externalPort) { - this( - port, hostname, module, context, time, UUID.randomUUID() - .toString(), - target, externalPort); + int externalPort) { + this(port, hostname, module, context, time, UUID.randomUUID().toString(), target, externalPort); + } + + public boolean matches(RegisterEntry re) { + return (re.port == -1 || re.port == port) && + (Objects.nonNull(re.hostname) || Objects.nonNull(hostname) && hostname.startsWith(re.hostname)) && + (Objects.nonNull(re.module) || Objects.nonNull(module) && module.startsWith(re.module)) && + (Objects.nonNull(re.context) || Objects.nonNull(context) && context.startsWith(re.context)) && + (Objects.nonNull(re.health) || re.health.equals(health)) && + (re.externalPort == -1 || re.externalPort != externalPort) && + (Objects.nonNull(re.manifest) || ( + (!re.manifest.containsKey("Implementation-revision")) || re.manifest.get("Implementation-revision").equals(manifest.get("Implementation-revision")) && + (!re.manifest.containsKey("Implementation-Timestamp")) || re.manifest.get("Implementation-Timestamp").equals(manifest.get("Implementation-Timestamp")) && + (!re.manifest.containsKey("Implementation-Version")) || re.manifest.get("Implementation-Version").equals(manifest.get("Implementation-Version")) + )); } } diff --git a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/ServiceRegistryResource.java b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/ServiceRegistryResource.java index 26e0b8d9d..8f45bee3c 100644 --- a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/ServiceRegistryResource.java +++ b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/ServiceRegistryResource.java @@ -1,14 +1,13 @@ package com.aol.micro.server.application.registry; import java.util.Arrays; +import java.util.Optional; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.container.AsyncResponse; import javax.ws.rs.container.Suspended; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.UriInfo; import cyclops.stream.ReactiveSeq; import org.slf4j.Logger; @@ -42,18 +41,17 @@ public ServiceRegistryResource(Cleaner cleaner, Finder finder, Register register @GET @Path("/list") @Produces("application/json") - public void list(@Suspended AsyncResponse response) { + public void list(@Context UriInfo uriInfo, @Suspended AsyncResponse response) { ReactiveSeq.of(this).foldFuture(WorkerThreads.ioExecutor.get(), s->s.forEach(Long.MAX_VALUE,next -> { try{ cleaner.clean(); - response.resume(finder.find()); + response.resume(finder.find(UriInfoParser.toRegisterEntry(uriInfo))); }catch(Exception e){ logger.error(e.getMessage(),e); response.resume(Arrays.asList("failed due to error")); } })); - } @POST diff --git a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/UriInfoParser.java b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/UriInfoParser.java new file mode 100644 index 000000000..891b5430e --- /dev/null +++ b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/UriInfoParser.java @@ -0,0 +1,17 @@ +package com.aol.micro.server.application.registry; + +import javax.ws.rs.core.UriInfo; +import java.util.Optional; + +public class UriInfoParser { + + public static Optional toRegisterEntry(UriInfo uriInfo) { + if (uriInfo.getQueryParameters().isEmpty()) { + return Optional.empty(); + } else { + RegisterEntry re = new RegisterEntry(); + // TODO: add the population logic + return Optional.of(re); + } + } +} From 3d331b6226688911f64a056500ea27df47deb5c0 Mon Sep 17 00:00:00 2001 From: Philip Clarke Date: Fri, 8 Sep 2017 12:21:39 +0100 Subject: [PATCH 13/20] MetricsCatcher now supports interval-count metrics per type --- .../aol/micro/server/event/metrics/MetricsCatcher.java | 6 ++++++ .../micro/server/event/metrics/MetricsCatcherTest.java | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java b/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java index 9031c00dc..3f40357aa 100644 --- a/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java +++ b/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java @@ -63,6 +63,9 @@ public void requestStart(AddQuery data) { .time()); registry.counter(prefix + ".requests-active-" + rd.getType() + "-count") .inc(); + ((InstantGauge) registry.gauge(prefix + ".requests-started-" + rd.getType() + "-interval-count", + () -> new InstantGauge())).increment(); + } } @@ -92,6 +95,9 @@ public void requestComplete(RemoveQuery data) { registry.counter(prefix + ".requests-active-" + rd.getType() + "-count") .dec(); + ((InstantGauge) registry.gauge(prefix + ".requests-completed-" + rd.getType() + "-interval-count", + () -> new InstantGauge())).increment(); + } } diff --git a/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherTest.java b/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherTest.java index 3daeed666..6eb51d09a 100644 --- a/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherTest.java +++ b/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherTest.java @@ -94,8 +94,9 @@ public void queriesIntervalCounterInc() { .correlationId(10l) .type("test") .build())); - assertThat(registry.getGauges().size(), equalTo(1)); + assertThat(registry.getGauges().size(), equalTo(2)); assertThat(registry.getGauges().get(this.config.getPrefix() + ".requests-started-interval-count").getValue(), equalTo(1l)); + assertThat(registry.getGauges().get(this.config.getPrefix() + ".requests-started-test-interval-count").getValue(), equalTo(1l)); } @Test @@ -106,9 +107,12 @@ public void queriesIntervalCounterDec() { .correlationId(10l) .type("test") .build())); - assertThat(registry.getGauges().size(), equalTo(1)); + assertThat(registry.getGauges().size(), equalTo(2)); assertThat(registry.getGauges().get(this.config.getPrefix() + ".requests-completed-interval-count").getValue(), equalTo(1l)); + assertThat(registry.getGauges().get(this.config.getPrefix() + ".requests-completed-test-interval-count").getValue(), + equalTo(1l)); + } @Test From c984d8932487013855225f318db37603cf7b1fab Mon Sep 17 00:00:00 2001 From: jijisv Date: Sat, 9 Sep 2017 00:04:19 +0100 Subject: [PATCH 14/20] updated tests --- .../application/registry/RegisterEntry.java | 24 +++++++++---------- .../aol/micro/server/RegistryAppRunner.java | 5 ++++ .../application/registry/CleanerTest.java | 3 ++- .../application/registry/FinderTest.java | 3 ++- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/RegisterEntry.java b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/RegisterEntry.java index 8b74716b5..03e042187 100644 --- a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/RegisterEntry.java +++ b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/RegisterEntry.java @@ -53,11 +53,16 @@ public RegisterEntry() { public RegisterEntry(int port, String hostname, String module, String context, Date time, String uuid, String target, int externalPort) { - this(port, hostname, module, context, time, UUID.randomUUID().toString(), target, Health.OK, null, externalPort); + this(port, hostname, module, context, time, UUID.randomUUID().toString(), target, null, Health.OK, null, externalPort); + } + + public RegisterEntry(int port, String hostname, String module, String context, Date time, String target, + int externalPort) { + this(port, hostname, module, context, time, UUID.randomUUID().toString(), target, externalPort); } private RegisterEntry(int port, String hostname, String module, String context, Date time, String uuid, - String target, Health health, List>> stats, + String target, String ignoreDate, Health health, List>> stats, int externalPort) { this.port = port; this.hostname = hostname; @@ -77,19 +82,14 @@ private RegisterEntry(int port, String hostname, String module, String context, } - public RegisterEntry(int port, String hostname, String module, String context, Date time, String target, - int externalPort) { - this(port, hostname, module, context, time, UUID.randomUUID().toString(), target, externalPort); - } - public boolean matches(RegisterEntry re) { return (re.port == -1 || re.port == port) && - (Objects.nonNull(re.hostname) || Objects.nonNull(hostname) && hostname.startsWith(re.hostname)) && - (Objects.nonNull(re.module) || Objects.nonNull(module) && module.startsWith(re.module)) && - (Objects.nonNull(re.context) || Objects.nonNull(context) && context.startsWith(re.context)) && - (Objects.nonNull(re.health) || re.health.equals(health)) && + (Objects.isNull(re.hostname) || Objects.nonNull(hostname) && hostname.startsWith(re.hostname)) && + (Objects.isNull(re.module) || Objects.nonNull(module) && module.startsWith(re.module)) && + (Objects.isNull(re.context) || Objects.nonNull(context) && context.startsWith(re.context)) && + (Objects.isNull(re.health) || re.health.equals(health)) && (re.externalPort == -1 || re.externalPort != externalPort) && - (Objects.nonNull(re.manifest) || ( + (Objects.isNull(re.manifest) || ( (!re.manifest.containsKey("Implementation-revision")) || re.manifest.get("Implementation-revision").equals(manifest.get("Implementation-revision")) && (!re.manifest.containsKey("Implementation-Timestamp")) || re.manifest.get("Implementation-Timestamp").equals(manifest.get("Implementation-Timestamp")) && (!re.manifest.containsKey("Implementation-Version")) || re.manifest.get("Implementation-Version").equals(manifest.get("Implementation-Version")) diff --git a/micro-application-register/src/test/java/app/registry/com/aol/micro/server/RegistryAppRunner.java b/micro-application-register/src/test/java/app/registry/com/aol/micro/server/RegistryAppRunner.java index 229b7e0d9..65aaed5be 100644 --- a/micro-application-register/src/test/java/app/registry/com/aol/micro/server/RegistryAppRunner.java +++ b/micro-application-register/src/test/java/app/registry/com/aol/micro/server/RegistryAppRunner.java @@ -95,4 +95,9 @@ private void sendPing(RegisterEntry entry) { } } + public static void main(String[] args) { + RegistryAppRunner appRunner = new RegistryAppRunner(); + appRunner.startServer(); + } + } diff --git a/micro-application-register/src/test/java/com/aol/micro/server/application/registry/CleanerTest.java b/micro-application-register/src/test/java/com/aol/micro/server/application/registry/CleanerTest.java index c23bcc5ff..98f1c3400 100644 --- a/micro-application-register/src/test/java/com/aol/micro/server/application/registry/CleanerTest.java +++ b/micro-application-register/src/test/java/com/aol/micro/server/application/registry/CleanerTest.java @@ -6,6 +6,7 @@ import java.io.File; import java.util.Date; import java.util.List; +import java.util.Optional; import org.junit.Before; import org.junit.Test; @@ -50,7 +51,7 @@ public void testClean() { System.currentTimeMillis() - 2000))); cleaner.clean(); - List list = finder.find(); + List list = finder.find(Optional.empty()); assertThat(list.size(), equalTo(0)); } } diff --git a/micro-application-register/src/test/java/com/aol/micro/server/application/registry/FinderTest.java b/micro-application-register/src/test/java/com/aol/micro/server/application/registry/FinderTest.java index 98ab4e878..064c2eb28 100644 --- a/micro-application-register/src/test/java/com/aol/micro/server/application/registry/FinderTest.java +++ b/micro-application-register/src/test/java/com/aol/micro/server/application/registry/FinderTest.java @@ -7,6 +7,7 @@ import java.io.File; import java.util.Date; import java.util.List; +import java.util.Optional; import org.junit.Before; import org.junit.Test; @@ -44,7 +45,7 @@ public void setUp() throws Exception { @Test public void testFind() { writer.register(entry); - List list = finder.find(); + List list = finder.find(Optional.empty()); assertThat(list.size(), greaterThan(0)); assertThat(list.get(0) .getContext(), From 12352ab07eb24fc5b49f7d3cdebf088efe69b8a3 Mon Sep 17 00:00:00 2001 From: jijisv Date: Sun, 10 Sep 2017 23:59:00 +0100 Subject: [PATCH 15/20] tests for the application registry filter added --- .../application/registry/RegisterEntry.java | 28 ++-- .../registry/ServiceRegistryResource.java | 6 +- .../application/registry/UriInfoParser.java | 50 +++++- .../aol/micro/server/RegistryAppRunner.java | 148 ++++++++++++------ .../registry/RegisterEntryTest.java | 53 ++++++- .../registry/UriInfoParserTest.java | 61 ++++++++ 6 files changed, 286 insertions(+), 60 deletions(-) create mode 100644 micro-application-register/src/test/java/com/aol/micro/server/application/registry/UriInfoParserTest.java diff --git a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/RegisterEntry.java b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/RegisterEntry.java index 03e042187..c30232bd1 100644 --- a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/RegisterEntry.java +++ b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/RegisterEntry.java @@ -12,6 +12,7 @@ import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; +import lombok.ToString; import lombok.experimental.FieldDefaults; import lombok.experimental.Wither; @@ -22,6 +23,7 @@ @Getter @Wither @Builder +@ToString public class RegisterEntry { private static SimpleDateFormat f = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z"); @@ -39,7 +41,7 @@ public class RegisterEntry { @Wither private final String target; private final String formattedDate; - private final Map manifest = ManifestLoader.instance.getManifest(); + private final Map manifest = new HashMap<>(); @Wither private final Health health; @Wither @@ -53,7 +55,7 @@ public RegisterEntry() { public RegisterEntry(int port, String hostname, String module, String context, Date time, String uuid, String target, int externalPort) { - this(port, hostname, module, context, time, UUID.randomUUID().toString(), target, null, Health.OK, null, externalPort); + this(port, hostname, module, context, time, uuid, target, null, Health.OK, null, externalPort); } public RegisterEntry(int port, String hostname, String module, String context, Date time, String target, @@ -80,20 +82,28 @@ private RegisterEntry(int port, String hostname, String module, String context, else this.formattedDate = null; + this.manifest.putAll(ManifestLoader.instance.getManifest()); + } public boolean matches(RegisterEntry re) { + //Only the fields which make sense to query is added for now. return (re.port == -1 || re.port == port) && (Objects.isNull(re.hostname) || Objects.nonNull(hostname) && hostname.startsWith(re.hostname)) && (Objects.isNull(re.module) || Objects.nonNull(module) && module.startsWith(re.module)) && (Objects.isNull(re.context) || Objects.nonNull(context) && context.startsWith(re.context)) && (Objects.isNull(re.health) || re.health.equals(health)) && - (re.externalPort == -1 || re.externalPort != externalPort) && - (Objects.isNull(re.manifest) || ( - (!re.manifest.containsKey("Implementation-revision")) || re.manifest.get("Implementation-revision").equals(manifest.get("Implementation-revision")) && - (!re.manifest.containsKey("Implementation-Timestamp")) || re.manifest.get("Implementation-Timestamp").equals(manifest.get("Implementation-Timestamp")) && - (!re.manifest.containsKey("Implementation-Version")) || re.manifest.get("Implementation-Version").equals(manifest.get("Implementation-Version")) - )); + (re.externalPort == -1 || re.externalPort == externalPort) && + (Objects.isNull(re.manifest) || re.manifest.isEmpty() || matchManifest(re.manifest)); + } + + private boolean matchManifest(Map manifest) { + return match(manifest, this.manifest, "Implementation-revision") && + match(manifest, this.manifest, "Implementation-Timestamp") && + match(manifest, this.manifest, "Implementation-Version"); } -} + private boolean match(Map map1, Map map2, String key) { + return !map1.containsKey(key) || (map2.containsKey(key) && map2.get(key).startsWith(map1.get(key))); + } +} \ No newline at end of file diff --git a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/ServiceRegistryResource.java b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/ServiceRegistryResource.java index 8f45bee3c..7f67db7c8 100644 --- a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/ServiceRegistryResource.java +++ b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/ServiceRegistryResource.java @@ -7,6 +7,8 @@ import javax.ws.rs.container.AsyncResponse; import javax.ws.rs.container.Suspended; import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; import cyclops.stream.ReactiveSeq; @@ -19,6 +21,8 @@ import com.aol.micro.server.auto.discovery.Rest; import com.aol.micro.server.utility.HashMapBuilder; +import static javax.ws.rs.core.Response.Status.*; + @Rest @Path("/service-registry") @@ -49,7 +53,7 @@ public void list(@Context UriInfo uriInfo, @Suspended AsyncResponse response) { response.resume(finder.find(UriInfoParser.toRegisterEntry(uriInfo))); }catch(Exception e){ logger.error(e.getMessage(),e); - response.resume(Arrays.asList("failed due to error")); + response.resume(Arrays.asList("Bad Request: " + e.getMessage())); } })); } diff --git a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/UriInfoParser.java b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/UriInfoParser.java index 891b5430e..03fe82d34 100644 --- a/micro-application-register/src/main/java/com/aol/micro/server/application/registry/UriInfoParser.java +++ b/micro-application-register/src/main/java/com/aol/micro/server/application/registry/UriInfoParser.java @@ -1,6 +1,12 @@ package com.aol.micro.server.application.registry; +import cyclops.stream.ReactiveSeq; + +import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Map; +import java.util.Objects; import java.util.Optional; public class UriInfoParser { @@ -9,9 +15,49 @@ public static Optional toRegisterEntry(UriInfo uriInfo) { if (uriInfo.getQueryParameters().isEmpty()) { return Optional.empty(); } else { - RegisterEntry re = new RegisterEntry(); - // TODO: add the population logic + MultivaluedMap parameters = uriInfo.getQueryParameters(); + RegisterEntry re = RegisterEntry.builder() + .context(parameters.getFirst("context")) + .hostname(parameters.getFirst("hostname")) + .port(toInt(parameters.getFirst("port"))) + .target(parameters.getFirst("target")) + .externalPort(toInt(parameters.getFirst("externalPort"))) + .module(parameters.getFirst("module")) + .health(toHealth(parameters.getFirst("health"))) + .build(); + + Map manifest = ReactiveSeq.fromIterable(parameters.entrySet()) + .filter(e -> e.getKey().startsWith("manifest.")) + .toMap(e -> e.getKey().replace("manifest.", ""), e -> parameters.getFirst(e.getKey())); + + re.getManifest().clear(); + re.getManifest().putAll(manifest); + return Optional.of(re); } } + + private static Health toHealth(String health) { + if (Objects.nonNull(health)) { + try { + return Health.valueOf(health); + } catch (Exception e) { + throw new IllegalArgumentException("'" + health + "' is not valid, valid values are " + + Arrays.asList(Health.values())); + } + } + return null; + } + + private static int toInt(String port) { + if (Objects.isNull(port)) + return -1; + + try { + return Integer.valueOf(port); + } catch (Exception e) { + throw new IllegalArgumentException("'" + port + "' is not a valid number."); + } + } + } diff --git a/micro-application-register/src/test/java/app/registry/com/aol/micro/server/RegistryAppRunner.java b/micro-application-register/src/test/java/app/registry/com/aol/micro/server/RegistryAppRunner.java index 65aaed5be..f998808f0 100644 --- a/micro-application-register/src/test/java/app/registry/com/aol/micro/server/RegistryAppRunner.java +++ b/micro-application-register/src/test/java/app/registry/com/aol/micro/server/RegistryAppRunner.java @@ -1,5 +1,6 @@ package app.registry.com.aol.micro.server; +import static java.util.stream.Collectors.joining; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; @@ -7,8 +8,12 @@ import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; import java.util.concurrent.ExecutionException; +import java.util.stream.Stream; +import com.aol.micro.server.rest.client.RestClient; +import com.fasterxml.jackson.core.type.TypeReference; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -25,17 +30,15 @@ public class RegistryAppRunner { RestAgent rest = new RestAgent(); - private final AsyncRestClient restAsync = new AsyncRestClient( - 100, 2000); + private final AsyncRestClient restAsync = new AsyncRestClient(100, 2000); MicroserverApp server; + String baseUrl = "http://localhost:8080/registry-app/service-registry"; + @Before public void startServer() { - - server = new MicroserverApp( - () -> "registry-app"); + server = new MicroserverApp(() -> "registry-app"); server.start(); - } @After @@ -46,58 +49,115 @@ public void stopServer() { @Test public void runAppAndBasicTest() throws InterruptedException, ExecutionException { - SimpleDateFormat f = new SimpleDateFormat( - "EEE"); + SimpleDateFormat f = new SimpleDateFormat("EEE"); String date = f.format(new Date()); Thread.sleep(1000); - assertThat(rest.post("http://localhost:8080/registry-app/service-registry/schedule"), - is("{\"status\":\"success\"}")); + assertThat(rest.post(baseUrl + "/schedule"), is("{\"status\":\"success\"}")); Thread.sleep(1000); - assertThat(rest.getJson("http://localhost:8080/registry-app/service-registry/list"), - containsString("[{\"port\":8080,")); - assertThat(rest.getJson("http://localhost:8080/registry-app/service-registry/list"), - containsString("externalPort\":8080")); - sendPing(new RegisterEntry( - 8081, "use-ip", "hello", "world", new Date(), "my-target", 8082)); + String listResponse = rest.getJson(baseUrl + "/list"); + + assertThat(listResponse, containsString("[{\"port\":8080,")); + assertThat(listResponse, containsString("externalPort\":8080")); + + sendPing("1", 8081, "use-ip", "hello", "world", "my-target", 8082); Thread.sleep(1000); - System.out.println(rest.getJson("http://localhost:8080/registry-app/service-registry/list")); - assertThat(rest.getJson("http://localhost:8080/registry-app/service-registry/list"), - containsString("{\"port\":8081,")); - - assertThat(rest.getJson("http://localhost:8080/registry-app/service-registry/list"), - containsString("\"target\":\"my-target\"")); - assertThat(rest.getJson("http://localhost:8080/registry-app/service-registry/list"), - containsString("\"target\":\"configured-target\"")); - assertThat(rest.getJson("http://localhost:8080/registry-app/service-registry/list"), - not(containsString("\"hostname\":\"test-host\""))); - assertThat(rest.getJson("http://localhost:8080/registry-app/service-registry/list"), - containsString("\"formattedDate\"")); - assertThat(rest.getJson("http://localhost:8080/registry-app/service-registry/list"), - containsString("\"manifest\"")); - assertThat(rest.getJson("http://localhost:8080/registry-app/service-registry/list"), - containsString("Manifest-Version")); - - assertThat(rest.getJson("http://localhost:8080/registry-app/service-registry/list"), containsString(date)); + + listResponse = rest.getJson(baseUrl + "/list");; + + assertThat(listResponse, containsString("{\"port\":8081,")); + assertThat(listResponse, containsString("\"target\":\"my-target\"")); + assertThat(listResponse, containsString("\"target\":\"configured-target\"")); + assertThat(listResponse, not(containsString("\"hostname\":\"test-host\""))); + assertThat(listResponse, containsString("\"formattedDate\"")); + assertThat(listResponse, containsString("\"manifest\"")); + assertThat(listResponse, containsString("Manifest-Version")); + assertThat(listResponse, containsString(date)); } - private void sendPing(RegisterEntry entry) { + @Test + public void filterTest() throws Exception { + Thread.sleep(1000); - try { + List entries = list(); + assertThat(entries.size(), is(1)); - restAsync.post("http://localhost:8080/registry-app/service-registry/register", - JacksonUtil.serializeToJson(entry)) - .join(); - } catch (Exception e) { + sendPing("121", 8080, "host1", "module1", "context1", "target1", 9080); + sendPing("122", 8080, "host2", "module1", "context1", "target1", 9080); + sendPing("131", 6080, "host3", "module2", "context2", "target2", 7080); + sendPing("132", 6080, "host4", "module2", "context2", "target2", 7080); + + entries = list(); + assertThat(entries.size(), is(5)); + + entries = list("port=8080"); + assertThat(entries.size(), is(3)); + + entries = list("port=8080", "externalPort=9080"); + System.out.println(entries); + assertThat(entries.size(), is(2)); - } + entries = list("port=8080", "externalPort=9080", "module=module", "context=context1"); + assertThat(entries.size(), is(2)); + + entries = list("port=8080", "externalPort=9080", "module=module", "context=context1", "hostname=host1"); + assertThat(entries.size(), is(1)); + + entries = list("port=8080", "externalPort=9080", "module=module1", "context=context2"); + assertThat(entries.size(), is(0)); + + entries = list("manifest.Implementation-Version=version"); + assertThat(entries.size(), is(4)); + + entries = list("manifest.Implementation-Version=version1"); + assertThat(entries.size(), is(4)); + + entries = list("manifest.Implementation-Version=version121"); + assertThat(entries.size(), is(1)); + + entries = list("manifest.Implementation-revision=rev12"); + assertThat(entries.size(), is(2)); + + entries = list("manifest.Implementation-Timestamp=2017_13"); + assertThat(entries.size(), is(2)); + + entries = list("health=OK"); + assertThat(entries.size(), is(5)); + + List list = JacksonUtil.convertFromJson(rest.getJson(baseUrl + "/list?port=OK"), new TypeReference>() {}); + assertThat(list.size(), is(1)); + assertThat(list.get(0), is("Bad Request: 'OK' is not a valid number.")); + + list = JacksonUtil.convertFromJson(rest.getJson(baseUrl + "/list?health=Suspended"), new TypeReference>() {}); + assertThat(list.size(), is(1)); + assertThat(list.get(0), is("Bad Request: 'Suspended' is not valid, valid values are [OK, ERROR]")); } - public static void main(String[] args) { - RegistryAppRunner appRunner = new RegistryAppRunner(); - appRunner.startServer(); + private List list(String... parameters) { + String url = baseUrl + "/list?" + Stream.of(parameters).collect(joining("&")); + return JacksonUtil.convertFromJson(rest.getJson(url), new TypeReference>() {}); } + private void sendPing(String uuid, int port, String hostName, String module, String context, String target, int externalPort) { + try { + RegisterEntry re = RegisterEntry.builder() + .port(port) + .hostname(hostName) + .module(module) + .context(context) + .time(new Date()) + .uuid(uuid) + .target(target) + .externalPort(externalPort) + .build(); + re.getManifest().put("Implementation-revision", "rev" + uuid); + re.getManifest().put("Implementation-Version", "version" + uuid); + re.getManifest().put("Implementation-Timestamp", "2017_" + uuid); + restAsync.post("http://localhost:8080/registry-app/service-registry/register", + JacksonUtil.serializeToJson(re)) + .get(); + } catch (Exception e) {} + } } diff --git a/micro-application-register/src/test/java/com/aol/micro/server/application/registry/RegisterEntryTest.java b/micro-application-register/src/test/java/com/aol/micro/server/application/registry/RegisterEntryTest.java index 5c3e5d237..de27b3007 100644 --- a/micro-application-register/src/test/java/com/aol/micro/server/application/registry/RegisterEntryTest.java +++ b/micro-application-register/src/test/java/com/aol/micro/server/application/registry/RegisterEntryTest.java @@ -1,8 +1,10 @@ package com.aol.micro.server.application.registry; +import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertTrue; import java.util.Date; +import java.util.Map; import org.junit.Before; import org.junit.Test; @@ -15,14 +17,57 @@ public class RegisterEntryTest { @Before public void setUp() throws Exception { - entry = new RegisterEntry( - 8080, "hostname", "name", "context", new Date(), null, 8080); + entry = RegisterEntry.builder() + .port(8080) + .hostname("host") + .module("module") + .context("context") + .time(new Date()) + .uuid("1") + .target("target") + .externalPort(9090) + .build(); + Map manifest = entry.getManifest(); + manifest.put("Implementation-revision", "a2edfe4bc"); + manifest.put("Implementation-Version", "version"); + manifest.put("Implementation-Timestamp", "2017_1201"); } @Test public void test() { + assertTrue(JacksonUtil.serializeToJson(entry).contains("\"context\":\"context")); + } + + @Test + public void matches() throws Exception { + RegisterEntry re = new RegisterEntry(); + re.getManifest().clear(); + assertFalse(entry.matches(re)); + + re = RegisterEntry.builder().port(8080).externalPort(-1).build(); + re.getManifest().clear(); + assertTrue(entry.matches(re)); + + re = RegisterEntry.builder().port(8080).externalPort(9090).build(); + re.getManifest().clear(); + assertTrue(entry.matches(re)); + + re = RegisterEntry.builder().port(8080).hostname("host").externalPort(9090).build(); + re.getManifest().clear(); + assertTrue(entry.matches(re)); + + re = RegisterEntry.builder().port(8080).hostname("host1").externalPort(9090).build(); + re.getManifest().clear(); + assertFalse(entry.matches(re)); + + re = RegisterEntry.builder().port(8080).hostname("host").externalPort(9090).build(); + re.getManifest().clear(); + re.getManifest().put("Implementation-revision", "a2edfe4bc"); + assertTrue(entry.matches(re)); - assertTrue(JacksonUtil.serializeToJson(entry) - .contains("\"context\":\"context")); + re = RegisterEntry.builder().port(8080).hostname("host").externalPort(9090).build(); + re.getManifest().clear(); + re.getManifest().put("Implementation-Version", "version1"); + assertFalse(entry.matches(re)); } } diff --git a/micro-application-register/src/test/java/com/aol/micro/server/application/registry/UriInfoParserTest.java b/micro-application-register/src/test/java/com/aol/micro/server/application/registry/UriInfoParserTest.java new file mode 100644 index 000000000..218bc15c3 --- /dev/null +++ b/micro-application-register/src/test/java/com/aol/micro/server/application/registry/UriInfoParserTest.java @@ -0,0 +1,61 @@ +package com.aol.micro.server.application.registry; + +import org.junit.Test; +import org.mockito.Mockito; + +import javax.ws.rs.core.*; + +import java.net.URI; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.*; +import static org.mockito.Mockito.when; + +public class UriInfoParserTest { + + @Test + public void toRegisterEntryFromQueryParameters() throws Exception { + UriInfo uriInfo = Mockito.mock(UriInfo.class); + MultivaluedMap data = new MultivaluedHashMap<>(); + data.put("port", Arrays.asList("8080")); + data.put("externalPort", Arrays.asList("9090")); + data.put("hostname", Arrays.asList("host1")); + data.put("module", Arrays.asList("module1")); + data.put("context", Arrays.asList("context1")); + data.put("target", Arrays.asList("target1")); + data.put("health", Arrays.asList("OK")); + data.put("manifest.Implementation-revision", Arrays.asList("revision1")); + data.put("manifest.Implementation-Timestamp", Arrays.asList("2017_001")); + data.put("manifest.Implementation-Version", Arrays.asList("v1")); + + when(uriInfo.getQueryParameters()).thenReturn(data); + + Optional reOptional = UriInfoParser.toRegisterEntry(uriInfo); + assertTrue(reOptional.isPresent()); + + RegisterEntry re = reOptional.get(); + assertThat(re.getPort(), is(8080)); + assertThat(re.getExternalPort(), is(9090)); + assertThat(re.getHostname(), is("host1")); + assertThat(re.getModule(), is("module1")); + assertThat(re.getContext(), is("context1")); + assertThat(re.getTarget(), is("target1")); + assertThat(re.getHealth(), is(Health.OK)); + assertThat(re.getManifest().get("Implementation-revision"), is("revision1")); + assertThat(re.getManifest().get("Implementation-Timestamp"), is("2017_001")); + assertThat(re.getManifest().get("Implementation-Version"), is("v1")); + } + + @Test + public void toRegisterEntryFromEmptyQueryParameter() throws Exception { + UriInfo uriInfo = Mockito.mock(UriInfo.class); + when(uriInfo.getQueryParameters()).thenReturn(new MultivaluedHashMap<>()); + + Optional re = UriInfoParser.toRegisterEntry(uriInfo); + assertFalse(re.isPresent()); + + } +} \ No newline at end of file From ad7935879f1970c96f702dadd68dbde1f59fe890 Mon Sep 17 00:00:00 2001 From: Philip Clarke Date: Tue, 12 Sep 2017 10:02:04 +0100 Subject: [PATCH 16/20] upgrade metrics-core to 3.2.3 This version contains SlidingTimeWindowArrayReservoir --- micro-metrics/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/micro-metrics/build.gradle b/micro-metrics/build.gradle index fcefead3d..f02225eb8 100644 --- a/micro-metrics/build.gradle +++ b/micro-metrics/build.gradle @@ -5,7 +5,7 @@ dependencies { exclude(group: 'io.dropwizard.metrics', module: 'metrics-core') } - compile("io.dropwizard.metrics:metrics-core:3.2.2") + compile("io.dropwizard.metrics:metrics-core:3.2.3") compile project(':micro-core') testCompile project(':micro-jackson-configuration') From 145ee1fa94aadfdce551450bd2e451538ef133f5 Mon Sep 17 00:00:00 2001 From: Philip Clarke Date: Fri, 8 Sep 2017 14:48:22 +0100 Subject: [PATCH 17/20] upgrade micro-server to 0.91.7 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index b75ff08a1..9899de2ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=0.91.6 +version=0.91.7 springVersion=4.3.3.RELEASE springBootVersion=1.4.1.RELEASE jerseyVersion=2.24 From 79abf25feebd5b65b8a5acc51a9c5a35310d918a Mon Sep 17 00:00:00 2001 From: Philip Clarke Date: Wed, 20 Sep 2017 10:37:13 +0100 Subject: [PATCH 18/20] Use SlidingTimeWindowArrayReservoir for timers with a default configurable interval of 10 seconds --- .../micro/server/event/metrics/Configuration.java | 3 +++ .../micro/server/event/metrics/MetricsCatcher.java | 13 +++++++++---- .../event/metrics/MetricsCatcherConfigOffTest.java | 2 +- .../server/event/metrics/MetricsCatcherTest.java | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/Configuration.java b/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/Configuration.java index 0d88df66d..581300776 100644 --- a/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/Configuration.java +++ b/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/Configuration.java @@ -24,6 +24,7 @@ class Configuration { private final int numJobs; private final int holdJobsForMinutes; + private final int timerIntervalSeconds; private final String prefix; @Autowired @@ -35,6 +36,7 @@ public Configuration(@Value("${event.metrics.capture.errors.by.type:true}") bool @Value("${event.metrics.capture.queries.minutes:180}") int holdQueriesForMinutes, @Value("${event.metrics.capture.number.of.jobs:10000}") int numJobs, @Value("${event.metrics.capture.jobs.minutes:180}") int holdJobsForMinutes, + @Value("${event.metrics.capture.timer.interval.seconds:10}") int timerIntervalSeconds, @Value("${event.metrics.capture.jobs.prefix:#{null}}") String prefix) { super(); this.errorsByType = errorsByType; @@ -45,6 +47,7 @@ public Configuration(@Value("${event.metrics.capture.errors.by.type:true}") bool this.holdQueriesForMinutes = holdQueriesForMinutes; this.numJobs = numJobs; this.holdJobsForMinutes = holdJobsForMinutes; + this.timerIntervalSeconds = timerIntervalSeconds; this.prefix = Optional.ofNullable(prefix) .orElseGet(() -> MetricsCatcher.class.getTypeName()); } diff --git a/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java b/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java index 3f40357aa..bcc5429ce 100644 --- a/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java +++ b/micro-event-metrics/src/main/java/com/aol/micro/server/event/metrics/MetricsCatcher.java @@ -2,6 +2,8 @@ import com.aol.micro.server.events.GenericEvent; import com.aol.micro.server.spring.metrics.InstantGauge; +import com.codahale.metrics.SlidingTimeWindowArrayReservoir; +import com.codahale.metrics.Timer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -20,6 +22,7 @@ import com.google.common.eventbus.Subscribe; import java.util.Objects; +import java.util.concurrent.TimeUnit; @Component public class MetricsCatcher { @@ -59,8 +62,7 @@ public void requestStart(AddQuery data) { registry.meter(queryStartName(rd) + "-meter") .mark(); - queries.start(rd.getCorrelationId(), registry.timer(queryEndName(rd) + "-timer") - .time()); + queries.start(rd.getCorrelationId(), timer(queryEndName(rd) + "-timer").time()); registry.counter(prefix + ".requests-active-" + rd.getType() + "-count") .inc(); ((InstantGauge) registry.gauge(prefix + ".requests-started-" + rd.getType() + "-interval-count", @@ -135,8 +137,7 @@ public void jobStarted(JobStartEvent data) { registry.meter(prefix + ".job-meter-" + data.getType()) .mark(); - jobs.start(data.getCorrelationId(), registry.timer(prefix + ".job-timer-" + data.getType()) - .time()); + jobs.start(data.getCorrelationId(), timer(prefix + ".job-timer-" + data.getType()).time()); registry.counter(prefix + ".jobs-active-" + data.getType() + "-count") .inc(); } @@ -223,4 +224,8 @@ public void genericEvent(GenericEvent event) { private String name(ErrorCode c) { return prefix + ".error-" + c.getSeverity() + "-" + c.getErrorId(); } + + private Timer timer (String name) { + return registry.timer(name, () -> new Timer(new SlidingTimeWindowArrayReservoir(configuration.getTimerIntervalSeconds(), TimeUnit.SECONDS))); + } } diff --git a/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherConfigOffTest.java b/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherConfigOffTest.java index 04bf7dd01..c5d0832c1 100644 --- a/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherConfigOffTest.java +++ b/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherConfigOffTest.java @@ -27,7 +27,7 @@ public void setup() { registry = new MetricRegistry(); bus = new EventBus(); config = new Configuration( - false, false, false, false, 5, 6, 7, 8, "bob"); + false, false, false, false, 5, 6, 7, 8, 10, "bob"); catcher = new MetricsCatcher<>( registry, bus, config); } diff --git a/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherTest.java b/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherTest.java index 6eb51d09a..dc8ce6d19 100644 --- a/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherTest.java +++ b/micro-event-metrics/src/test/java/com/aol/micro/server/event/metrics/MetricsCatcherTest.java @@ -29,7 +29,7 @@ public void setup() { registry = new MetricRegistry(); bus = new EventBus(); config = new Configuration( - true, true, true, true, 5, 6, 7, 8, "bob"); + true, true, true, true, 5, 6, 7, 8, 10,"bob"); catcher = new MetricsCatcher<>( registry, bus, config); } From 40ea257d729566338cbaf8b8ca34580dfcd77c32 Mon Sep 17 00:00:00 2001 From: Philip Clarke Date: Wed, 20 Sep 2017 10:50:44 +0100 Subject: [PATCH 19/20] update readme for new counters and properties --- micro-event-metrics/readme.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/micro-event-metrics/readme.md b/micro-event-metrics/readme.md index c25d9a5f0..41b53693c 100644 --- a/micro-event-metrics/readme.md +++ b/micro-event-metrics/readme.md @@ -108,9 +108,14 @@ Number of active jobs to cache in memory ```text com.aol.micro.server.event.metrics.MetricsCatcher.requests-started +com.aol.micro.server.event.metrics.MetricsCatcher.requests-started-interval-count com.aol.micro.server.event.metrics.MetricsCatcher.request-start- +com.aol.micro.server.event.metrics.MetricsCatcher.request-start--interval-count com.aol.micro.server.event.metrics.MetricsCatcher.requests-completed +com.aol.micro.server.event.metrics.MetricsCatcher.requests-completed-interval-type com.aol.micro.server.event.metrics.MetricsCatcher.request-completed- +com.aol.micro.server.event.metrics.MetricsCatcher.request-completed--interval-count + ``` #### Timers : @@ -172,6 +177,8 @@ event.metrics.capture.jobs.by.type=true # jobsByType, event.metrics.capture.number.of.queries=10000 # numQueries, event.metrics.capture.queries.minutes=180 # holdQueriesForMinutes, event.metrics.capture.number.of.jobs=10000 # numJobs, -event.metrics.capture.jobs.minutes=180 +event.metrics.capture.jobs.minutes=180, +event.metrics.capture.timer.interval.seconds=10 +event.metrics.capture.jobs.prefix=null ``` From 6bdb22024b5b2f80efde614852ac11e02be5e190 Mon Sep 17 00:00:00 2001 From: Philip Clarke Date: Mon, 25 Sep 2017 09:28:14 +0100 Subject: [PATCH 20/20] upgrade micro-server version to 0.81.8 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 9899de2ff..3f863afb5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=0.91.7 +version=0.91.8 springVersion=4.3.3.RELEASE springBootVersion=1.4.1.RELEASE jerseyVersion=2.24