|
@@ -85,7 +85,7 @@ public class DatanodeManager {
|
|
* Mapping: StorageID -> DatanodeDescriptor
|
|
* Mapping: StorageID -> DatanodeDescriptor
|
|
*/
|
|
*/
|
|
private final Map<String, DatanodeDescriptor> datanodeMap
|
|
private final Map<String, DatanodeDescriptor> datanodeMap
|
|
- = new HashMap<String, DatanodeDescriptor>();
|
|
|
|
|
|
+ = new HashMap<>();
|
|
|
|
|
|
/** Cluster network topology */
|
|
/** Cluster network topology */
|
|
private final NetworkTopology networktopology;
|
|
private final NetworkTopology networktopology;
|
|
@@ -162,7 +162,7 @@ public class DatanodeManager {
|
|
* Software version -> Number of datanodes with this version
|
|
* Software version -> Number of datanodes with this version
|
|
*/
|
|
*/
|
|
private HashMap<String, Integer> datanodesSoftwareVersions =
|
|
private HashMap<String, Integer> datanodesSoftwareVersions =
|
|
- new HashMap<String, Integer>(4, 0.75f);
|
|
|
|
|
|
+ new HashMap<>(4, 0.75f);
|
|
|
|
|
|
/**
|
|
/**
|
|
* The minimum time between resending caching directives to Datanodes,
|
|
* The minimum time between resending caching directives to Datanodes,
|
|
@@ -217,7 +217,7 @@ public class DatanodeManager {
|
|
// locations of those hosts in the include list and store the mapping
|
|
// locations of those hosts in the include list and store the mapping
|
|
// in the cache; so future calls to resolve will be fast.
|
|
// in the cache; so future calls to resolve will be fast.
|
|
if (dnsToSwitchMapping instanceof CachedDNSToSwitchMapping) {
|
|
if (dnsToSwitchMapping instanceof CachedDNSToSwitchMapping) {
|
|
- final ArrayList<String> locations = new ArrayList<String>();
|
|
|
|
|
|
+ final ArrayList<String> locations = new ArrayList<>();
|
|
for (InetSocketAddress addr : hostFileManager.getIncludes()) {
|
|
for (InetSocketAddress addr : hostFileManager.getIncludes()) {
|
|
locations.add(addr.getAddress().getHostAddress());
|
|
locations.add(addr.getAddress().getHostAddress());
|
|
}
|
|
}
|
|
@@ -370,7 +370,7 @@ public class DatanodeManager {
|
|
// here we should get node but not datanode only .
|
|
// here we should get node but not datanode only .
|
|
Node client = getDatanodeByHost(targethost);
|
|
Node client = getDatanodeByHost(targethost);
|
|
if (client == null) {
|
|
if (client == null) {
|
|
- List<String> hosts = new ArrayList<String> (1);
|
|
|
|
|
|
+ List<String> hosts = new ArrayList<> (1);
|
|
hosts.add(targethost);
|
|
hosts.add(targethost);
|
|
List<String> resolvedHosts = dnsToSwitchMapping.resolve(hosts);
|
|
List<String> resolvedHosts = dnsToSwitchMapping.resolve(hosts);
|
|
if (resolvedHosts != null && !resolvedHosts.isEmpty()) {
|
|
if (resolvedHosts != null && !resolvedHosts.isEmpty()) {
|
|
@@ -522,7 +522,7 @@ public class DatanodeManager {
|
|
void datanodeDump(final PrintWriter out) {
|
|
void datanodeDump(final PrintWriter out) {
|
|
synchronized (datanodeMap) {
|
|
synchronized (datanodeMap) {
|
|
Map<String,DatanodeDescriptor> sortedDatanodeMap =
|
|
Map<String,DatanodeDescriptor> sortedDatanodeMap =
|
|
- new TreeMap<String,DatanodeDescriptor>(datanodeMap);
|
|
|
|
|
|
+ new TreeMap<>(datanodeMap);
|
|
out.println("Metasave: Number of datanodes: " + datanodeMap.size());
|
|
out.println("Metasave: Number of datanodes: " + datanodeMap.size());
|
|
for (DatanodeDescriptor node : sortedDatanodeMap.values()) {
|
|
for (DatanodeDescriptor node : sortedDatanodeMap.values()) {
|
|
out.println(node.dumpDatanode());
|
|
out.println(node.dumpDatanode());
|
|
@@ -660,7 +660,7 @@ public class DatanodeManager {
|
|
|
|
|
|
private void countSoftwareVersions() {
|
|
private void countSoftwareVersions() {
|
|
synchronized(datanodeMap) {
|
|
synchronized(datanodeMap) {
|
|
- HashMap<String, Integer> versionCount = new HashMap<String, Integer>();
|
|
|
|
|
|
+ HashMap<String, Integer> versionCount = new HashMap<>();
|
|
for(DatanodeDescriptor dn: datanodeMap.values()) {
|
|
for(DatanodeDescriptor dn: datanodeMap.values()) {
|
|
// Check isAlive too because right after removeDatanode(),
|
|
// Check isAlive too because right after removeDatanode(),
|
|
// isDatanodeDead() is still true
|
|
// isDatanodeDead() is still true
|
|
@@ -677,7 +677,7 @@ public class DatanodeManager {
|
|
|
|
|
|
public HashMap<String, Integer> getDatanodesSoftwareVersions() {
|
|
public HashMap<String, Integer> getDatanodesSoftwareVersions() {
|
|
synchronized(datanodeMap) {
|
|
synchronized(datanodeMap) {
|
|
- return new HashMap<String, Integer> (this.datanodesSoftwareVersions);
|
|
|
|
|
|
+ return new HashMap<> (this.datanodesSoftwareVersions);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -710,7 +710,7 @@ public class DatanodeManager {
|
|
*/
|
|
*/
|
|
private String resolveNetworkLocation (DatanodeID node)
|
|
private String resolveNetworkLocation (DatanodeID node)
|
|
throws UnresolvedTopologyException {
|
|
throws UnresolvedTopologyException {
|
|
- List<String> names = new ArrayList<String>(1);
|
|
|
|
|
|
+ List<String> names = new ArrayList<>(1);
|
|
if (dnsToSwitchMapping instanceof CachedDNSToSwitchMapping) {
|
|
if (dnsToSwitchMapping instanceof CachedDNSToSwitchMapping) {
|
|
names.add(node.getIpAddr());
|
|
names.add(node.getIpAddr());
|
|
} else {
|
|
} else {
|
|
@@ -1000,7 +1000,7 @@ public class DatanodeManager {
|
|
// If the network location is invalid, clear the cached mappings
|
|
// If the network location is invalid, clear the cached mappings
|
|
// so that we have a chance to re-add this DataNode with the
|
|
// so that we have a chance to re-add this DataNode with the
|
|
// correct network location later.
|
|
// correct network location later.
|
|
- List<String> invalidNodeNames = new ArrayList<String>(3);
|
|
|
|
|
|
+ List<String> invalidNodeNames = new ArrayList<>(3);
|
|
// clear cache for nodes in IP or Hostname
|
|
// clear cache for nodes in IP or Hostname
|
|
invalidNodeNames.add(nodeReg.getIpAddr());
|
|
invalidNodeNames.add(nodeReg.getIpAddr());
|
|
invalidNodeNames.add(nodeReg.getHostName());
|
|
invalidNodeNames.add(nodeReg.getHostName());
|
|
@@ -1275,7 +1275,7 @@ public class DatanodeManager {
|
|
final HostFileManager.HostSet excludedNodes = hostFileManager.getExcludes();
|
|
final HostFileManager.HostSet excludedNodes = hostFileManager.getExcludes();
|
|
|
|
|
|
synchronized(datanodeMap) {
|
|
synchronized(datanodeMap) {
|
|
- nodes = new ArrayList<DatanodeDescriptor>(datanodeMap.size());
|
|
|
|
|
|
+ nodes = new ArrayList<>(datanodeMap.size());
|
|
for (DatanodeDescriptor dn : datanodeMap.values()) {
|
|
for (DatanodeDescriptor dn : datanodeMap.values()) {
|
|
final boolean isDead = isDatanodeDead(dn);
|
|
final boolean isDead = isDatanodeDead(dn);
|
|
final boolean isDecommissioning = dn.isDecommissionInProgress();
|
|
final boolean isDecommissioning = dn.isDecommissionInProgress();
|
|
@@ -1351,7 +1351,7 @@ public class DatanodeManager {
|
|
VolumeFailureSummary volumeFailureSummary) throws IOException {
|
|
VolumeFailureSummary volumeFailureSummary) throws IOException {
|
|
synchronized (heartbeatManager) {
|
|
synchronized (heartbeatManager) {
|
|
synchronized (datanodeMap) {
|
|
synchronized (datanodeMap) {
|
|
- DatanodeDescriptor nodeinfo = null;
|
|
|
|
|
|
+ DatanodeDescriptor nodeinfo;
|
|
try {
|
|
try {
|
|
nodeinfo = getDatanode(nodeReg);
|
|
nodeinfo = getDatanode(nodeReg);
|
|
} catch(UnregisteredNodeException e) {
|
|
} catch(UnregisteredNodeException e) {
|
|
@@ -1389,7 +1389,7 @@ public class DatanodeManager {
|
|
final DatanodeStorageInfo[] storages = b.getExpectedStorageLocations();
|
|
final DatanodeStorageInfo[] storages = b.getExpectedStorageLocations();
|
|
// Skip stale nodes during recovery - not heart beated for some time (30s by default).
|
|
// Skip stale nodes during recovery - not heart beated for some time (30s by default).
|
|
final List<DatanodeStorageInfo> recoveryLocations =
|
|
final List<DatanodeStorageInfo> recoveryLocations =
|
|
- new ArrayList<DatanodeStorageInfo>(storages.length);
|
|
|
|
|
|
+ new ArrayList<>(storages.length);
|
|
for (int i = 0; i < storages.length; i++) {
|
|
for (int i = 0; i < storages.length; i++) {
|
|
if (!storages[i].getDatanodeDescriptor().isStale(staleInterval)) {
|
|
if (!storages[i].getDatanodeDescriptor().isStale(staleInterval)) {
|
|
recoveryLocations.add(storages[i]);
|
|
recoveryLocations.add(storages[i]);
|
|
@@ -1431,7 +1431,7 @@ public class DatanodeManager {
|
|
return new DatanodeCommand[] { brCommand };
|
|
return new DatanodeCommand[] { brCommand };
|
|
}
|
|
}
|
|
|
|
|
|
- final List<DatanodeCommand> cmds = new ArrayList<DatanodeCommand>();
|
|
|
|
|
|
+ final List<DatanodeCommand> cmds = new ArrayList<>();
|
|
//check pending replication
|
|
//check pending replication
|
|
List<BlockTargetPair> pendingList = nodeinfo.getReplicationCommand(
|
|
List<BlockTargetPair> pendingList = nodeinfo.getReplicationCommand(
|
|
maxTransfers);
|
|
maxTransfers);
|