This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 188
dmctl, scheduler: support manually transfer-source #1492
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1ac6076
dmctl, scheduler: support manually transfer-source
lance6716 69e4263
Merge branch 'master' into transfer-source
lance6716 7bb67a2
fix some comment
lance6716 fecce7f
add dmctl interface
lance6716 818f928
fix CI
lance6716 2561700
refine logic
lance6716 e12156d
fix CI
lance6716 e8f3da9
Merge branch 'master' into transfer-source
GMHDBJD 30f87fb
error when there's running task on that source
lance6716 78c66e4
Merge branch 'master' of https://github.com/pingcap/dm into transfer-…
lance6716 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright 2021 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package master | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"os" | ||
|
||
"github.com/pingcap/dm/dm/ctl/common" | ||
"github.com/pingcap/dm/dm/pb" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NewTransferSourceCmd creates a TransferSource command | ||
func NewTransferSourceCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "transfer-source <source-id> <worker-id>", | ||
Short: "Transfers a upstream MySQL/MariaDB source to a free worker.", | ||
RunE: transferSourceFunc, | ||
} | ||
return cmd | ||
} | ||
|
||
func transferSourceFunc(cmd *cobra.Command, _ []string) (err error) { | ||
if len(cmd.Flags().Args()) != 2 { | ||
cmd.SetOut(os.Stdout) | ||
common.PrintCmdUsage(cmd) | ||
err = errors.New("please check output to see error") | ||
return | ||
} | ||
|
||
sourceID := cmd.Flags().Arg(0) | ||
workerID := cmd.Flags().Arg(1) | ||
|
||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
|
||
resp := &pb.TransferSourceResponse{} | ||
err = common.SendRequest( | ||
ctx, | ||
"TransferSource", | ||
&pb.TransferSourceRequest{ | ||
Source: sourceID, | ||
Worker: workerID, | ||
}, | ||
&resp, | ||
) | ||
|
||
if err != nil { | ||
return | ||
} | ||
|
||
common.PrettyPrintResponse(resp) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any problem when the last worker doesn't stop its own source timely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete source bound can't handle it? If so, we may have the same problem when there is a network isolation between worker and master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
30f87fb