This document introduces BookKeeper HTTP endpoints, which can be used for BookKeeper administration. To use this feature, set httpServerEnabled to true in file conf/bk_server.conf.

All the endpoints

Currently all the HTTP endpoints could be divided into these 5 components:

  1. Heartbeat: heartbeat for a specific bookie.
  2. Config: doing the server configuration for a specific bookie.
  3. Ledger: HTTP endpoints related to ledgers.
  4. Bookie: HTTP endpoints related to bookies.
  5. AutoRecovery: HTTP endpoints related to auto recovery.

Heartbeat

Endpoint: /heartbeat

  • Method: GET
  • Description: Get heartbeat status for a specific bookie
  • Response:
CodeDescription
200Successful operation

Config

Endpoint: /api/v1/config/server_config

  1. Method: GET

    • Description: Get value of all configured values overridden on local server config
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
  2. Method: PUT

    • Description: Update a local server config
    • Parameters:

      NameTypeRequiredDescription
      configNameStringYesConfiguration name(key)
      configValueStringYesConfiguration value(value)
    • Body:

      1. {
      2. "configName1": "configValue1",
      3. "configName2": "configValue2"
      4. }
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found

Config

Endpoint: /metrics

  1. Method: GET

    • Description: Get all metrics by calling writeAllMetrics() of statsProvider internally
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found

Ledger

Endpoint: /api/v1/ledger/delete/?ledger_id=<ledger_id>

  1. Method: DELETE

    • Description: Delete a ledger.
    • Parameters:

      NameTypeRequiredDescription
      ledger_idLongYesledger id of the ledger.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found

Endpoint: /api/v1/ledger/list/?print_metadata=<metadata>

  1. Method: GET

    • Description: List all the ledgers.
    • Parameters:

      NameTypeRequiredDescription
      print_metadataBooleanNowhether print out metadata
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
    • Response Body format:

      1. {
      2. "ledgerId1": "ledgerMetadata1",
      3. "ledgerId2": "ledgerMetadata2",
      4. ...
      5. }

Endpoint: /api/v1/ledger/metadata/?ledger_id=<ledger_id>

  1. Method: GET

    • Description: Get the metadata of a ledger.
    • Parameters:

      NameTypeRequiredDescription
      ledger_idLongYesledger id of the ledger.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
    • Response Body format:

      1. {
      2. "ledgerId1": "ledgerMetadata1"
      3. }

Endpoint: /api/v1/ledger/read/?ledger_id=<ledger_id>&start_entry_id=<start_entry_id>&end_entry_id=<end_entry_id>

  1. Method: GET

    • Description: Read a range of entries from ledger.
    • Parameters:

      NameTypeRequiredDescription
      ledger_idLongYesledger id of the ledger.
      start_entry_idLongNostart entry id of read range.
      end_entry_idLongNoend entry id of read range.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
    • Response Body format:

      1. {
      2. "entryId1": "entry content 1",
      3. "entryId2": "entry content 2",
      4. ...
      5. }

Bookie

Endpoint: /api/v1/bookie/info

  1. Method: GET

    • Description: Get bookie info
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      501Not implemented
    • Body:

      1. {
      2. "freeSpace" : 0,
      3. "totalSpace" : 0
      4. }

Endpoint: /api/v1/bookie/list_bookies/?type=<type>&print_hostnames=<hostnames>

  1. Method: GET

    • Description: Get all the available bookies.
    • Parameters:

      NameTypeRequiredDescription
      typeStringYesvalue: “rw” or “ro” , list read-write/read-only bookies.
      print_hostnamesBooleanNowhether print hostname of bookies.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
    • Response Body format:

      1. {
      2. "bookieSocketAddress1": "hostname1",
      3. "bookieSocketAddress2": "hostname2",
      4. ...
      5. }

Endpoint: /api/v1/bookie/list_bookie_info

  1. Method: GET

    • Description: Get bookies disk usage info of this cluster.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
    • Response Body format:

      1. {
      2. "bookieAddress" : {free: xxx, total: xxx},
      3. "bookieAddress" : {free: xxx, total: xxx},
      4. ...
      5. "clusterInfo" : {total_free: xxx, total: xxx}
      6. }

Endpoint: /api/v1/bookie/last_log_mark

  1. Method: GET

    • Description: Get the last log marker.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
    • Response Body format:

      1. {
      2. JournalId1 : position1,
      3. JournalId2 : position2,
      4. ...
      5. }

Endpoint: /api/v1/bookie/list_disk_file/?file_type=<type>

  1. Method: GET

    • Description: Get all the files on disk of current bookie.
    • Parameters:

      NameTypeRequiredDescription
      typeStringNofile type: journal/entrylog/index.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
    • Response Body format:

      1. {
      2. "journal files" : "filename1 filename2 ...",
      3. "entrylog files" : "filename1 filename2...",
      4. "index files" : "filename1 filename2 ..."
      5. }

Endpoint: /api/v1/bookie/expand_storage

  1. Method: PUT

    • Description: Expand storage for a bookie.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found

Endpoint: /api/v1/bookie/gc

  1. Method: PUT

    • Description: trigger gc for this bookie.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
  2. Method: GET

    • Description: whether force triggered Garbage Collection is running or not for this bookie. true for is running.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
    • Body:

      1. {
      2. "is_in_force_gc" : "false"
      3. }

Endpoint: /api/v1/bookie/gc_details

  1. Method: GET

    • Description: get details of Garbage Collection Thread, like whether it is in compacting, last compaction time, compaction counter, etc.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
    • Body:

      1. [ {
      2. "forceCompacting" : false,
      3. "majorCompacting" : false,
      4. "minorCompacting" : false,
      5. "lastMajorCompactionTime" : 1544578144944,
      6. "lastMinorCompactionTime" : 1544578144944,
      7. "majorCompactionCounter" : 1,
      8. "minorCompactionCounter" : 0
      9. } ]

Endpoint: /api/v1/bookie/state

  1. Method: GET

    • Description: Exposes the current state of bookie
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
    • Body:

      1. {
      2. "running" : true,
      3. "readOnly" : false,
      4. "shuttingDown" : false,
      5. "availableForHighPriorityWrites" : true
      6. }

Endpoint: /api/v1/bookie/is_ready

  1. Method: GET

    • Description: Return true if the bookie is ready
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
      503Bookie is not ready
    • Body:

Auto recovery

Endpoint: /api/v1/autorecovery/bookie/

  1. Method: PUT

    • Description: Ledger data recovery for failed bookie
    • Body:

      1. {
      2. "bookie_src": [ "bookie_src1", "bookie_src2"... ],
      3. "bookie_dest": [ "bookie_dest1", "bookie_dest2"... ],
      4. "delete_cookie": <bool_value>
      5. }
    • Parameters:

      NameTypeRequiredDescription
      bookie_srcStringsYesbookie source to recovery
      bookie_destStringsNobookie data recovery destination
      delete_cookieBooleanNoWhether delete cookie
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found

Endpoint: /api/v1/autorecovery/list_under_replicated_ledger/?missingreplica=<bookie_address>&excludingmissingreplica=<bookie_address>

  1. Method: GET

    • Description: Get all under replicated ledgers.
    • Parameters:

      NameTypeRequiredDescription
      missingreplicaStringNomissing replica bookieId
      excludingmissingreplicaStringNoexclude missing replica bookieId
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
    • Response Body format:

      1. {
      2. [ledgerId1, ledgerId2...]
      3. }

Endpoint: /api/v1/autorecovery/who_is_auditor

  1. Method: GET

    • Description: Get auditor bookie id.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
    • Response Body format:

      1. {
      2. "Auditor": "hostname/hostAddress:Port"
      3. }

Endpoint: /api/v1/autorecovery/trigger_audit

  1. Method: PUT

    • Description: Force trigger audit by resting the lostBookieRecoveryDelay.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found

Endpoint: /api/v1/autorecovery/lost_bookie_recovery_delay

  1. Method: GET

    • Description: Get lostBookieRecoveryDelay value in seconds.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found
  2. Method: PUT

    • Description: Set lostBookieRecoveryDelay value in seconds.
    • Body:

      1. {
      2. "delay_seconds": <delay_seconds>
      3. }
    • Parameters:

      NameTypeRequiredDescription
      delay_secondsLongYesset delay value in seconds.
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found

Endpoint: /api/v1/autorecovery/decommission

  1. Method: PUT

    • Description: Decommission Bookie, Force trigger Audit task and make sure all the ledgers stored in the decommissioning bookie are replicated.
    • Body:

      1. {
      2. "bookie_src": <bookie_src>
      3. }
    • Parameters:

      NameTypeRequiredDescription
      bookie_srcStringYesBookie src to decommission..
    • Response:

      CodeDescription
      200Successful operation
      403Permission denied
      404Not found