private void initializeCursors(final ManagedLedgerCallback<Void> callback) { log.debug("[{}] initializing cursors", name); store.getConsumers( name, new MetaStoreCallback<List<Pair<String, Position>>>() { public void operationComplete(List<Pair<String, Position>> result, Version v) { // Load existing cursors try { for (Pair<String, Position> pair : result) { log.debug("[{}] Loading cursor {}", name, pair); cursors.add(new ManagedCursorImpl(ManagedLedgerImpl.this, pair.first, pair.second)); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); callback.operationFailed(new ManagedLedgerException(e)); return; } catch (ManagedLedgerException e) { callback.operationFailed(e); return; } // Calculate total entries and size for (LedgerStat ls : ledgers.values()) { numberOfEntries.addAndGet(ls.getEntriesCount()); totalSize.addAndGet(ls.getSize()); } callback.operationComplete(null); } public void operationFailed(MetaStoreException e) { callback.operationFailed(new ManagedLedgerException(e)); } }); }