HDFS-13413. Ozone: ClusterId and DatanodeUuid should be marked mandatory fields in SCMRegisteredCmdResponseProto. Contributed by Shashikant Banerjee.
This commit is contained in:
parent
51459d4351
commit
d5a8e60256
|
@ -17,6 +17,8 @@
|
|||
package org.apache.hadoop.ozone.container.common.states.endpoint;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
|
||||
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
|
||||
|
@ -28,6 +30,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
|
@ -98,6 +101,11 @@ public final class RegisterEndpointTask implements
|
|||
SCMRegisteredCmdResponseProto response = rpcEndPoint.getEndPoint()
|
||||
.register(datanodeDetails.getProtoBufMessage(),
|
||||
conf.getStrings(ScmConfigKeys.OZONE_SCM_NAMES));
|
||||
Preconditions.checkState(UUID.fromString(response.getDatanodeUUID())
|
||||
.equals(datanodeDetails.getUuid()),
|
||||
"Unexpected datanode ID in the response.");
|
||||
Preconditions.checkState(!StringUtils.isBlank(response.getClusterID()),
|
||||
"Invalid cluster ID in the response.");
|
||||
if (response.hasHostname() && response.hasIpAddress()) {
|
||||
datanodeDetails.setHostName(response.getHostname());
|
||||
datanodeDetails.setIpAddress(response.getIpAddress());
|
||||
|
|
|
@ -162,13 +162,11 @@ public class RegisteredCommand extends
|
|||
Preconditions.checkNotNull(response);
|
||||
if (response.hasHostname() && response.hasIpAddress()) {
|
||||
return new RegisteredCommand(response.getErrorCode(),
|
||||
response.hasDatanodeUUID() ? response.getDatanodeUUID() : "",
|
||||
response.hasClusterID() ? response.getClusterID() : "",
|
||||
response.getDatanodeUUID(), response.getClusterID(),
|
||||
response.getHostname(), response.getIpAddress());
|
||||
} else {
|
||||
return new RegisteredCommand(response.getErrorCode(),
|
||||
response.hasDatanodeUUID() ? response.getDatanodeUUID() : "",
|
||||
response.hasClusterID() ? response.getClusterID() : "");
|
||||
response.getDatanodeUUID(), response.getClusterID());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -178,8 +178,8 @@ message SCMRegisteredCmdResponseProto {
|
|||
errorNodeNotPermitted = 2;
|
||||
}
|
||||
required ErrorCode errorCode = 2;
|
||||
optional string datanodeUUID = 3;
|
||||
optional string clusterID = 4;
|
||||
required string datanodeUUID = 3;
|
||||
required string clusterID = 4;
|
||||
optional SCMNodeAddressList addressList = 5;
|
||||
optional string hostname = 6;
|
||||
optional string ipAddress = 7;
|
||||
|
|
Loading…
Reference in New Issue