mytang0 commented on code in PR #1044:
URL:
https://github.com/apache/incubator-eventmesh/pull/1044#discussion_r931719435
##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/registry/Registry.java:
##########
@@ -31,23 +31,37 @@
public class Registry {
private static final Logger logger =
LoggerFactory.getLogger(Registry.class);
- private static RegistryService registryService;
- public void init(String registryPluginType) throws Exception {
- registryService =
EventMeshExtensionFactory.getExtension(RegistryService.class,
registryPluginType);
- if (registryService == null) {
- logger.error("can't load the registryService plugin, please
check.");
- throw new RuntimeException("doesn't load the registryService
plugin, please check.");
+ private volatile boolean inited = false;
+
+ private volatile boolean started = false;
+
+ private RegistryService registryService;
+
+ public synchronized void init(String registryPluginType) throws Exception {
+ if (!inited) {
+ registryService =
EventMeshExtensionFactory.getExtension(RegistryService.class,
registryPluginType);
+ if (registryService == null) {
+ logger.error("can't load the registryService plugin, please
check.");
+ throw new RuntimeException("doesn't load the registryService
plugin, please check.");
+ }
+ registryService.init();
+ inited = true;
}
- registryService.init();
}
- public void start() throws Exception {
- registryService.start();
+ public synchronized void start() throws Exception {
+ if (!started) {
+ registryService.start();
+ started = true;
+ }
}
- public void shutdown() throws Exception {
- registryService.shutdown();
+ public synchronized void shutdown() throws Exception {
+ if (started) {
+ registryService.shutdown();
+ started = false;
Review Comment:
Thanks, fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]