Skip to content

Commit 2cb0772

Browse files
Update the fix based on PR #10542.
1 parent cc80116 commit 2cb0772

19 files changed

Lines changed: 98 additions & 632 deletions

File tree

hadoop-hdds/cli-common/src/main/java/org/apache/hadoop/hdds/cli/DeprecatedCliOption.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
import java.util.Objects;
2424

2525
/**
26-
* Emits warnings when deprecated CLI option aliases are used.
26+
* Emits warnings when deprecated CLI option aliases are used
27+
* and return the recommended replacement option.
2728
*/
2829
public final class DeprecatedCliOption {
2930

hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/ContainerBalancerStartSubcommand.java

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -55,49 +55,25 @@ public class ContainerBalancerStartSubcommand extends ScmSubcommand {
5555
"'20' for 20%%).")
5656
private Optional<Integer> maxDatanodesPercentageToInvolvePerIteration;
5757

58-
/** For backward compatibility. */
59-
@Deprecated
60-
@SuppressWarnings("DeprecatedIsStillUsed")
61-
@Option(names = "--maxDatanodesPercentageToInvolvePerIteration", hidden = true)
62-
private Optional<Integer> deprecatedMaxDatanodesPercentage;
63-
6458
@Option(names = {"-s", "--max-size-to-move-per-iteration-in-gb"},
6559
description = "Maximum size that can be moved per iteration of " +
6660
"balancing. The value should be positive, with a default of 500 " +
6761
"(specify '500' for 500GB).")
6862
private Optional<Long> maxSizeToMovePerIterationInGB;
6963

70-
/** For backward compatibility. */
71-
@Deprecated
72-
@SuppressWarnings("DeprecatedIsStillUsed")
73-
@Option(names = "--maxSizeToMovePerIterationInGB", hidden = true)
74-
private Optional<Long> deprecatedMaxSizeToMovePerIterationInGB;
75-
7664
@Option(names = {"-e", "--max-size-entering-target-in-gb"},
7765
description = "Maximum size that can enter a target datanode while " +
7866
"balancing. This is the sum of data from multiple sources. The value " +
7967
"should be positive, with a default of 26 (specify '26' for 26GB).")
8068
private Optional<Long> maxSizeEnteringTargetInGB;
8169

82-
/** For backward compatibility. */
83-
@Deprecated
84-
@SuppressWarnings("DeprecatedIsStillUsed")
85-
@Option(names = "--maxSizeEnteringTargetInGB", hidden = true)
86-
private Optional<Long> deprecatedMaxSizeEnteringTargetInGB;
87-
8870
@Option(names = {"-l", "--max-size-leaving-source-in-gb"},
8971
description = "Maximum size that can leave a source datanode while " +
9072
"balancing. This is the sum of data moving to multiple targets. " +
9173
"The value should be positive, with a default of 26 " +
9274
"(specify '26' for 26GB).")
9375
private Optional<Long> maxSizeLeavingSourceInGB;
9476

95-
/** For backward compatibility. */
96-
@Deprecated
97-
@SuppressWarnings("DeprecatedIsStillUsed")
98-
@Option(names = "--maxSizeLeavingSourceInGB", hidden = true)
99-
private Optional<Long> deprecatedMaxSizeLeavingSourceInGB;
100-
10177
@Option(names = {"--balancing-iteration-interval-minutes"},
10278
description = "The interval period in minutes between each iteration of Container Balancer. " +
10379
"The value should be positive, with a default of 70 (specify '70' for 70 minutes).")
@@ -154,43 +130,13 @@ public class ContainerBalancerStartSubcommand extends ScmSubcommand {
154130
"(specify \"1,2,3\" for container IDs).")
155131
private Optional<String> includeContainers;
156132

157-
private Optional<Integer> resolveMaxDatanodesPercentageToInvolvePerIteration() {
158-
if (maxDatanodesPercentageToInvolvePerIteration != null
159-
&& maxDatanodesPercentageToInvolvePerIteration.isPresent()) {
160-
return maxDatanodesPercentageToInvolvePerIteration;
161-
}
162-
return deprecatedMaxDatanodesPercentage;
163-
}
164-
165-
private Optional<Long> resolveMaxSizeToMovePerIterationInGB() {
166-
if (maxSizeToMovePerIterationInGB != null
167-
&& maxSizeToMovePerIterationInGB.isPresent()) {
168-
return maxSizeToMovePerIterationInGB;
169-
}
170-
return deprecatedMaxSizeToMovePerIterationInGB;
171-
}
172-
173-
private Optional<Long> resolveMaxSizeEnteringTargetInGB() {
174-
if (maxSizeEnteringTargetInGB != null && maxSizeEnteringTargetInGB.isPresent()) {
175-
return maxSizeEnteringTargetInGB;
176-
}
177-
return deprecatedMaxSizeEnteringTargetInGB;
178-
}
179-
180-
private Optional<Long> resolveMaxSizeLeavingSourceInGB() {
181-
if (maxSizeLeavingSourceInGB != null && maxSizeLeavingSourceInGB.isPresent()) {
182-
return maxSizeLeavingSourceInGB;
183-
}
184-
return deprecatedMaxSizeLeavingSourceInGB;
185-
}
186-
187133
@Override
188134
public void execute(ScmClient scmClient) throws IOException {
189135
StartContainerBalancerResponseProto response = scmClient.
190136
startContainerBalancer(threshold, iterations,
191-
resolveMaxDatanodesPercentageToInvolvePerIteration(),
192-
resolveMaxSizeToMovePerIterationInGB(), resolveMaxSizeEnteringTargetInGB(),
193-
resolveMaxSizeLeavingSourceInGB(), balancingInterval, moveTimeout,
137+
maxDatanodesPercentageToInvolvePerIteration,
138+
maxSizeToMovePerIterationInGB, maxSizeEnteringTargetInGB,
139+
maxSizeLeavingSourceInGB, balancingInterval, moveTimeout,
194140
moveReplicationTimeout, networkTopologyEnable, includeNodes,
195141
excludeNodes, excludeContainers, includeContainers);
196142
if (response.getStart()) {

hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/CreatePipelineSubcommand.java

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -38,67 +38,35 @@ public class CreatePipelineSubcommand extends ScmSubcommand {
3838
@CommandLine.Option(
3939
names = {"-t", "--replication-type"},
4040
description = "Replication type is RATIS.",
41+
defaultValue = "RATIS",
4142
hidden = true
4243
)
4344
private HddsProtos.ReplicationType type;
4445

45-
/** For backward compatibility. */
46-
@Deprecated
47-
@SuppressWarnings("DeprecatedIsStillUsed")
48-
@CommandLine.Option(names = "--replicationType", hidden = true)
49-
private HddsProtos.ReplicationType deprecatedReplicationType;
50-
51-
@CommandLine.Option(
46+
@CommandLine.Option(
5247
names = {"-f", "--replication-factor"},
53-
description = "Replication factor for RATIS (ONE, THREE)."
48+
description = "Replication factor for RATIS (ONE, THREE).",
49+
defaultValue = "ONE"
5450
)
5551
private HddsProtos.ReplicationFactor factor;
5652

57-
/** For backward compatibility. */
58-
@Deprecated
59-
@SuppressWarnings("DeprecatedIsStillUsed")
60-
@CommandLine.Option(names = "--replicationFactor", hidden = true)
61-
private HddsProtos.ReplicationFactor deprecatedReplicationFactor;
62-
63-
private HddsProtos.ReplicationType getReplicationType() {
64-
if (type != null) {
65-
return type;
66-
}
67-
if (deprecatedReplicationType != null) {
68-
return deprecatedReplicationType;
69-
}
70-
return HddsProtos.ReplicationType.RATIS;
71-
}
72-
73-
private HddsProtos.ReplicationFactor getReplicationFactor() {
74-
if (factor != null) {
75-
return factor;
76-
}
77-
if (deprecatedReplicationFactor != null) {
78-
return deprecatedReplicationFactor;
79-
}
80-
return HddsProtos.ReplicationFactor.ONE;
81-
}
82-
8353
@Override
8454
public void execute(ScmClient scmClient) throws IOException {
85-
HddsProtos.ReplicationType resolvedType = getReplicationType();
86-
HddsProtos.ReplicationFactor resolvedFactor = getReplicationFactor();
8755
// Once we support creating EC containers/pipelines from the client, the
8856
// client should check if SCM is able to fulfil the request, and
8957
// understands an EcReplicationConfig. For that we also need to have SCM's
9058
// version here from ScmInfo response.
9159
// As I see there is no way to specify ECReplicationConfig properly here
9260
// so failing the request if type is EC, seems to be safe.
93-
if (resolvedType == HddsProtos.ReplicationType.CHAINED
94-
|| resolvedType == HddsProtos.ReplicationType.EC
95-
|| resolvedType == HddsProtos.ReplicationType.STAND_ALONE) {
96-
throw new IllegalArgumentException(resolvedType.name()
61+
if (type == HddsProtos.ReplicationType.CHAINED
62+
|| type == HddsProtos.ReplicationType.EC
63+
|| type == HddsProtos.ReplicationType.STAND_ALONE) {
64+
throw new IllegalArgumentException(type.name()
9765
+ " is not supported yet.");
9866
}
9967
Pipeline pipeline = scmClient.createReplicationPipeline(
100-
resolvedType,
101-
resolvedFactor,
68+
type,
69+
factor,
10270
HddsProtos.NodePool.getDefaultInstance());
10371

10472
if (pipeline != null) {

hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/ListPipelinesSubcommand.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ public void execute(ScmClient scmClient) throws IOException {
6363
if (replicationFilter.isPresent()) {
6464
stream = stream.filter(replicationFilter.get());
6565
}
66-
<<<<<<< HEAD
6766
if (!Strings.isNullOrEmpty(state)) {
68-
=======
69-
String effectiveState = getState();
70-
if (!Strings.isNullOrEmpty(effectiveState)) {
71-
>>>>>>> a71ff80348 (Remove conflicts and refactor the code to use DeprecatedCliOption class)
7267
stream = stream.filter(p -> p.getPipelineState().toString()
7368
.compareToIgnoreCase(state) == 0);
7469
}

hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/TransferOmLeaderSubCommand.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,15 @@ static class TransferOption {
4646
)
4747
private String omNodeId;
4848

49-
/** For backward compatibility. */
50-
@Deprecated
51-
@SuppressWarnings("DeprecatedIsStillUsed")
52-
@CommandLine.Option(names = "--newLeaderId", hidden = true)
53-
private String deprecatedOmNodeId;
54-
5549
@CommandLine.Option(names = {"-r", "--random"},
5650
description = "Randomly choose a follower to transfer leadership.")
5751
private boolean isRandom;
58-
59-
String getOmNodeId() {
60-
return omNodeId != null ? omNodeId : deprecatedOmNodeId;
61-
}
6252
}
6353

6454
@Override
6555
public Void call() throws Exception {
6656
if (configGroup.isRandom) {
6757
configGroup.omNodeId = "";
68-
} else {
69-
configGroup.omNodeId = configGroup.getOmNodeId();
7058
}
7159
try (OzoneManagerProtocol client = omServiceOption.newClient()) {
7260
client.transferLeadership(configGroup.omNodeId);

hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/scm/TransferScmLeaderSubCommand.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,9 @@ static class TransferOption {
5252
)
5353
private String scmId;
5454

55-
/** For backward compatibility. */
56-
@Deprecated
57-
@SuppressWarnings("DeprecatedIsStillUsed")
58-
@CommandLine.Option(names = "--newLeaderId", hidden = true)
59-
private String deprecatedScmId;
60-
6155
@CommandLine.Option(names = {"-r", "--random"},
6256
description = "Randomly choose a follower to transfer leadership.")
6357
private boolean isRandom;
64-
65-
String getScmId() {
66-
return scmId != null ? scmId : deprecatedScmId;
67-
}
6858
}
6959

7060
@Override
@@ -73,8 +63,6 @@ public Void call() throws Exception {
7363
parent.getParent().getOzoneConf());
7464
if (configGroup.isRandom) {
7565
configGroup.scmId = "";
76-
} else {
77-
configGroup.scmId = configGroup.getScmId();
7866
}
7967
client.transferLeadership(configGroup.scmId);
8068
System.out.println("Transfer leadership successfully to " +

hadoop-ozone/cli-debug/src/main/java/org/apache/hadoop/ozone/debug/ldb/DBScanner.java

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,13 @@ public class DBScanner extends AbstractSubcommand implements Callable<Void> {
9090

9191
private static final Logger LOG = LoggerFactory.getLogger(DBScanner.class);
9292
private static final String SCHEMA_V3 = "V3";
93-
private static final String DEFAULT_DN_DB_SCHEMA_VERSION = "V3";
9493

9594
@CommandLine.ParentCommand
9695
private RDBParser parent;
9796

98-
@CommandLine.ArgGroup(multiplicity = "1")
99-
private ColumnFamilyOption columnFamilyOption;
100-
97+
@CommandLine.Option(names = {"--column-family", "--cf"},
98+
required = true,
99+
description = "Table name")
101100
private String tableName;
102101

103102
@CommandLine.Option(names = {"--with-keys"},
@@ -139,15 +138,10 @@ public class DBScanner extends AbstractSubcommand implements Callable<Void> {
139138
private String filter;
140139

141140
@CommandLine.Option(names = {"--dn-schema", "-d"},
142-
description = "Datanode DB Schema Version: V1/V2/V3")
141+
description = "Datanode DB Schema Version: V1/V2/V3",
142+
defaultValue = "V3")
143143
private String dnDBSchemaVersion;
144144

145-
/** For backward compatibility. */
146-
@Deprecated
147-
@SuppressWarnings("DeprecatedIsStillUsed")
148-
@CommandLine.Option(names = "--dnSchema", hidden = true)
149-
private String deprecatedDnDBSchemaVersion;
150-
151145
@CommandLine.Option(names = {"--container-id", "--cid"},
152146
description = "Container ID. Applicable if datanode DB Schema is V3",
153147
defaultValue = "-1")
@@ -188,37 +182,8 @@ public class DBScanner extends AbstractSubcommand implements Callable<Void> {
188182
private static volatile boolean exception;
189183
private static final long FIRST_SEQUENCE_ID = 0L;
190184

191-
static class ColumnFamilyOption {
192-
@CommandLine.Option(names = {"--column-family", "--cf"},
193-
description = "Table name",
194-
required = true)
195-
private String tableName;
196-
197-
/** For backward compatibility. */
198-
@Deprecated
199-
@SuppressWarnings("DeprecatedIsStillUsed")
200-
@CommandLine.Option(names = "--column_family", hidden = true, required = true)
201-
private String deprecatedTableName;
202-
203-
String getTableName() {
204-
return tableName != null ? tableName : deprecatedTableName;
205-
}
206-
}
207-
208-
private String getDnDBSchemaVersion() {
209-
if (dnDBSchemaVersion != null) {
210-
return dnDBSchemaVersion;
211-
}
212-
if (deprecatedDnDBSchemaVersion != null) {
213-
return deprecatedDnDBSchemaVersion;
214-
}
215-
return DEFAULT_DN_DB_SCHEMA_VERSION;
216-
}
217-
218185
@Override
219186
public Void call() throws Exception {
220-
tableName = columnFamilyOption.getTableName();
221-
dnDBSchemaVersion = getDnDBSchemaVersion();
222187
fileSuffix = 0;
223188
globalCount = 0;
224189
List<ColumnFamilyDescriptor> cfDescList =

0 commit comments

Comments
 (0)