@Test public void getNotFound() { assertNull(registrationCache.getHandlerForCommand(Topology.DEFAULT_CONTEXT, Command.newBuilder().setName("command3").build(), "command1")); }
public CommandHandler getHandlerForCommand(String context, Command request, String routingKey) { String command = request.getName(); Set<ClientStreamIdentification> candidates = getCandidates(request); if (candidates.isEmpty()) { return null; } if (candidates.size() == 1) { return commandHandlersPerClientContext.get(candidates.iterator().next()); } Set<String> candidateNames = candidates.stream().map(ClientStreamIdentification::getClientStreamId).collect( Collectors .toSet()); RoutingSelector<String> routingSelector = routingSelector(context, command); return routingSelector .selectHandler(routingKey, candidateNames) .map(client -> commandHandlersPerClientContext.get(new ClientStreamIdentification(context, client))) .orElse(null); }
CommandRegistrationCache { public CommandHandler getHandlerForCommand(String context, Command request, String routingKey) { String command = request.getName(); Set<ClientStreamIdentification> candidates = getCandidates(request); if (candidates.isEmpty()) { return null; } if (candidates.size() == 1) { return commandHandlersPerClientContext.get(candidates.iterator().next()); } Set<String> candidateNames = candidates.stream().map(ClientStreamIdentification::getClientStreamId).collect( Collectors .toSet()); RoutingSelector<String> routingSelector = routingSelector(context, command); return routingSelector .selectHandler(routingKey, candidateNames) .map(client -> commandHandlersPerClientContext.get(new ClientStreamIdentification(context, client))) .orElse(null); } }
CommandRegistrationCache { public CommandHandler getHandlerForCommand(String context, Command request, String routingKey) { String command = request.getName(); Set<ClientStreamIdentification> candidates = getCandidates(request); if (candidates.isEmpty()) { return null; } if (candidates.size() == 1) { return commandHandlersPerClientContext.get(candidates.iterator().next()); } Set<String> candidateNames = candidates.stream().map(ClientStreamIdentification::getClientStreamId).collect( Collectors .toSet()); RoutingSelector<String> routingSelector = routingSelector(context, command); return routingSelector .selectHandler(routingKey, candidateNames) .map(client -> commandHandlersPerClientContext.get(new ClientStreamIdentification(context, client))) .orElse(null); } @Autowired  CommandRegistrationCache(
            BiFunction<Map<String, MetaDataValue>, Set<ClientStreamIdentification>, Set<ClientStreamIdentification>> metaDataBasedNodeSelector);  CommandRegistrationCache();  CommandRegistrationCache(Function<CommandTypeIdentifier, RoutingSelector<String>> selectorFactory);  CommandRegistrationCache(Function<CommandTypeIdentifier, RoutingSelector<String>> selectorFactory,
                                    BiFunction<Map<String, MetaDataValue>, Set<ClientStreamIdentification>, Set<ClientStreamIdentification>> metaDataBasedNodeSelector); }
CommandRegistrationCache { public CommandHandler getHandlerForCommand(String context, Command request, String routingKey) { String command = request.getName(); Set<ClientStreamIdentification> candidates = getCandidates(request); if (candidates.isEmpty()) { return null; } if (candidates.size() == 1) { return commandHandlersPerClientContext.get(candidates.iterator().next()); } Set<String> candidateNames = candidates.stream().map(ClientStreamIdentification::getClientStreamId).collect( Collectors .toSet()); RoutingSelector<String> routingSelector = routingSelector(context, command); return routingSelector .selectHandler(routingKey, candidateNames) .map(client -> commandHandlersPerClientContext.get(new ClientStreamIdentification(context, client))) .orElse(null); } @Autowired  CommandRegistrationCache(
            BiFunction<Map<String, MetaDataValue>, Set<ClientStreamIdentification>, Set<ClientStreamIdentification>> metaDataBasedNodeSelector);  CommandRegistrationCache();  CommandRegistrationCache(Function<CommandTypeIdentifier, RoutingSelector<String>> selectorFactory);  CommandRegistrationCache(Function<CommandTypeIdentifier, RoutingSelector<String>> selectorFactory,
                                    BiFunction<Map<String, MetaDataValue>, Set<ClientStreamIdentification>, Set<ClientStreamIdentification>> metaDataBasedNodeSelector); void remove(ClientStreamIdentification client); void remove(ClientStreamIdentification client, String command); void add(String command, CommandHandler commandHandler); Map<CommandHandler, Set<RegistrationEntry>> getAll(); Set<String> getCommandsFor(ClientStreamIdentification clientNode); CommandHandler getHandlerForCommand(String context, Command request, String routingKey); CommandHandler findByClientAndCommand(ClientStreamIdentification clientIdentification, String request); @EventListener void on(SubscribeCommand event); @EventListener void on(UnsubscribeCommand event); }
CommandRegistrationCache { public CommandHandler getHandlerForCommand(String context, Command request, String routingKey) { String command = request.getName(); Set<ClientStreamIdentification> candidates = getCandidates(request); if (candidates.isEmpty()) { return null; } if (candidates.size() == 1) { return commandHandlersPerClientContext.get(candidates.iterator().next()); } Set<String> candidateNames = candidates.stream().map(ClientStreamIdentification::getClientStreamId).collect( Collectors .toSet()); RoutingSelector<String> routingSelector = routingSelector(context, command); return routingSelector .selectHandler(routingKey, candidateNames) .map(client -> commandHandlersPerClientContext.get(new ClientStreamIdentification(context, client))) .orElse(null); } @Autowired  CommandRegistrationCache(
            BiFunction<Map<String, MetaDataValue>, Set<ClientStreamIdentification>, Set<ClientStreamIdentification>> metaDataBasedNodeSelector);  CommandRegistrationCache();  CommandRegistrationCache(Function<CommandTypeIdentifier, RoutingSelector<String>> selectorFactory);  CommandRegistrationCache(Function<CommandTypeIdentifier, RoutingSelector<String>> selectorFactory,
                                    BiFunction<Map<String, MetaDataValue>, Set<ClientStreamIdentification>, Set<ClientStreamIdentification>> metaDataBasedNodeSelector); void remove(ClientStreamIdentification client); void remove(ClientStreamIdentification client, String command); void add(String command, CommandHandler commandHandler); Map<CommandHandler, Set<RegistrationEntry>> getAll(); Set<String> getCommandsFor(ClientStreamIdentification clientNode); CommandHandler getHandlerForCommand(String context, Command request, String routingKey); CommandHandler findByClientAndCommand(ClientStreamIdentification clientIdentification, String request); @EventListener void on(SubscribeCommand event); @EventListener void on(UnsubscribeCommand event);  }