-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-14595 Move ReassignPartitionsCommand to java #13247
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
Changes from 7 commits
ffe57e5
e875075
ca8dc2a
634d185
28ae6bb
857e499
cd4095d
4ae392c
30be4ee
d2bd8ac
de2e660
25bd213
fa4b0b0
0ea3552
4924947
86ec361
780d906
22a1382
804d08e
948958f
737aa69
13f8125
724c0d3
6be819c
7c056c9
5c7dc12
fe06e63
93ca02a
a7ad316
26c76fc
741e578
568f662
794b57c
e567030
ac1705a
21cca4f
20bc620
30aa8d8
d80dc69
145dd4c
4053c8a
996e30b
cf43956
dcb8b2b
2d76eca
62205b4
3b6d212
97fb3f4
1372fcb
928ba42
1bbd0c3
b3c20a8
07e1204
290133d
97319a3
c6d1275
9877ef7
cffd681
79c4f6f
840fa62
fcfb95e
d5a33fb
6929eeb
7ce33f7
420af78
7d22f15
bbd2f4c
b8e4c29
25eae9a
11dd1ae
17726a5
8700c05
08e8795
5a40d88
dfde62a
2dd787e
95e69a2
6d5e2ba
cfc8597
aa149f2
208ac6a
68a0301
11fc0bb
7cf703c
23d3d00
d8e50ab
7175901
d9ca29f
be82fbc
c2e2356
d4b30c1
70ddeeb
c90a6da
5282f60
6fe1aa0
f66fb6f
85c441d
f40b5a5
ceaf2bf
48363ef
b604480
369e888
89eb550
f26a02e
24a69fb
53e767a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You 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, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.kafka.tools.reassign; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * A replica log directory move state where the move is in progress. | ||
| */ | ||
| public final class ActiveMoveState implements LogDirMoveState { | ||
| private final String currentLogDir; | ||
|
|
||
| private final String targetLogDir; | ||
|
|
||
| private final String futureLogDir; | ||
|
|
||
| /** | ||
| * @param currentLogDir The current log directory. | ||
| * @param futureLogDir The log directory that the replica is moving to. | ||
| * @param targetLogDir The log directory that we wanted the replica to move to. | ||
| */ | ||
| public ActiveMoveState(String currentLogDir, String targetLogDir, String futureLogDir) { | ||
| this.currentLogDir = currentLogDir; | ||
| this.targetLogDir = targetLogDir; | ||
| this.futureLogDir = futureLogDir; | ||
| } | ||
|
|
||
| public String currentLogDir() { | ||
| return currentLogDir; | ||
| } | ||
|
|
||
| public String targetLogDir() { | ||
| return targetLogDir; | ||
| } | ||
|
|
||
| public String futureLogDir() { | ||
| return futureLogDir; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean done() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) return true; | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| ActiveMoveState that = (ActiveMoveState) o; | ||
| return Objects.equals(currentLogDir, that.currentLogDir) && Objects.equals(targetLogDir, that.targetLogDir) && Objects.equals(futureLogDir, that.futureLogDir); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to override
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. scala case classes generated Anyway, I removed them. We can implement them when we want. |
||
| return Objects.hash(currentLogDir, targetLogDir, futureLogDir); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "ActiveMoveState{" + | ||
| "currentLogDir='" + currentLogDir + '\'' + | ||
| ", targetLogDir='" + targetLogDir + '\'' + | ||
| ", futureLogDir='" + futureLogDir + '\'' + | ||
| '}'; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You 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, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.kafka.tools.reassign; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * A replica log directory move state where there is no move in progress, but we did not | ||
| * reach the target log directory. | ||
| */ | ||
| public final class CancelledMoveState implements LogDirMoveState { | ||
| private final String currentLogDir; | ||
|
|
||
| private final String targetLogDir; | ||
|
|
||
| /** | ||
| * @param currentLogDir The current log directory. | ||
| * @param targetLogDir The log directory that we wanted the replica to move to. | ||
| */ | ||
| public CancelledMoveState(String currentLogDir, String targetLogDir) { | ||
| this.currentLogDir = currentLogDir; | ||
| this.targetLogDir = targetLogDir; | ||
| } | ||
|
|
||
| public String currentLogDir() { | ||
| return currentLogDir; | ||
| } | ||
|
|
||
| public String targetLogDir() { | ||
| return targetLogDir; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean done() { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) return true; | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| CancelledMoveState that = (CancelledMoveState) o; | ||
| return Objects.equals(currentLogDir, that.currentLogDir) && Objects.equals(targetLogDir, that.targetLogDir); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(currentLogDir, targetLogDir); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "CancelledMoveState{" + | ||
| "currentLogDir='" + currentLogDir + '\'' + | ||
| ", targetLogDir='" + targetLogDir + '\'' + | ||
| '}'; | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're missing a new line here
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You 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, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.kafka.tools.reassign; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * The completed replica log directory move state. | ||
| */ | ||
| public final class CompletedMoveState implements LogDirMoveState { | ||
| private final String targetLogDir; | ||
|
|
||
| /** | ||
| * @param targetLogDir The log directory that we wanted the replica to move to. | ||
| */ | ||
| public CompletedMoveState(String targetLogDir) { | ||
| this.targetLogDir = targetLogDir; | ||
| } | ||
|
|
||
| public String targetLogDir() { | ||
| return targetLogDir; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean done() { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) return true; | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| CompletedMoveState that = (CompletedMoveState) o; | ||
| return Objects.equals(targetLogDir, that.targetLogDir); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(targetLogDir); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "CompletedMoveState{" + | ||
| "targetLogDir='" + targetLogDir + '\'' + | ||
| '}'; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You 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, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.kafka.tools.reassign; | ||
|
|
||
| /** | ||
| * The state of a replica log directory movement. | ||
| */ | ||
| public interface LogDirMoveState { | ||
| /** | ||
| * True if the move is done without errors. | ||
| */ | ||
| boolean done(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You 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, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.kafka.tools.reassign; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * A replica log directory move state where the source replica is missing. | ||
| */ | ||
| public final class MissingLogDirMoveState implements LogDirMoveState { | ||
| private final String targetLogDir; | ||
|
|
||
| /** | ||
| * @param targetLogDir The log directory that we wanted the replica to move to. | ||
| */ | ||
| public MissingLogDirMoveState(String targetLogDir) { | ||
| this.targetLogDir = targetLogDir; | ||
| } | ||
|
|
||
| public String targetLogDir() { | ||
| return targetLogDir; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean done() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) return true; | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| MissingLogDirMoveState that = (MissingLogDirMoveState) o; | ||
| return Objects.equals(targetLogDir, that.targetLogDir); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(targetLogDir); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "MissingLogDirMoveState{" + | ||
| "targetLogDir='" + targetLogDir + '\'' + | ||
| '}'; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You 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, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.kafka.tools.reassign; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * A replica log directory move state where the source log directory is missing. | ||
| */ | ||
| public final class MissingReplicaMoveState implements LogDirMoveState { | ||
| private final String targetLogDir; | ||
|
|
||
| /** | ||
| * @param targetLogDir The log directory that we wanted the replica to move to. | ||
| */ | ||
| public MissingReplicaMoveState(String targetLogDir) { | ||
| this.targetLogDir = targetLogDir; | ||
| } | ||
|
|
||
| public String targetLogDir() { | ||
| return targetLogDir; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean done() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) return true; | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| MissingReplicaMoveState that = (MissingReplicaMoveState) o; | ||
| return Objects.equals(targetLogDir, that.targetLogDir); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(targetLogDir); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "MissingReplicaMoveState{" + | ||
| "targetLogDir='" + targetLogDir + '\'' + | ||
| '}'; | ||
| } | ||
| } |
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.
These classes are extremely verbose. I wonder if we could make the
finalfields public and get rid of all the setters.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.
Done