From 4b75535a9d31c03f8998b19dc5506a58e7818697 Mon Sep 17 00:00:00 2001 From: lucio Date: Thu, 14 Jul 2022 11:56:32 +0200 Subject: [PATCH] added logs --- .../lifecycle/ApplicationProfileManager.java | 7 +++++++ .../lifecycle/ContainerProfileManager.java | 4 +++- .../smartgears/managers/ContainerManager.java | 14 +++++++------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/gcube/smartgears/handlers/application/lifecycle/ApplicationProfileManager.java b/src/main/java/org/gcube/smartgears/handlers/application/lifecycle/ApplicationProfileManager.java index 683a4a9..5528d18 100644 --- a/src/main/java/org/gcube/smartgears/handlers/application/lifecycle/ApplicationProfileManager.java +++ b/src/main/java/org/gcube/smartgears/handlers/application/lifecycle/ApplicationProfileManager.java @@ -141,9 +141,14 @@ public class ApplicationProfileManager extends ApplicationLifecycleHandler { }); } + }); + + //registering ContextObserver in container HUB + context.container().events().subscribe(new Object() { @Observes(value = addToContext) void addTo(String scope) { + log.info("add_to_context event arrived in app {}", context.name()); for (Publisher publisher: publishers) try { log.debug("publishing application in context {}", scope); @@ -165,6 +170,7 @@ public class ApplicationProfileManager extends ApplicationLifecycleHandler { @Observes(value = removeFromContext) void removeFrom(String scope) { + log.info("remove_from_context event arrived in app {}", context.name()); for (Publisher publisher: publishers) try { log.debug("unpublishing application from scope {}", scope); @@ -183,6 +189,7 @@ public class ApplicationProfileManager extends ApplicationLifecycleHandler { } }); + } private void schedulePeriodicUpdates() { diff --git a/src/main/java/org/gcube/smartgears/handlers/container/lifecycle/ContainerProfileManager.java b/src/main/java/org/gcube/smartgears/handlers/container/lifecycle/ContainerProfileManager.java index c0eeb4d..80adbd9 100644 --- a/src/main/java/org/gcube/smartgears/handlers/container/lifecycle/ContainerProfileManager.java +++ b/src/main/java/org/gcube/smartgears/handlers/container/lifecycle/ContainerProfileManager.java @@ -131,6 +131,7 @@ public class ContainerProfileManager extends ContainerHandler { @Observes(value = addToContext) void addTo(String scope) { + log.info("add_to_context event arrived in container"); for (Publisher publisher: publishers) try { log.trace("publishing container within new scope"); @@ -152,6 +153,7 @@ public class ContainerProfileManager extends ContainerHandler { @Observes(value = removeFromContext) void removeFrom(String scope) { + log.info("remove_from_context event arrived in container"); for (Publisher publisher: publishers) try { log.trace("unpublishing container from context {}", scope); @@ -160,7 +162,7 @@ public class ContainerProfileManager extends ContainerHandler { }catch (Exception e) { - log.error("cannot add container to {} with publisher type {} (see details)",scope, publisher.getClass().getCanonicalName(), e); + log.error("cannot remove container from {} with publisher type {} (see details)",scope, publisher.getClass().getCanonicalName(), e); // since we've failed no published event is fired and profile // will not be stored. diff --git a/src/main/java/org/gcube/smartgears/managers/ContainerManager.java b/src/main/java/org/gcube/smartgears/managers/ContainerManager.java index 8e8bac4..4dc0bb3 100644 --- a/src/main/java/org/gcube/smartgears/managers/ContainerManager.java +++ b/src/main/java/org/gcube/smartgears/managers/ContainerManager.java @@ -18,6 +18,7 @@ import org.gcube.common.events.Observes.Kind; import org.gcube.smartgears.configuration.Mode; import org.gcube.smartgears.context.application.ApplicationContext; import org.gcube.smartgears.context.container.ContainerContext; +import org.gcube.smartgears.handlers.ProfileEvents; import org.gcube.smartgears.handlers.container.ContainerHandler; import org.gcube.smartgears.handlers.container.ContainerLifecycleEvent; import org.gcube.smartgears.handlers.container.ContainerPipeline; @@ -115,9 +116,7 @@ public class ContainerManager { } public void manage(ApplicationContext app) { - app.events().subscribe(this); - } @Observes(value={ApplicationLifecycle.failure,ApplicationLifecycle.stop},kind=Kind.critical) @@ -126,14 +125,15 @@ public class ContainerManager { } @Observes(value=ContextEvents.ADD_CONTEXT_TO_CONTAINER,kind=Kind.critical) - void addContext(String context) { - log.trace("adding context {} to container", context); - + void addContext(String scope) { + log.info("adding context {} event send", context); + context.events().fire(scope, ProfileEvents.addToContext); } @Observes(value=ContextEvents.REMOVE_CONTEXT_FROM_CONTAINER,kind=Kind.critical) - void removeContext(String context) { - log.trace("removing context {} from container", context); + void removeContext(String scope) { + log.info("removing context {} event send", context); + context.events().fire(scope, ProfileEvents.removeFromContext); } /**