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

[tools] add cookie related commands #1794

Merged
merged 4 commits into from
Nov 9, 2018
Merged

Conversation

sijie
Copy link
Member

@sijie sijie commented Nov 7, 2018

Descriptions of the changes in this PR:

Motivation

In some use cases, you need cookie related tools to create/delete/update/get cookie when handling production issues.
Currently bookkeeper doesn't provide such commands.

Changes

Add cookie related commands

  • create
  • delete
  • get
  • update
  • generate

In order to uphold a high standard for quality for code contributions, Apache BookKeeper runs various precommit
checks for pull requests. A pull request can only be merged when it passes precommit checks. However running all
the precommit checks can take a long time, some trivial changes don't need to run all the precommit checks. You
can check following list to skip the tests that don't need to run for your pull request. Leave them unchecked if
you are not sure, committers will help you:

  • [skip bookkeeper-server bookie tests]: skip testing org.apache.bookkeeper.bookie in bookkeeper-server module.
  • [skip bookkeeper-server client tests]: skip testing org.apache.bookkeeper.client in bookkeeper-server module.
  • [skip bookkeeper-server replication tests]: skip testing org.apache.bookkeeper.replication in bookkeeper-server module.
  • [skip bookkeeper-server tls tests]: skip testing org.apache.bookkeeper.tls in bookkeeper-server module.
  • [skip bookkeeper-server remaining tests]: skip testing all other tests in bookkeeper-server module.
  • [skip integration tests]: skip docker based integration tests. if you make java code changes, you shouldn't skip integration tests.
  • [skip build java8]: skip build on java8. ONLY skip this when ONLY changing files under documentation under site.
  • [skip build java9]: skip build on java9. ONLY skip this when ONLY changing files under documentation under site.


Be sure to do all of the following to help us incorporate your contribution
quickly and easily:

If this PR is a BookKeeper Proposal (BP):

  • Make sure the PR title is formatted like:
    <BP-#>: Description of bookkeeper proposal
    e.g. BP-1: 64 bits ledger is support
  • Attach the master issue link in the description of this PR.
  • Attach the google doc link if the BP is written in Google Doc.

Otherwise:

  • Make sure the PR title is formatted like:
    <Issue #>: Description of pull request
    e.g. Issue 123: Description ...
  • Make sure tests pass via mvn clean apache-rat:check install spotbugs:check.
  • Replace <Issue #> in the title with the actual Issue number.

*Motivation*

In some use cases, you need cookie related tools to create/delete/update/get cookie when handling production issues.
Currently bookkeeper doesn't provide such commands.

*Changes*

Add cookie related commands

- create
- delete
- get
- update
- generate
@sijie
Copy link
Member Author

sijie commented Nov 7, 2018

first cut, still working on adding them to the old bookkeeper shell tool and tests for them.

@sijie
Copy link
Member Author

sijie commented Nov 7, 2018

example run of the commands:

$ bin/bkctl cookie create -cf ~/tmp/cookie1 127.0.0.1:4181
$ bin/bkctl cookie get 127.0.0.1:4181
Cookie for bookie '127.0.0.1:4181' is:
---
4
bookieHost: "127.0.0.1:4181"
journalDir: "data/bookie_3181"
ledgerDirs: "data/bookie_3181"
instanceId: "c8e1c213-fda2-4bb3-b136-66ae90cffaf9"

---
$ bin/bkctl cookie ^C27.0.0.1:4181
$ cp ~/tmp/cookie1 ~/tmp/cookie2
$ vim ~/tmp/cookie2
$ bin/bkctl cookie update -cf ~/tmp/cookie1 127.0.0.1:4181
$ bin/bkctl cookie get 127.0.0.1:4181
Cookie for bookie '127.0.0.1:4181' is:
---
4
bookieHost: "127.0.0.1:4181"
journalDir: "data/bookie_3181"
ledgerDirs: "data/bookie_3181"
instanceId: "c8e1c213-fda2-4bb3-b136-66ae90cffaf9"

---
$ bin/bkctl cookie update -cf ~/tmp/cookie2 127.0.0.1:4181
$ bin/bkctl cookie get 127.0.0.1:4181
Cookie for bookie '127.0.0.1:4181' is:
---
4
bookieHost: "127.0.0.1:4181"
journalDir: "data1/bookie_3181"
ledgerDirs: "data1/bookie_3181"

---
$ bin/bkctl cookie delete 127.0.0.1:4181
$ bin/bkctl cookie get 127.0.0.1:4181
Cookie not found for bookie '127.0.0.1:4181'
Failed to process cookie command 'get'
org.apache.bookkeeper.bookie.BookieException$CookieNotFoundException: 127.0.0.1:4181
	at org.apache.bookkeeper.discover.ZKRegistrationManager.readCookie(ZKRegistrationManager.java:350)
	at org.apache.bookkeeper.bookie.Cookie.readFromRegistrationManager(Cookie.java:335)
	at org.apache.bookkeeper.tools.cli.commands.cookie.GetCookieCommand.apply(GetCookieCommand.java:70)
	at org.apache.bookkeeper.tools.cli.commands.cookie.GetCookieCommand.apply(GetCookieCommand.java:38)
	at org.apache.bookkeeper.tools.cli.commands.cookie.CookieCommand.lambda$apply$0(CookieCommand.java:66)
	at org.apache.bookkeeper.meta.MetadataDrivers.lambda$runFunctionWithRegistrationManager$1(MetadataDrivers.java:398)
	at org.apache.bookkeeper.meta.MetadataDrivers.runFunctionWithMetadataBookieDriver(MetadataDrivers.java:373)
	at org.apache.bookkeeper.meta.MetadataDrivers.runFunctionWithRegistrationManager(MetadataDrivers.java:398)
	at org.apache.bookkeeper.tools.cli.commands.cookie.CookieCommand.apply(CookieCommand.java:64)
	at org.apache.bookkeeper.tools.common.BKCommand.apply(BKCommand.java:80)
	at org.apache.bookkeeper.tools.common.BKCommand.lambda$apply$0(BKCommand.java:48)
	at org.apache.bookkeeper.tools.framework.Cli.run(Cli.java:224)
	at org.apache.bookkeeper.tools.framework.Cli.runCli(Cli.java:244)
	at org.apache.bookkeeper.tools.common.BKCommand.apply(BKCommand.java:50)
	at org.apache.bookkeeper.tools.common.BKCommand.apply(BKCommand.java:38)
	at org.apache.bookkeeper.tools.framework.Cli.run(Cli.java:232)
	at org.apache.bookkeeper.tools.framework.Cli.runCli(Cli.java:244)
	at org.apache.bookkeeper.tools.framework.CliCommandGroup.apply(CliCommandGroup.java:68)
	at org.apache.bookkeeper.tools.framework.Cli.run(Cli.java:232)
	at org.apache.bookkeeper.tools.framework.Cli.runCli(Cli.java:244)
	at org.apache.bookkeeper.tools.cli.BKCtl.main(BKCtl.java:58)

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great.
I wonder if we can have this new feature on branch 4.8

@sijie sijie changed the title (WIP) [tools] add cookie related commands [tools] add cookie related commands Nov 8, 2018
Copy link
Contributor

@merlimat merlimat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice work

@sijie
Copy link
Member Author

sijie commented Nov 9, 2018

run integration tests

@sijie
Copy link
Member Author

sijie commented Nov 9, 2018

IGNORE IT CI

@sijie sijie merged commit e31e844 into apache:master Nov 9, 2018
sijie added a commit that referenced this pull request Nov 9, 2018
Descriptions of the changes in this PR:

*Motivation*

In some use cases, you need cookie related tools to create/delete/update/get cookie when handling production issues.
Currently bookkeeper doesn't provide such commands.

*Changes*

Add cookie related commands

- create
- delete
- get
- update
- generate

Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Jia Zhai <None>, Matteo Merli <mmerli@apache.org>

This closes #1794 from sijie/add_cookie_commands

(cherry picked from commit e31e844)
Signed-off-by: Sijie Guo <sijie@apache.org>
@sijie sijie deleted the add_cookie_commands branch November 9, 2018 05:52
jiazhai pushed a commit that referenced this pull request Oct 29, 2019
…nd setting

Descriptions of the changes in this PR:

### Motivation

In PR #1794 we brought in a way to generate a cookie from command line.
However during generation, we have to also encode the ledger dirs by default.

### Changes

Added encoding of ledger dir paths while setting the ledger dirs in a generated cookie in `GenerateCookieCommand.java`.
Tweaked existing test to include more than one ledger path for test coverage.

Master Issue: #2145 

Reviewers: Jia Zhai <zhaijia@apache.org>, Sijie Guo <None>, Enrico Olivelli <eolivelli@gmail.com>

This closes #2146 from Ghatage/community/2145, closes #2145 and squashes the following commits:

2de21f8 [Anup Ghatage] Fix checkstyle
4695675 [Anup Ghatage] Revert to handling encoding like in generateCookie(), Add another test
90d0213 [Anup Ghatage] Change GenerateCookieCommandTest's to encodeDirPaths while creating cookies
d8da515 [Anup Ghatage] Issue #2145: Make ledgerDirs in Cookie consistent across generating and setting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants