Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
.classpath
.project
.settings
*.factorypath
target
build
dependency-reduced-pom.xml
Expand Down Expand Up @@ -61,5 +62,6 @@ output.xml
report.html

hadoop-hdds/docs/public
hadoop-ozone/recon/node_modules

.mvn
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class DatanodeDetails extends NodeImpl implements
private String hostName;
private List<Port> ports;
private String certSerialId;
private String version;
private long setupTime;

/**
* Constructs DatanodeDetails instance. DatanodeDetails.Builder is used
Expand All @@ -59,15 +61,21 @@ public class DatanodeDetails extends NodeImpl implements
* @param networkLocation DataNode's network location path
* @param ports Ports used by the DataNode
* @param certSerialId serial id from SCM issued certificate.
* @param version DataNode's version
* @param setupTime the setup time of DataNode
*/
@SuppressWarnings("parameternumber")
private DatanodeDetails(UUID uuid, String ipAddress, String hostName,
String networkLocation, List<Port> ports, String certSerialId) {
String networkLocation, List<Port> ports, String certSerialId,
String version, long setupTime) {
super(hostName, networkLocation, NetConstants.NODE_COST_DEFAULT);
this.uuid = uuid;
this.ipAddress = ipAddress;
this.hostName = hostName;
this.ports = ports;
this.certSerialId = certSerialId;
this.version = version;
this.setupTime = setupTime;
}

public DatanodeDetails(DatanodeDetails datanodeDetails) {
Expand All @@ -79,6 +87,8 @@ public DatanodeDetails(DatanodeDetails datanodeDetails) {
this.ports = datanodeDetails.ports;
this.setNetworkName(datanodeDetails.getNetworkName());
this.setParent(datanodeDetails.getParent());
this.version = datanodeDetails.version;
this.setupTime = datanodeDetails.setupTime;
}

/**
Expand Down Expand Up @@ -207,6 +217,12 @@ public static DatanodeDetails getFromProtoBuf(
if (datanodeDetailsProto.hasNetworkLocation()) {
builder.setNetworkLocation(datanodeDetailsProto.getNetworkLocation());
}
if (datanodeDetailsProto.hasVersion()) {
builder.setVersion(datanodeDetailsProto.getVersion());
}
if (datanodeDetailsProto.hasSetupTime()) {
builder.setSetupTime(datanodeDetailsProto.getSetupTime());
}
return builder.build();
}

Expand Down Expand Up @@ -248,6 +264,13 @@ public HddsProtos.DatanodeDetailsProto getProtoBufMessage() {
.setValue(port.getValue())
.build());
}

if (!Strings.isNullOrEmpty(getVersion())) {
builder.setVersion(getVersion());
}

builder.setSetupTime(getSetupTime());

return builder.build();
}

Expand Down Expand Up @@ -300,6 +323,8 @@ public static final class Builder {
private String networkLocation;
private List<Port> ports;
private String certSerialId;
private String version;
private long setupTime;

/**
* Default private constructor. To create Builder instance use
Expand Down Expand Up @@ -388,6 +413,30 @@ public Builder setCertSerialId(String certId) {
return this;
}

/**
* Sets the DataNode version.
*
* @param ver the version of DataNode.
*
* @return DatanodeDetails.Builder
*/
public Builder setVersion(String ver) {
this.version = ver;
return this;
}

/**
* Sets the DataNode setup time.
*
* @param time the setup time of DataNode.
*
* @return DatanodeDetails.Builder
*/
public Builder setSetupTime(long time) {
this.setupTime = time;
return this;
}

/**
* Builds and returns DatanodeDetails instance.
*
Expand All @@ -399,7 +448,7 @@ public DatanodeDetails build() {
networkLocation = NetConstants.DEFAULT_RACK;
}
DatanodeDetails dn = new DatanodeDetails(id, ipAddress, hostName,
networkLocation, ports, certSerialId);
networkLocation, ports, certSerialId, version, setupTime);
if (networkName != null) {
dn.setNetworkName(networkName);
}
Expand Down Expand Up @@ -505,4 +554,40 @@ public String getCertSerialId() {
public void setCertSerialId(String certSerialId) {
this.certSerialId = certSerialId;
}

/**
* Returns the DataNode version.
*
* @return DataNode version
*/
public String getVersion() {
return version;
}

/**
* Set DataNode version.
*
* @param version DataNode version
*/
public void setVersion(String version) {
this.version = version;
}

/**
* Returns the DataNode setup time.
*
* @return DataNode setup time
*/
public long getSetupTime() {
return setupTime;
}

/**
* Set DataNode setup time.
*
* @param setupTime DataNode setup time
*/
public void setSetupTime(long setupTime) {
this.setupTime = setupTime;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
import static org.apache.hadoop.hdds.security.x509.certificates.utils.CertificateSignRequest.getEncodedString;
import static org.apache.hadoop.ozone.OzoneConfigKeys.HDDS_DATANODE_PLUGINS_KEY;
import static org.apache.hadoop.util.ExitUtil.terminate;

import org.apache.hadoop.util.Time;
import org.bouncycastle.pkcs.PKCS10CertificationRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -191,6 +193,9 @@ public void start() {
datanodeDetails = initializeDatanodeDetails();
datanodeDetails.setHostName(hostname);
datanodeDetails.setIpAddress(ip);
datanodeDetails.setVersion(
HddsVersionInfo.HDDS_VERSION_INFO.getVersion());
datanodeDetails.setSetupTime(Time.now());
TracingUtil.initTracing(
"HddsDatanodeService." + datanodeDetails.getUuidString()
.substring(0, 8), conf);
Expand Down
2 changes: 2 additions & 0 deletions hadoop-hdds/interface-client/src/main/proto/hdds.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ message DatanodeDetailsProto {
// network name, can be Ip address or host name, depends
optional string networkName = 6;
optional string networkLocation = 7; // Network topology location
optional string version = 8; // Datanode version
optional int64 setupTime = 9;
// TODO(runzhiwang): when uuid is gone, specify 1 as the index of uuid128 and mark as required
optional UUID uuid128 = 100; // UUID with 128 bits assigned to the Datanode.
}
Expand Down
12 changes: 11 additions & 1 deletion hadoop-hdds/interface-client/src/main/proto/proto.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,16 @@
"name": "networkLocation",
"type": "string"
},
{
"id": 8,
"name": "version",
"type": "string"
},
{
"id": 9,
"name": "setupTime",
"type": "int64"
},
{
"id": 100,
"name": "uuid128",
Expand Down Expand Up @@ -1925,4 +1935,4 @@
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public Response getDatanodes() {
.withPipelines(pipelines)
.withLeaderCount(leaderCount.get())
.withUUid(datanode.getUuidString())
.withVersion(datanode.getVersion())
.withSetupTime(datanode.getSetupTime())
.build());
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ public final class DatanodeMetadata {
@XmlElement(name = "leaderCount")
private int leaderCount;

@XmlElement(name = "version")
private String version;

@XmlElement(name = "setupTime")
private long setupTime;

private DatanodeMetadata(Builder builder) {
this.hostname = builder.hostname;
this.uuid = builder.uuid;
Expand All @@ -64,6 +70,8 @@ private DatanodeMetadata(Builder builder) {
this.pipelines = builder.pipelines;
this.containers = builder.containers;
this.leaderCount = builder.leaderCount;
this.version = builder.version;
this.setupTime = builder.setupTime;
}

public String getHostname() {
Expand Down Expand Up @@ -98,6 +106,14 @@ public String getUuid() {
return uuid;
}

public String getVersion() {
return version;
}

public long getSetupTime() {
return setupTime;
}

/**
* Returns new builder class that builds a DatanodeMetadata.
*
Expand All @@ -120,6 +136,8 @@ public static final class Builder {
private List<DatanodePipeline> pipelines;
private int containers;
private int leaderCount;
private String version;
private long setupTime;

public Builder() {
this.containers = 0;
Expand Down Expand Up @@ -167,6 +185,16 @@ public Builder withUUid(String uuid) {
return this;
}

public Builder withVersion(String version) {
this.version = version;
return this;
}

public Builder withSetupTime(long setupTime) {
this.setupTime = setupTime;
return this;
}

/**
* Constructs DatanodeMetadata.
*
Expand Down
Loading