Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BP-27: New BookKeeper CLI #1000

Closed
sijie opened this issue Jan 17, 2018 · 2 comments
Closed

BP-27: New BookKeeper CLI #1000

sijie opened this issue Jan 17, 2018 · 2 comments
Assignees
Milestone

Comments

@sijie
Copy link
Member

sijie commented Jan 17, 2018

BP

This is the master ticket for tracking BP-27:

BookieShell is becoming a gaint class to contain all the sub command. It is a good time to think about how to break this class down:

  • group the commands into categories, e.g. bookie, cluster, metadata.
  • break this class into smaller classes for different commands, and improve the testability
  • it is probably good to rethink using jcommander to implement this.

This BP proposes refactoring the bookkeeper commands in BookieShell in new CLI tool.

Proposal PR - #1093

@sijie sijie changed the title Break down bookie shell class BP-27: New BookKeeper CLI Jan 31, 2018
@sijie sijie self-assigned this Jan 31, 2018
jiazhai pushed a commit that referenced this issue Feb 2, 2018
Descriptions of the changes in this PR:

`BookieShell` is the current bookkeeper cli for interacting and operating a bookkeeper cluster. However, this class is getting bigger with more commands added to it. It is facing a few problems for maintenance and extensibility.

- All commands sit in one gaint shell class. It is hard to tell if a command is used for managing a bookie only or if a command is used for managing a cluster.
- Lack of unit tests. This class has very few test coverage. Most of the commands (introduced in early days) don't have a unit test.
- Lack of extensibility. If a new function component (for example, dlog) is introduced, it is a bit hard to extend this CLI to have commands for new function component.

All these problems lead to the proposal here. This proposal is to propose refactoring/redesigning the bookkeeper CLI to allow better managebility for maintenance, better test coverage and better extensibility for new function components.

Master Issue: #1000

Author: Sijie Guo <sijie@apache.org>

Reviewers: Ivan Kelly <ivank@apache.org>, Jia Zhai <None>

This closes #1093 from sijie/BP_27_new_bookkeeper_cli
sijie added a commit that referenced this issue Feb 16, 2018
Descriptions of the changes in this PR:

This is first implementation of BP-27 (#1000). This change includes:

- introduce a bookkeeper-tools module for keep the commands and also for developing the new CLI
- introduce 4 command groups: `cluster`, `bookie`, `client`, `metadata`.
- move 3 command: `listbookies` under `cluster` group, `lastmark` under `bookie` group, `simpletest` under `client` group.
- unit tests for those 3 command.

Author: Sijie Guo <sijie@apache.org>

Reviewers: Charan Reddy Guttapalem <reddycharan18@gmail.com>, Yiming Zang <yzang2016@gmail.com>

This closes #1094 from sijie/bookie_shell_refactor
sijie added a commit that referenced this issue Feb 27, 2018
Descriptions of the changes in this PR:

*Motivation*

since 4.7, we are shipping the binary distribution using bookkeeper-dist modules. so it is making more sense to have {bin,conf} directory at root module,
rather than bookkeeper-server module.

*Solution*

- move bookkeeper-server/bin to bin
- move bookkeeper-server/conf to conf
- update the new bookkeeper cli related files as "experimental"

This change is needed for integrating with dlog scripts for BP-26 and new bookkeeper cli for BP-27.

Master Issue: #1147

Related Issues:

- BP-26 #1024
- BP-27 #1000

Author: Sijie Guo <sijie@apache.org>

Reviewers: Ivan Kelly <ivank@apache.org>

This closes #1210 from sijie/move_bin_conf, closes #1147
@sijie sijie added this to the 4.7.0 milestone Mar 12, 2018
@jiazhai
Copy link
Member

jiazhai commented Mar 14, 2018

made a rough group based on the 4 groups: bookie, cluster, metadata, client.

## bookie
Done: lastmark

Todo:

- CMD_BOOKIEFORMAT
 // Formats the local data present in current bookie server.
class BookieFormatCmd extends MyCommand

- CMD_RECOVER
 // Recover command for ledger data recovery for failed bookie.
class RecoverCmd extends MyCommand

- CMD_READLOG
 // Command to read entry log files.
class ReadLogCmd extends MyCommand

- CMD_READLOGMETADATA
// Command to print metadata of entrylog.

class ReadLogMetadataCmd extends MyCommand

- CMD_READJOURNAL
// Command to read journal files.

class ReadJournalCmd extends MyCommand

- CMD_LISTFILESONDISC
List the files in JournalDirectory/LedgerDirectories/IndexDirectories
class ListDiskFilesCmd extends MyCommand

- CMD_DECOMMISSIONBOOKIE
// Command to trigger AuditTask by resetting lostBookieRecoveryDelay and then make sure the
// ledgers stored in the bookie are properly replicated.
class DecommissionBookieCmd extends MyCommand


## cluster
done: listBookies

Todo:
- CMD_BOOKIEINFO
// Command to retrieve bookie information like free disk space, etc from all the bookies in the cluster.
class BookieInfoCmd extends MyCommand

- CMD_INITNEWCLUSTER
// Intializes new cluster by creating required znodes for the cluster.
class InitNewCluster extends MyCommand

- CMD_NUKEEXISTINGCLUSTER
// Nuke bookkeeper metadata of existing cluster in zookeeper.
class NukeExistingCluster extends MyCommand {
}

- CMD_LEDGER
//  dump ledger index entries into readable format.
class LedgerCmd extends MyCommand {

- CMD_READ_LEDGER_ENTRIES
// Command for reading ledger entries.
class ReadLedgerEntriesCmd extends MyCommand {

- CMD_LISTLEDGERS
// Command to list all ledgers in the cluster.
class ListLedgersCmd extends MyCommand

- CMD_LEDGERMETADATA
// Print the metadata for a ledger.
class LedgerMetadataCmd extends MyCommand

-  CMD_LISTUNDERREPLICATED
// Command for listing underreplicated ledgers.
class ListUnderreplicatedCmd extends MyCommand

- CMD_WHATISINSTANCEID
// Prints the instanceid of the cluster.
class WhatIsInstanceId extends MyCommand

- CMD_AUTORECOVERY
// Command for administration of autorecovery.
// Enable or disable autorecovery in the cluster.
class AutoRecoveryCmd extends MyCommand

- CMD_TRIGGERAUDIT
// Command to trigger AuditTask by resetting lostBookieRecoveryDelay to its current value.
class TriggerAuditCmd extends MyCommand


## client
done: simpletest

TODO:
- CMD_BOOKIESANITYTEST
// Command to run a bookie sanity test.
class BookieSanityTestCmd extends MyCommand

- CMD_UPDATELEDGER
// Update bookie id in ledgers
class UpdateLedgerCmd extends MyCommand

- CMD_DELETELEDGER
// Command to delete a given ledger.
class DeleteLedgerCmd extends MyCommand


## metadata
Todo:
- CMD_METAFORMAT
// Format the bookkeeper metadata present in zookeeper.
class MetaFormatCmd extends MyCommand

- CMD_INITBOOKIE
// Initializes bookie, by making sure that the journalDir, ledgerDirs and
// indexDirs are empty and there is no registered Bookie with this BookieId.
class InitBookieCmd extends MyCommand

- CMD_WHOISAUDITOR
// Print which node has the auditor lock.
class WhoIsAuditorCmd extends MyCommand

- CMD_UPDATECOOKIE,
// Update cookie command.
class UpdateCookieCmd extends MyCommand

- CMD_LOSTBOOKIERECOVERYDELAY
// Setter and Getter for LostBookieRecoveryDelay value (in seconds) in Zookeeper.
class LostBookieRecoveryDelayCmd extends MyCommand

- CMD_CONVERT_TO_DB_STORAGE
// Convert bookie indexes from InterleavedStorage to DbLedgerStorage format.
class ConvertToDbStorageCmd extends MyCommand

- CMD_CONVERT_TO_INTERLEAVED_STORAGE
// Convert bookie indexes from DbLedgerStorage to InterleavedStorage format.
class ConvertToInterleavedStorageCmd extends MyCommand

- CMD_REBUILD_DB_LEDGER_LOCATIONS_INDEX
// Rebuild DbLedgerStorage locations index.
class RebuildDbLedgerLocationsIndexCmd extends MyCommand

@sijie sijie modified the milestones: 4.7.0, 4.8.0 Apr 10, 2018
sijie added a commit that referenced this issue Jun 4, 2018
…ther

Descriptions of the changes in this PR:

*Motivation*

There are multiple CLI tools spreading across multiple places, e.g. new bookkeeper cli, stream storage cli and dlog. There have similar implementations. It would be better to consolidate all these tools in one place `bookkeeper-tools`.

This is a PR to prepare moving `stream/cli` to be part of bookkeeper-tools.

*Solution*

- Abstract the CLI logic in bookkeeper-tools into a simple tools framework that can be reused in a extensible way to unify multiple tools together.
- organize the tools module into tools/framework and tools/all

*Result*

Example output of the tool using this framework is listed as below:

```
$ bin/bkctl
bkctl interacts and operates Apache BookKeeper clusters

Usage:  bkctl [flags] [command group] [commands]

Commands:

    bookie          Commands on operating a single bookie
    bookies         Commands on operating a cluster of bookies
    cluster         Commands on administrating bookkeeper clusters
    ledger          Commands on interacting with ledgers
    namespace       Commands on operating namespaces
    table           Commands on interacting with tables
    tables          Commands on operating tables

    help            Display help information about it

Flags:

    -c, --conf
        Configuration file

    -n, --namespace
        Namespace scope to run commands (only valid for table service for now)

    -u, --service-uri
        Service Uri

    -h, --help
        Display help information

Use "bkctl [command] --help" or "bkctl help [command]" for more information
about a command
```

*result from help sub-command*

```
$ bin/bkctl help table
Commands on interacting with tables

Usage:  bkctl table [command] [command options]

Commands:

    get         Get key/value pair from a table
    inc         Increment the amount of a key in a table
    put         Put key/value pair to a table

    help        Display help information about it

Use "bkctl table [command] --help" or "bkctl table help [command]" for more
information about a command
```

*result from help sub-sub-command*

```
$ bin/bkctl table help inc
Increment the amount of a key in a table

Usage:  bkctl table inc [flags] <table> <key> <amount>

Flags:

    -h, --help
        Display help information
```

Master Issue: #1000

Author: Sijie Guo <sijie@apache.org>

Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Jia Zhai <None>

This closes #1471 from sijie/tools_framework
@eolivelli eolivelli modified the milestones: 4.8.0, 4.9.0 Sep 6, 2018
@sijie sijie modified the milestones: 4.9.0, 4.10.0 Dec 27, 2018
@sijie
Copy link
Member Author

sijie commented Aug 18, 2019

All the bookkeeper CLI commands have been implemented in bkctl. Close it now.

@sijie sijie closed this as completed Aug 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants