Search in sources :

Example 1 with SortedStorage

use of io.datarouter.storage.node.op.raw.SortedStorage 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;
}
Also used : SortedStorage(io.datarouter.storage.node.op.raw.SortedStorage) OptionalDouble(java.util.OptionalDouble) LoggerFactory(org.slf4j.LoggerFactory) PhysicalNode(io.datarouter.storage.node.type.physical.PhysicalNode) PhysicalDatabeanFieldInfo(io.datarouter.storage.serialize.fieldcache.PhysicalDatabeanFieldInfo) PhysicalMapStorageNode(io.datarouter.storage.node.op.raw.MapStorage.PhysicalMapStorageNode) Deque(java.util.Deque) Singleton(javax.inject.Singleton) ServerName(io.datarouter.storage.config.properties.ServerName) Function(java.util.function.Function) ServiceName(io.datarouter.web.config.service.ServiceName) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Map(java.util.Map) ClientId(io.datarouter.storage.client.ClientId) StreamTool(io.datarouter.util.StreamTool) Config(io.datarouter.storage.config.Config) DatarouterNodes(io.datarouter.storage.node.DatarouterNodes) DatarouterClients(io.datarouter.storage.client.DatarouterClients) DatarouterWebSettingRoot(io.datarouter.web.config.DatarouterWebSettingRoot) Logger(org.slf4j.Logger) DatarouterClientAvailabilitySwitchThresholdSettingsProvider(io.datarouter.storage.config.setting.impl.DatarouterClientAvailabilitySwitchThresholdSettingsProvider) Gauges(io.datarouter.storage.metric.Gauges) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Counters(io.datarouter.instrumentation.count.Counters) SortedStorage(io.datarouter.storage.node.op.raw.SortedStorage) DatarouterDuration(io.datarouter.util.duration.DatarouterDuration) Collectors(java.util.stream.Collectors) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque) PrimaryKey(io.datarouter.model.key.primary.PrimaryKey) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) ClientInitializationTracker(io.datarouter.storage.client.ClientInitializationTracker) Stream(java.util.stream.Stream) TreeMap(java.util.TreeMap) Entry(java.util.Map.Entry) Optional(java.util.Optional) Pair(io.datarouter.util.tuple.Pair) Collections(java.util.Collections) PhysicalMapStorageNode(io.datarouter.storage.node.op.raw.MapStorage.PhysicalMapStorageNode) ArrayList(java.util.ArrayList) ClientId(io.datarouter.storage.client.ClientId) Stream(java.util.stream.Stream) PhysicalNode(io.datarouter.storage.node.type.physical.PhysicalNode)

Aggregations

Counters (io.datarouter.instrumentation.count.Counters)1 PrimaryKey (io.datarouter.model.key.primary.PrimaryKey)1 ClientId (io.datarouter.storage.client.ClientId)1 ClientInitializationTracker (io.datarouter.storage.client.ClientInitializationTracker)1 DatarouterClients (io.datarouter.storage.client.DatarouterClients)1 Config (io.datarouter.storage.config.Config)1 ServerName (io.datarouter.storage.config.properties.ServerName)1 DatarouterClientAvailabilitySwitchThresholdSettingsProvider (io.datarouter.storage.config.setting.impl.DatarouterClientAvailabilitySwitchThresholdSettingsProvider)1 Gauges (io.datarouter.storage.metric.Gauges)1 DatarouterNodes (io.datarouter.storage.node.DatarouterNodes)1 PhysicalMapStorageNode (io.datarouter.storage.node.op.raw.MapStorage.PhysicalMapStorageNode)1 SortedStorage (io.datarouter.storage.node.op.raw.SortedStorage)1 PhysicalNode (io.datarouter.storage.node.type.physical.PhysicalNode)1 PhysicalDatabeanFieldInfo (io.datarouter.storage.serialize.fieldcache.PhysicalDatabeanFieldInfo)1 StreamTool (io.datarouter.util.StreamTool)1 DatarouterDuration (io.datarouter.util.duration.DatarouterDuration)1 Pair (io.datarouter.util.tuple.Pair)1 DatarouterWebSettingRoot (io.datarouter.web.config.DatarouterWebSettingRoot)1 ServiceName (io.datarouter.web.config.service.ServiceName)1 ArrayList (java.util.ArrayList)1