@Override public long approximateNumEntries() { final List<ReadOnlyKeyValueStore<K, V>> stores = storeProvider.stores(storeName, storeType); long total = 0; for (final ReadOnlyKeyValueStore<K, V> store : stores) { total += store.approximateNumEntries(); if (total < 0) { return Long.MAX_VALUE; } } return total; }
@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 Optional<ClusterValue> getClusterByKey(ClusterKey clusterKey) { ClusterValue clusterValue; Validate.validState(store != null, "Infra Manager should be configured"); try { log.debug("Approximate Num. of Entries in Infra Table-{}", store.approximateNumEntries()); clusterValue = store.get(clusterKey); } catch (Exception e) { throw new IllegalStateException("Error while retrieving the cluster Value using cluster key:" + clusterKey, e); } if (clusterValue == null) { log.error("Cluster Not Found, key: {}", clusterKey); } else { log.info("Cluster Name - {}", clusterValue.getClusterProperties()); } return Optional.ofNullable(clusterValue); } }