Fixing corner cases

This commit is contained in:
Luca Frosini 2022-06-09 16:17:31 +02:00
parent 615dcd90c8
commit 5947a095f8
2 changed files with 24 additions and 4 deletions

View File

@ -104,8 +104,6 @@ public class EServiceHandler extends ApplicationLifecycleHandler {
Set<UUID> startContextsUUID = new HashSet<>();
for (String token : startTokens) {
UUID contextUUID = ContextUtility.getContextUUID(token);
startContextsUUID.add(contextUUID);
if (create) {
ContextUtility.setContextFromToken(token);
eServiceManager = new EServiceManager(applicationContext);
@ -113,6 +111,7 @@ public class EServiceHandler extends ApplicationLifecycleHandler {
create = false;
} else {
try {
UUID contextUUID = ContextUtility.getContextUUID(token);
eServiceManager.addToContext(contextUUID);
} catch (Exception e) {
UUID uuid = UUID.fromString(applicationContext.id());
@ -121,6 +120,16 @@ public class EServiceHandler extends ApplicationLifecycleHandler {
throw e;
}
}
/*
* Do not move this code before having instantiated HostingNodeManager
* which in turn instantiate the ResourceRegistryPublisher
* which in turn initialize ContextCacheRenewal in ContextCache.
* Please note that to properly instantiate ResourceRegistryPublisher
* it is necessary having set a token.
*/
UUID contextUUID = ContextUtility.getContextUUID(token);
startContextsUUID.add(contextUUID);
}
Set<UUID> resourceContextsUUID = eServiceManager.getContextsUUID().keySet();

View File

@ -102,10 +102,10 @@ public class HostingNodeHandler extends ContainerHandler {
List<String> startTokens = containerContext.configuration().startTokens();
Set<UUID> startContextsUUID = new HashSet<>();
for (String token : startTokens) {
UUID contextUUID = ContextUtility.getContextUUID(token);
startContextsUUID.add(contextUUID);
if (create) {
ContextUtility.setContextFromToken(token);
hostingNodeManager = new HostingNodeManager(containerContext);
@ -113,6 +113,7 @@ public class HostingNodeHandler extends ContainerHandler {
create = false;
} else {
try {
UUID contextUUID = ContextUtility.getContextUUID(token);
hostingNodeManager.addToContext(contextUUID);
} catch (Exception e) {
UUID uuid = UUID.fromString(containerContext.id());
@ -121,6 +122,16 @@ public class HostingNodeHandler extends ContainerHandler {
throw e;
}
}
/*
* Do not move this code before having instantiated HostingNodeManager
* which in turn instantiate the ResourceRegistryPublisher
* which in turn initialize ContextCacheRenewal in ContextCache.
* Please note that to properly instantiate ResourceRegistryPublisher
* it is necessary having set a token.
*/
UUID contextUUID = ContextUtility.getContextUUID(token);
startContextsUUID.add(contextUUID);
}
Set<UUID> resourceContextsUUID = hostingNodeManager.getContextsUUID().keySet();