Skip to content

Commit 48fa54a

Browse files
authored
Merge branch 'apache:trunk' into YARN-11515
2 parents 94a01ab + 37b2d36 commit 48fa54a

88 files changed

Lines changed: 46413 additions & 1539 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Balancer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ public class Balancer {
206206
+ "on over-utilized machines."
207207
+ "\n\t[-asService]\tRun as a long running service."
208208
+ "\n\t[-sortTopNodes]"
209-
+ "\n\t[-hotBlockTimeInterval]\tprefer to move cold blocks."
210209
+ "\tSort datanodes based on the utilization so "
211-
+ "that highly utilized datanodes get scheduled first.";
210+
+ "that highly utilized datanodes get scheduled first."
211+
+ "\n\t[-hotBlockTimeInterval]\tprefer to move cold blocks.";
212212

213213
@VisibleForTesting
214214
private static volatile boolean serviceRunning = false;

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockChecksumHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,9 @@ void compute() throws IOException {
493493
checksumBlock(block, idx, liveBlkInfo.getToken(),
494494
liveBlkInfo.getDn());
495495
} catch (IOException ioe) {
496-
LOG.warn("Exception while reading checksum", ioe);
496+
String msg = String.format("Exception while reading checksum for block %s at index " +
497+
"%d in blockGroup %s", block, idx, blockGroup);
498+
LOG.warn(msg, ioe);
497499
// reconstruct block and calculate checksum for the failed node
498500
recalculateChecksum(idx, block.getNumBytes());
499501
}

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/metrics/DataNodeMetricHelper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package org.apache.hadoop.hdfs.server.datanode.metrics;
1919

20-
import org.apache.hadoop.hdfs.server.datanode.metrics.FSDatasetMBean;
2120
import org.apache.hadoop.metrics2.MetricsCollector;
2221
import org.apache.hadoop.metrics2.MetricsTag;
2322
import org.apache.hadoop.metrics2.lib.Interns;

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
126126
public static final String ENTERING_MAINTENANCE_STATUS =
127127
"is ENTERING MAINTENANCE";
128128
public static final String IN_MAINTENANCE_STATUS = "is IN MAINTENANCE";
129+
public static final String STALE_STATUS = "is STALE";
129130
public static final String NONEXISTENT_STATUS = "does not exist";
130131
public static final String FAILURE_STATUS = "FAILED";
131132
public static final String UNDEFINED = "undefined";
@@ -370,6 +371,8 @@ private void printDatanodeReplicaStatus(Block block,
370371
out.print(ENTERING_MAINTENANCE_STATUS);
371372
} else if (this.showMaintenanceState && dn.isInMaintenance()) {
372373
out.print(IN_MAINTENANCE_STATUS);
374+
} else if (dn.isStale(this.staleInterval)) {
375+
out.print(STALE_STATUS);
373376
} else {
374377
out.print(HEALTHY_STATUS);
375378
}

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSck.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,8 @@ else if (args[idx].equals("-replicaDetails")) {
404404
errCode = 4;
405405
} else if (lastLine.endsWith(NamenodeFsck.ENTERING_MAINTENANCE_STATUS)) {
406406
errCode = 5;
407+
} else if (lastLine.endsWith(NamenodeFsck.STALE_STATUS)) {
408+
errCode = 6;
407409
}
408410
return errCode;
409411
}

hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/HDFSCommands.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ Usage:
292292
[-idleiterations <idleiterations>]
293293
[-runDuringUpgrade]
294294
[-asService]
295+
[-sortTopNodes]
296+
[-hotBlockTimeInterval <specified time interval>]
295297

296298
| COMMAND\_OPTION | Description |
297299
|:---- |:---- |
@@ -304,6 +306,7 @@ Usage:
304306
| `-idleiterations` \<iterations\> | Maximum number of idle iterations before exit. This overwrites the default idleiterations(5). |
305307
| `-runDuringUpgrade` | Whether to run the balancer during an ongoing HDFS upgrade. This is usually not desired since it will not affect used space on over-utilized machines. |
306308
| `-asService` | Run Balancer as a long running service. |
309+
| `-sortTopNodes` | Sort datanodes based on the utilization so that highly utilized datanodes get scheduled first. |
307310
| `-hotBlockTimeInterval` | Prefer moving cold blocks i.e blocks associated with files accessed or modified before the specified time interval. |
308311
| `-h`\|`--help` | Display the tool usage and help information and exit. |
309312

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFsck.java

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.hadoop.hdfs.server.namenode;
2020

2121
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_CORRUPT_BLOCK_DELETE_IMMEDIATELY_ENABLED;
22+
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_STALE_DATANODE_INTERVAL_KEY;
2223
import static org.apache.hadoop.hdfs.MiniDFSCluster.HDFS_MINIDFS_BASEDIR;
2324
import static org.junit.Assert.assertEquals;
2425
import static org.junit.Assert.assertFalse;
@@ -1681,6 +1682,91 @@ public Boolean get() {
16811682
assertFalse(fsckOut.contains(NamenodeFsck.IN_MAINTENANCE_STATUS));
16821683
}
16831684

1685+
/**
1686+
* Test for blockIdCK with datanode staleness.
1687+
*/
1688+
@Test
1689+
public void testBlockIdCKStaleness() throws Exception {
1690+
final short replFactor = 1;
1691+
final long blockSize = 512;
1692+
Configuration configuration = new Configuration();
1693+
1694+
// Shorten dfs.namenode.stale.datanode.interval for easier testing.
1695+
configuration.setLong(DFS_NAMENODE_STALE_DATANODE_INTERVAL_KEY, 5000);
1696+
configuration.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, blockSize);
1697+
configuration.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, replFactor);
1698+
1699+
String[] racks = {"/rack1", "/rack2"};
1700+
String[] hosts = {"host1", "host2"};
1701+
1702+
File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
1703+
cluster = new MiniDFSCluster.Builder(configuration, builderBaseDir)
1704+
.hosts(hosts).racks(racks).build();
1705+
assertNotNull("Failed Cluster Creation", cluster);
1706+
cluster.waitClusterUp();
1707+
DistributedFileSystem fs = cluster.getFileSystem();
1708+
assertNotNull("Failed to get FileSystem", fs);
1709+
1710+
try {
1711+
DFSTestUtil util = new DFSTestUtil.Builder().
1712+
setName(getClass().getSimpleName()).setNumFiles(1).build();
1713+
1714+
// Create one file.
1715+
final String pathString = new String("/testfile");
1716+
final Path path = new Path(pathString);
1717+
util.createFile(fs, path, 1024L, replFactor, 1024L);
1718+
util.waitReplication(fs, path, replFactor);
1719+
StringBuilder sb = new StringBuilder();
1720+
for (LocatedBlock lb: util.getAllBlocks(fs, path)) {
1721+
sb.append(lb.getBlock().getLocalBlock().getBlockName() + " ");
1722+
}
1723+
String[] bIds = sb.toString().split(" ");
1724+
1725+
// Make sure datanode is HEALTHY before down.
1726+
String outStr = runFsck(configuration, 0, true, "/", "-blockId", bIds[0]);
1727+
assertTrue(outStr.contains(NamenodeFsck.HEALTHY_STATUS));
1728+
1729+
FSNamesystem fsn = cluster.getNameNode().getNamesystem();
1730+
BlockManager bm = fsn.getBlockManager();
1731+
DatanodeManager dnm = bm.getDatanodeManager();
1732+
DatanodeDescriptor dn = dnm.getDatanode(cluster.getDataNodes().get(0)
1733+
.getDatanodeId());
1734+
final String dnName = dn.getXferAddr();
1735+
1736+
// Make the block on datanode enter stale state.
1737+
cluster.stopDataNode(0);
1738+
GenericTestUtils.waitFor(new Supplier<Boolean>() {
1739+
@Override
1740+
public Boolean get() {
1741+
try {
1742+
DatanodeInfo datanodeInfo = null;
1743+
for (DatanodeInfo info : fs.getDataNodeStats()) {
1744+
if (dnName.equals(info.getXferAddr())) {
1745+
datanodeInfo = info;
1746+
}
1747+
}
1748+
if (datanodeInfo != null && datanodeInfo.isStale(5000)) {
1749+
return true;
1750+
}
1751+
} catch (Exception e) {
1752+
LOG.warn("Unexpected exception: " + e);
1753+
return false;
1754+
}
1755+
return false;
1756+
}
1757+
}, 500, 30000);
1758+
outStr = runFsck(configuration, 6, true, "/", "-blockId", bIds[0]);
1759+
assertTrue(outStr.contains(NamenodeFsck.STALE_STATUS));
1760+
} finally {
1761+
if (fs != null) {
1762+
fs.close();
1763+
}
1764+
if (cluster != null) {
1765+
cluster.shutdown();
1766+
}
1767+
}
1768+
}
1769+
16841770
/**
16851771
* Test for blockIdCK with block corruption.
16861772
*/

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/commit/staging/Paths.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,19 @@ private static int getAppAttemptId(Configuration conf) {
227227
MRJobConfig.APPLICATION_ATTEMPT_ID, 0);
228228
}
229229

230+
/**
231+
* Build a qualified parent path for the temporary multipart upload commit
232+
* directory built by {@link #getMultipartUploadCommitsDirectory(Configuration, String)}.
233+
* @param conf configuration defining default FS.
234+
* @param uuid uuid of job
235+
* @return a path which can be used for temporary work
236+
* @throws IOException on an IO failure.
237+
*/
238+
public static Path getStagingUploadsParentDirectory(Configuration conf,
239+
String uuid) throws IOException {
240+
return getMultipartUploadCommitsDirectory(conf, uuid).getParent();
241+
}
242+
230243
/**
231244
* Build a qualified temporary path for the multipart upload commit
232245
* information in the cluster filesystem.

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/commit/staging/StagingCommitter.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,8 @@ public void cleanupStagingDirs() {
501501

502502
/**
503503
* Staging committer cleanup includes calling wrapped committer's
504-
* cleanup method, and removing all destination paths in the final
505-
* filesystem.
504+
* cleanup method, and removing staging uploads path and all
505+
* destination paths in the final filesystem.
506506
* @param commitContext commit context
507507
* @param suppressExceptions should exceptions be suppressed?
508508
* @throws IOException IO failures if exceptions are not suppressed.
@@ -515,6 +515,9 @@ protected void cleanup(CommitContext commitContext,
515515
maybeIgnore(suppressExceptions, "Cleanup wrapped committer",
516516
() -> wrappedCommitter.cleanupJob(
517517
commitContext.getJobContext()));
518+
maybeIgnore(suppressExceptions, "Delete staging uploads path",
519+
() -> deleteStagingUploadsParentDirectory(
520+
commitContext.getJobContext()));
518521
maybeIgnore(suppressExceptions, "Delete destination paths",
519522
() -> deleteDestinationPaths(
520523
commitContext.getJobContext()));
@@ -543,11 +546,26 @@ protected void abortJobInternal(CommitContext commitContext,
543546
}
544547
}
545548

549+
/**
550+
* Delete the multipart upload staging directory.
551+
* @param context job context
552+
* @throws IOException IO failure
553+
*/
554+
protected void deleteStagingUploadsParentDirectory(JobContext context)
555+
throws IOException {
556+
Path stagingUploadsPath = Paths.getStagingUploadsParentDirectory(
557+
context.getConfiguration(), getUUID());
558+
ignoreIOExceptions(LOG,
559+
"Deleting staging uploads path", stagingUploadsPath.toString(),
560+
() -> deleteWithWarning(
561+
stagingUploadsPath.getFileSystem(getConf()),
562+
stagingUploadsPath,
563+
true));
564+
}
546565

547566
/**
548567
* Delete the working paths of a job.
549568
* <ol>
550-
* <li>The job attempt path</li>
551569
* <li>{@code $dest/__temporary}</li>
552570
* <li>the local working directory for staged files</li>
553571
* </ol>
@@ -556,14 +574,6 @@ protected void abortJobInternal(CommitContext commitContext,
556574
* @throws IOException IO failure
557575
*/
558576
protected void deleteDestinationPaths(JobContext context) throws IOException {
559-
Path attemptPath = getJobAttemptPath(context);
560-
ignoreIOExceptions(LOG,
561-
"Deleting Job attempt Path", attemptPath.toString(),
562-
() -> deleteWithWarning(
563-
getJobAttemptFileSystem(context),
564-
attemptPath,
565-
true));
566-
567577
// delete the __temporary directory. This will cause problems
568578
// if there is >1 task targeting the same dest dir
569579
deleteWithWarning(getDestFS(),

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/commit/AbstractITCommitProtocol.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,30 @@ public JobData(Job job,
403403
this.committer = committer;
404404
conf = job.getConfiguration();
405405
}
406+
407+
public Job getJob() {
408+
return job;
409+
}
410+
411+
public JobContext getJContext() {
412+
return jContext;
413+
}
414+
415+
public TaskAttemptContext getTContext() {
416+
return tContext;
417+
}
418+
419+
public AbstractS3ACommitter getCommitter() {
420+
return committer;
421+
}
422+
423+
public Configuration getConf() {
424+
return conf;
425+
}
426+
427+
public Path getWrittenTextPath() {
428+
return writtenTextPath;
429+
}
406430
}
407431

408432
/**

0 commit comments

Comments
 (0)