/*
   * (non-Javadoc)
   *
   * @see org.apache.bookkeeper.mledger.ManagedLedger#openCursor(java.
   * lang.String)
   */
  @Override
  public synchronized ManagedCursor openCursor(String cursorName)
      throws InterruptedException, ManagedLedgerException {
    checkFenced();

    ManagedCursor cursor = cursors.get(cursorName);

    if (cursor == null) {
      // Create a new one and persist it
      Position position = new Position(currentLedger.getId(), currentLedger.getLastAddConfirmed());

      cursor = new ManagedCursorImpl(this, cursorName, position);
      store.updateConsumer(name, cursorName, position);
      cursors.add(cursor);
    }

    log.debug("[{}] Opened new cursor: {}", this.name, cursor);
    return cursor;
  }