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 Jul 25, 2023
1 parent dde5679 commit 4335208
Showing 1 changed file with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,30 +245,42 @@ 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);
if (serverInstancesById.containsKey(serverInstance.getServerInstanceId())) {
// If Server is already connected do not proceed with Artifacts Build
logger.info("Server {} already registered", serverInstance);
logger.info("Skipping build of containers");
}
else {
logger.info("Server {} connected!", serverInstance);

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

buildClientsForServer(serverInstance);

KieServicesClient adminClient = adminClients.get(serverInstance.getServerTemplateId());
// update admin clients
updateOrBuildClient(adminClient, 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()));
}

private void buildClientsForServer(final ServerInstance 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;
});
}

public List<Object> broadcastToKieServers(String serverTemplateId,
Function<KieServicesClient, Object> operation) {
List<Object> results = new ArrayList<>();
Expand Down

0 comments on commit 4335208

Please sign in to comment.