Browse code

BM-15295 Chore: replace static initialiser by a verticle so we d'ont miss check results from bm-core start

Thomas Cataldo authored on 24/10/2019 14:33:06
Showing 4 changed files
... ...
@@ -33,9 +33,11 @@ public class Checks {
33 33
 			break;
34 34
 		case WARN:
35 35
 			ctx.warn(Strings.padEnd(check, 25, ' ') + result.level.name());
36
+			ctx.info(Strings.nullToEmpty(result.message));
36 37
 			break;
37 38
 		case CRIT:
38 39
 			ctx.error(Strings.padEnd(check, 25, ' ') + result.level.name());
40
+			ctx.info(Strings.nullToEmpty(result.message));
39 41
 			break;
40 42
 		case UNKNOWN:
41 43
 		default:
... ...
@@ -29,7 +29,8 @@ Require-Bundle: org.eclipse.core.runtime,
29 29
  com.netflix.spectator.api,
30 30
  net.bluemind.metrics.registry,
31 31
  net.bluemind.system.validation,
32
- net.bluemind.hornetq.client
32
+ net.bluemind.hornetq.client,
33
+ io.vertx.platform
33 34
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
34 35
 Automatic-Module-Name: net.bluemind.metrics.core
35 36
 Bundle-ActivationPolicy: lazy
... ...
@@ -218,5 +218,11 @@
218 218
             impl="net.bluemind.metrics.core.db.DbCheck$Factory">
219 219
       </verticle>
220 220
    </extension>
221
+   <extension
222
+         point="net.bluemind.lib.vertx.verticles">
223
+      <verticle
224
+            impl="net.bluemind.metrics.core.service.ProductChecksService$ConsumerFactory">
225
+      </verticle>
226
+   </extension>
221 227
    
222 228
 </plugin>
... ...
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
25 25
 import org.slf4j.Logger;
26 26
 import org.slf4j.LoggerFactory;
27 27
 import org.vertx.java.core.json.JsonObject;
28
+import org.vertx.java.platform.Verticle;
28 29
 
29 30
 import com.netflix.spectator.api.Registry;
30 31
 
... ...
@@ -35,6 +36,7 @@ import net.bluemind.core.task.api.TaskRef;
35 36
 import net.bluemind.core.task.service.ITasksManager;
36 37
 import net.bluemind.hornetq.client.MQ;
37 38
 import net.bluemind.hornetq.client.Topic;
39
+import net.bluemind.lib.vertx.IVerticleFactory;
38 40
 import net.bluemind.metrics.alerts.api.CheckResult;
39 41
 import net.bluemind.metrics.alerts.api.CheckResult.Level;
40 42
 import net.bluemind.metrics.alerts.api.IProductChecks;
... ...
@@ -46,7 +48,29 @@ public class ProductChecksService implements IProductChecks {
46 48
 
47 49
 	private static final Map<String, Optional<CheckResult>> results = new ConcurrentHashMap<>();
48 50
 
49
-	static {
51
+	public static class ChecksConsumerVerticle extends Verticle {
52
+		@Override
53
+		public void start() {
54
+			initConsumer();
55
+		}
56
+
57
+	}
58
+
59
+	public static class ConsumerFactory implements IVerticleFactory {
60
+
61
+		@Override
62
+		public boolean isWorker() {
63
+			return true;
64
+		}
65
+
66
+		@Override
67
+		public Verticle newInstance() {
68
+			return new ChecksConsumerVerticle();
69
+		}
70
+
71
+	}
72
+
73
+	private static void initConsumer() {
50 74
 		MQ.init().whenComplete((v, ex) -> {
51 75
 
52 76
 			if (ex != null) {