public KeyValueIterator<AvroStreamKey, AvroStream> getAllStreams(){ return view.all(); } }
songsStore = streams.store(KafkaMusicExample.ALL_SONGS, QueryableStoreTypes.<Long, Song>keyValueStore()); return songsStore.all().hasNext(); } catch (Exception e) { return false;
songsStore = streams.store(KafkaMusicExample.ALL_SONGS, QueryableStoreTypes.<Long, Song>keyValueStore()); return songsStore.all().hasNext(); } catch (Exception e) { return false;
KeyValueIterator<String, String> keyValueIterator = readOnlyKeyValueStore.all(); assertThat(keyValueIterator).containsExactlyElementsOf(expectedResultsForJoinStateStore);
@Override public KeyValueIterator<K, V> apply(final ReadOnlyKeyValueStore<K, V> store) { try { return store.all(); } catch (final InvalidStateStoreException e) { throw new InvalidStateStoreException("State store is not available anymore and may have been migrated to another instance; please re-discover its location from the state metadata."); } } };
@Override Supplier<List<DependencyLink>> query() { return () -> { try { ReadOnlyKeyValueStore<String, DependencyLink> store = kafkaStreams.store(storeName, QueryableStoreTypes.keyValueStore()); List<DependencyLink> dependencyLinks = new ArrayList<>(); store.all().forEachRemaining(dependencyLink -> dependencyLinks.add(dependencyLink.value)); return dependencyLinks; } catch (Exception e) { LOG.error("Error looking up for dependencies", e); return new ArrayList<>(); } }; }
@Override public Map<String, OpennmsModelProtos.Alarm> getAlarms() { final Map<String, OpennmsModelProtos.Alarm> alarmsByReductionKey = new LinkedHashMap<>(); getAlarmTableNow().all().forEachRemaining(kv -> { try { alarmsByReductionKey.put(kv.key, kv.value != null ? OpennmsModelProtos.Alarm.parseFrom(kv.value) : null); } catch (InvalidProtocolBufferException e) { LOG.error("Failed to parse alarm for bytes at reduction key '{}'. Alarm will be empty in map.", kv.key); alarmsByReductionKey.put(kv.key, null); } }); return alarmsByReductionKey; }
@Override public Map<ClusterKey, ClusterValue> getAllClusters() { Map<ClusterKey, ClusterValue> clusterKeyValueMap = new HashMap<>(); try (KeyValueIterator<ClusterKey, ClusterValue> clusterKeyValueIterator = store.all()) { log.debug("Approximate Num. of Entries in Infra Table-{}", store.approximateNumEntries()); while (clusterKeyValueIterator.hasNext()) { KeyValue<ClusterKey, ClusterValue> next = clusterKeyValueIterator.next(); clusterKeyValueMap.put(next.key, next.value); } } catch (Exception e) { throw new IllegalStateException("Infra Manager State Store not initialized ", e); } return clusterKeyValueMap; }
@Override public Map<String, OpennmsModelProtos.Alarm> getAlarms() { final Map<String, OpennmsModelProtos.Alarm> alarmsByReductionKey = new LinkedHashMap<>(); getAlarmTableNow().all().forEachRemaining(kv -> { try { alarmsByReductionKey.put(kv.key, kv.value != null ? OpennmsModelProtos.Alarm.parseFrom(kv.value) : null); } catch (InvalidProtocolBufferException e) { LOG.error("Failed to parse alarm for bytes at reduction key '{}'. Alarm will be empty in map.", kv.key); alarmsByReductionKey.put(kv.key, null); } }); return alarmsByReductionKey; }
@Override Supplier<List<String>> query() { return () -> { try { ReadOnlyKeyValueStore<String, Set<String>> store = kafkaStreams.store(storeName, QueryableStoreTypes.keyValueStore()); List<String> keys = new ArrayList<>(); store.all().forEachRemaining(keyValue -> keys.add(keyValue.key)); return keys; } catch (Exception e) { LOG.error("Error looking up services", e); return new ArrayList<>(); } }; }
@Override public Iterable<KeyValue<K, VV>> result() { return () -> streams.store(solutionSetStore, QueryableStoreTypes.<K, VV>keyValueStore()).all(); }
public static <K, V> List<KeyValue<K, V>> listFromStore(KafkaStreams streams, String storeName) { final ReadOnlyKeyValueStore<K, V> store = streams.store( storeName, QueryableStoreTypes.keyValueStore()); final KeyValueIterator<K, V> all = store.all(); List<KeyValue<K, V>> result = new ArrayList<>(); while (all.hasNext()) { result.add(all.next()); } return result; }
public static <K, V> Map<K, V> mapFromStore(KafkaStreams streams, String storeName) { final ReadOnlyKeyValueStore<K, V> store = streams.store( storeName, QueryableStoreTypes.keyValueStore()); final KeyValueIterator<K, V> all = store.all(); Map<K, V> result = new HashMap<>(); while (all.hasNext()) { KeyValue<K, V> next = all.next(); result.put(next.key, next.value); } return result; } }
KeyValueIterator<Integer, String> iterator = store.all(); iterator.forEachRemaining(kv -> { ObjectNode node = JsonNodeFactory.instance.objectNode();