if (syn.getReturnCode() != MSException.Code.OK.getCode()) {
throw new IOException("Failed to get topics : ", MSException.create(
MSException.Code.get(syn.getReturnCode()), ""));
}
final MetastoreCursor cursor = syn.getValue();
return new Iterator<ByteString>() {
Iterator<MetastoreTableItem> itemIter = null;
@Override
public boolean hasNext() {
while (null == itemIter || !itemIter.hasNext()) {
if (!cursor.hasMoreEntries()) {
return false;
}
try {
itemIter = cursor.readEntries(cfg.getMetastoreMaxEntriesPerScan());
} catch (MSException mse) {
logger.warn("Interrupted when iterating the topics list : ", mse);
return false;
}
}