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

pdctl/command: add scheduler command #537

Merged
merged 3 commits into from Feb 23, 2017
Merged

Conversation

huachaohuang
Copy link
Contributor

@huachaohuang huachaohuang commented Feb 22, 2017

Add command to show, add and remove schedulers.
Close #492

» help scheduler
show schedulers

Usage:
  pdctl scheduler
  scheduler [command]

Available Commands:
  add         add a scheduler
  remove      remove a scheduler

» help scheduler add
add a scheduler

Usage:
  add [command]

Available Commands:
  evict-leader-scheduler   add a scheduler to evict leader from a store
  grant-leader-scheduler   add a scheduler to grant leader to a store
  shuffle-leader-scheduler add a scheduler to shuffle leaders between stores
  shuffle-region-scheduler add a scheduler to shuffle regions between stores

» help scheduler remove
remove a scheduler

Usage:
  pdctl scheduler remove <scheduler>

@ngaut
Copy link
Member

ngaut commented Feb 22, 2017

Well done!

@huachaohuang huachaohuang changed the base branch from master to huachao/shuffle-region February 22, 2017 08:15
@huachaohuang
Copy link
Contributor Author

PTAL @siddontang @disksing

_, err := doRequest(cmd, prefix, http.MethodDelete)
if err != nil {
fmt.Println(err)
return
Copy link
Contributor

Choose a reason for hiding this comment

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

No need return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's more consistent.

@@ -0,0 +1,158 @@
// Copyright 2016 PingCAP, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

2017

return
}

prefix := schedulersPrefix + "/" + args[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think path or uri would be a better variable name than prefix.

@disksing
Copy link
Contributor

LGTM

return
}
defer r.Body.Close()

Copy link
Contributor

Choose a reason for hiding this comment

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

should read all r.Body, I remember if not, the connection may be leak even close the body.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't find any resource about why I must read r.Body, any link?

Copy link
Contributor

Choose a reason for hiding this comment

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

because we can't know whether the body has data or not.

In most of the cases, PUT returns no body, but it is still valid that PUT returns body.

Copy link
Contributor

Choose a reason for hiding this comment

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

So the safest way here is to read body and discard it.

Copy link
Contributor

@siddontang siddontang left a comment

Choose a reason for hiding this comment

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

Rest LGTM

@huachaohuang huachaohuang changed the base branch from huachao/shuffle-region to master February 23, 2017 02:53
@huachaohuang huachaohuang merged commit 9cbfbe5 into master Feb 23, 2017
@huachaohuang huachaohuang deleted the huachao/scheduler-command branch February 23, 2017 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants