-
Notifications
You must be signed in to change notification settings - Fork 204
MOSIP-18889 #2174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kaledOu
wants to merge
6
commits into
mosip:develop
Choose a base branch
from
kaledOu:develop-MOSIP-18889
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
MOSIP-18889 #2174
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
745dbdd
remove INFO: from log
kaledOu 3de2d18
remove changes from logbak.xml
kaledOu 9a9ffa6
add mdsKey
kaledOu de01889
change in EventTracingHandler
kaledOu 282b6f7
change in TracingRoutingContextHandlerLocal revert EventTracingHandler
kaledOu d58faa3
revert TracingRoutingContextHandlerLocal & change logback
kaledOu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
147 changes: 77 additions & 70 deletions
147
...n/java/io/mosip/registration/processor/stages/executor/MosipStageExecutorApplication.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,84 +1,91 @@ | ||
| package io.mosip.registration.processor.stages.executor; | ||
|
|
||
| import io.mosip.kernel.core.exception.ExceptionUtils; | ||
| import io.mosip.kernel.core.logger.spi.Logger; | ||
| import io.mosip.registration.processor.core.abstractverticle.MosipVerticleAPIManager; | ||
| import io.mosip.registration.processor.core.logger.RegProcessorLogger; | ||
| import io.mosip.registration.processor.stages.executor.config.StagesConfig; | ||
| import io.mosip.registration.processor.stages.executor.util.StageClassesUtil; | ||
| import org.slf4j.bridge.SLF4JBridgeHandler; | ||
| import org.springframework.context.annotation.AnnotationConfigApplicationContext; | ||
| import org.springframework.core.env.MutablePropertySources; | ||
|
|
||
| import java.util.List; | ||
| import java.util.concurrent.ExecutorService; | ||
| import java.util.concurrent.Executors; | ||
| import java.util.logging.LogManager; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import io.mosip.registration.processor.core.logger.RegProcessorLogger; | ||
| import io.mosip.kernel.core.logger.spi.Logger; | ||
| import org.springframework.context.annotation.AnnotationConfigApplicationContext; | ||
| import org.springframework.core.env.MutablePropertySources; | ||
|
|
||
| import io.mosip.kernel.core.exception.ExceptionUtils; | ||
| import io.mosip.registration.processor.core.abstractverticle.MosipVerticleAPIManager; | ||
|
|
||
| import io.mosip.registration.processor.stages.executor.config.StagesConfig; | ||
| import io.mosip.registration.processor.stages.executor.util.StageClassesUtil; | ||
|
|
||
| /** | ||
| * The Class MosipStageExecutorApplication. | ||
| */ | ||
| public class MosipStageExecutorApplication { | ||
|
|
||
| /** The Constant regProcLogger. */ | ||
| private static final Logger regProcLogger = RegProcessorLogger.getLogger(MosipStageExecutorApplication.class); | ||
|
|
||
| /** | ||
| * main method to launch external stage application. | ||
| * | ||
| * @param args the arguments | ||
| */ | ||
| public static void main(String[] args) { | ||
| regProcLogger.info("Starting mosip-stage-executor..."); | ||
| //This context is closed after deploying the stages | ||
| try (AnnotationConfigApplicationContext stageInfoApplicationContext = new AnnotationConfigApplicationContext( | ||
| new Class<?>[] { StagesConfig.class });) { | ||
| StagesConfig stagesConfig = stageInfoApplicationContext.getBean(StagesConfig.class); | ||
| MutablePropertySources propertySources = stagesConfig.getCloudPropertySources(); | ||
|
|
||
| List<String> stageBeansBasePackages = StageClassesUtil.getStageBeansBasePackages(stagesConfig, propertySources); | ||
|
|
||
| if(!stageBeansBasePackages.isEmpty()) { | ||
|
|
||
| regProcLogger.info("Base packages for stage beans from configuration: {}", stageBeansBasePackages); | ||
|
|
||
| List<Class<MosipVerticleAPIManager>> stageClasses = StageClassesUtil.getStageBeanClasses(stageBeansBasePackages); | ||
|
|
||
| regProcLogger.info("Stage classes identified: {}", stageClasses.stream().map(Class::getCanonicalName).collect(Collectors.joining(", "))); | ||
|
|
||
| Class<?>[] entrypointConfigClasses = Stream.concat(Stream.of(StagesConfig.class), stageClasses.stream()) | ||
| .toArray(size -> new Class<?>[size]); | ||
|
|
||
| //This context should not be closed and to be kept for consumption by the verticles | ||
| AnnotationConfigApplicationContext mainApplicationContext = new PropertySourcesCustomizingApplicationContext( | ||
| entrypointConfigClasses) { | ||
| @Override | ||
| public MutablePropertySources getPropertySources() { | ||
| return propertySources; | ||
| }; | ||
| }; | ||
|
|
||
| if (!stageClasses.isEmpty()) { | ||
| ExecutorService executorService = Executors.newFixedThreadPool(stageClasses.size()); | ||
| stageClasses.forEach(stageClass -> executorService.execute(() -> { | ||
| try { | ||
| regProcLogger.info("Executing Stage: {}", stageClass.getCanonicalName()); | ||
| MosipVerticleAPIManager stageBean = StageClassesUtil.getStageBean(mainApplicationContext, stageClass); | ||
| stageBean.deployVerticle(); | ||
| } catch (Exception e) { | ||
| regProcLogger.error("Exception occured while loading verticles. Please make sure correct verticle name was passed from deployment script. \n {}", | ||
| ExceptionUtils.getStackTrace(e)); | ||
| } | ||
| })); | ||
| executorService.close(); | ||
| } else { | ||
| regProcLogger.error("No stage class is found. Please make sure correct correct stage class base packages are specified in properties and stages are added to classpath/dependencies."); | ||
| } | ||
| } else { | ||
| regProcLogger.error("No base packages configured for stages."); | ||
| } | ||
| } | ||
| } | ||
| /** | ||
| * The Constant regProcLogger. | ||
| */ | ||
| private static final Logger regProcLogger = RegProcessorLogger.getLogger(MosipStageExecutorApplication.class); | ||
|
|
||
| /** | ||
| * main method to launch external stage application. | ||
| * | ||
| * @param args the arguments | ||
| */ | ||
| public static void main(String[] args) { | ||
| LogManager.getLogManager().reset(); | ||
| SLF4JBridgeHandler.removeHandlersForRootLogger(); | ||
| SLF4JBridgeHandler.install(); | ||
|
Comment on lines
+36
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| regProcLogger.info("Starting mosip-stage-executor..."); | ||
| //This context is closed after deploying the stages | ||
| try (AnnotationConfigApplicationContext stageInfoApplicationContext = new AnnotationConfigApplicationContext( | ||
| new Class<?>[]{StagesConfig.class});) { | ||
| StagesConfig stagesConfig = stageInfoApplicationContext.getBean(StagesConfig.class); | ||
| MutablePropertySources propertySources = stagesConfig.getCloudPropertySources(); | ||
|
|
||
| List<String> stageBeansBasePackages = StageClassesUtil.getStageBeansBasePackages(stagesConfig, propertySources); | ||
|
|
||
| if (!stageBeansBasePackages.isEmpty()) { | ||
|
|
||
| regProcLogger.info("Base packages for stage beans from configuration: {}", stageBeansBasePackages); | ||
|
|
||
| List<Class<MosipVerticleAPIManager>> stageClasses = StageClassesUtil.getStageBeanClasses(stageBeansBasePackages); | ||
|
|
||
| regProcLogger.info("Stage classes identified: {}", stageClasses.stream().map(Class::getCanonicalName).collect(Collectors.joining(", "))); | ||
|
|
||
| Class<?>[] entrypointConfigClasses = Stream.concat(Stream.of(StagesConfig.class), stageClasses.stream()) | ||
| .toArray(size -> new Class<?>[size]); | ||
|
|
||
| //This context should not be closed and to be kept for consumption by the verticles | ||
| AnnotationConfigApplicationContext mainApplicationContext = new PropertySourcesCustomizingApplicationContext( | ||
| entrypointConfigClasses) { | ||
| @Override | ||
| public MutablePropertySources getPropertySources() { | ||
| return propertySources; | ||
| } | ||
|
|
||
| ; | ||
| }; | ||
|
|
||
| if (!stageClasses.isEmpty()) { | ||
| ExecutorService executorService = Executors.newFixedThreadPool(stageClasses.size()); | ||
| stageClasses.forEach(stageClass -> executorService.execute(() -> { | ||
| try { | ||
| regProcLogger.info("Executing Stage: {}", stageClass.getCanonicalName()); | ||
| MosipVerticleAPIManager stageBean = StageClassesUtil.getStageBean(mainApplicationContext, stageClass); | ||
| stageBean.deployVerticle(); | ||
| } catch (Exception e) { | ||
| regProcLogger.error("Exception occured while loading verticles. Please make sure correct verticle name was passed from deployment script. \n {}", | ||
| ExceptionUtils.getStackTrace(e)); | ||
| } | ||
| })); | ||
| executorService.close(); | ||
| } else { | ||
| regProcLogger.error("No stage class is found. Please make sure correct correct stage class base packages are specified in properties and stages are added to classpath/dependencies."); | ||
| } | ||
| } else { | ||
| regProcLogger.error("No base packages configured for stages."); | ||
| } | ||
| } | ||
| } | ||
| } | ||
6 changes: 3 additions & 3 deletions
6
registration-processor/mosip-stage-executor/src/main/resources/logback.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| <configuration> | ||
| <springProperty scope="context" name="appName" source="spring.application.name"/> | ||
| <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
| <encoder class="net.logstash.logback.encoder.LogstashEncoder"/> | ||
| <logger name="io.mosip.registration.processor" level="DEBUG"/> | ||
| <logger name="brave" level="DEBUG"/> | ||
| </appender> | ||
|
|
||
| <root level="INFO"> | ||
| <appender-ref ref="STDOUT" /> | ||
| <appender-ref ref="STDOUT"/> | ||
| </root> | ||
| </configuration> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why these unnecessary changes are there ?