diff --git a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/pom.xml b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/pom.xml index 6f7d961fe8f..32e005d1254 100644 --- a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/pom.xml +++ b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/pom.xml @@ -108,15 +108,5 @@ spring-boot-starter-webflux ${spring.boot.version} - - io.micrometer - micrometer-core - ${io.micrometer.prometheus.version} - - - io.micrometer - micrometer-registry-prometheus - ${io.micrometer.prometheus.version} - diff --git a/registration-processor/pre-processor/registration-processor-packet-validator-stage/pom.xml b/registration-processor/pre-processor/registration-processor-packet-validator-stage/pom.xml index db5712d034f..777b29f44d8 100644 --- a/registration-processor/pre-processor/registration-processor-packet-validator-stage/pom.xml +++ b/registration-processor/pre-processor/registration-processor-packet-validator-stage/pom.xml @@ -105,6 +105,11 @@ spring-boot-starter-webflux ${spring.boot.version} + + io.mosip.registrationprocessor + registration-processor-packet-classifier-stage + 1.1.5.2 + diff --git a/registration-processor/registration-processor-common-camel-bridge/pom.xml b/registration-processor/registration-processor-common-camel-bridge/pom.xml index 298238fdf6c..3251aee9cf9 100644 --- a/registration-processor/registration-processor-common-camel-bridge/pom.xml +++ b/registration-processor/registration-processor-common-camel-bridge/pom.xml @@ -92,7 +92,7 @@ org.apache.camel - camel-jsonpath + camel-jsonpath ${camel.vertx.version} diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/abstractverticle/MosipVerticleAPIManager.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/abstractverticle/MosipVerticleAPIManager.java index 3bfdd9102bd..41e3ea3fd9f 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/abstractverticle/MosipVerticleAPIManager.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/abstractverticle/MosipVerticleAPIManager.java @@ -1,182 +1,187 @@ -package io.mosip.registration.processor.core.abstractverticle; - -import brave.Tracing; -import io.mosip.registration.processor.core.tracing.VertxWebTracingLocal; -import io.vertx.core.Handler; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.env.Environment; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import io.mosip.registration.processor.core.constant.HealthConstant; -import io.mosip.registration.processor.core.util.DigitalSignatureUtility; -import io.vertx.core.Vertx; -import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.json.Json; -import io.vertx.ext.web.Router; -import io.vertx.ext.web.RoutingContext; -import io.vertx.ext.web.handler.BodyHandler; - -/** - * @author Mukul Puspam - * - */ -public abstract class MosipVerticleAPIManager extends MosipVerticleManager { - - @Value("${registration.processor.signature.isEnabled}") - Boolean isEnabled; - - @Autowired - DigitalSignatureUtility digitalSignatureUtility; - - @Autowired - Environment environment; - - @Autowired - ObjectMapper objectMapper; - - @Autowired - private Tracing tracing; - - /** - * This method creates a body handler for the routes - * - * @param vertx - * @return - */ - public Router postUrl(Vertx vertx, MessageBusAddress consumeAddress, MessageBusAddress sendAddress) { - Router router = Router.router(vertx); - - VertxWebTracingLocal vertxWebTracing = VertxWebTracingLocal.create(tracing); - Handler routingContextHandler = vertxWebTracing.routingContextHandler(); - router.route() - .order(-1) //applies before routes - .handler(routingContextHandler) - .failureHandler(routingContextHandler); - - router.route().handler(BodyHandler.create()); - if (consumeAddress == null && sendAddress == null) - configureHealthCheckEndpoint(vertx, router, environment.getProperty(HealthConstant.SERVLET_PATH), null, - null); - else if (consumeAddress == null) - configureHealthCheckEndpoint(vertx, router, environment.getProperty(HealthConstant.SERVLET_PATH), null, - sendAddress.getAddress()); - else if (sendAddress == null) - configureHealthCheckEndpoint(vertx, router, environment.getProperty(HealthConstant.SERVLET_PATH), - consumeAddress.getAddress(), null); - else - configureHealthCheckEndpoint(vertx, router, environment.getProperty(HealthConstant.SERVLET_PATH), - consumeAddress.getAddress(), sendAddress.getAddress()); - return router; - } - - public void configureHealthCheckEndpoint(Vertx vertx, Router router, final String servletPath, - String consumeAddress, String sendAddress) { - StageHealthCheckHandler healthCheckHandler = new StageHealthCheckHandler(vertx, null, objectMapper, - environment); - router.get(servletPath + HealthConstant.HEALTH_ENDPOINT).handler(healthCheckHandler); - if (servletPath.contains("packetreceiver") || servletPath.contains("uploader")) { - healthCheckHandler.register("virusscanner", healthCheckHandler::virusScanHealthChecker); - healthCheckHandler.register( - servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Verticle", - future -> healthCheckHandler.senderHealthHandler(future, vertx, sendAddress)); - } - if (checkServletPathContainsCoreProcessor(servletPath)) { - healthCheckHandler.register( - servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Send", future -> { - healthCheckHandler.senderHealthHandler(future, vertx, sendAddress); - }); - healthCheckHandler.register( - servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Consume", - future -> { - healthCheckHandler.consumerHealthHandler(future, vertx, consumeAddress); - }); - } - if (servletPath.contains("external") || servletPath.contains("bioauth")) { - healthCheckHandler.register( - servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Send", future -> { - healthCheckHandler.senderHealthHandler(future, vertx, sendAddress); - }); - healthCheckHandler.register( - servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Consume", - future -> { - healthCheckHandler.senderHealthHandler(future, vertx, consumeAddress); - }); - } - if (servletPath.contains("manual")) { - healthCheckHandler.register( - servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Verticle", - future -> healthCheckHandler.senderHealthHandler(future, vertx, sendAddress)); - } - if (servletPath.contains("print") || servletPath.contains("abismiddleware")) { - healthCheckHandler.register("queuecheck", healthCheckHandler::queueHealthChecker); - healthCheckHandler.register( - servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Verticle", - future -> healthCheckHandler.consumerHealthHandler(future, vertx, consumeAddress)); - } - if (servletPath.contains("sender")) { - healthCheckHandler.register( - servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Verticle", - future -> healthCheckHandler.consumerHealthHandler(future, vertx, consumeAddress)); - } - - healthCheckHandler.register("diskSpace", healthCheckHandler::dispSpaceHealthChecker); - healthCheckHandler.register("db", healthCheckHandler::databaseHealthChecker); - } - - private boolean checkServletPathContainsCoreProcessor(String servletPath) { - return servletPath.contains("packetvalidator") || servletPath.contains("osi") || servletPath.contains("demo") - || servletPath.contains("bio") || servletPath.contains("uin") || servletPath.contains("quality") - || servletPath.contains("abishandler") || servletPath.contains("securezone"); - } - - /** - * This method creates server for vertx web application - * - * @param router - * @param port - */ - public void createServer(Router router, int port) { - vertx.createHttpServer().requestHandler(router::accept).listen(port); - } - - /** - * This method returns a response to the routing context - * - * @param ctx - * @param object - */ - public void setResponse(RoutingContext ctx, Object object) { - ctx.response().putHeader("content-type", "text/plain").putHeader("Access-Control-Allow-Origin", "*") - .putHeader("Access-Control-Allow-Methods", "GET, POST").setStatusCode(200) - .end(Json.encodePrettily(object)); - }; - - /** - * This method returns a response to the routing context - * - * @param ctx - * @param object - * @param contentType - */ - public void setResponseWithDigitalSignature(RoutingContext ctx, Object object, String contentType) { - HttpServerResponse response = ctx.response(); - Gson gson=new GsonBuilder().serializeNulls().create(); - if (isEnabled) - response.putHeader("Response-Signature", - digitalSignatureUtility.getDigitalSignature(gson.toJson(object))); - response.putHeader("content-type", contentType).putHeader("Access-Control-Allow-Origin", "*") - .putHeader("Access-Control-Allow-Methods", "GET, POST").setStatusCode(200) - .end(gson.toJson(object)); - } - - // Added this method to cast all the stages to this class and invoke the deployVerticle method - // to start the stage by configuration, since we don't want to test all the stages now, not marking this as - // an abstract method, but later this need to be marked as abstract - public void deployVerticle() { - - } +package io.mosip.registration.processor.core.abstractverticle; + +import brave.Tracing; +import io.mosip.registration.processor.core.tracing.VertxWebTracingLocal; +import io.vertx.core.Handler; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import io.mosip.registration.processor.core.constant.HealthConstant; +import io.mosip.registration.processor.core.util.DigitalSignatureUtility; +import io.vertx.core.Vertx; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.core.json.Json; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.handler.BodyHandler; +import io.vertx.micrometer.PrometheusScrapingHandler; + +/** + * @author Mukul Puspam + * + */ +public abstract class MosipVerticleAPIManager extends MosipVerticleManager { + + private static final String PROMETHEUS_ENDPOINT = "/actuator/prometheus"; + + @Value("${registration.processor.signature.isEnabled}") + Boolean isEnabled; + + @Autowired + DigitalSignatureUtility digitalSignatureUtility; + + @Autowired + Environment environment; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + private Tracing tracing; + + /** + * This method creates a body handler for the routes + * + * @param vertx + * @return + */ + public Router postUrl(Vertx vertx, MessageBusAddress consumeAddress, MessageBusAddress sendAddress) { + Router router = Router.router(vertx); + + VertxWebTracingLocal vertxWebTracing = VertxWebTracingLocal.create(tracing); + Handler routingContextHandler = vertxWebTracing.routingContextHandler(); + router.route() + .order(-1) //applies before routes + .handler(routingContextHandler) + .failureHandler(routingContextHandler); + + router.route().handler(BodyHandler.create()); + router.get(environment.getProperty(HealthConstant.SERVLET_PATH) + PROMETHEUS_ENDPOINT).handler(PrometheusScrapingHandler.create()); + + if (consumeAddress == null && sendAddress == null) + configureHealthCheckEndpoint(vertx, router, environment.getProperty(HealthConstant.SERVLET_PATH), null, + null); + else if (consumeAddress == null) + configureHealthCheckEndpoint(vertx, router, environment.getProperty(HealthConstant.SERVLET_PATH), null, + sendAddress.getAddress()); + else if (sendAddress == null) + configureHealthCheckEndpoint(vertx, router, environment.getProperty(HealthConstant.SERVLET_PATH), + consumeAddress.getAddress(), null); + else + configureHealthCheckEndpoint(vertx, router, environment.getProperty(HealthConstant.SERVLET_PATH), + consumeAddress.getAddress(), sendAddress.getAddress()); + return router; + } + + public void configureHealthCheckEndpoint(Vertx vertx, Router router, final String servletPath, + String consumeAddress, String sendAddress) { + StageHealthCheckHandler healthCheckHandler = new StageHealthCheckHandler(vertx, null, objectMapper, + environment); + router.get(servletPath + HealthConstant.HEALTH_ENDPOINT).handler(healthCheckHandler); + if (servletPath.contains("packetreceiver") || servletPath.contains("uploader")) { + healthCheckHandler.register("virusscanner", healthCheckHandler::virusScanHealthChecker); + healthCheckHandler.register( + servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Verticle", + future -> healthCheckHandler.senderHealthHandler(future, vertx, sendAddress)); + } + if (checkServletPathContainsCoreProcessor(servletPath)) { + healthCheckHandler.register( + servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Send", future -> { + healthCheckHandler.senderHealthHandler(future, vertx, sendAddress); + }); + healthCheckHandler.register( + servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Consume", + future -> { + healthCheckHandler.consumerHealthHandler(future, vertx, consumeAddress); + }); + } + if (servletPath.contains("external") || servletPath.contains("bioauth")) { + healthCheckHandler.register( + servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Send", future -> { + healthCheckHandler.senderHealthHandler(future, vertx, sendAddress); + }); + healthCheckHandler.register( + servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Consume", + future -> { + healthCheckHandler.senderHealthHandler(future, vertx, consumeAddress); + }); + } + if (servletPath.contains("manual")) { + healthCheckHandler.register( + servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Verticle", + future -> healthCheckHandler.senderHealthHandler(future, vertx, sendAddress)); + } + if (servletPath.contains("print") || servletPath.contains("abismiddleware")) { + healthCheckHandler.register("queuecheck", healthCheckHandler::queueHealthChecker); + healthCheckHandler.register( + servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Verticle", + future -> healthCheckHandler.consumerHealthHandler(future, vertx, consumeAddress)); + } + if (servletPath.contains("sender")) { + healthCheckHandler.register( + servletPath.substring(servletPath.lastIndexOf("/") + 1, servletPath.length()) + "Verticle", + future -> healthCheckHandler.consumerHealthHandler(future, vertx, consumeAddress)); + } + + healthCheckHandler.register("diskSpace", healthCheckHandler::dispSpaceHealthChecker); + healthCheckHandler.register("db", healthCheckHandler::databaseHealthChecker); + } + + private boolean checkServletPathContainsCoreProcessor(String servletPath) { + return servletPath.contains("packetvalidator") || servletPath.contains("osi") || servletPath.contains("demo") + || servletPath.contains("bio") || servletPath.contains("uin") || servletPath.contains("quality") + || servletPath.contains("abishandler") || servletPath.contains("securezone"); + } + + /** + * This method creates server for vertx web application + * + * @param router + * @param port + */ + public void createServer(Router router, int port) { + vertx.createHttpServer().requestHandler(router::accept).listen(port); + } + + /** + * This method returns a response to the routing context + * + * @param ctx + * @param object + */ + public void setResponse(RoutingContext ctx, Object object) { + ctx.response().putHeader("content-type", "text/plain").putHeader("Access-Control-Allow-Origin", "*") + .putHeader("Access-Control-Allow-Methods", "GET, POST").setStatusCode(200) + .end(Json.encodePrettily(object)); + }; + + /** + * This method returns a response to the routing context + * + * @param ctx + * @param object + * @param contentType + */ + public void setResponseWithDigitalSignature(RoutingContext ctx, Object object, String contentType) { + HttpServerResponse response = ctx.response(); + Gson gson=new GsonBuilder().serializeNulls().create(); + if (isEnabled) + response.putHeader("Response-Signature", + digitalSignatureUtility.getDigitalSignature(gson.toJson(object))); + response.putHeader("content-type", contentType).putHeader("Access-Control-Allow-Origin", "*") + .putHeader("Access-Control-Allow-Methods", "GET, POST").setStatusCode(200) + .end(gson.toJson(object)); + } + + // Added this method to cast all the stages to this class and invoke the deployVerticle method + // to start the stage by configuration, since we don't want to test all the stages now, not marking this as + // an abstract method, but later this need to be marked as abstract + public void deployVerticle() { + + } } \ No newline at end of file diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/abstractverticle/MosipVerticleManager.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/abstractverticle/MosipVerticleManager.java index b5d51d874b2..f6fb6972fd7 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/abstractverticle/MosipVerticleManager.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/abstractverticle/MosipVerticleManager.java @@ -80,10 +80,6 @@ public abstract class MosipVerticleManager extends AbstractVerticle @Autowired private ObjectMapper objectMapper; - private static final String PROMETHEUS_ENDPOINT = "/actuator/prometheus"; - - private static final String PROMETHEUS_ENDPOINT = "/actuator/prometheus"; - @Value("${mosip.regproc.eventbus.type:vertx}") private String eventBusType; @@ -135,9 +131,6 @@ public MosipEventBus getEventBus(Object verticleName, String clusterManagerUrl, MicrometerMetricsOptions micrometerMetricsOptions = new MicrometerMetricsOptions() .setPrometheusOptions(new VertxPrometheusOptions() - .setStartEmbeddedServer(true) - .setEmbeddedServerOptions(new HttpServerOptions().setPort(Integer.parseInt(port))) - .setEmbeddedServerEndpoint(serverPath + PROMETHEUS_ENDPOINT) .setEnabled(true)) .setEnabled(true); diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/dao/RegistrationStatusDao.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/dao/RegistrationStatusDao.java index 90332a81af5..34015f2ee33 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/dao/RegistrationStatusDao.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/dao/RegistrationStatusDao.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; +import io.mosip.kernel.core.util.DateUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component;