use of io.datarouter.storage.node.op.raw.MapStorage.PhysicalMapStorageNode in project datarouter by hotpads.
the class LatencyMonitoringService method getClientChecks.
public List<LatencyCheck> getClientChecks() {
List<LatencyCheck> checks = new ArrayList<>();
if (MAKE_GET_CHECK) {
for (ClientId clientId : clientInitializationTracker.getInitializedClients()) {
Collection<PhysicalNode<?, ?, ?>> nodesForClient = nodes.getPhysicalNodesForClient(clientId.getName());
Optional<PhysicalNode<?, ?, ?>> findFirst = nodesForClient.stream().findFirst();
if (findFirst.isPresent()) {
PhysicalNode<?, ?, ?> node = findFirst.get();
if (node instanceof PhysicalMapStorageNode) {
PhysicalMapStorageNode<?, ?, ?> ms = (PhysicalMapStorageNode<?, ?, ?>) node;
checks.add(new DatarouterClientLatencyCheck(LatencyMonitoringService.DR_CLIENT_PREFIX + clientId + LatencyMonitoringService.MS_CHECK_SUFIX, makeGet(ms), clientId));
}
}
}
}
Function<ClientId, Stream<Pair<ClientId, SortedStorage<?, ?>>>> mapClientIdToFirstSortedStorageNode = clientId -> nodes.getPhysicalNodesForClient(clientId.getName()).stream().filter(node -> node instanceof SortedStorage).limit(1).map(SortedStorage.class::cast).peek(sortedStorage -> logger.info("selected SortedStorage {}", sortedStorage)).map(sortedStorage -> new Pair<>(clientId, sortedStorage));
checks.addAll(clientInitializationTracker.getInitializedClients().stream().filter(clientId -> clients.getClientManager(clientId).monitorLatency()).flatMap(mapClientIdToFirstSortedStorageNode).map(pair -> new DatarouterClientLatencyCheck(getCheckNameForDatarouterClient(pair.getLeft()), () -> pair.getRight().scanKeys(ONLY_FIRST).findFirst(), pair.getLeft())).collect(Collectors.toList()));
return checks;
}
Aggregations