|
@@ -56,6 +56,7 @@ public class DatanodeInfo extends DatanodeID implements Node {
|
|
private List<String> dependentHostNames = new LinkedList<>();
|
|
private List<String> dependentHostNames = new LinkedList<>();
|
|
private String upgradeDomain;
|
|
private String upgradeDomain;
|
|
public static final DatanodeInfo[] EMPTY_ARRAY = {};
|
|
public static final DatanodeInfo[] EMPTY_ARRAY = {};
|
|
|
|
+ private int numBlocks;
|
|
|
|
|
|
// Datanode administrative states
|
|
// Datanode administrative states
|
|
public enum AdminStates {
|
|
public enum AdminStates {
|
|
@@ -106,6 +107,7 @@ public class DatanodeInfo extends DatanodeID implements Node {
|
|
this.upgradeDomain = from.getUpgradeDomain();
|
|
this.upgradeDomain = from.getUpgradeDomain();
|
|
this.lastBlockReportTime = from.getLastBlockReportTime();
|
|
this.lastBlockReportTime = from.getLastBlockReportTime();
|
|
this.lastBlockReportMonotonic = from.getLastBlockReportMonotonic();
|
|
this.lastBlockReportMonotonic = from.getLastBlockReportMonotonic();
|
|
|
|
+ this.numBlocks = from.getNumBlocks();
|
|
}
|
|
}
|
|
|
|
|
|
protected DatanodeInfo(DatanodeID nodeID) {
|
|
protected DatanodeInfo(DatanodeID nodeID) {
|
|
@@ -123,6 +125,7 @@ public class DatanodeInfo extends DatanodeID implements Node {
|
|
this.adminState = null;
|
|
this.adminState = null;
|
|
this.lastBlockReportTime = 0L;
|
|
this.lastBlockReportTime = 0L;
|
|
this.lastBlockReportMonotonic = 0L;
|
|
this.lastBlockReportMonotonic = 0L;
|
|
|
|
+ this.numBlocks = 0;
|
|
}
|
|
}
|
|
|
|
|
|
protected DatanodeInfo(DatanodeID nodeID, String location) {
|
|
protected DatanodeInfo(DatanodeID nodeID, String location) {
|
|
@@ -139,7 +142,8 @@ public class DatanodeInfo extends DatanodeID implements Node {
|
|
final long lastUpdate, final long lastUpdateMonotonic,
|
|
final long lastUpdate, final long lastUpdateMonotonic,
|
|
final int xceiverCount, final String networkLocation,
|
|
final int xceiverCount, final String networkLocation,
|
|
final AdminStates adminState, final String upgradeDomain,
|
|
final AdminStates adminState, final String upgradeDomain,
|
|
- final long lastBlockReportTime, final long lastBlockReportMonotonic) {
|
|
|
|
|
|
+ final long lastBlockReportTime, final long lastBlockReportMonotonic,
|
|
|
|
+ final int blockCount) {
|
|
super(ipAddr, hostName, datanodeUuid, xferPort, infoPort, infoSecurePort,
|
|
super(ipAddr, hostName, datanodeUuid, xferPort, infoPort, infoSecurePort,
|
|
ipcPort);
|
|
ipcPort);
|
|
this.capacity = capacity;
|
|
this.capacity = capacity;
|
|
@@ -157,6 +161,7 @@ public class DatanodeInfo extends DatanodeID implements Node {
|
|
this.upgradeDomain = upgradeDomain;
|
|
this.upgradeDomain = upgradeDomain;
|
|
this.lastBlockReportTime = lastBlockReportTime;
|
|
this.lastBlockReportTime = lastBlockReportTime;
|
|
this.lastBlockReportMonotonic = lastBlockReportMonotonic;
|
|
this.lastBlockReportMonotonic = lastBlockReportMonotonic;
|
|
|
|
+ this.numBlocks = blockCount;
|
|
}
|
|
}
|
|
|
|
|
|
/** Network location name. */
|
|
/** Network location name. */
|
|
@@ -246,6 +251,13 @@ public class DatanodeInfo extends DatanodeID implements Node {
|
|
*/
|
|
*/
|
|
public long getLastUpdateMonotonic() { return lastUpdateMonotonic;}
|
|
public long getLastUpdateMonotonic() { return lastUpdateMonotonic;}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @return Num of Blocks
|
|
|
|
+ */
|
|
|
|
+ public int getNumBlocks() {
|
|
|
|
+ return numBlocks;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Set lastUpdate monotonic time
|
|
* Set lastUpdate monotonic time
|
|
*/
|
|
*/
|
|
@@ -301,6 +313,11 @@ public class DatanodeInfo extends DatanodeID implements Node {
|
|
this.xceiverCount = xceiverCount;
|
|
this.xceiverCount = xceiverCount;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /** Sets number of blocks. */
|
|
|
|
+ public void setNumBlocks(int blockCount) {
|
|
|
|
+ this.numBlocks = blockCount;
|
|
|
|
+ }
|
|
|
|
+
|
|
/** network location */
|
|
/** network location */
|
|
@Override
|
|
@Override
|
|
public String getNetworkLocation() {return location;}
|
|
public String getNetworkLocation() {return location;}
|
|
@@ -351,6 +368,7 @@ public class DatanodeInfo extends DatanodeID implements Node {
|
|
float cacheUsedPercent = getCacheUsedPercent();
|
|
float cacheUsedPercent = getCacheUsedPercent();
|
|
float cacheRemainingPercent = getCacheRemainingPercent();
|
|
float cacheRemainingPercent = getCacheRemainingPercent();
|
|
String lookupName = NetUtils.getHostNameOfIP(getName());
|
|
String lookupName = NetUtils.getHostNameOfIP(getName());
|
|
|
|
+ int blockCount = getNumBlocks();
|
|
|
|
|
|
buffer.append("Name: ").append(getName());
|
|
buffer.append("Name: ").append(getName());
|
|
if (lookupName != null) {
|
|
if (lookupName != null) {
|
|
@@ -406,6 +424,7 @@ public class DatanodeInfo extends DatanodeID implements Node {
|
|
.append(
|
|
.append(
|
|
lastBlockReportTime != 0 ? new Date(lastBlockReportTime) : "Never")
|
|
lastBlockReportTime != 0 ? new Date(lastBlockReportTime) : "Never")
|
|
.append("\n");
|
|
.append("\n");
|
|
|
|
+ buffer.append("Num of Blocks: ").append(blockCount).append("\n");
|
|
return buffer.toString();
|
|
return buffer.toString();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -680,6 +699,8 @@ public class DatanodeInfo extends DatanodeID implements Node {
|
|
private long nonDfsUsed = 0L;
|
|
private long nonDfsUsed = 0L;
|
|
private long lastBlockReportTime = 0L;
|
|
private long lastBlockReportTime = 0L;
|
|
private long lastBlockReportMonotonic = 0L;
|
|
private long lastBlockReportMonotonic = 0L;
|
|
|
|
+ private int numBlocks;
|
|
|
|
+
|
|
|
|
|
|
public DatanodeInfoBuilder setFrom(DatanodeInfo from) {
|
|
public DatanodeInfoBuilder setFrom(DatanodeInfo from) {
|
|
this.capacity = from.getCapacity();
|
|
this.capacity = from.getCapacity();
|
|
@@ -697,6 +718,7 @@ public class DatanodeInfo extends DatanodeID implements Node {
|
|
this.upgradeDomain = from.getUpgradeDomain();
|
|
this.upgradeDomain = from.getUpgradeDomain();
|
|
this.lastBlockReportTime = from.getLastBlockReportTime();
|
|
this.lastBlockReportTime = from.getLastBlockReportTime();
|
|
this.lastBlockReportMonotonic = from.getLastBlockReportMonotonic();
|
|
this.lastBlockReportMonotonic = from.getLastBlockReportMonotonic();
|
|
|
|
+ this.numBlocks = from.getNumBlocks();
|
|
setNodeID(from);
|
|
setNodeID(from);
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
@@ -823,13 +845,18 @@ public class DatanodeInfo extends DatanodeID implements Node {
|
|
this.lastBlockReportMonotonic = time;
|
|
this.lastBlockReportMonotonic = time;
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
+ public DatanodeInfoBuilder setNumBlocks(int blockCount) {
|
|
|
|
+ this.numBlocks = blockCount;
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
|
|
public DatanodeInfo build() {
|
|
public DatanodeInfo build() {
|
|
return new DatanodeInfo(ipAddr, hostName, datanodeUuid, xferPort,
|
|
return new DatanodeInfo(ipAddr, hostName, datanodeUuid, xferPort,
|
|
infoPort, infoSecurePort, ipcPort, capacity, dfsUsed, nonDfsUsed,
|
|
infoPort, infoSecurePort, ipcPort, capacity, dfsUsed, nonDfsUsed,
|
|
remaining, blockPoolUsed, cacheCapacity, cacheUsed, lastUpdate,
|
|
remaining, blockPoolUsed, cacheCapacity, cacheUsed, lastUpdate,
|
|
lastUpdateMonotonic, xceiverCount, location, adminState,
|
|
lastUpdateMonotonic, xceiverCount, location, adminState,
|
|
- upgradeDomain, lastBlockReportTime, lastBlockReportMonotonic);
|
|
|
|
|
|
+ upgradeDomain, lastBlockReportTime, lastBlockReportMonotonic,
|
|
|
|
+ numBlocks);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|