@Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final StreamsMetadata that = (StreamsMetadata) o; if (!hostInfo.equals(that.hostInfo)) return false; if (!stateStoreNames.equals(that.stateStoreNames)) return false; return topicPartitions.equals(that.topicPartitions); }
private void rebuildMetadata(final Map<HostInfo, Set<TopicPartition>> currentState) { allMetadata.clear(); if (currentState.isEmpty()) { return; } final Map<String, List<String>> stores = builder.stateStoreNameToSourceTopics(); for (final Map.Entry<HostInfo, Set<TopicPartition>> entry : currentState.entrySet()) { final HostInfo key = entry.getKey(); final Set<TopicPartition> partitionsForHost = new HashSet<>(entry.getValue()); final Set<String> storesOnHost = new HashSet<>(); for (final Map.Entry<String, List<String>> storeTopicEntry : stores.entrySet()) { final List<String> topicsForStore = storeTopicEntry.getValue(); if (hasPartitionsForAnyTopics(topicsForStore, partitionsForHost)) { storesOnHost.add(storeTopicEntry.getKey()); } } storesOnHost.addAll(globalStores); final StreamsMetadata metadata = new StreamsMetadata(key, storesOnHost, partitionsForHost); allMetadata.add(metadata); if (key.equals(thisHost)) { myMetadata = metadata; } } }
@RequestMapping("/charts/top-five") @SuppressWarnings("unchecked") public List<SongPlayCountBean> topFive(@RequestParam(value="genre") String genre) { HostInfo hostInfo = interactiveQueryService.getHostInfo(KafkaStreamsInteractiveQuerySample.TOP_FIVE_SONGS_STORE, KafkaStreamsInteractiveQuerySample.TOP_FIVE_KEY, new StringSerializer()); if (interactiveQueryService.getCurrentHostInfo().equals(hostInfo)) { logger.info("Top Five songs request served from same host: " + hostInfo); return topFiveSongs(KafkaStreamsInteractiveQuerySample.TOP_FIVE_KEY, KafkaStreamsInteractiveQuerySample.TOP_FIVE_SONGS_STORE); } else { //find the store from the proper instance. logger.info("Top Five songs request served from different host: " + hostInfo); RestTemplate restTemplate = new RestTemplate(); return restTemplate.postForObject( String.format("http://%s:%d/%s", hostInfo.host(), hostInfo.port(), "charts/top-five?genre=Punk"), "punk", List.class); } }
songPlayCount.getSongId(), new LongSerializer()); if (interactiveQueryService.getCurrentHostInfo().equals(hostInfo)) { logger.info("Song info request served from same host: " + hostInfo);