|
55 | 55 | import org.apache.hadoop.util.Daemon;
|
56 | 56 | import org.apache.hadoop.util.ReflectionUtils;
|
57 | 57 | import org.apache.hadoop.util.Sets;
|
| 58 | +import org.apache.hadoop.util.Time; |
58 | 59 | import org.apache.hadoop.util.Timer;
|
59 | 60 | import org.slf4j.Logger;
|
60 | 61 | import org.slf4j.LoggerFactory;
|
@@ -1286,7 +1287,7 @@ nodes with its data cleared (or user can just remove the StorageID
|
1286 | 1287 | * refresh the network topology of this cluster based on the mapping_topology.data file.
|
1287 | 1288 | */
|
1288 | 1289 | public void refreshTopology() throws IOException {
|
1289 |
| - long start = System.currentTimeMillis(); |
| 1290 | + long start = Time.monotonicNow(); |
1290 | 1291 | int datanodeNums = 0;
|
1291 | 1292 | Set<String> storageIds = datanodeMap.keySet();
|
1292 | 1293 | Set<String> forIterations = new HashSet<>();
|
@@ -1315,22 +1316,24 @@ public void refreshTopology() throws IOException {
|
1315 | 1316 | }
|
1316 | 1317 | try {
|
1317 | 1318 | synchronized (this) {
|
| 1319 | + networktopology.remove(dnDescriptor); |
1318 | 1320 | dnDescriptor.setNetworkLocation(resolvedNetwork);
|
1319 | 1321 | networktopology.add(dnDescriptor); // may throw InvalidTopologyException
|
1320 | 1322 | }
|
1321 | 1323 | } catch (Throwable e) {
|
1322 |
| - LOG.error(getClass().getSimpleName() + ".refreshTopology: update datanode " + dnDescriptor + |
1323 |
| - " failed. reset from Rack: " + resolvedNetwork + " to Rack: " + originNetwork); |
| 1324 | + LOG.error("{}.refreshTopology: update datanode: {} failed. reset from Rack: {} to Rack: {}.", |
| 1325 | + getClass().getSimpleName(), dnDescriptor, resolvedNetwork, originNetwork); |
1324 | 1326 | dnDescriptor.setNetworkLocation(originNetwork);
|
1325 | 1327 | throw new IOException(getClass().getSimpleName() + ".refreshTopology: update datanode " + dnDescriptor +
|
1326 | 1328 | " failed. reset from Rack: " + resolvedNetwork + " to Rack: " + originNetwork);
|
1327 | 1329 | }
|
1328 |
| - LOG.info(getClass().getSimpleName() + ".refreshTopology: update datanode :" + dnDescriptor + |
1329 |
| - " from Rack: " + dnDescriptor.getNetworkLocation() + " to Rack: " + resolvedNetwork); |
| 1330 | + LOG.info("{}.refreshTopology: update datanode: {} from Rack: {} to Rack: {}.", |
| 1331 | + getClass().getSimpleName(), dnDescriptor, originNetwork, resolvedNetwork); |
| 1332 | + |
1330 | 1333 | checkIfClusterIsNowMultiRack(dnDescriptor);
|
1331 | 1334 | }
|
1332 |
| - long end = System.currentTimeMillis() - start; |
1333 |
| - LOG.info(getClass().getSimpleName() + ".refreshTopology: " + "costs " + end + "ms"); |
| 1335 | + long end = Time.monotonicNow() - start; |
| 1336 | + LOG.info("{}.refreshTopology: costs {} ms.", getClass().getSimpleName(), end); |
1334 | 1337 | }
|
1335 | 1338 |
|
1336 | 1339 | /**
|
|
0 commit comments