added logs

This commit is contained in:
Lucio Lelii 2022-07-14 11:56:32 +02:00
parent e5c0b8a23d
commit 4b75535a9d
3 changed files with 17 additions and 8 deletions

View File

@ -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() {

View File

@ -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.

View File

@ -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);
}
/**