Skip to content

Commit 74b83eb

Browse files
committed
HADOOP-17981 javadocs
Change-Id: I922802b0f8251c56878bdd5419d4524b39b39ccd
1 parent 66c90be commit 74b83eb

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/lib/output/ResilientCommitByRenameHelper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ public class ResilientCommitByRenameHelper {
5757
*/
5858
private final boolean renameRecoveryAvailable;
5959

60+
/**
61+
* Counter of times recovery took place.
62+
*/
6063
private final AtomicInteger recoveryCount = new AtomicInteger();
6164

62-
63-
6465
/**
6566
* Instantiate.
6667
* @param fileSystem filesystem to work with.

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemResilientCommit.java

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
4444

4545
/**
46-
* Test the commit helper; parameterized on whether or not the FS
46+
* Test the {@link ResilientCommitByRenameHelper}.
47+
* Parameterized on whether or not the FS
4748
* raises exceptions on rename failures.
4849
* The outcome must be the same through the commit helper;
4950
* exceptions and error messages will be different.
@@ -134,7 +135,7 @@ FileStatus file(Path path, byte[] data) throws IOException {
134135
}
135136

136137
/**
137-
* make sure the filesystem resilience matches the text
138+
* Make sure the filesystem resilience matches the text
138139
* expectations.
139140
*/
140141
@Test
@@ -184,9 +185,9 @@ public void testSimpleRenameNoSource() throws Throwable {
184185
}
185186

186187
/**
187-
* commit a file twice.
188+
* Commit a file twice.
188189
* the second time the source file is missing but the dest file
189-
* has the same etag. as a result, this is considered a success.
190+
* has the same etag. As a result, this is considered a success.
190191
*/
191192
@Test
192193
public void testDoubleCommitTriggersRecovery() throws Throwable {
@@ -234,9 +235,9 @@ public void testDoubleCommitDifferentFiles() throws Throwable {
234235
}
235236

236237
/**
237-
* commit a file, then
238-
* expectone with a filestatus with a different source etag,
239-
* to fail
238+
* Commit a file, then
239+
* try to commit again with a filestatus with a different source etag.
240+
* Recovery will not report success.
240241
*/
241242
@Test
242243
public void testDoubleCommitDifferentFiles2() throws Throwable {
@@ -246,23 +247,29 @@ public void testDoubleCommitDifferentFiles2() throws Throwable {
246247
// its status will not match that of the dest
247248
final FileStatus status2 = file(sourcePath, DATA2);
248249

250+
// overwrite with dataset 1; this will have a different
251+
// etag
249252
final FileStatus status = file(sourcePath, DATA);
250-
commit(status, false);
251253

252-
// ioe raised; type will depend on whether or not FS
253-
// is raising exceptions.
254+
// commit the data1 dataset, which works
255+
commit(status, false);
256+
257+
// now attempt to commit with the file status of
258+
// dataset 2. this is the file which was overwritten,
259+
// so the etag at the dest path does not match it.
260+
// expect a failure.
254261
intercept(IOException.class, () ->
255262
commit(status2, false));
256263
}
257264

258265
/**
259-
* commit a file twice.
260-
* the second time the source file is missing but the dest file
261-
* has the same etag. as a result, this is considered a success.
266+
* try to commit a file to a path where the destination
267+
* directory does not exist -expect an exception to
268+
* be raised.
262269
*/
263270
@Test
264271
public void testCommitMissingDestDir() throws Throwable {
265-
describe("commit a file twice; expect the second to be recovery");
272+
describe("commit a file under a nonexistent dir; expect an IOE");
266273
final FileStatus status = file(sourcePath, DATA);
267274
final Path subpath = new Path(destPath, "subpath");
268275
intercept(IOException.class, () ->
@@ -280,7 +287,15 @@ public void testCommitNoSource() throws Throwable {
280287
() -> commit(status, false));
281288
}
282289

283-
private ResilientCommitByRenameHelper.CommitOutcome commit(final FileStatus status,
290+
/**
291+
* Try to commit a file.
292+
* @param status source status
293+
* @param expectRecovery expect the operation to have required failure recovery.
294+
* @return the outcome
295+
* @throws IOException any failure to rename the file
296+
*/
297+
private ResilientCommitByRenameHelper.CommitOutcome commit(
298+
final FileStatus status,
284299
boolean expectRecovery)
285300
throws IOException {
286301
final ResilientCommitByRenameHelper.CommitOutcome outcome = commitHelper.commitFile(

0 commit comments

Comments
 (0)