refactor(diagrams): retire findContentHashForRouteByAgents
All production callers migrated to findLatestContentHashForAppRoute in the preceding commits. The agent-scoped lookup adds no coverage beyond the latest-per-(app,env,route) resolver, so the dead API is removed along with its test coverage and unused imports. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,8 +16,6 @@ import java.security.MessageDigest;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HexFormat;
|
import java.util.HexFormat;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -203,36 +201,6 @@ public class ClickHouseDiagramStore implements DiagramStore {
|
|||||||
return Optional.of(hash);
|
return Optional.of(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<String> findContentHashForRouteByAgents(String routeId, List<String> agentIds) {
|
|
||||||
if (agentIds == null || agentIds.isEmpty()) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try cache first — return first hit
|
|
||||||
for (String agentId : agentIds) {
|
|
||||||
String cached = hashCache.get(cacheKey(routeId, agentId));
|
|
||||||
if (cached != null) {
|
|
||||||
return Optional.of(cached);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fall back to ClickHouse
|
|
||||||
String placeholders = String.join(", ", Collections.nCopies(agentIds.size(), "?"));
|
|
||||||
String sql = "SELECT content_hash FROM route_diagrams " +
|
|
||||||
"WHERE tenant_id = ? AND route_id = ? AND instance_id IN (" + placeholders + ") " +
|
|
||||||
"ORDER BY created_at DESC LIMIT 1";
|
|
||||||
var params = new ArrayList<Object>();
|
|
||||||
params.add(tenantId);
|
|
||||||
params.add(routeId);
|
|
||||||
params.addAll(agentIds);
|
|
||||||
List<Map<String, Object>> rows = jdbc.queryForList(sql, params.toArray());
|
|
||||||
if (rows.isEmpty()) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
return Optional.of((String) rows.get(0).get("content_hash"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<String> findLatestContentHashForAppRoute(String applicationId,
|
public Optional<String> findLatestContentHashForAppRoute(String applicationId,
|
||||||
String routeId,
|
String routeId,
|
||||||
|
|||||||
@@ -154,24 +154,6 @@ class ClickHouseDiagramStoreIT {
|
|||||||
assertThat(retrieved.getDescription()).isEqualTo("v2");
|
assertThat(retrieved.getDescription()).isEqualTo("v2");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void findContentHashForRouteByAgents_returnsHash() {
|
|
||||||
RouteGraph graph = buildGraph("route-4", "node-z");
|
|
||||||
store.store(tagged("agent-10", "app-b", graph));
|
|
||||||
store.store(tagged("agent-20", "app-b", graph));
|
|
||||||
|
|
||||||
Optional<String> result = store.findContentHashForRouteByAgents(
|
|
||||||
"route-4", java.util.List.of("agent-10", "agent-20"));
|
|
||||||
|
|
||||||
assertThat(result).isPresent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void findContentHashForRouteByAgents_emptyListReturnsEmpty() {
|
|
||||||
Optional<String> result = store.findContentHashForRouteByAgents("route-x", java.util.List.of());
|
|
||||||
assertThat(result).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void findProcessorRouteMapping_extractsMapping() {
|
void findProcessorRouteMapping_extractsMapping() {
|
||||||
// Build a graph with 3 nodes: root + 2 children
|
// Build a graph with 3 nodes: root + 2 children
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.cameleer.server.core.storage;
|
|||||||
import com.cameleer.common.graph.RouteGraph;
|
import com.cameleer.common.graph.RouteGraph;
|
||||||
import com.cameleer.server.core.ingestion.TaggedDiagram;
|
import com.cameleer.server.core.ingestion.TaggedDiagram;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -15,16 +14,13 @@ public interface DiagramStore {
|
|||||||
|
|
||||||
Optional<String> findContentHashForRoute(String routeId, String instanceId);
|
Optional<String> findContentHashForRoute(String routeId, String instanceId);
|
||||||
|
|
||||||
Optional<String> findContentHashForRouteByAgents(String routeId, List<String> instanceIds);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the most recently stored {@code content_hash} for the given
|
* Return the most recently stored {@code content_hash} for the given
|
||||||
* {@code (applicationId, environment, routeId)} triple, regardless of the
|
* {@code (applicationId, environment, routeId)} triple, regardless of the
|
||||||
* agent instance that produced it.
|
* agent instance that produced it.
|
||||||
*
|
*
|
||||||
* <p>Unlike {@link #findContentHashForRoute(String, String)} and
|
* <p>Unlike {@link #findContentHashForRoute(String, String)}, this lookup
|
||||||
* {@link #findContentHashForRouteByAgents(String, List)}, this lookup is
|
* is independent of the agent registry — so it keeps working for routes
|
||||||
* independent of the agent registry — so it keeps working for routes
|
|
||||||
* whose publishing agents have since been redeployed or removed.
|
* whose publishing agents have since been redeployed or removed.
|
||||||
*/
|
*/
|
||||||
Optional<String> findLatestContentHashForAppRoute(String applicationId,
|
Optional<String> findLatestContentHashForAppRoute(String applicationId,
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ class ChunkAccumulatorTest {
|
|||||||
public void store(com.cameleer.server.core.ingestion.TaggedDiagram d) {}
|
public void store(com.cameleer.server.core.ingestion.TaggedDiagram d) {}
|
||||||
public Optional<com.cameleer.common.graph.RouteGraph> findByContentHash(String h) { return Optional.empty(); }
|
public Optional<com.cameleer.common.graph.RouteGraph> findByContentHash(String h) { return Optional.empty(); }
|
||||||
public Optional<String> findContentHashForRoute(String r, String a) { return Optional.empty(); }
|
public Optional<String> findContentHashForRoute(String r, String a) { return Optional.empty(); }
|
||||||
public Optional<String> findContentHashForRouteByAgents(String r, List<String> a) { return Optional.empty(); }
|
|
||||||
public Optional<String> findLatestContentHashForAppRoute(String app, String r, String env) { return Optional.empty(); }
|
public Optional<String> findLatestContentHashForAppRoute(String app, String r, String env) { return Optional.empty(); }
|
||||||
public Map<String, String> findProcessorRouteMapping(String app, String env) { return Map.of(); }
|
public Map<String, String> findProcessorRouteMapping(String app, String env) { return Map.of(); }
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user