Skip to content

Commit

Permalink
[JBPM-10184] Build templates optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Fanjul committed Feb 22, 2024
1 parent a518726 commit 15c3513
Showing 1 changed file with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,26 +245,36 @@ public void onServerInstanceDisconnected(@Observes ServerInstanceDisconnected se
public void onServerInstanceConnected(@Observes ServerInstanceConnected serverInstanceConnected) {
ServerInstance serverInstance = serverInstanceConnected.getServerInstance();

serverTemplatesClients.computeIfPresent(serverInstance.getServerTemplateId(),
(serverTemplateId, clients) -> {
clients.forEach((key, client) -> {
// update regular clients
updateOrBuildClient(client,
serverInstance);

logger.debug("KieServerClient load balancer updated for server template {}",
serverTemplateId.equals(SERVER_TEMPLATE_KEY) ? serverInstance.getServerTemplateId() : serverTemplateId);
});
return clients;
});

serverInstancesById.put(serverInstance.getServerInstanceId(),
serverInstance);
ServerInstanceKey serverInstanceKey = serverInstancesById.computeIfAbsent(serverInstance.getServerInstanceId(),s -> {
logger.debug("Server {} connected!", serverInstance);

serverTemplatesClients.computeIfPresent(serverInstance.getServerTemplateId(),
(serverTemplateId, clients) -> {
clients.forEach((key, client) -> {
// update regular clients
updateOrBuildClient(client,
serverInstance);

logger.debug("KieServerClient load balancer updated for server template {}",
serverTemplateId.equals(SERVER_TEMPLATE_KEY) ? serverInstance.getServerTemplateId() : serverTemplateId);
});
return clients;
});

serverInstancesById.put(serverInstance.getServerInstanceId(),
serverInstance);

KieServicesClient adminClient = adminClients.get(serverInstance.getServerTemplateId());
// update admin clients
updateOrBuildClient(adminClient,
serverInstance);
return serverInstance;
});
if (serverInstance != serverInstanceKey) {
// If Server is already connected do not proceed with Artifacts Build
logger.debug("Server {} already registered. Skipping build of containers", serverInstance);
}

KieServicesClient adminClient = adminClients.get(serverInstance.getServerTemplateId());
// update admin clients
updateOrBuildClient(adminClient,
serverInstance);
// once all steps are completed successfully notify other parts interested so the serverClient can actually be used
serverInstanceRegisteredEvent.fire(new ServerInstanceRegistered(serverInstanceConnected.getServerInstance()));
}
Expand Down

0 comments on commit 15c3513

Please sign in to comment.