refactor: consolidate heartbeat findById into single lookup
Merge the route state update and route catalog upsert blocks to share one registryService.findById() call instead of two, reducing overhead on the high-frequency heartbeat path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -257,24 +257,20 @@ public class AgentRegistrationController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request != null && request.getRouteStates() != null && !request.getRouteStates().isEmpty()) {
|
if (routeIds != null && !routeIds.isEmpty()) {
|
||||||
AgentInfo agent = registryService.findById(id);
|
AgentInfo agent = registryService.findById(id);
|
||||||
if (agent != null) {
|
if (agent != null) {
|
||||||
for (var entry : request.getRouteStates().entrySet()) {
|
// Update route states from heartbeat
|
||||||
RouteStateRegistry.RouteState state = parseRouteState(entry.getValue());
|
if (request != null && request.getRouteStates() != null) {
|
||||||
if (state != null) {
|
for (var entry : request.getRouteStates().entrySet()) {
|
||||||
routeStateRegistry.setState(agent.applicationId(), entry.getKey(), state);
|
RouteStateRegistry.RouteState state = parseRouteState(entry.getValue());
|
||||||
|
if (state != null) {
|
||||||
|
routeStateRegistry.setState(agent.applicationId(), entry.getKey(), state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// Persist routes in catalog for server-restart recovery
|
||||||
}
|
routeCatalogStore.upsert(agent.applicationId(), agent.environmentId(), routeIds);
|
||||||
|
|
||||||
// Persist routes in catalog for server-restart recovery
|
|
||||||
if (routeIds != null && !routeIds.isEmpty()) {
|
|
||||||
AgentInfo agentForCatalog = registryService.findById(id);
|
|
||||||
if (agentForCatalog != null) {
|
|
||||||
String catalogEnv = agentForCatalog.environmentId();
|
|
||||||
routeCatalogStore.upsert(agentForCatalog.applicationId(), catalogEnv, routeIds);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user