@@ -85,7 +85,7 @@ public class DatanodeManager {
8585 * Mapping: StorageID -> DatanodeDescriptor
8686 */
8787 private final Map <String , DatanodeDescriptor > datanodeMap
88- = new HashMap <String , DatanodeDescriptor >();
88+ = new HashMap <>();
8989
9090 /** Cluster network topology */
9191 private final NetworkTopology networktopology ;
@@ -162,7 +162,7 @@ public class DatanodeManager {
162162 * Software version -> Number of datanodes with this version
163163 */
164164 private HashMap <String , Integer > datanodesSoftwareVersions =
165- new HashMap <String , Integer >(4 , 0.75f );
165+ new HashMap <>(4 , 0.75f );
166166
167167 /**
168168 * The minimum time between resending caching directives to Datanodes,
@@ -217,7 +217,7 @@ public class DatanodeManager {
217217 // locations of those hosts in the include list and store the mapping
218218 // in the cache; so future calls to resolve will be fast.
219219 if (dnsToSwitchMapping instanceof CachedDNSToSwitchMapping ) {
220- final ArrayList <String > locations = new ArrayList <String >();
220+ final ArrayList <String > locations = new ArrayList <>();
221221 for (InetSocketAddress addr : hostFileManager .getIncludes ()) {
222222 locations .add (addr .getAddress ().getHostAddress ());
223223 }
@@ -370,7 +370,7 @@ public void sortLocatedBlocks(final String targethost,
370370 // here we should get node but not datanode only .
371371 Node client = getDatanodeByHost (targethost );
372372 if (client == null ) {
373- List <String > hosts = new ArrayList <String > (1 );
373+ List <String > hosts = new ArrayList <> (1 );
374374 hosts .add (targethost );
375375 List <String > resolvedHosts = dnsToSwitchMapping .resolve (hosts );
376376 if (resolvedHosts != null && !resolvedHosts .isEmpty ()) {
@@ -522,7 +522,7 @@ public DatanodeStorageInfo[] getDatanodeStorageInfos(
522522 void datanodeDump (final PrintWriter out ) {
523523 synchronized (datanodeMap ) {
524524 Map <String ,DatanodeDescriptor > sortedDatanodeMap =
525- new TreeMap <String , DatanodeDescriptor >(datanodeMap );
525+ new TreeMap <>(datanodeMap );
526526 out .println ("Metasave: Number of datanodes: " + datanodeMap .size ());
527527 for (DatanodeDescriptor node : sortedDatanodeMap .values ()) {
528528 out .println (node .dumpDatanode ());
@@ -660,7 +660,7 @@ private boolean shouldCountVersion(DatanodeDescriptor node) {
660660
661661 private void countSoftwareVersions () {
662662 synchronized (datanodeMap ) {
663- HashMap <String , Integer > versionCount = new HashMap <String , Integer >();
663+ HashMap <String , Integer > versionCount = new HashMap <>();
664664 for (DatanodeDescriptor dn : datanodeMap .values ()) {
665665 // Check isAlive too because right after removeDatanode(),
666666 // isDatanodeDead() is still true
@@ -677,7 +677,7 @@ private void countSoftwareVersions() {
677677
678678 public HashMap <String , Integer > getDatanodesSoftwareVersions () {
679679 synchronized (datanodeMap ) {
680- return new HashMap <String , Integer > (this .datanodesSoftwareVersions );
680+ return new HashMap <> (this .datanodesSoftwareVersions );
681681 }
682682 }
683683
@@ -710,7 +710,7 @@ private String resolveNetworkLocationWithFallBackToDefaultLocation (
710710 */
711711 private String resolveNetworkLocation (DatanodeID node )
712712 throws UnresolvedTopologyException {
713- List <String > names = new ArrayList <String >(1 );
713+ List <String > names = new ArrayList <>(1 );
714714 if (dnsToSwitchMapping instanceof CachedDNSToSwitchMapping ) {
715715 names .add (node .getIpAddr ());
716716 } else {
@@ -1000,7 +1000,7 @@ nodes with its data cleared (or user can just remove the StorageID
10001000 // If the network location is invalid, clear the cached mappings
10011001 // so that we have a chance to re-add this DataNode with the
10021002 // correct network location later.
1003- List <String > invalidNodeNames = new ArrayList <String >(3 );
1003+ List <String > invalidNodeNames = new ArrayList <>(3 );
10041004 // clear cache for nodes in IP or Hostname
10051005 invalidNodeNames .add (nodeReg .getIpAddr ());
10061006 invalidNodeNames .add (nodeReg .getHostName ());
@@ -1275,7 +1275,7 @@ public List<DatanodeDescriptor> getDatanodeListForReport(
12751275 final HostFileManager .HostSet excludedNodes = hostFileManager .getExcludes ();
12761276
12771277 synchronized (datanodeMap ) {
1278- nodes = new ArrayList <DatanodeDescriptor >(datanodeMap .size ());
1278+ nodes = new ArrayList <>(datanodeMap .size ());
12791279 for (DatanodeDescriptor dn : datanodeMap .values ()) {
12801280 final boolean isDead = isDatanodeDead (dn );
12811281 final boolean isDecommissioning = dn .isDecommissionInProgress ();
@@ -1351,7 +1351,7 @@ public DatanodeCommand[] handleHeartbeat(DatanodeRegistration nodeReg,
13511351 VolumeFailureSummary volumeFailureSummary ) throws IOException {
13521352 synchronized (heartbeatManager ) {
13531353 synchronized (datanodeMap ) {
1354- DatanodeDescriptor nodeinfo = null ;
1354+ DatanodeDescriptor nodeinfo ;
13551355 try {
13561356 nodeinfo = getDatanode (nodeReg );
13571357 } catch (UnregisteredNodeException e ) {
@@ -1389,7 +1389,7 @@ public DatanodeCommand[] handleHeartbeat(DatanodeRegistration nodeReg,
13891389 final DatanodeStorageInfo [] storages = b .getExpectedStorageLocations ();
13901390 // Skip stale nodes during recovery - not heart beated for some time (30s by default).
13911391 final List <DatanodeStorageInfo > recoveryLocations =
1392- new ArrayList <DatanodeStorageInfo >(storages .length );
1392+ new ArrayList <>(storages .length );
13931393 for (int i = 0 ; i < storages .length ; i ++) {
13941394 if (!storages [i ].getDatanodeDescriptor ().isStale (staleInterval )) {
13951395 recoveryLocations .add (storages [i ]);
@@ -1431,7 +1431,7 @@ public DatanodeCommand[] handleHeartbeat(DatanodeRegistration nodeReg,
14311431 return new DatanodeCommand [] { brCommand };
14321432 }
14331433
1434- final List <DatanodeCommand > cmds = new ArrayList <DatanodeCommand >();
1434+ final List <DatanodeCommand > cmds = new ArrayList <>();
14351435 //check pending replication
14361436 List <BlockTargetPair > pendingList = nodeinfo .getReplicationCommand (
14371437 maxTransfers );
0 commit comments