HDFS-15347. Replace the deprecated method shaHex. Contributed by bianqi.

This commit is contained in:
Ayush Saxena 2020-05-10 00:11:46 +05:30
parent c784ba370e
commit cb64e993c2
6 changed files with 10 additions and 10 deletions

View File

@ -399,7 +399,7 @@ private NodePlan verifyPlanHash(String planID, String plan)
if ((planID == null) || if ((planID == null) ||
(planID.length() != sha1Length) || (planID.length() != sha1Length) ||
!DigestUtils.shaHex(plan.getBytes(Charset.forName("UTF-8"))) !DigestUtils.sha1Hex(plan.getBytes(Charset.forName("UTF-8")))
.equalsIgnoreCase(planID)) { .equalsIgnoreCase(planID)) {
LOG.error("Disk Balancer - Invalid plan hash."); LOG.error("Disk Balancer - Invalid plan hash.");
throw new DiskBalancerException("Invalid or mis-matched hash.", throw new DiskBalancerException("Invalid or mis-matched hash.",

View File

@ -94,7 +94,7 @@ private void cancelPlan(String planData) throws IOException {
String dataNodeAddress = plan.getNodeName() + ":" + plan.getPort(); String dataNodeAddress = plan.getNodeName() + ":" + plan.getPort();
Preconditions.checkNotNull(dataNodeAddress); Preconditions.checkNotNull(dataNodeAddress);
ClientDatanodeProtocol dataNode = getDataNodeProxy(dataNodeAddress); ClientDatanodeProtocol dataNode = getDataNodeProxy(dataNodeAddress);
String planHash = DigestUtils.shaHex(planData); String planHash = DigestUtils.sha1Hex(planData);
try { try {
dataNode.cancelDiskBalancePlan(planHash); dataNode.cancelDiskBalancePlan(planHash);
} catch (DiskBalancerException ex) { } catch (DiskBalancerException ex) {

View File

@ -99,7 +99,7 @@ private void submitPlan(final String planFile, final String planData,
String dataNodeAddress = plan.getNodeName() + ":" + plan.getPort(); String dataNodeAddress = plan.getNodeName() + ":" + plan.getPort();
Preconditions.checkNotNull(dataNodeAddress); Preconditions.checkNotNull(dataNodeAddress);
ClientDatanodeProtocol dataNode = getDataNodeProxy(dataNodeAddress); ClientDatanodeProtocol dataNode = getDataNodeProxy(dataNodeAddress);
String planHash = DigestUtils.shaHex(planData); String planHash = DigestUtils.sha1Hex(planData);
try { try {
dataNode.submitDiskBalancerPlan(planHash, DiskBalancerCLI.PLAN_VERSION, dataNode.submitDiskBalancerPlan(planHash, DiskBalancerCLI.PLAN_VERSION,
planFile, planData, skipDateCheck); planFile, planData, skipDateCheck);

View File

@ -642,7 +642,7 @@ public void executePlan(NodePlan plan) throws
node = cluster.getDataNodes().get(dataNodeIndex); node = cluster.getDataNodes().get(dataNodeIndex);
String planJson = plan.toJson(); String planJson = plan.toJson();
String planID = DigestUtils.shaHex(planJson); String planID = DigestUtils.sha1Hex(planJson);
// Submit the plan and wait till the execution is done. // Submit the plan and wait till the execution is done.
node.submitDiskBalancerPlan(planID, 1, PLAN_FILE, planJson, node.submitDiskBalancerPlan(planID, 1, PLAN_FILE, planJson,
@ -740,7 +740,7 @@ public void run() {
reconfigThread.start(); reconfigThread.start();
String planJson = plan.toJson(); String planJson = plan.toJson();
String planID = DigestUtils.shaHex(planJson); String planID = DigestUtils.sha1Hex(planJson);
diskBalancer.submitPlan(planID, 1, PLAN_FILE, planJson, false); diskBalancer.submitPlan(planID, 1, PLAN_FILE, planJson, false);
GenericTestUtils.waitFor(new Supplier<Boolean>() { GenericTestUtils.waitFor(new Supplier<Boolean>() {

View File

@ -317,7 +317,7 @@ public RpcTestHelper invoke() throws Exception {
plan = new NodePlan(node.getDataNodeName(), node.getDataNodePort()); plan = new NodePlan(node.getDataNodeName(), node.getDataNodePort());
planner.balanceVolumeSet(node, node.getVolumeSets().get("DISK"), plan); planner.balanceVolumeSet(node, node.getVolumeSets().get("DISK"), plan);
planVersion = 1; planVersion = 1;
planHash = DigestUtils.shaHex(plan.toJson()); planHash = DigestUtils.sha1Hex(plan.toJson());
return this; return this;
} }
} }

View File

@ -126,7 +126,7 @@ public void testDiskBalancerEnabled() throws DiskBalancerException {
private void executeSubmitPlan(NodePlan plan, DiskBalancer balancer, private void executeSubmitPlan(NodePlan plan, DiskBalancer balancer,
int version) throws IOException { int version) throws IOException {
String planJson = plan.toJson(); String planJson = plan.toJson();
String planID = DigestUtils.shaHex(planJson); String planID = DigestUtils.sha1Hex(planJson);
balancer.submitPlan(planID, version, PLAN_FILE, planJson, false); balancer.submitPlan(planID, version, PLAN_FILE, planJson, false);
} }
@ -215,7 +215,7 @@ public void testSubmitWithNullPlan() throws Exception {
NodePlan plan = mockMoverHelper.getPlan(); NodePlan plan = mockMoverHelper.getPlan();
DiskBalancer balancer = mockMoverHelper.getBalancer(); DiskBalancer balancer = mockMoverHelper.getBalancer();
String planJson = plan.toJson(); String planJson = plan.toJson();
String planID = DigestUtils.shaHex(planJson); String planID = DigestUtils.sha1Hex(planJson);
thrown.expect(DiskBalancerException.class); thrown.expect(DiskBalancerException.class);
thrown.expect(new DiskBalancerResultVerifier(DiskBalancerException thrown.expect(new DiskBalancerResultVerifier(DiskBalancerException
@ -232,7 +232,7 @@ public void testSubmitWithInvalidHash() throws Exception {
String planJson = plan.toJson(); String planJson = plan.toJson();
String planID = DigestUtils.shaHex(planJson); String planID = DigestUtils.sha1Hex(planJson);
char repChar = planID.charAt(0); char repChar = planID.charAt(0);
repChar++; repChar++;
@ -262,7 +262,7 @@ public void testCancelDiskBalancerPlan() throws Exception {
String planJson = plan.toJson(); String planJson = plan.toJson();
String planID = DigestUtils.shaHex(planJson); String planID = DigestUtils.sha1Hex(planJson);
balancer.cancelPlan(planID); balancer.cancelPlan(planID);
DiskBalancerWorkStatus status = balancer.queryWorkStatus(); DiskBalancerWorkStatus status = balancer.queryWorkStatus();