/** * Returns an iterator of {@link TopicMetadata} of all the topics including the ones that were deleted. * * @return {@link CloseableIterator} of {@link TopicMetadata} * @throws IOException if failed to scan topics */ public CloseableIterator<TopicMetadata> scanTopics() throws IOException { return scanTopics(null, null); }
/** * Returns an iterator of {@link TopicMetadata} of all the topics including the ones that were deleted. * * @return {@link CloseableIterator} of {@link TopicMetadata} * @throws IOException if failed to scan topics */ public CloseableIterator<TopicMetadata> scanTopics() throws IOException { return scanTopics(null, null); }
private List<TopicId> listTopics(@Nullable byte[] startKey, @Nullable byte[] stopKey) throws IOException { List<TopicId> topicList = new ArrayList<>(); try (CloseableIterator<TopicMetadata> iterator = scanTopics(startKey, stopKey)) { while (iterator.hasNext()) { TopicMetadata metadata = iterator.next(); if (metadata.exists()) { topicList.add(metadata.getTopicId()); } } } return topicList; }
private List<TopicId> listTopics(@Nullable byte[] startKey, @Nullable byte[] stopKey) throws IOException { List<TopicId> topicList = new ArrayList<>(); try (CloseableIterator<TopicMetadata> iterator = scanTopics(startKey, stopKey)) { while (iterator.hasNext()) { TopicMetadata metadata = iterator.next(); if (metadata.exists()) { topicList.add(metadata.getTopicId()); } } } return topicList; }
@Override public void run() { if (metadataTable == null || payloadTable == null || messageTable == null) { return; } long timeStamp = System.currentTimeMillis(); try (CloseableIterator<TopicMetadata> metadataIterator = metadataTable.scanTopics()) { while (metadataIterator.hasNext()) { TopicMetadata metadata = metadataIterator.next(); messageTable.pruneMessages(metadata, timeStamp); payloadTable.pruneMessages(metadata, timeStamp); } } catch (IOException ex) { LOG.debug("Unable to perform data cleanup in TMS LevelDB tables", ex); } } }
try (CloseableIterator<TopicMetadata> metadataIterator = metadataTable.scanTopics()) { while (metadataIterator.hasNext()) { TopicMetadata metadata = metadataIterator.next();
Assert.assertEquals(2, allTopics.size()); List<TopicMetadata> metadatas = new ArrayList<>(); Iterators.addAll(metadatas, table.scanTopics()); Assert.assertEquals(2, metadatas.size()); Iterators.addAll(metadatas, table.scanTopics()); Assert.assertEquals(2, metadatas.size()); Iterators.addAll(metadatas, table.scanTopics());